Sign in to follow this  

keyframe animation

This topic is 4763 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

i guys, i've learned how to load a simple mesh inside my "game". Now i would jusmp to load animated mesh. So these are my doubts (please help me): 1)Do i necessarily need to use bones to animate my mesh (in 3dsmax) or can i just make animation simply using keyframe method? (and exporting it in .x) 2)Must i create a own Parse class to handle animated mesh (i'm reading Advance Animation with directx) or can i use Directx for that? BIG TNX

Share this post


Link to post
Share on other sites
Hello,

1. You don't need to use bones, but it is usually very fast and convenient to use within an application, that's why most game used skinned meshes for their animations. There are a few other alternatives, such as keyframe animation as you mentionned and morphing.

2. I think there are classes to handle skinned meshes in D3DX, but I'm not 100% sure.

Share this post


Link to post
Share on other sites
ok, assume i've a simply animation it doesn't need bones, how can handle keyframe animation in my game?
Are there some tutorial in the network about it? (i've found anything with google)

Share this post


Link to post
Share on other sites
I don't know of any tutorial, but I'm pretty sure there are a few articles on the Internet.

The concept is not so hard for simple keyframe animation, you can just do a linear interpolation between two keyframes of your mesh.

Here's an example to go from keyframeA to keyframeB in 1 second:


// Linear interpolation between f1 and f2
// Assuming t is in the [0..1] range
float Lerp(float f1, float f2, float t)
{
return f1 + (f2 - f1) * t;
}

void ProcessAnimation(Vector3* vertices, KeyFrame* keyframeA, KeyFrame* keyframeB, float time)
{
unsigned long i;

// ...

for (i = 0; i < keyframeA->nbVertices; ++i)
{
vertices[i].x = Lerp(keyframeA->vertices[i].x, keyframeB->vertices[i].x, time);
vertices[i].y = Lerp(keyframeA->vertices[i].y, keyframeB->vertices[i].y, time);
vertices[i].z = Lerp(keyframeA->vertices[i].z, keyframeB->vertices[i].z, time);
}
}


Share this post


Link to post
Share on other sites
so the frames in the .x files other to rappresent a part of the whole mesh it rappresent the real FRAME in the movie...
So you advice me to load at the start the 1° frame then the 2° end so on...
Isn't it?
Tnx, i've rated you.

Share this post


Link to post
Share on other sites
Yes, but keep in mind that this is only one way of animating meshes, and as you realized, it is memory expensive. The main advantages of this technique is that it is very simple and does not require much CPU power. IIRC, Quake2 was using keyframe animation for characters.

Still, I recommend bone animation since you need to store the geometry only once and animation data is only made of rotation, translation and sometimes scaling of the bones. It may also be easier to use in DirectX since D3DX provides the ID3DXMesh and ID3DXSkinInfo interfaces, but I've never worked with them so I can't comment on that.

Share this post


Link to post
Share on other sites

This topic is 4763 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this