Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


root NULL in D3DXLoadMeshHierarchyFromX


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 cHimura   Members   -  Reputation: 122

Like
0Likes
Like

Posted 01 February 2012 - 11:49 PM

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:
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;
}


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)
{	

	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;
}

Anyone can help me??

Thanks

Sponsor:

#2 programci_84   Members   -  Reputation: 336

Like
0Likes
Like

Posted 02 February 2012 - 12:13 AM

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() ?
There's no "hard", and "the impossible" takes just a little time.

#3 cHimura   Members   -  Reputation: 122

Like
0Likes
Like

Posted 05 February 2012 - 12:47 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS