Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 May 2013
Offline Last Active May 26 2013 04:15 AM

Topics I've Started

trianglelist from mesh

19 May 2013 - 05:52 AM

There is probably reference to code to do this action already, please point me in the right direction


I am trying to draw triangles from a mesh in directx x file

The directx x file is exported from blender .. I have not taken care of the mirrored part yet


the code I am trying (very badly put together by me) only draws every other triangle, what have I missed?

I am using .. C#, sharpdx and assimp net


ASI.Scene model = importer.ImportFile(fileName,

var vertices = new VertexBuffer(device, 
Utilities.SizeOf() * 2 * model.Meshes[0].VertexCount, Usage.WriteOnly,
VertexFormat.None, Pool.Managed);

Vector4[] VSet = new Vector4[model.Meshes[0].VertexCount * 2];

foreach (ASI.Mesh AMesh in model.Meshes)
 int i2 = -1;
 for(int i1 = 0; i1 < AMesh.VertexCount * 2; i1++)
    VSet[i1] = new Vector4(AMesh.Vertices[i2][0], AMesh.Vertices[i2][1], AMesh.Vertices[ i2][2], 1.0f);
    VSet[i1] = new Vector4(AMesh.Normals[i2][0], AMesh.Normals[i2][1], AMesh.Normals[i2] [2], 1.0f);
vertices.Lock(0, 0, LockFlags.None).WriteRange(VSet); 


then draw with:


device.DrawPrimitives(PrimitiveType.TriangleList, 0, model.Meshes[0].VertexCount / 3);