Changes

Jump to: navigation, search

User:Dsventura

1,332 bytes added, 17:51, 30 March 2011
added known issues
<h1>GAM670 - XAnimation</h1>
<h2>Source Code</h2>
<h2>Overview</h2>
Animation in DirectX9 can be done using .X files. The .X extension refers to a file containing a Microsoft proprietary format for exported 3D models. This format is similar to COLLADA, except the file parsing is handled by DirectX internally. To export a model in .X format in 3Ds MAX, I used a plugin from PandaSoft called the Panda DirectX Max exporter (link on last page).
To put all of this into the framework, we create an XObject class which is derived from Object. This will hold model information as well as the animation controller. It will also hold information that allows us to change animation sets and the speed of the animation. (refer to XObject.h)
<h4h3>Animation Controller</h4h3>
To give you an overview of the animation controller and it's functions, here's a list of functions used in this example (descriptions from msdn.microsoft.com):
'''m_animController->SetTrackEnable( newTrack, TRUE );'''
 
<h2>Known Issues</h2>
<h3>CreateFrame() and CreateMeshContainer</h3>
In both CreateFrame and CreateMeshContainer, name was never set in the original code. If you were to implement this code yourself, make sure you set the frame or mesh container's name to the Name parameter. Forgetting to do this will make the animation controller always return NULL from the D3DXLoadMeshHierarchyFromX call.
<pre>
// for CreateFrame
if(Name){
newFrame->Name = new char[strlen(Name)+1];
strcpy(newFrame->Name, Name);
newFrame->Name[strlen(Name)] = 0;
}
</pre>
<h3>DestroyFrame() and DestroyMeshContainer()</h3>
<pre>
if(meshContainer->Name)
delete []meshContainer->Name;
</pre>
<h3>XObject::Draw()</h3>
This line used to be in the draw function:
<pre>
static DWORD lastTime=timeGetTime();
</pre>
The problem arose when I put multiple instances of XObject in design. Due to the static keyword, this variable would be shared among all of the animated objects. The first animation would run smoothly, while any animations added afterwords would be extremely slow. This is because this variable tells the function when the last time it drew the object's state along the animation time-line, and each object's time-line is different. To fix this, I made last time a data member and initialized it to 0 in the constructor.
1
edit

Navigation menu