Page 1 of 2

basic principle of animation?

Posted: Mon Jun 28, 2004 6:42 pm
by tchilrri
Hi,
I saw in the demo applications that animated game figures are just loaded and started with a simple run command, means animation is predefined by the file created with an external program. But that sort of animation seems to me like it's beein very fixed and simple.
I want to know if it's possible to have more flexibility, and to just load a kind of a marionette with articulars that I can control from program like: puppet.RaiseArmAndWave() or puppet.SitDown() or puppet.Squat(). Of course I would need to implement e.g. method Squat() by a sequence of subcommands to the articulars of the marionette.
Well that's my poor humble newbie understanding of how animation must be programmed. Please, enlight me how it's done or can be done in common game-programming. What approaches are possible (especially with Irrlicht) and which ones can you recommend?

Thanks,
Tschilrri

Posted: Mon Jun 28, 2004 6:44 pm
by bal
I thought Irrlicht was (just) a rendering-engine and therefore was not able to animate. Most engines can't animate, only import animations and then play them on a certain way.

Posted: Mon Jun 28, 2004 6:55 pm
by tchilrri
I thought I might be possible to load e.g. an animation file and create and instanciate an object of an Irrlicht class of it, and Irrlicht could be able to support more detailed animation controlling like accessing the articulars and move them or give them life somehow.
How do you program for instance a game figure able to wave, squat, lay down, shot, walk, shake hands and eat sitting on a table? Do you just create several predefined animation sequences with e.g. 3DSMax and just call: if (shouldEat) { sequ1.Run(); } else { sequ2.Run(); } from Irrlicht?

Thanks
Tschilrri

Posted: Tue Jun 29, 2004 7:41 am
by arras
That sort of aproach is possible in general but not in such simple way as you would wish and not with irrlicht yet...

Diferent formats do store animation in diferent ways. I will describe you howe x (directx) format does that (I will do it simplified):

3d model consist of bunch of data as any other thing in computing. Since 3D model consist of vertices and polygoons x format store info about theyr number, order, position and normals + some aditional info.

When you want to animate model, you usualy do it wia so caled joints (there are other methods too). These are points in model space to which vertices and polygoons are attached. Joints serve as reference points for manipulating vertices and polygoons attached to them ...you can rotate, move, scale joint and that affect its vertices. Joints usualy have certain hierarchy, which can be visualy seen as skelet.

To make animation you make key frames, which store info about model joints (rotation, position) in diferent periods of animation time.

And thats what x format store ...keyframes of joints. Engine like Irrlicht than use this data to calculate position of model vertices based on joints in diferent frames of animation and then draw your model on screen based on that info.

Some engines alowe you to manipulate joints directly using theyr functions. For example you have joint number 5 which have vertices of robot arm attached to it. You can use fictional function rotateJoint(jointnum, xrot, yrot, zrot) to rotate arm.

Unfotunately Irrlicht don't have such functions yet ...lets hope, it will in the future, since this kind of functions can be wery useful in certain situation.

What Irrlicht alowe is building model from limbs using diferent models glued together using parent and child parameters. You can attach one object to another defining second one to be parent of firsth one. Then you use standard commands to manipulate second one, making kind of animation.

Posted: Tue Jun 29, 2004 8:07 am
by joy
I thought Irrlicht is a grafic engine and uses for example directx for rendering. So Irrlicht is not a render engine, is it?

Posted: Tue Jun 29, 2004 8:51 am
by tchilrri
Thanks a lot for your quite detailed explanation. So I understand my 'articular' is called a 'joint'. Your message helped me a lot to understand the basics. :)

Posted: Tue Jun 29, 2004 9:25 am
by arras
Rendering is basic function of each graphic engine. Most of today engines use DirectX or OpenGL. Bye the way Irrlicht have its own software renderer too...

Posted: Tue Jun 29, 2004 6:32 pm
by Tyn
Go onto GameDev.net and look at their game programming dictionary. Helps clear up a few misunderstandings here and there sometimes.

Posted: Wed Jun 30, 2004 5:50 am
by tchilrri
Thanks Tyn, what do you think are good catchword for the dictionary concerning to this topic?

Furthermore arras wrote:
> And thats what x format store ...keyframes of joints. Engine like
> Irrlicht than use this data to calculate position of model vertices
> based on joints in diferent frames of animation and then
> draw your model on screen based on that info.
Since Irrlicht uses such joints, which class represents those joints in the Irrlicht library or is everything from file dumped just into basic vertice objects (by loosing their meaning)?

Thanks
tchilrri

Posted: Wed Jun 30, 2004 8:01 am
by arras
I don't know hove Irrlicht works in this way but engines usualy translate data from model format to theyr internal format. Thats why you need diferent loading code to load diferent formats (x, 3ds, md2...)

Hovewer what confuse me a bit in case of Irrlicht is that there are format specific commands ...author would be able to tell you more ;)

There is function to get matrix of joints on loaded x model depending on frame.

For ms3d (Milkshape) you can acces position of joints directly.

md2 format doesn't store joints but instead position of each vertex in each frame of animation ...as much as I know since I am not using this format.

Posted: Wed Jun 30, 2004 8:09 am
by Captain_Kill
Hi tchilrri,

I have used Quake 2 models before with (of course) Quake 2 and QFusion. What you want to do is DEFINATELY possible in the way in which you want, HOWEVER, if you want new animations, you'll have to add them in in the engine OR use Quake 2's anims. eg. If you don't need attack then replace the attack frames with your own and just call EMAT_ATTACK (I think...) to run that new anim.
eg.
To create the model:

Code: Select all

node = smgr->addAnimatedMeshSceneNode(yourMeshHere);
To run an animation:

Code: Select all

node->setMD2Animation(scene::EMAT_RUN);
To swap animations just call "node->setMD2Animation" again with a different EMAT. You can find a list of all EMATs in the Irrlicht docs.

And on a technical note, MD2s do indeed store all frames. That's why they're a pain to load cause they use alot of memory. However, they are simple and easy to both model and implement

Posted: Wed Jun 30, 2004 12:22 pm
by Electron
I was looking at the source of CXAnimationPlayer to see how difficult it would be to add functionality to manipulate joints. The code in there is pretty formidable looking, but it might be possible.

Also, I have made an addition to IAnimatedMeshSceneNode to allow one to get a scene node that follows a joint's transformations as one can already do for .ms3d. If anyone needs this (and doesn't want to bother doing it themselves, it wasn't hard) I can post the source.

Posted: Wed Jun 30, 2004 9:01 pm
by arras
Of course we want it ...post it!!! ...best in Howe to Forum :P

Posted: Wed Jun 30, 2004 9:35 pm
by Electron

Posted: Sat Jul 03, 2004 8:15 am
by Endar
Does anyone know if there is a program that will allow you to load models and create an animation for them, say for a cutscene and then save it in a format that can be loaded? (verrrry long shot I know, but just in case :D )