Drawing Custom Model Format

hi, im started with DXSDK a few days and i want to know if there is a way to fill a ID3DXMESH with my custom format

my code:

namespace my_work
{
   struct my_vertex
   {
      int vIndex;
      D3DXVECTOR3 vPosition;
      D3DXVECTOR3 vNormal;
      D3DXVECTOR2 vUV;
   };

   struct my_face
   {
      int vIndex1,vIndex2,vIndex3;
   };
}

OBS: i've tryed to use vertex buffer with FVF but my models don't have a constant vertex indexes like face 1 : verts 1,2 and 3; sometimes a face have verts 2,7,9. 



Answer this question

Drawing Custom Model Format

  • Rodrigo Harambure

    Tanks realy help me a lot!Big Smile
  • yy608

    You can do everything you requested with Direct3D Smile

    I assume you can compose your own FVF for that vertex format, as such you can use the D3DXCreateMesh() function.

    I answered a very similar question in this thread - I suggest you read my answer there...

    With regards to the order of your vertices - thats an absolutely classic example of index buffers! Have a read on that topic and you should be able to find a solution to what you want Smile

    For example, if you render from an index buffer as a triangle list you'll use [0,1,2],[3,4,5],[6,7,8] - but the index stored at those respective indices can be arbitrary. if 0=2, 1=7 and 2=9 then you get your example: the first primitive renders from vertices 2,7,9.

    hth
    Jack


  • Drawing Custom Model Format