basic principle of animation?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
tchilrri
Posts: 8
Joined: Mon Jun 28, 2004 6:26 pm
Location: Germany

basic principle of animation?

Post 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
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post 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.
tchilrri
Posts: 8
Joined: Mon Jun 28, 2004 6:26 pm
Location: Germany

Post 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
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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.
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Post 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?
tchilrri
Posts: 8
Joined: Mon Jun 28, 2004 6:26 pm
Location: Germany

Post 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. :)
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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...
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Go onto GameDev.net and look at their game programming dictionary. Helps clear up a few misunderstandings here and there sometimes.
tchilrri
Posts: 8
Joined: Mon Jun 28, 2004 6:26 pm
Location: Germany

Post 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
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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.
Captain_Kill
Posts: 124
Joined: Sun Jun 27, 2004 11:02 am
Contact:

Post 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
2.8GHz P4 with HT - 512MB DDR - ATI Radeon 9600XT 256MB - Windows XP - VC++ 6 and VC++ 2003

Dark Reign 3 Home Page: http://darkreign3.notwhatyouthink.org/
Dark Reign 3 Forums: http://notwhatyouthink.org/darkreign3bb/
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post 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.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Of course we want it ...post it!!! ...best in Howe to Forum :P
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

Endar
Posts: 145
Joined: Mon Jun 14, 2004 7:59 am

Post 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 )
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
Post Reply