animating .x WITHOUT bones

Started by
14 comments, last by apanjocko 20 years, 5 months ago
everywhere i search about animating meshes in directx (even this forum) it''s always about bones. if the question is not about bones, the answer is. i have a regular simple animation with keyframes in 3ds and have exported it to a .x file. how do you animate it using directx9? where can i read about it? thanks!
Advertisement
The only keyframe animation tutorial I beleive I have seen is the dolphin demo from the SDK. You might wanna check that out.

Isn't a boneless animation the same as an animation with 1 bone? EDIT: No, now that I think about it, it's not the same.

[edited by - SiliconMunky on October 23, 2003 7:25:42 PM]
you don''t have to add a bone in 3ds to make an animation.
the dolphin example uses vertex shaders to tween between 3 .x files that is loded separately. that is really really complicatied for me right now. is''t there an example somewhere how to animate .x files like .md2 files? a whole separate set of vertices for every part of the animation... and NO tweening i''d like that...
How would you smoothly display a key framed animation without tweening?


EDIT: I suppose you could display teh first mesh for 20 frames and then the next mesh for 20 frames and so on until you loop back to the first mesh again. But that wouldn't be all that smooth.

[edited by - SiliconMunky on October 23, 2003 6:59:56 PM]
as an amateur that don''t know anything about vertex shaders, except that they are complicated, would simply create more frames. that didn''t cross your mind?? now i see why there are som little information about it. everyone wants to make it extremely complicated (bones, tweening etc)
Actually, creating lots of frames did cross my mind, that''s the way I was going to implement animations in my code about 4 months ago. But unfortunatly there is no smooth and decent way of implementing animations without bones or tweening. So I decided to use bones.

I suppose you could make it smooth by using a tonne of key frames, and just switch from one to another with no tweening. The problem with that is that it will take a lot of memory to store all that mesh information.
aaah,
i suddenly see the light
now i get why there is so little information about that...

so, more or less, you use vertex shaders to animate stuff like dolphins, wheels and such, and bones for characters?
You don''t have to use VertexShaders for animation, but it eases the coding I guess. If I were you, I''d learn the .X file, and write a tutorial about it. Hehehe..

--
You''re Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..
You don''t have to have every single frame for that...It''s called "keyframe" animation for a reason. The idea is to present enough frames so that each motion is kinda believeable....i.e. Major parts of the movement, places where something changes direction, etc. Each animation, run, jump, crouch, or whatever, represents a change from one pose to another, usually standing.

You should only need around 7-10 keyframes to make a believable animation. Instead of instantly displaying the next keyframe, you create a function that produces a *transition* from one keyframe to the next. Basically that just (incrementally) alters the vertexes to match the next keyframe. You can easily adjust your framerate by changing how many frames are in-between each keyframe. Get my drift?


An excellent book over this is "3D Character Animation", "Tips and Tricks of the 3D programming Gurus", And almost any of LaMothe''s Direct3D Books. You can prolly read them at your local Borders bookstore by just spending some time there.
"This I Command" - Serpentor, Ruler of C.O.B.R.A
You don''t have to use bones - you can use Transform Animation; that is rotation, translation and scaling. These are all done by modifying an object''s Local to World matrix, the matrix that positions the object into the 3D space.

If you are using Direct3D, take a look at the D3DXVec3Lerp function. It takes two vectors and interpolates linearly (hence LERP, spherical interpolation is SLERP) based on a factor from [0..1].

If, for example, you have a bunch of boxes that are animated moving around (forget rotation for now). If you export the animation at 30 frames a second, but play it back at 60 frames a second, obviously ever second frame of display will be a duplicate of the previous frame''s animation data.

If, instead of simply displaying the object at the given location, you draw it at the half way point between LAST frame''s locatio and NEXT frame''s location, you have ''interpolated'' a position relative to the two frame''s of animation.


D3DXVECTOR3 vecPos0 = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vecPos1 = D3DXVECTOR3(100.0f, 0.0f, 0.0f);

D3DXVECTOR3 vecResultFrame0, vecResultFrame1, vecResultFrame2;


D3DXVec3Lerp(&vecResultFrame0, &vecPos0, &vecPos1, 0.0f);
// vecResultFrame0 == { 0.0f, 0.0f, 0.0f }

D3DXVec3Lerp(&vecResultFrame1, &vecPos0, &vecPos1, 0.5f);
// vecResultFrame1 == { 50.0f, 0.0f, 0.0f }

D3DXVec3Lerp(&vecResultFrame2, &vecPos0, &vecPos1, 1.0f);
// vecResultFrame2 == { 100.0f, 0.0f, 0.0f }


This is all using the Direct3D helper stuff, but the code is all available on the internet. This can also be extended to rotations. If you have the rotation components stored in a quaternion, you can SLERP between the twho using D3DXQuaternionSlerp(). Take the interpolated position and interpolated rotation, concatenate them into a matrix and you have the new interpolated world matrix for your animated object, based at some value t between frame (n) and frame (n+1).

I have to admit to not knowing how to get this data from .X files, but I hope it can help you a bit.

Hope that''s some food for thought.


This topic is closed to new replies.

Advertisement