Sign in to follow this  
derek7

take a look at traverse the .x file.

Recommended Posts

void ParseObject(IDirectXFileData *pData)
{
	IDirectXFileObject *pObject = NULL;
	IDirectXFileData *pSubData = NULL;
	IDirectXFileDataReference *pRef = NULL;

	// Scan for embedded objects
	while(SUCCEEDED(pData->GetNextObject(&pObject))) 
	{
		// Look for referenced objects
		if(SUCCEEDED(pObject->QueryInterface( 			IID_IDirectXFileDataReference, (void**)&pRef))) 
		{
			// Resolve the data object
			pRef->Resolve(&pSubData);
			// Parse the object by calling ParseObject
			ParseObject(pSubData);
			// Free interfaces
			pSubData->Release();
			pRef->Release();

		}
		// Look for instanced objects
		if(SUCCEEDED(pObject->QueryInterface( 			IID_IDirectXFileData, (void**)&pSubData))) 
		{
			// Parse the object by calling ParseObject
			ParseObject(pSubData);
			// Free the object interface
			pSubData->Release();
		}
		// Free the interface for next object to use
		pObject->Release();
	}
}


it seem to has a bug. it only get a subObject. if a parentObject has more than one subObject, it seem to be only access a subObject. the code is from advanced_animation_with_directx by Jim Adams. maybe in .x file is there only a childobject under a parentojbect?

Share this post


Link to post
Share on other sites
I found the problem here:

while(SUCCEEDED(IDirectXFileData::GetNextObject(IDirectXFileObject)))
{

}

GetNextObject does the job: it get subobject of a object. but it CAN remember position ,so when GetNextObject call again. it will get next subobject

right?

Share this post


Link to post
Share on other sites

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