Steps for loading and rendering a bone animated mesh

Started by
3 comments, last by Hilbily001 17 years, 9 months ago
OK, I'm slowly trying to understand DX along with C++. I have read few books, millions of web pages, followed online tutorials and such. As of right now, I'm attempting a step by step procedure to implement certian things involved in the game making process. Right now, I have a personal Create DX Device program. Then I took that and added a DX Font and Frames per sec output. Then I took the program and loaded my own .x file with animations using the D3DXLoadMeshFromX function, just to get my model displayed and to play with the device settings and stuff. I have not used any form of classes to make any implementations of the DX functions in my code. I have 1 main.cpp that contains all the code. I am using 1 Globals.h header just for my variables and includes to keep my code understandable. I apologize for being so long winded... I am looking for a quick step by step of how to load an animated .x file and display the animations. I would like to see the bare minimum requirements to do this in a simple procedural style. Heres a quick pseudo of what I have. These are the contents of my Main.cpp file. - Includes //all global vars and header file includes - GetFPS() //Function to get and display the FPS - DispText() //Function used to display text using DX Font - InitD3D() // Initializes DX, creates the Device and sets the parameters - InitGeometry() //Loads the .x file and textures using D3DXLoadMeshFromX - Cleanup() //releases all the memory used by DX interfaces - SetupMatrices() //Creates a World Matrices used for viewing the model - Render() //Shows the scene - MsgProc() //Handles any window event messages - WinMain() //Creates the window, the handle and preliminary info I have no idea which functions are required to get the animated .x file loaded and to render the animations on the most simple level. (Simple meaning Procedural with the least amount of code possible). The bad thing about the SDK sample is that there is alot more going on then just showing the animated mesh. Theres the fonts, the input control and user options that can be set at runtime, etc. I would just like to see the least amount of code required to get an animated mesh on screen. Thanks for any help.
Hilbily001Admin@HilBily-Works.comhttp://www.hilbily-works.com
Advertisement
OK, I'm at the end of day 3 and heres what I came up with so far...

I am just trying to get the animated model loaded into my program using procedural code to try and keep things simple.

Step 1 - Create an ID3DXAllocateHierarchy object. This interfaces contains a few functions for creating and freeing objects of the mesh.

Step 2 - Call D3DXLoadMeshHierarchyFromX function passing in the ID3DXAllocateHierarchy object as a parameter. This will actually load the .x file info and distribute the data into the appropriate areas(?)

Step 3 - Call ID3DXAllocateHierarchy::CreateMeshContainer Method. Is this the actually storage device that contains all the x file data?

Step 4 - Call ID3DXAllocateHierarchy::CreateFrame Method. Must pass in the CreateMeshContainer parameter. I dont really understand what this does. OK, what does the frame actually represent? A limb of the model? The actual matrice of the limb in a position of the animation?

I apologize if I seem to be a lost cause here, I am experiencing major info overload and from what I read, a typical outcome when dealing with DX. Tomorrow I will be begin attemting to implement the above steps into my program. Thanks for any help.


Hilbily001Admin@HilBily-Works.comhttp://www.hilbily-works.com
I hear you. It took me weeks to figure it all out. Take a look at this sample:

ToyMaker

It is a tad easier to understand than the SDK SkinnedMesh and MultiAnimation samples, though I studied the multi one to learn how to play and blend animation sets.

The functions in the Allocate Hierarchy class are what the D3DXLoadMeshHierarchyFromX call as it loads the .x file.

--------------------------Most of what I know came from Frank D. Luna's DirectX books
Thanks for the input there DXNut. I have looked at that web page quite a few times since beginning this endeavor. By you bringing it up, I looked it over again. It seems to be a good starting point because the web page explains stuff pretty good. Its hard for me to determine from his conglomeration of source files and header files what is required to load a .x file using D3DXLoadMeshHierarchyFromX. I am currently trying to piece together the bare minimum code to do this using procedural code in lieu of classes and seperate files. Heres what I got so far...

HRESULT InitGeometry(){	LPD3DXALLOCATEHIERARCHY dx_Alloc;	LPD3DXFRAME dx_FrameRoot;	LPD3DXANIMATIONCONTROLLER dx_AnimController;	//HRESULT hr = D3DXLoadMeshHierarchyFromX("cloneman.x", D3DXMESH_MANAGED, dx_Device, &dx_Alloc, NULL, &dx_FrameRoot, &dx_AnimController);	//if (FAILED(hr))		//return E_FAIL;    return S_OK;}


This function is called in the winmain function and returns true if S_OK, then enters the main loop. I had to comment out the D3DXLoadMeshHierarchyFromX due to too many errors. With it commented out, I get my window and no errors or warnings. LOL. Ill keep plowing away though.
Hilbily001Admin@HilBily-Works.comhttp://www.hilbily-works.com
Well, Im starting day five of this. I am going to create a ID3DXAllocateHierarchy class and use redefinitions of the D3DXFrame and MeshContainer structs. I will put all this in header files and definition files. The reason you ask? Well, cause out of the 2 books I have (Programming RPG Games and Programming a Multiplayer FPS) and the 3 websites out of 1,343,234,987 that actually have D3DXLoadMeshHierarchyFromX information, thats the way they did it. I could put it all in 1 file and create somewhat of a procedural structure to the code, but the file would get extrememly long and I finally cracked in allowing a few seperate header files and such.


Anyways... This is Hilbily001 checking in and until tomorrow or tonight if I get something working, thanks for listening to me.
Hilbily001Admin@HilBily-Works.comhttp://www.hilbily-works.com

This topic is closed to new replies.

Advertisement