#include
<windows.h>
#include
<stdio.h>
#include
<rmxftmpl.h>
// D3DRM_XTEMPLATES definition
#define
ULONG_PTR unsigned
long
#pragma
comment(lib,
"D3d8.lib") // DirectX 8 lib files
#pragma
comment(lib,
"D3dx8.lib")
#include
<d3dx8.h>
//
DirectX 8 header file
#include
<Dxfile.h>
#pragma
comment(lib,
"D3dxof.lib")
typedef
struct sFrame
{
} sFrame;
void
ParseXFileData(IDirectXFileData* pData, sFrame* ParentFrame)
{
DWORD dwSize;
pData->GetName(NULL, &dwSize);
if( dwSize )
{
char str[100];
pData->GetName( str, &dwSize );
MessageBox(0, str, str, 0);
}
const GUID* pType = NULL;
pData->GetType( &pType );
// pType could now be set to a number of type,
here are the most important ones
// TID_D3DRMFrame
// TID_D3DRMMesh
// TID_D3DRMaterial
// TID_D3DRMFrameTransformMatrix
// TID_D3DRMAnimationSet
// TID_D3DRMAnimationKey
// TID_D3DRMAnimation
// A list of them can be found in rmxfguid.h
// Check if theres any embeded object now...so we
don't just get the
// top layer.
IDirectXFileObject* pSubObj;
while( pData->GetNextObject(&pSubObj) == 0 )
{
IDirectXFileData *pSubData = NULL;
// Made up of 2 parts!...one that has
more babies..I mean
// children, and another that is just
on its own.
/*
IDirectXFileDataReference *pDataRef = NULL;
if( pSubObj->QueryInterface(IID_IDirectXFileDataReference,
(void**)&pDataRef) == 0)
if(pDataRef->Resolve(&pSubData))
ParseXFileData(pSubData, NULL);
*/
// This will loop deeper
if( pSubObj->QueryInterface(
IID_IDirectXFileData, (void**)&pSubData) ==
0)
{
ParseXFileData(pSubData, NULL);
pSubData->Release();
}
pSubObj->Release();
}//
End fo While loop
}//
End of ParseXFileData(..)
bool
ParseXFile(char* filename)
{
IDirectXFile *pDXFile = NULL;
IDirectXFileEnumObject *pDXEnum = NULL;
IDirectXFileData *pDXData = NULL;
DirectXFileCreate(&pDXFile); //
requires Dxfile.h and D3dxof.lib
//
return 0 if okay
// Tell direct3D which templates to use
pDXFile->RegisterTemplates( (LPVOID)D3DRM_XTEMPLATES, D3DRM_XTEMPLATE_BYTES
);
// Need to mention "rmxftmpl.h"
pDXFile->CreateEnumObject( (LPVOID)filename, DXFILELOAD_FROMFILE, &pDXEnum
);
while( pDXEnum->GetNextDataObject(&pDXData)
== 0 )
{
ParseXFileData( pDXData, NULL );
}
// Tidy up
pDXEnum->Release();
pDXFile->Release();
return true;
}//
End of ParseXFile(..)
// Program entry point.
int
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR,
int)
{
ParseXFile("bomb.x");
return 0;
}//
End of WinMain(..) |