Page 1 of 8

skeletal human animations [UPDATED]

Posted: Fri Aug 10, 2007 1:54 pm
by xray
UPDATED 7. december 2008

I made some big updates to my animation class. First
one is that there are four new animations and the existing where
updated. Now the class can simulate this:

+ running (improved)
+ walking
+ jump (improved)
+ strafe left (new)
+ strafe right (new)
+ backward (new)
+ head will point to mouse direction, to simulate watching (new)

I also recoded the whole interpolation structure for blending from one
to another animation. Now you dont have to code it by your own for example if you want to add your own animation. This blending function
is able to handle every function you create. So if you want to add your own
animation, do the following ->

- create an extra function in the skeleton class (private section)
which handles your animation
- extend the switch branch in 'animSkeleton' and 'animInterpolation'
- thats it

So give it a try i know you will like it, the demo shows also a moving player and fade moving camera system!! Link as usual or on my website:

http://www.solar-ray.org

---------------------------------------------

A new version is out, and now it looks much more realistic.
I added to all animations shaking bones, also the blendings
are now a little bit better, so have a look at it!

---------------------------------------------

Now it works also with Irrlicht 1.4, so you dont need Acki's IrrExtension !

---------------------------------------------

I changed some things to the class:

+ improved running mode
+ added walk cycle
+ added motion in stand position


original post:
---------------------------------------------

I wrote a class which calculates skeleton human animations in realtime, so this is not a frame based animation. For my project Im needing running/walking/jumping... animations for the main player. But I dont want to use frame based animations like the md2 format, because later I want an easy way to implement other players, this way that I just have to model them with their bones in blender and import them into my project. So this would be also really easy for other fans of my project to implement their own players, without recreating all the animations. The other Idea is that realtime calculated animations could have smooth blending effects from one anim to another one.

Here you can download the packed source:
http://home.mnet-online.de/sk9/skeleton.rar

Needed files for the skeleton animations in your project:
+Skeleton.h
+Skeleton.cpp
+BMaths.h
+BMaths.cpp

I hope my source is documented well enough for you :)

There is also a compiled version if you just want to have a look at it!
I also copied the blender file with the human into it, the human isnt good
enough for my project but will maybe helpful for someone.

Comments are welcome

Posted: Fri Aug 10, 2007 3:27 pm
by MolokoTheMole
What is it for, does it use actual models for rendering?

Posted: Fri Aug 10, 2007 3:57 pm
by xray
What is it for
I thought it would be clear, well I need a player model for my project
as alot of other developers, and this models have to be animated! Otherwise
it will not look realistic. So my class animates a human, and you dont have
to create frame based animations in a 3d app. You only have to create a player model for example in blender and append it to the class.
does it use actual models for rendering?
dont understand what you mean.

Posted: Fri Aug 10, 2007 4:27 pm
by BlindSide
cool thanks! Can you tell us what bone layout we need for this to be compatible? I have a very simple layout for hands and legs, 2 for each leg and 2 for each arm. Would this work with your code and if it wont what modifications would be needed?

Posted: Sat Aug 11, 2007 11:43 am
by xray
One thing before, I forgot to say that you only need the CustomBones from Ackis IrrExtension, not the hole branch of his extensions.

Now to your question BlindSide:
It is really simply to modify it to your terms. My player skeleton has the following bones:

- torso
- body
- neck
- head

- arms
- under arms
- hands
- fingers

- legs
- shins
- feets
- toes

Note, that yet not all of this bones are animated with my class like toes, feets, fingers and hands. So lets take your bone example:

- legs
- shins
- arms
- under arms
- hands (not needed, cause there isnt an animation yet)

It would be good if you apply to your skeleton a torso or a body bone which is a parent of all others so that you can modify the hole position/rotation of the player over this main bone. If you have a look into the Skeleton header you will find an enumeration in private section named "SKT_BONE"! Simple remove the bones which you dont have... for you it should look like this:

Code: Select all

	enum SKT_BONE {
		SKT_BONE_ZERO,
		
		// main items
		SKT_BONE_TORSO,
		
		// right arm items
		SKT_BONE_ARM_R,
		SKT_BONE_UARM_R,
		SKT_BONE_HAND_R,
		
		// left arm items
		SKT_BONE_ARM_L,
		SKT_BONE_UARM_L,
		SKT_BONE_HAND_L,
		
		// right leg items
		SKT_BONE_LEG_R,
		SKT_BONE_SHIN_R,
		
		// left leg items
		SKT_BONE_LEG_L,
		SKT_BONE_SHIN_L,
		
		// number of bones
		SKT_BONE_COUNT
	};
