X File Loading (DX 9)IntroductionThe x file format is a Microsoft format for holding mesh data. Exporters exist for most 3D packages and DirectX provides objects and methods in the D3DX library to work with the data. This section describes the different ways of loading and using x files in your game. XAnimator Animation LibraryImplementing code to load and play back animated .x files is a difficult task, although I do describe it in the notes. But in order to allow people to use animated x files without implementing all this code I have written a small library which you download via the XAnimator page. Methods of loading x filesThere are a number of D3DX functions that can be used to load an x file, these are divided into simple methods that collapse any hierarchy in the file but are easy to use and more complex methods that maintain the hierarchy and hence allow animation, skinning etc. Simple methods, collapses hierarchy- D3DXLoadMeshFromX - the simplest way but unfortunately all hierarchy information is lost.
- D3DXLoadMeshFromXInMemory - as above but to load from memory rather than disk.
- D3DXLoadMeshFromXof - as above but loads a mesh from a ID3DXFileData object
- D3DXLoadMeshFromXResource - as above but loads from a resource in a module
These functions are described in the Load X Simply notes. More complex methods, maintains hierarchy- D3DXLoadMeshHierarchyFromX - loads animation data and frame hierarchy from a .x file
- D3DXLoadMeshHierarchyFromXInMemory - as above but loads from memory not disk.
- D3DXLoadSkinMeshFromXof - loads hierarchy and skinning data from a ID3DXFileData object.
These methods allow skinning and animation. These functions are described in the Load X Hierarchy notes. InterfacesThese notes refer to the X file interfaces first introduced in the December 2004 update of the SDK. The old interfaces still work but are now marked as deprecated. The old legacy interfaces were: - IDirectXFile
- Pointer type: LPDIRECTXFILE
- IDirectXFileData
- Pointer type: LPDIRECTXFILEDATA
- IDirectXFileObject
- Pointer type: LPDIRECTXFILEOBJECT
- IDirectXFileSaveObject
- Pointer type: LPDIRECTXFILESAVEOBJECT
- IDirectXFileBinary
- Pointer type: LPDIRECTXFILEBINARY
- IDirectXFileDataReference
- Pointer type: LPDIRECTXFILEDATAREFERENCE
- IDirectXFileEnumObject
- Pointer type: LPDIRECTXFILEENUMOBJECT
The new interfaces are: - ID3DXFile
- ID3DXFileData
- Pointer type: LPD3DXFILEDATA
- ID3DXFileEnumObject
- Pointer type: LPD3DXFILEENUMOBJECT
- ID3DXFileSaveData
- Pointer type: LPD3DXFILESAVEDATA
- ID3DXFileSaveObject
- Pointer type: LPD3DXFILESAVEOBJECT
The pointer type is simply used to ease typing since you generally use a pointer to these interface classes. For example LPD3DXFILE is defined like this: typedef ID3DXFile* LPD3DXFILE; In these notes I will not use these typedefs as I find they confuse people, instead I will use the full pointer declaration. |