# Programming RPG with DX 2nd edition book problem

## Recommended Posts

Hi there, I'm having trouble with the .X file animation loading function on this book. I've done some search, and modified most of the codes to the new DX9 interface for .X parsing, but I'm still getting error compiling it. This is the error message I'm getting:
c:\Documents and Settings\Administrator\My Documents\DirectX9
Sandbox\CoreGraphics.cpp(2327): error
C2664: 'IDirectXFileEnumObject::GetNextDataObject' : cannot convert parameter 1
from 'ID3DXFileData **__w64  ' to 'LPDIRECTXFILEDATA * '

The error occurs on this part of the code (marked as ERROR HERE):
bool Animation::Load(char *filename, Mesh *mapMesh)
{
IDirectXFile			*pDXFile = NULL;
IDirectXFileEnumObject		*pDXEnum = NULL;
ID3DXFileData			*pDXData = NULL;

// Free a prior animation
Free();

// Error checking
if (filename == NULL)
return FALSE;

// Create the file object
if (FAILED(DirectXFileCreate(&pDXFile)))
return FALSE;

// Register the templates
if (FAILED(pDXFile->RegisterTemplates((LPVOID)D3DRM_XTEMPLATES, D3DRM_XTEMPLATE_BYTES)))
{
pDXFile->Release();
return FALSE;
}

// Create an enumeration object
{
pDXFile->Release();
return FALSE;
}

// ******** ERROR HERE
// Loop through all objects looking for the animation
while (SUCCEEDED(pDXEnum->GetNextDataObject(&pDXData)))
{
ParseXFileData(pDXData, NULL, NULL);
ReleaseCOM(pDXData);
}
.
.   // *snip*
.
}


I've check the below pages, but none of them deals with this part of the code, unfortunately... http://www.gamedev.net/community/forums/topic.asp?topic_id=388255&PageSize=25&WhichPage=1 http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=104342&SiteID=1 Anyone knows what's wrong? Or did I mess up somewhere else? Thanks!

##### Share on other sites
I believe that this post was about this. I don't know if it resolved the problem or not.

Paul

##### Share on other sites
I'm working trough this book, too. And encountered this problem. Because I'm writing my own rpg in parallel it is not so hard for me, I'll just write the x file handling stuff with the newer interfaces.
An excellent article about the ne ID3DX* interfaces is http://www.moon-labs.com/resources/d3dx_skinnedmesh.pdf

##### Share on other sites
Finally found some time to look into this again. Thanks for the replies guys [smile]

I've successfully (or I think I have) replaced all the old interface with the new ones. It compiles without any errors but now there's another problem! Skin mesh isn't animating. It's just stucked at it's default T-figure pose. Anyone had the same problem?

Below is the code that I use to load and apply animation to the model, but I don't think the problem is located here...

The model is from the book's CD, I've checked that the animation name is correct, and the currentTicks timer is incrementing every loop... I'm out of ideas at the moment on how to fix this. Anyone who's familiar with the book, a point in the right direction would be greatly appreciated. Thanks! [smile]

// ** Inside initialize function// Loading modelm_mesh.Load(&m_graphics, "warrior.x");// Load anim and loop walk animm_anim.Load("warrior.x", &m_mesh);m_anim.SetLoop(TRUE, "Walk");// Create and position objectm_object.Create(&m_graphics, &m_mesh);m_object.Move(0.0f, 0.0f, 300.0f);// Apply walk anim to objectm_object.SetAnimation(&m_anim, "Walk", currentTicks);// ** Inside render loopm_object.UpdateAnimation(currentTicks, TRUE);m_object.Render();

* if mods think this better belongs to the DirectX forum, please move the thread for me. Thanks!