• Advertisement

Archived

This topic is now archived and is closed to further replies.

How will I know that my .x file has ended?

This topic is 5553 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im working on an animation that would change depending on my input. I used skinned mesh models to make my characters look good. So, what I am planning to do is to load for example "character01.x" then if a user inputs a certain value it would load "character02.x" and so on... Or when the character finishes the animation in "character02.x" it will go directly in "character03.x" How will i able to achieve this? I messed around with the code in skinnedmesh found in sdk, and my problem is I dont know what variables i need to watch for to know that the x file has finished doing its motion... in short it would not "loop" and i would like to know when its going to stop. alternatives would be nice as long as its not to advanced need help... deadline next week

Share this post


Link to post
Share on other sites
Advertisement
The SDK skinned mesh example makes my head spin!

Go here for a simpler version of it.

Download the code for it here

Read the forum here on how to make a couple of easy fixes to get it to compile

I wrote a post about modifying this code so that it will display multiple animations, but it looks like it was deleted....

Anyway if you are using the same model but just different animations, just copy and paste the AnimationSet template from each file into just one of your .x files.

Also be sure and name each AnimationSet template after you paste them. The skinned mesh example already loads multiple animation sets, it just cant display them

Modify CSkinMesh::SetTime to the following:

void CSkinMesh::SetTime( DWORD dwtime )
{
CAnimationNode* animSetNode = NULL;
string animationSetName;

animSetNode = static_cast(Animations.GetFirstChild());
while( animSetNode != NULL )
{
animationSetName = animSetNode->GetName();
if ( animationSetName == m_sCurrentAnim )
{
animSetNode->SetTime( dwtime );
break;
}
animSetNode = static_cast(animSetNode->GetNextSibling());
}
}


Next add:
string m_sCurrentAnim;
to the public section of CSkinMesh.

Setting this string to the name of any of the AnimationSets in the .x file will display a particular animation. I set this string in WndProc. So a user can switch between a "stand" and "attack" animation by hitting F1 and F2. Something like this:

case WM_KEYDOWN:
{
switch( wparam )
{
// The F1 key was pressed
case VK_F1:
{
g_SkinMesh.m_sCurrentAnim = "Stand";
break;
}
// The F2 key was pressed
case VK_F2:
{
g_SkinMesh.m_sCurrentAnim = "Attack";
break;
}
}

This will at least get you to where you can display each different animation and switch with a key press.

CSkinMesh::Animations is a tree structure. The top lvl nodes of this structure hold just the names of the AnimationSets loaded from the .x files. Under these nodes are the animation data for that particular AnimationSet. Thats all the above code does is look for a particular AnimationSet's name in CAnimationNode::Name and then recursively calls CAnimationNode::SetTime() on that node.

As for telling when an animation ends?

In CAnimationNode::SetTime() you will see the following line

dwtime %= aMatrixKey[dwMatrixKeyCount-1].dwTime;

All this does it loop the current animation over and over. You will have to modify this function so that when an animation is over it doesnt loop but instead changes CSkinMesh::m_sCurrenAnim to another animation.





[edited by - Wikkyd on December 6, 2002 5:27:14 AM]

[edited by - Wikkyd on December 6, 2002 5:32:22 AM]

Share this post


Link to post
Share on other sites
i just curious...
i have been spending a lot of time on google searching for articles related to skinned mesh and .x... and i tried finding good books and looked at msdn...

just wondering, how do you guys learn all this stuff?

any tips on how i can study for my self and not keep on posting here for my dumb questions?

Share this post


Link to post
Share on other sites
Good luck on finding a book or other good article on this subject. Ive searched and not found any whatsoever.

I learned skinning for Direct3D from this article and its source code.

My best advice to you is to download that code and run it in debug mode and watch how it loads everything into memory. It took me about 2-3 weeks to fully understand what it was doing.

There is no quick and easy tutorial out there. You just have to dig deep into that code.

Share this post


Link to post
Share on other sites

  • Advertisement