keyframe animation

Started by
5 comments, last by Link 19 years, 4 months ago
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
Advertisement
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.
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)
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] rangefloat 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.x = Lerp(keyframeA->vertices.x, keyframeB->vertices.x, time);    vertices.y = Lerp(keyframeA->vertices.y, keyframeB->vertices.y, time);    vertices.z = Lerp(keyframeA->vertices.z, keyframeB->vertices.z, time);  }}
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.
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.
ok VERY VERY tnx

This topic is closed to new replies.

Advertisement