Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  

root NULL in D3DXLoadMeshHierarchyFromX

This topic is 2814 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


I made a demo for load a skinned mesh (one mesh with one skeleton) and works fine.

A friend give me a model (in X format) with two meshes and one skeleton. When I load the model with method D3DXLoadMeshHierarchyFromX the root return NULL and the animationController too.

This is the method CreateFrame on the class that extends of ID3DXAllocateHierarchy:

HRESULT AllocMeshHierarchy::CreateFrame(PCTSTR Name, D3DXFRAME** ppNewFrame)
FrameEx* frameEx = new FrameEx();

if( Name ) CopyString(Name, &frameEx->Name);
else CopyString("<no name>", &frameEx->Name);

frameEx->pMeshContainer = NULL;
frameEx->pFrameSibling = NULL;
frameEx->pFrameFirstChild = NULL;

*ppNewFrame = frameEx;

return D3D_OK;

This is the method CreateMeshContainer on the class that extends of ID3DXAllocateHierarchy:

HRESULT AllocMeshHierarchy::CreateMeshContainer(PCTSTR Name,
const D3DXMESHDATA* pMeshData, const D3DXMATERIAL* pMaterials,
const D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials,
const DWORD *pAdjacency, ID3DXSkinInfo* pSkinInfo,
D3DXMESHCONTAINER** ppNewMeshContainer)

::ZeroMemory(meshContainer, sizeof(D3DXMESHCONTAINER));
if( Name ) CopyString(Name, &meshContainer->Name);
else CopyString("<no name>", &meshContainer->Name);

*ppNewMeshContainer = meshContainer;

if( pSkinInfo == 0 || pMeshData->Type != D3DXMESHTYPE_MESH)
return D3D_OK;

meshContainer->NumMaterials = NumMaterials;
meshContainer->pMaterials = new D3DXMATERIAL[NumMaterials];
for(DWORD i = 0; i < NumMaterials; ++i)
D3DXMATERIAL* mtrls = meshContainer->pMaterials;
mtrls.MatD3D = pMaterials.MatD3D;
mtrls.MatD3D.Ambient = pMaterials.MatD3D.Diffuse;


meshContainer->pEffects = 0;
meshContainer->pAdjacency = 0;

meshContainer->MeshData.Type = D3DXMESHTYPE_MESH;
meshContainer->MeshData.pMesh = pMeshData->pMesh;
meshContainer->pSkinInfo = pSkinInfo;

return D3D_OK;

Anyone can help me??


Share this post

Link to post
Share on other sites
Are you sure that model file has no problem? Can you open it via DirectX Viewer (comes with SDK) or any other viewer? Also, what's the returning value from D3DXLoadMeshHierarchyFromX() ?

Share this post

Link to post
Share on other sites
Hi programci_84,

Yes I'm sure that the file has no problem.

The values returns by D3DXLoadMeshHierarchyFromX() are:
root = NULL and animationController = NULL

The ID3DXAllocateHierarchy instance creates the frames and the 2 meshes but I don't understand why the root is null.


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!