CreateFrame creates some sort of infinite loop?

Started by
4 comments, last by ankhd 16 years, 11 months ago
Heres my createframe implementation:
HRESULT loadH::CreateFrame(LPCSTR _frameName, LPD3DXFRAME *ppNewFrame)
{
	*ppNewFrame = NULL;
	frameName = _frameName;

	D3DXFRAME* frame = new D3DXFRAME;
	ZeroMemory(frame,sizeof(D3DXFRAME));

	frame->Name = loadH::strConv(frameName);
	D3DXMatrixIdentity(&frame->TransformationMatrix);

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

	*ppNewFrame = frame;

	return true;
}
As you can probably guess it isn't working, everytime I try to create a frame (in a seperate calss) it gets me stuck on some sort of loop or just crashes. Usually it crashes and gives me an unhandled exception error though it does get stuck on infinite loops sometimes... I don't know whats causing it so umm, any help?
Advertisement
Quote:Original post by chillypacman
Heres my createframe implementation:
*** Source Snippet Removed ***

As you can probably guess it isn't working, everytime I try to create a frame (in a seperate calss) it gets me stuck on some sort of loop or just crashes. Usually it crashes and gives me an unhandled exception error though it does get stuck on infinite loops sometimes...

I don't know whats causing it so umm, any help?
Define "crashes". What error do you get? Where does the debugger say it's crashing? When it goes into an infinite loop, where is it looping?
Ok, the infinite loop turns out to be something else entirely (not in the code above) and I can't be bothered fixing it today so I've just taken it out (for the time being).

I'm not sure if I'm doing this right but heres what I have so far:

ID3DXAllocateHierarchy* H;	ID3DXLoadUserData *LUD;	LPD3DXFRAME* f;	LPD3DXANIMATIONCONTROLLER* animC;			D3DXLoadMeshHierarchyFromX("tiger", D3DXMESH_MANAGED, Device, H, LUD, f, animC);		LPD3DXFRAME * newFrame;	H->CreateFrame("frame 1", newFrame);


H->CreateFrame is what is making it crash, when I run the code it gives me an unhandled exception error.

Quote:Unhandled exception at 0x0040234e in shapes2.exe: 0xC0000005: Access violation reading location 0x00000000.
Quote:Original post by chillypacman
Quote:Unhandled exception at 0x0040234e in shapes2.exe: 0xC0000005: Access violation reading location 0x00000000.

Translation: The instruction in your compiled code at 0x0040234e tried to read from address 0x00000000.

In other words: You have a null pointer you tried to dereference. Why isn't H being initialised at all?
ID3DXAllocateHierarchy is an abstract class so ID3DXAllocateHierarchy* H = new ID3DXAllocateHierarchy doesn't work.

I'm doing this for the first time so the problem is probably pretty obvious, I might just be missing something.

I thought D3DXLoadMeshHierarchyFromX actually initialized H.


ok, when I use the following code:

D3DXFRAME * newFrame = new D3DXFRAME;
H->CreateFrame("frame 1", &newFrame);

I get the following error now: "Unhandled exception at 0x0040213f in shapes2.exe: 0xC0000005: Access violation reading location 0x00000050."

I think I changed the model it was loading, since the original one (tiger.x) didn't have any animation bones so I thought that might have been causing the problems.


Could the problem actually be here?

HRESULT loadH::CreateMeshContainer(THIS_ LPCSTR Name, CONST D3DXMESHDATA * pMeshData, 								   CONST D3DXMATERIAL * pMaterials, CONST D3DXEFFECTINSTANCE * pEffectInstances,								   DWORD NumMaterials, CONST DWORD * pAdjacency, LPD3DXSKININFO pSkinInfo, 								   LPD3DXMESHCONTAINER * ppMC){	MC = new D3DXMESHCONTAINER_EXTENDED();	MC->Name = strConv(Name);	MC->NumMaterials = numMtrls;	MC->pMaterials = mtrls;	MC->MeshData.pMesh = model;	DWORD dwFaces = pMeshData->pMesh->GetNumFaces();	MC->pAdjacency = new DWORD[dwFaces*3];	memcpy(MC->pAdjacency, pAdjacency, sizeof(DWORD) * dwFaces*3);	LPDIRECT3DDEVICE9 pd3dDevice = NULL;	pMeshData->pMesh->GetDevice(&pd3dDevice);	D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE];	if (FAILED(pMeshData->pMesh->GetDeclaration(Declaration)))		return E_FAIL;	pMeshData->pMesh->CloneMesh(D3DXMESH_MANAGED, 		Declaration, pd3dDevice, 		&MC->MeshData.pMesh);	//ppMC = &MC;	return true;}


ppMC is of type D3DXMESHCONTAINER* wherein MC is D3DXMESHCONTAINER_EXTENDED. D3DXMESHCONTAINER_EXTENDED is defined as:

struct D3DXMESHCONTAINER_EXTENDED: public D3DXMESHCONTAINER	{		std::vector<D3DMATERIAL9> Mtrls;		std::vector<IDirect3DTexture9*> Textures;		// Skinned mesh variables		ID3DXMesh*   exSkinMesh;      // The skin mesh		D3DXMATRIX*  exBoneOffsets;    // The bone matrix Offsets		D3DXMATRIX**  exFrameCombinedMatrixPointer; // Array of frame matrix	};


I knew it was going to cause me troubles sooner or later but it seems like it was sooner. I don't know how else to work with it, should I not extend D3DXMESHCONTAINER?

[Edited by - chillypacman on May 22, 2007 10:43:37 AM]
Hey there, here is a good link to a site, this helped me. read it if not allready done so.
http://www.toymaker.info/Games/html/load_x_hierarchy.html#HierarchyConcept

This topic is closed to new replies.

Advertisement