Jump to content
  • Advertisement
Sign in to follow this  
Stowelly

problems understanding D3DXLoadMeshHierarchyFromX

This topic is 4835 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 was just wondering if im using this function correctly, ive tried using the skinned mesh example and various other example code throughout the web, but there not to clear whats going on, (i understand i will have to make the variables acessable within my class, they are just local for the sake of example). ive tried this with all of the meshes from the sample codes, anmated and not.
ID3DXMesh* cMesh::LoadAnimatedMesh(LPCTSTR pFilename,LPDIRECT3DDEVICE9 pD3DDevice,bool isPmesh,D3DXVECTOR3 StartPos)
{
    LPD3DXFRAME                 m_pFrameRoot =0;
    LPD3DXANIMATIONCONTROLLER   m_pAnimController =0;
    LPD3DXLOADUSERDATA		m_pUserDataLoader =0;
    D3DXMATRIXA16*              m_pBoneMatrices =0;
    LPD3DXALLOCATEHIERARCHY Alloc =0 ;
	

     //   return hr;

    hr = D3DXLoadMeshHierarchyFromX(pFilename,D3DXMESH_MANAGED,pD3DDevice, Alloc, m_pUserDataLoader, &m_pFrameRoot,&m_pAnimController);
    if (FAILED(hr))
	{
		::MessageBox(0, "D3DXLoadMeshHierarchyFromX() - FAILED", 0, 0);
	}
thanks for your time

Share this post


Link to post
Share on other sites
Advertisement
You have to create a class that will handle the allocation of frames and mesh. So the fourth parameter needs to be a pointer to an instance of a class that defines four specific functions:

CreateFrame - requests allocation of a frame object
CreateMeshContainer - requests allocation of a mesh container object
DestroyFrame - deallocation of frame object
DestroyMeshContainer - deallocation of mesh container object

I have some notes on how to do this here: http://www.toymaker.info/Games/html/load_x_hierarchy.html

Share this post


Link to post
Share on other sites
cheers.

ive been following through your code, and thanks to that i now have the skinnedBouncyThing.X file animated within my code, but appear to have come across a few problems, using exactly the same code to load any other animated mesh such as the bones_all.x and a number of other anim meshes within the DXSDK sample code the D3DXLoadMeshHierarchyFromX function returns fail.

im pretty sure this is still to do with the CMeshHierarchy class.

i have modified this line of code due to it not compiling

WCHAR wszTexName[MAX_PATH];
CUtilities::FillWideStringFromCharString(pMaterials.pTextureFilename,wszTexName,MAX_PATH);

// Use the D3DX function to create the texturer
if(FAILED(D3DXCreateTextureFromFile(pd3dDevice, wszTexName,&newMeshContainer->exTextures)))
{


and was recieving the following error "error C2664: 'D3DXCreateTextureFromFileA' : cannot convert parameter 2 from 'unsigned short [260]' to 'const char *'"



i resolved this by replacing the createtexturefromfile function with

if(FAILED(D3DXCreateTextureFromFile(pd3dDevice, pMaterials.pTextureFilename,&newMeshContainer->exTextures)))



could this be the problem?, please please help directx is gonna turn me old and grey within a week at this rate lol

thank you

Share this post


Link to post
Share on other sites
I doubt that is the problem - my code is set to work with Unicode hence the conversion but if you are not compiling with unicode you can safely use the filename directly. Do you get any Direct3D debug output when it fails? Make sure you have D3D_DEBUG_INFO defined. You also may want to put breakpoinrs in the mesh hierarchy code to find out the actual place where it is failing.

Share this post


Link to post
Share on other sites
cheers, i tried debugging the class but it doesntappear to reach anywhere in that class, ive print screened the debug info for allocate hierarchy as it doesnt make much sense to me im afraid

does this make any sense to you?

http://img371.imageshack.us/img371/3923/dx2lx.jpg

Share this post


Link to post
Share on other sites
hmm, no that appears to be nothing to do with it, i think ive got myself in too deep here :-(


any idea what the fundimental difference between skinnedbouncything.x and bones_all.x are?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!