Sign in to follow this  

root NULL in D3DXLoadMeshHierarchyFromX

This topic is 2172 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 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:
[code]
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;
D3DXMatrixIdentity(&frameEx->TransformationMatrix);
D3DXMatrixIdentity(&frameEx->toRoot);

*ppNewFrame = frameEx;

return D3D_OK;
}
[/code]


This is the method CreateMeshContainer on the class that extends of ID3DXAllocateHierarchy:
[code]
HRESULT AllocMeshHierarchy::CreateMeshContainer(PCTSTR Name,
const D3DXMESHDATA* pMeshData, const D3DXMATERIAL* pMaterials,
const D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials,
const DWORD *pAdjacency, ID3DXSkinInfo* pSkinInfo,
D3DXMESHCONTAINER** ppNewMeshContainer)
{

D3DXMESHCONTAINER* meshContainer = new D3DXMESHCONTAINER();
::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[i].MatD3D = pMaterials[i].MatD3D;
mtrls[i].MatD3D.Ambient = pMaterials[i].MatD3D.Diffuse;

CopyString(pMaterials[i].pTextureFilename,
&mtrls[i].pTextureFilename);
}


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

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

return D3D_OK;
}
[/code]

Anyone can help me??

Thanks

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.

Thanks

Share this post


Link to post
Share on other sites

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