The Framework X File ClassThe Direct3D 7 IM Framework provides you the following interface class:
These methods are exported by the Framework. The GetMeshVertices() method retrieves the vertices for a specified mesh by traversing its hierarchy of frames and meshes, whereas GetMeshIndices() retrieves the vertices for the specified mesh. Both methods are useful, when, for example, you would like to use your own render method and not the one provided with the framework. To use your own RenderMethod, you might use these in two function calls in InitDeviceObjects() and call DrawIndexedPrimitive() with the array of vertices and indices in the Render() method. Check out the second tutorial First Steps to Animations to learn more about indexed primitives. FindObject() returns the named meshes by searching through all meshes a in file object, whereas EnumObjects() enumerates all objects in the file. It's also used by FindObjects(). Scale() scales a mesh with the help of ScaleMeshCB(). Load() creates a hierarchy of frames and meshes and loads the X file with ParseFrame() and ParseMesh(), which enumerate all the child objects. There are two Render() methods in d3dfile.cpp in the Framework source. One is in the class CD3DFileObject and the other one in the class CD3DFile. That brings us to the second class used only internally by the Framework for objects in a .X file. You'll find it in the d3dfile.h:
The class CD3DFile uses this class to solve a lot of its tasks. The CD3DFile::Render() method will call CD3DFileObject::Render() to render the object. We don't worry about it here, because it's used internally by CD3DFile. These render methods aren't optimal. They support alpha blending, but not other features of Direct3D, especially Multi-Texturing. You might be programming your own X file routines to wring out the last possible byte and cycle of the X file format and Direct3D. So d3dfile.cpp should only serve as an example for your own X file class, which will be optimized based on the needs your game will have. See the tutorial from Mr. Gamemaker at Loading X files for an optimized X file class. Well, now that you know the Framework interface, we can dive deeper into the code of the sample app.
|
||||||||||||||||||||