Loading .X

Started by
4 comments, last by kevlur 20 years, 2 months ago
Hi, im trying to loading .x objects into a graphic motor SDK DX9 based, i''ve found a function in the SDK package: D3DXLoadMeshFromX() and it takes 8 parameter, i use it in this way : D3DXLoadMeshFromX( strPath, D3DXMESH_SYSTEMMEM, pd3dDevice, NULL, &pMtrlBuffer, NULL, &m_dwNumMaterials, &m_pSysMemMesh ); The first parameter is the filename of the .x object, then there is a flag, LPDIRECT3DDEVICE9 pd3dDevice, LPD3DXBUFFER pMtrlBuffer,a DWORD m_dwNumMaterials and.... the last parameter LPD3DXMESH m_pSysMemMesh (that i thought it was a structure, it isn''t'') is an interface and is so defined: ... ... typedef struct ID3DXMesh *LPD3DXMESH; ... ... ... #undef INTERFACE #define INTERFACE ID3DXMesh DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) { // IUnknown STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXBaseMesh STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; STDMETHOD_(DWORD, GetFVF)(THIS) PURE; STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, void** ppData) PURE; STDMETHOD(UnlockVertexBuffer)(THIS) PURE; STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, void** ppData) PURE; STDMETHOD(UnlockIndexBuffer)(THIS) PURE; STDMETHOD(GetAttributeTable)( THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; // ID3DXMesh STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, LPD3DXMESH* ppOptMesh) PURE; STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; STDMETHOD(SetAttributeTable)(THIS_ CONST D3DXATTRIBUTERANGE *pAttribTable, DWORD cAttribTableSize) PURE; }; I dont know what an interface is, but i think the .x object data are loaded into this interface, and at this point there is my problem.... i want to copy the .x object data from this interface to my data object structure: typedef struct OBJECT4DV2_TYP { int id; // numeric id of this object char name[64]; // int state; // state of object int attr; // attributes of object int mati; // material index overide (-1) - no material (new) float *avg_radius; // [OBJECT4DV2_MAX_FRAMES]; // average radius of object used for collision detection float *max_radius; // [OBJECT4DV2_MAX_FRAMES]; // maximum radius of object POINT4D world_pos; // position of object in world VECTOR4D dir; // rotation angles of object VECTOR4D ux,uy,uz; // local axes to track full orientation int num_vertices; // number of vertices per frame of this object int num_frames; // number of frames int total_vertices; int curr_frame; // current animation frame (0) if single frame VERTEX4DTV1_PTR vlist_local; VERTEX4DTV1_PTR vlist_trans; VERTEX4DTV1_PTR head_vlist_local; VERTEX4DTV1_PTR head_vlist_trans; POINT2D_PTR tlist; // 3*num polys at max BITMAP_IMAGE_PTR texture; // pointer to the texture information for simple texture mapping int num_polys; // number of polygons in object mesh POLY4DV2_PTR plist; // ptr to polygons int ivar1, ivar2; float fvar1, fvar2; int Set_Frame(int frame); } OBJECT4DV2, *OBJECT4DV2_PTR; And the problem is that i dont know how to get data from the interface to my object structure. Help me please, i''m going mad Thank you Kev
Advertisement
Why not read the documentation? The ID3DXMesh interface supports several methods you might find interesting, like GetFVF(), GetNumVertices(), GetVertexBuffer(), LockVertexBuffer(), etc.
Yes i could read documentation if i find something but i cant find anything on how copy vertices and faces from the interface to my structure
Lock the vertex buffers and copy it?
www.JeremyPardon.com
thank you, and how about the faces?
Read the index buffer. It''s ordered in triangles ie index[0],index[1],index[2] is the first triangle. If there is no index buffer the vertex buffer is ordered into triangles ie vb[0],vb[1],vb[2] is your first triangle. This is my understanding anyway.
www.JeremyPardon.com

This topic is closed to new replies.

Advertisement