IDirectXFileData-GetData() - Deprecated!

Started by
1 comment, last by stenny 17 years, 7 months ago
Hello, I'll cut straight to the chase. I have a ParseXFileData function, which (of course) parses XFiles for their data. It first gives a call to ID3DXFileData->GetType() and stores the information into a GUID *Type. Then all the possible Types are checked:

void cMesh::ParseXFileData(ID3DXFileData *pDataObj, sFrame *ParentFrame, char *TexturePath)
{
	GUID		*Type = NULL;
	char		*Name = NULL;
	DWORD		Size;
	sFrame		*SubFrame = NULL;
	char		Path[MAX_PATH];

	sFrame		*Frame = NULL;
	D3DXMATRIX	*FrameMatrix = NULL;

	sMesh			*Mesh = NULL;
	ID3DXBuffer		*MaterialBuffer = NULL;
	D3DXMATERIAL	*Materials = NULL;
	ID3DXBuffer		*Adjecancy = NULL;
	DWORD			*ADjecancyIn = NULL;
	DWORD			*AdjecancyOut = NULL;

	DWORD	i;
	BYTE	**Ptr;

	if(FAILED(pDataObj->GetType(Type))) { return; }
	if(FAILED(pDataObj->GetName(NULL, &Size))) { return; }
	if(Size)
	{
		if((Name = new char[Size]) != NULL) { pDataObj->GetName(Name, &Size); }
	}

	if(Name == NULL)
	{
		if((Name = new char[9]) == NULL) { return; }
		strcpy(Name, "%NoName%");
	}

	SubFrame = ParentFrame;

	if(*Type == TID_D3DRMFrame)
	{
		Frame = new sFrame();

		Frame->m_Name = Name;
		Name = NULL;

		Frame->m_Parent = ParentFrame;
		Frame->m_Sibling = ParentFrame->m_Child;
		ParentFrame->m_Child = Frame;

		m_NumFrames++;

		SubFrame = Frame;
	}

	if(*Type == TID_D3DRMFrameTransformationMatrix)
	{
		if(FAILED(pDataObj->GetData(NULL, &Size, (PVOID*)&FrameMatrix))) { return; }
		ParentFrame->m_MatOriginal = *FrameMatrix;
	}
}
Most of the function isn't that important but the last part of the function gives some errors. I'm converting code from a book that uses DirectX 9.0a so instead of IDirectXFileData I use ID3DXFileData. The problem is that ID3DXFileData doesn't have a GetData() function as used in the last part of the code. Can someone help to convert this part to DirectX SDK9.0c? (Also: I use C++, MVSC++, and the books' "programming Role Playing Games with DirectX") -Stenny
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
Advertisement
If I'm not wrong, this should be it [smile]

if (Type == TID_D3DRMFrameTransformMatrix){	BYTE** DataPtr = NULL;	if (FAILED(pDataObj->Lock(&Size, (LPCVOID*)&DataPtr)))		return;	memcpy(&ParentFrame->m_MatOriginal, (void*)DataPtr, Size);	pDataObj->Unlock();}



I've changed this line as well (removing the * pointer), not sure if it's necessary:
GUID Type = GUID_NULL;
Thank you! It's working! [smile]!

Although I don't even dare to doubt you (hehe), is there someone who can tell me that is indeed (one of) the right way(s) to do it? I don't want to end up with a wrong function.

-Stenny
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel

This topic is closed to new replies.

Advertisement