Animate a Character

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
m4lomb
Posts: 8
Joined: Tue Feb 12, 2008 3:52 pm

Animate a Character

Post by m4lomb »

Does anyone know how to animate a character by loading animations form a file? I am a newbie. I know I can load an animated mesh, but I want to be able to load a mesh with bones, load some files containing animation information (collada for example, or bvh) and then play the appropriate animation by name, as needed. For example (this is totally pseudocode):

mesh->Load("Soldier.X");
mesh->LoadAnimation("Walk.bvh");
mesh->LoadAnimation("Stand.bvh");
mesh->LoadAnimation("Run.bvh");

and thed activate each animation using:
mesh->PlayAnimation("Walk.bvh");

Thank you for your help!
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

currently not possible, you'll have to load the animations as separate meshes and copy the positions and rotations of the bones across manually each frame.

To do this, see-

http://www.irrlicht3d.org/wiki/index.ph ... tionSystem
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
m4lomb
Posts: 8
Joined: Tue Feb 12, 2008 3:52 pm

Thank you!

Post by m4lomb »

that is rough!
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

hmm so its quite hardcore to make an RPG like game on irrlicht like:

- Separate meshes for each body part like armor,gloves,helm etc.
- All body parts connected to player skeleton
- All body parts are animated by player skeleton only
- Player can have for example 200 different animations

It seems to be impossible without totally custom mesh/skeleton loading and own animation engine. Am i wrong ?
m4lomb
Posts: 8
Joined: Tue Feb 12, 2008 3:52 pm

yes...

Post by m4lomb »

but it is less work if somebody else already implemented how to load a bvh file ;) framework is great though. object oriented, great design, seems fast, allows you to get to nodes and modify meshes in a very intuitive way, no complaints.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Since .x also supports several animation sets it would be a nice extensions for the skinned mesh to support a compact representation of additional animation sets. But this will need some more work, community patches appreciated :D
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

Im trying to make a game character be able to wear something like an Armor but im completely lost here and don't really know where to start and how to arrange this. Is seems to be a little complicated for me ... BUT i really want to learn and do it. Someday i would have to anyway so ...

Can someone "guide" me a little how to load couple of meshes for example a box and sphere and attach them to the same already existing skeleton ?

Maybe there is other a better way to do what i want to do ?

I hope someone can understand this :P
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, you just have to get the joint you want to attach the armor or weapon to. You can attach scene nodes as childs to it, which will then move according to the joint's movement. The link bitplane gave above should contain the necessary stuff.
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

The problem is i dont want to attach as a child.
Child attach is good but for weapons in hands and i know about that.

I want to "switch" the player Torso to Armor and use the same skeleton as the Torso and attach the Armor to proper joints as defined in the Armor model.

Both models Torso and Armor have included the same player skeleton.
Its like to build a player model from a separate body parts attached to a one global skeleton and then replace them by other one .... like to change the torso body part to armor body part.

More Visual (virtual code) example :

player -> setSkeleton ( "skeleton.skl" );
player -> setTorsoMesh ( "torso.x" );
...
player -> setTorsoMesh ( "armor.x" );

torso.x and armor.x have the skeleton.skl included as the basic skeleton so all the models "know" to whitch bone all the triangles should be attached to.

I think solution is to use a custom Mesh Node with couple of Vertex buffers and render each buffer separately with separate texture.
xifeng4487
Posts: 1
Joined: Thu Feb 14, 2008 5:42 am

you can't do it

Post by xifeng4487 »

your problem is my problem. we can use the OGRE model format --- "mesh" and "skeleton" to do it . But the irrlicht has a lot of bugs in "mesh" load and do nothing with the "skeleton"!!! God! I must do it myself. faint!
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

ogre is only for static meshes at the moment, it isn't supported by Irrlicht's SkinnedMesh.

The simplest and easiest way to do this would be to read tutorial 3 and make a custom scene node - for example CClothingSceneNode, make it add a child as an animated mesh then in the OnAnimate method, copy the joint positions from the node's parent and apply them to the joints with the same name in your clothing node.
Then adding clothes is as simple as creating a CClothingSceneNode for each item.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

Is on Irrlidht some BuiltIn method to get all the Node Joints ? (enumerate)

Because it seems that i need to get all the Joints of all the Submeshes and set each one position and rotation by hand like :

playerArmor -> getJointNode ( "Torso01" );
or
playerArmor -> getJointNode ( 0 );

The best method i think is to create a Loop with :
playerArmor -> getJointNode ( i );
i++;

BUT how to get the Joints count or all the Joints Names / IDs ?

I know that getJointNode returns 0 if no Joint found but what if a mesh have non sorted Joint IDs like 1,5,3,2,8,12 ? It should return 0 if i try to get Joint 4 and its correct but how to figure out is there any Joint left ?

BTW.
Its quite stupid to make the "JointChildSceneNodes" private
and do not make any copyJoints / getJoints / setJoints / useRemoteJoints methods :/ ... maybe i should start thinking about Irrlicht source modifications.

Solution seems to be quite easy:
-Replace the Joints array by pointer to JointsArray.
-If is defined a pointer then use the remote JointsArray and act as a Ragdoll ... if not then act as a common node with local JointsArray.

It should make the Node to animate by the same skeleton as the parent is without setting each child skeleton separately and copying it.

Second solution is to just copy the CAnimatedMeshSceneNode as CBodyPartMeshSceneNode and make it a brand new node.
It could be nice to add multifile animations support by the way (bvh,smd).

What do you guys think about that ?
m4lomb
Posts: 8
Joined: Tue Feb 12, 2008 3:52 pm

QUAKE 2 accomplishes just that

Post by m4lomb »

With quake2 (md2 files) you can do something very close to that.. so

IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh )

node->setMD2Animation ( scene::EMAT_RUN ); // or stand or whatever
not quite BVH in separate files, but very close
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The animations stored are not separate animations, but animation sequences which are all put sequentially into one large animation. You can then choose an interval from that large animation to play.
The idea of using a separate set of weights sounds interesting. If there is a way to implement this efficiently it might be worth considering it. Just prepare an implementation and show your results.
Also note that the joint API provides something called useAnimationFrom. I don't know exactly what it does, but you might use it already now to achieve the desired effect.
I'll move this thread to the advanced section to avoid it getting lost.
m4lomb
Posts: 8
Joined: Tue Feb 12, 2008 3:52 pm

3DS Max Plugin

Post by m4lomb »

I was looking at the MD2 format and it should be doable. I do need to get more comfortable with Irrlicht.

Do any of you know of a good plug in to go from 3DSMax 9 to MP2? Not sure I like QTip.
Post Reply