   ID3DXFileData-GetNextObject - how to do this with DirectX 9.0C?
  Hello,I too have problems with the (in)famous book from Jim Adams 'Programming Role Playing Games with DirectX'. Don't get me wrong, it's a good book, but I didn't know it was written with the DirectX 9.0a SDK, and I use DirectX 9.0c.So, I've already done a bit of conversionwork to get the meshessystem done but I've ran into a problem now. I can't convert the code from DirectX 9.0a to DirectX 9.0c (and I've tried a lót!) but it just won't work. If there is ányone (yes you too!) that can help me, and the other people with these problems, then please reply. If I can succesfully solve this conversionpuzzle (hehe...), then I'll sure post the solution. Now to the real code:void cMesh::ParseXFileData(IDirectXFileData *pDataObj, sFrame *ParentFrame, char *TexturePath){  IDirectXFileObject *pSubObj  = NULL;  IDirectXFileData   *pSubData = NULL;  IDirectXFileDataReference *pDataRef = NULL;  // ...A lot of code snipped... //  while(SUCCEEDED(pDataObj->GetNextObject(&pSubObj))) {    // Process embedded references    if(SUCCEEDED(pSubObj->QueryInterface(IID_IDirectXFileDataReference, (void**)&pDataRef))) { if(SUCCEEDED(pDataRef->Resolve(&pSubData))) {   ParseXFileData(pSubData, SubFrame, TexturePath);   ReleaseCOM(pSubData); } ReleaseCOM(pDataRef);    }    // Process non-referenced embedded templates    if(SUCCEEDED(pSubObj->QueryInterface(IID_IDirectXFileData, (void**)&pSubData))) { ParseXFileData(pSubData, SubFrame, TexturePath); ReleaseCOM(pSubData);    }    ReleaseCOM(pSubObj);  }  return;}I know that the IDirectXFileObject and IDirectXFileDataReference COM objects don't exist with DirectX 9.0a, as for some functions (GetNextObject() e.g.) don't exist with DXSDK 9.0c and I need yóur help to convert this into proper 9.0c. I don't want you to just convert it for me (that'd be wrong) but just help me with it. Even if you know very little about this but think you can help me...do!I know there are more then hundres, thousands, millions of people out there who can help me, and other desperate people, with this problem. There are enough people creating games and the know how hard it was to learn, but half of them won't even post now.I just want to create fun games, so please bring up the will to answer this time and guide this helpless little child[smile].Please...-Stenny   
  Looks like it's just me again... [lol]I'm no expert at this stuff, so don't just take my word for it. Everything I know is from bits and pieces that I've gathered from around the net.What I did last time was to replace the whole 'while' condition with the one below:// Enumerate the file data object for its child dataDWORD children = 0;pDataObj->GetChildren(&children);for (DWORD i = 0; i < children; ++i){// Query the child for its file dataif (SUCCEEDED(pDataObj->GetChild(i, &pSubData))){ParseXFileData(pSubData, SubFrame, TexturePath);ReleaseCOM(pSubData);}}I got the code fix from here (there's a bit of explaination in there, so do check it out):http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=104342&SiteID=1Hope that helps.   ;  Thanks, that worked[smile][smile][smile]! That topic only covers the cMesh class but I think I can find out cAnimation myself. I'll post if otherwise!-Stenny   ;  Ok, a new one:I know ID3DXFileData::GetData doesn't exist anymore, and I've solved this problem with FrameTransformationMatrices. Now AnimationKeys apparently use this too and I don't know how to adjust this:PBYTE *DataPtr;if(Type == TID_D3DRMAnimationKey && CurrentAnim != NULL){if(FAILED(pDataObj->GetData(NULL, Size, (PVOID*)&DataPtr))) { return; }KeyType = ((DWORD*)DataPtr)[0];NumKeys = ((DWORD*)DataPtr)[1];}Should it be something like:PBYTE *DataPtr;if(Type == TID_D3DRMAnimationKey && CurrentAnim != NULL){   BYTE** DataPtr = NULL;if(FAILED(pDataObj->Lock(&Size, (LPCVOID*)&DataPtr))) { return; }// something copystuff here or something?pDataObj->Unlock();   KeyType = ((DWORD*)DataPtr)[0];NumKeys = ((DWORD*)DataPtr)[1];}-Stenny[Edited by - stenny on September 24, 2006 8:00:24 AM];  Ah, the animation part. I wasn't able to get mine to work properly. Sorry that I couldn't help out on this.... [depressed]This is what I did though, but I think it's wrong because I kinda forcefully typecast the DataPtr to ID3DXFileData to get rid of the compiler errors.if (Type == TID_D3DRMAnimationKey && CurrentAnim != NULL){// Load in this animation's key dataif (FAILED(pDataObj->GetChild(Size, (ID3DXFileData **)&DataPtr)))return;KeyType = ((DWORD*)DataPtr)[0];NumKeys = ((DWORD*)DataPtr)[1];};  Well the only part I got a problem with is that piece of code, so if anyone knows the solution...?Also, I only need to do the vertexbufferfunctions, but each time I compile I get this error:error LNK2005: "unsigned char * D3DRM_XTEMPLATES" (?D3DRM_XTEMPLATES@@3PAEA) already defined in Core_Graphics.objWinMain.objHas anyone got a clue what this means and how to solve this?-Stenny   ;  I think I've encountered this before...Just guessing here since there's not much info, you've to put the below lines in the .CPP source instead of the .H header file:#include "rmxftmpl.h"#include "rmxfguid.h"   ;  And again, that worked. lolI've finished the Graphics core now and look if it works...EDITWhy isn't this working?BOOL cTexture::Blit(long DestX, long DestY, long SrcX, long SrcY, long Width, long Height, float XScale, float YScale, D3DCOLOR Color){RECT Rect;ID3DXSprite *pSprite;D3DXMATRIXmatTemp;if(m_Texture == NULL) { return FALSE; }if(m_Graphics == NULL) { return FALSE; }if((pSprite = m_Graphics->GetSpriteCOM()) == NULL) { return FALSE; }if(!Width) { Width = m_Width; }if(!Height) { Height = m_Height; }Rect.left = SrcX;Rect.top = SrcY;Rect.right = Rect.left + Width;Rect.bottom = Rect.top + Height;D3DXMatrixIdentity(&matTemp);D3DXMatrixScaling(&matTemp, XScale, YScale, 1.0f);if(FAILED(pSprite->SetTransform(&matTemp))) { return FALSE; }if(FAILED(pSprite->Draw(m_Texture,&Rect,NULL,&D3DXVECTOR3(DestX, DestY, 0.0f),Color))){return FALSE;}return TRUE;}The Debugger says there's a mistake in the Draw function, at least, that's where it returns a FALSE.-Stenny-Stenny[Edited by - stenny on September 25, 2006 10:37:02 AM]