Custom IAnimatedMeshSceneNode class or something alike

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.
Post Reply
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Custom IAnimatedMeshSceneNode class or something alike

Post by shadowslair »

Hi again...

As I already mentioned in the topic title, I need to create a custom class, very similar to IAnimatedMeshSceneNode (or somewhat, since it turned to be only a virtual header class- CAnimatedMeshSceneNode.cpp). The last three days I`m exploring the Irrlicht source code to become familiar what`s going on there. I tried to create copies of IAnimatedMeshSceneNode.h, CAnimatedMeshSceneNode.cpp and some others related to them, renamed and edited their class names etc, but it looks like all the stuff is tightly connected- like IAnimatedMeshSceneNode leads to ISceneNode and on.

I`m creating my node with my custom class, everything complies well and on, but it looks like all the changes I make in my custom classes take no effect or lead to errors, not to mention that I`m still far from achieving my goal.

Everything became far too complicated for my N00B skills, so here I`m asking for some advice on how things should be done, because I`m not that fluent in Irr or C++ as well. ( I believe I`m much better modeller and artist than a programmer. )

I`m not asking for someone to do it for me. I just need someone try to explain me how such a thing will have look like done in Irrlicht. Yeah, I hardly tried HkAnimation also, but as expected I cannot integrate it to Irr.

So here`s what I`m trying to do:
1) Load animated .X (or any of the other bone-supported types)
2) From my custom class to access all joints and their key rotations from the buffer (.X)
3) Be able to call sth like: joint_Head->setAnimationLoop( beginframe, endframe, speed) and only the head will move, following the model keyframe animation- as defined in the modelling program (3dsMax9 in this case using kW exporter) and all other joints will be static, waiting for a command to animate them also.

All this is done for the idea of dividing the joints(bones) into joint groups like BONE_GROUP_UPPERBODY and BONE_GROUP_LOWERBODY and on, and this way to be able to keyframe animate particular parts of the body independantly from the others, because for now I can only keyframe animate the whole body, and for example rotate some limbs, which isn`t giving much agility to the animation.

PS: I already took a look at ray`s Skeleton Animation example(actually almost learned everything by heart), understood the CustomSceneNode tut, explored the source( the X loader too), searched the forum, googled it, and really did my best doing it myself... :?

Thanks for your time. :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I don't see any reason why you'd need a custom scene node here. Could you please elaborate on this?
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Well, please tell me how to access the buffer-stored keyframes then and use them in my application. :?:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, now that you point to the main issue of your lengthy post I can see your target. What you need is a different animation system. The current one can only handle two at the same time. Use transition time for this. Otherwise you have to split the mesh into two and animate those separately. Another way is to use manually animated meshes. You'd need a proper animator for this.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

That`s right. That`s why I tried implementing my custom animation system. But it does not need to be that complicated at all. I may create my own class like in ray`s human skeleton example, read and write all the key rotations from the .X into one animation vector/matrix array and get all the bones in another array. To get sth like this:
//frame value
1, (0, 45, 0);
201, (-90, 50, 20); and on... (similar to the keys like in the .X format file, but stored in Irrlicht- yep, I took a look at the .X formatting documentation.)
I already did some stuff at interpolating the bone rotations and got willing behaviour, setting the rotations from within my class, but it is not very useful. The only problem is loading all those rotations from the .X into Irr.
Use transition time for this.
I cannot understand what do you mean.

Splitting the mesh does not do the job.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Transition time can be set for blending two animations, which means that the old animation still continues while the new one starts. Check the animated mesh API.
eye776
Posts: 94
Joined: Sun Dec 28, 2008 11:07 pm

Post by eye776 »

Dude, what you need to implement are "animation channels".

Traditionally there's one "channel" for each bone.

So you basically need to do something like ... uhh ... this
(very crude, i'm kinda sleepy and it's 2 AM)

Code: Select all

class IAnimationControlAnimator: public ISceneNodeAnimator
{
private:
  u32 TransitionTime;
  core::list<u32> ChannelFrameList; //(ChannelFrameList[0] , ChannelFrameList[1]) point to (Joint[0]->StartFrame, Joint[0]->EndFrame
});
  core::list<bool>ChannelLoop; 

public:
  setAnimationLoop(u32 JointID, u32 Start, u32 End, bool Loop);
Anyway, in the constructor set the Node->setJointMode(2); Then in the OnAnimate use Node->animateJoints(); at the beginning. Now comes the hard part.
1) What this does is basically cancel out the animation for whatever Joints you mess with. (And basically does away with the AnimationCallBack, too).
2) So, now you have to rewrite the animation function (use the MS3D loader as a reference and do not forget to use the INVERTED transformation of the parent on EVERY JOINT that is moved).

So yeah, basically you have to write your own anim system.
And this doesn't even TOUCH blending. :P

Anyway, enough rambling. I'll see if this mess of ideeas can be put into a more useful form tomorrow.
Post Reply