Sign in to follow this  

Help on using D3DXLoadMeshHierarchyFromX

This topic is 3301 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am a beginner in DirectX programming. I have two questions (maybe more questions in the future, but for now these are the two questions I focus myself on): 1. For the structure, D3DXMESHDATA, there is a member variable that specifies the data types of the mesh, according to MSDN, the types are mesh, progressive mesh and patch mesh. I tried so hard to search for what they are, what their differences are and when each of they should be used. However, there are no information about this on the web. Please, someone answer my question. Also, why is it the case that the D3DXLoadMeshHierarchyFromX function does not have an input parameter for this information? Does it means this piece of information is responsible by the programmer when they implement the CreateMeshContainer function in the derived class of ID3DXAllocateHierarchy? In other words, does it means that this piece of information is not contained in the X file? 2. I read a tutorial on using D3DXLoadMeshHierarchyFromX function to load a mesh from a X file with the hirarchy preserved. In the tutorial, the author suggested that: quote starts[ The base D3DXMESHCONTAINER has a pMaterials member which is a D3DXMATERIAL structure that contains a texture filename and material data. It is easier to ignore this and instead store the data in arrays of created textures and materials in our derived structure (exTextures and exMaterials). struct D3DXMESHCONTAINER_EXTENDED: public D3DXMESHCONTAINER { IDirect3DTexture9** exTextures; // Array of texture pointers D3DMATERIAL9* exMaterials; // Array of materials // Skinned mesh variables ID3DXMesh* exSkinMesh; // The skin mesh D3DXMATRIX* exBoneOffsets; // The bone matrix Offsets D3DXMATRIX** exFrameCombinedMatrixPointer; // Array of frame matrix }; ]quote ends why is it easier to ignore LPD3DXMATERIAL pMaterials in the base D3DXMESHCONTAINER structure, and instead store the data in arrays of created textures and materials in the author's derived structure (exTextures and exMaterials). Can we use LPD3DXMATERIAL pMaterials? If no, then why did Microsoft put it there? If yes, can someone compare them? (i.e. what are good and what are bad for each approach) Thanks a million times for answering these questions

Share this post


Link to post
Share on other sites
First question:
Mesh - The standard class for representing a 3D model mesh, complete with vertex, index, and attribute buffers (for subsets).
ProgressiveMesh - A subclass of mesh that allows for vertex count manipulation, decreasing or increasing the vertex count of a mesh, often used to create Level of Detail levels.
PatchMesh - No clue, possibly a mesh container that stores Bezier patches (or some other curve patch) instead of static vertex/index buffers?

As for why there is no input parameter, as far as I know, you generally load a Mesh object first, and then convert it to a progressive mesh if you so desire at a later time. Not sure how PatchMeshes are loaded. As for information in the X file, a progressive mesh is not a different type of mesh, only a container for specific behaviors to apply to a loaded mesh. Again not sure about a Patch Mesh.

2) Generally, you want to store the texture and materials in seperate arrays instead of the combined structure, just to make things a bit easier. This allows you to load textures seperately, and generally makes life better. Also, the D3DXMATERIAL structure has an incomplete implementation of a full material if I am not mistaken (does not seperate ambient and diffuse, etc.)

Share this post


Link to post
Share on other sites

This topic is 3301 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this