The "SKT_BONE_ZERO" is just because of the first enum = "0" isnt a bone, I dont know why. Maybe it is differrent with your one so you may uncomment it.
Another important thing is the order of SKT_BONES, they arent random. They have to be the order you created the bones in your 3d app.
After you changed the enumeration to your needs, you have to uncomment some bone oscillation functions in the skeketon.cpp! In there you will find the method "animSkeleton" where the bone positions are calculated, it should work if you just uncomment all the bonesOsci assignations of the bones which you dont have. For example you dont have body/neck/torso bones so just uncomment all the:

Code: Select all

// bonesOsci[SKT_BONE_NECK]...
// bonesOsci[SKT_BONE_BODY]...
// bonesOsci[SKT_BONE_TORSO]... 
The model will be loaded over the constructor. If you want you can change some things in there like the file name of the model or the stand position.

greetings!

Posted: Mon Aug 13, 2007 12:36 am
by tmighty
Hi xray!

Your animation system looks just like what I have been searching for.
I do not program in C++, anyway I would like to ask you a general question:

In your animation system you state e. g. that when Bone1 is at location X1 then Bone2 must be at location x2, correct?

In this step, you do nothing else but calculate bone positions, and you name this part the "constructor", right?

Second question:
If you want to make e. g. the head bigger ingame or the nose smaller... how would you achieve this? This doesn't seem to have anything to do with the bones, right?

Thank you very much for a reply.

Posted: Mon Aug 13, 2007 10:57 am
by xray
I do not program in C++, anyway I would like to ask you a general question:
In what language do you code ?
In your animation system you state e. g. that when Bone1 is at location X1 then Bone2 must be at location x2, correct?

In this step, you do nothing else but calculate bone positions, and you name this part the "constructor", right?
The first thing is right, that I do nothing else than calculating the bones rotations. But no this is not the "constructor". If you dont know c++ I could imagine that you also dont know classes. The constructor is nothing specifig of my skeleton class. In classes you have every time an constructor and a destructor. The constructor is called when you "create" a variable of the type of the class, like this:

Code: Select all

cSkeleton *skeleton;
than the constructor will be passed automatically. And my constructor of the skeleton class is to load the model file setting the scale factor and some variables, this is not the code of calculating the bone rotations. The real calculations of the bones are in the method "animSkeleton()"
If you want to make e. g. the head bigger ingame or the nose smaller... how would you achieve this? This doesn't seem to have anything to do with the bones, right?
Well at the moment the animations are only achieved by rotating the bones, I also tested scaling them but without any effect. But I think that must also work. Maybe it lies on ackis irr extension, I dont know, I have to ask him...

Do you want to translate the code into another language?

Posted: Mon Aug 13, 2007 11:46 am
by BlindSide
xray have you tried the skinnedMesh branch? It supports setting the scale and position of bones.

Posted: Mon Aug 13, 2007 9:40 pm
by xray
Hi BlindSide,

I dont know skinnedMesh, is it an extension ? Im also waiting for the new animation system for irrlicht which will give you the same access to bones like ackis custom bones, and I think also with scale function.

Posted: Mon Aug 13, 2007 10:00 pm
by BlindSide
skinnedMesh is the new system you are talking about, you can find it in the irrlicht SVN on sourceforge. It is working very well right now with MS3D and B3D models, and X support is almost complete.

Posted: Mon Aug 13, 2007 10:10 pm
by xray
Ah ok thanks, will have a look at it!

Posted: Mon Aug 13, 2007 10:24 pm
by tmighty
Hi xray,

I code in VB.Net, and I do understand what you're talking about now. For me constructor and destructor are Class_New and Class_Finalize, but it's just the same.

Thank you very much for your nice explanation.

Best regards.

Posted: Tue Aug 14, 2007 6:17 am
by xray
For me constructor and destructor are Class_New and Class_Finalize
Right!

cheers :)

Posted: Thu Aug 16, 2007 9:06 pm
by xray
I did the following changes to the class:

+ improved running mode
+ added walk cycle
+ added motion in stand position

download link is updated, again with a compiled version.

Posted: Fri Aug 17, 2007 9:04 am
by Cardinal4
whoa, this looks extremely useful and cool! Nice work! :D I'm curious though, why are some faces on the model flickering light and dark, is it a problem with lighting or something else?