How to force 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.
Post Reply
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

How to force animation

Post by Sfortza »

Using Irrlicht to develop a mobile game for the Android.
Using the android port for GLES 1.1.
There are about 15,000 polygons in the scene.
Terrain, skydome, static and animated 3D objects are models of the scene.
FPS is 28 - 30.
Using skeletal animation.
To play the animation using two meshes of format .X.
One for basic animation of running.
Second to play advanced animations: attack, defense, etc.
The second model contains a sequence of 114 frames for 8 animations and takes 250 polys.

Now, what is the actual problem.
When the scene is fully loaded and rendering starts
even the basic animation is not played immediately.
It takes 0.8 - 1 second before the animation begins.
At the same time the rest of the scene is rendered without any problem
and demostrate a decent FPS for mobile devices (28 - 30).

And of course the main problem is switching between animations in the model,
where a few animations.
I do not think this is actually true, but there is a feeling
as if the animation has a lower priority than the rest of the scene rendering.
It seems that the engine pays less attention to the operation of animated models,
than all the rest.

The following snippets of code that I use to load and switch the animation.

Code: Select all

Parent = smgr->addEmptySceneNode(0);
 
// Load main node with basic (walk) animation
Node = smgr->addAnimatedMeshSceneNode(smgr->getMesh(modelPath), Parent);
 
// Load node with extended animations
ExtAnimNode = smgr->addAnimatedMeshSceneNode(smgr->getMesh(extAnimModelPath), Parent);
 
ExtAnimNode->grab();
ExtAnimNode->remove();
 
================
 
Switch to fight for example
 
ExtAnimNode->setPosition(Node->getPosition());
ExtAnimNode->setParent(Parent);
ExtAnimNode->drop();
 
ExtAnimNode->setAnimationSpeed(ANIMATION_SPEED); 
ExtAnimNode->setLoopMode(true); 
ExtAnimNode->setCurrentFrame(55.f);     
ExtAnimNode->setFrameLoop(55, 64);              
ExtAnimNode->setVisible(true);
 
Node->grab();
Node->remove();
 
================
 
// animation speed
const f32 AnimationController::ANIMATION_SPEED          = 24.0f;
Thanks in advance.
Last edited by Sfortza on Sun Sep 18, 2011 3:07 pm, edited 1 time in total.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Re: How to force animation

Post by shadowslair »

To be honest, did not read the whole post, but the things I don`t get is why you add emptySceneNode as a parent and use grab(), remove() and drop() this way? What is the point of calling setCurrentFrame() right before setFrameLoop()? Looks rather pointless, at least in this piece of code.

PS: You can use code tags for code
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: How to force animation

Post by Sfortza »

Shadowslair, thanks for reply.

1. I was hoping that setCurrentFrame() can help more quickly switch between animations.
Should I even count on that?
Perhaps you prompt me, in what circumstances it is appropriate to use setCurrentFrame()?

2. I use empty scene node as a parent for my animated nodes to the right moment to remove
from the scene graph node with a basic animation and put into a graph node with enhanced animation
and vice versa.
Since the node is not being used is out of the scene, but in memory,
so you can quickly restore it if necessary.
grab(), remove() and drop() for right memory management.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Re: How to force animation

Post by shadowslair »

1) setFrameLoop() calls setCurrentFrame() internally, so whatever you set with setCurrentFrame() will get overwritten, so this call is pointless, as it serves nothing.

setCurrentFrame() can be used for example if I have one animation sequence where my character is walking from 50-100 frame. The animation starts with his right leg forward. But, for some reason I want him to start with his left leg forward this time, then keep walking as usual. The frame where his left leg is forward is 75 for example. So I call:

Code: Select all

Node->setLoopMode(true); // I tell him I want him to walk forever until I tell him to do sth else
Node->setFrameLoop(50, 100);  // call the walking seqence
Node->setCurrentFrame(75.f);  //  but start with his left leg this time, then keep as usual       
2) Ok you add and remove the node as you wish, but it`s still a bit messy solution...
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to force animation

Post by CuteAlien »

shadowslair wrote:2) Ok you add and remove the node as you wish, but it`s still a bit messy solution...
The solution is clean unless it's parent is removed in the meantime (that's why I usually save the parent as well when doing something like this).

The pause is strange - it would be good to have a simple compilable example to reproduce this (starting an animation on button-click for example). The code looks correct on first view.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: How to force animation

Post by Sfortza »

Thanks for replies!

The Android port of the engine I'm using is based on Irrlicht 1.7.0.
Were any bugs connected with animation fixed in later releases till 1.7.2?

Thank you.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to force animation

Post by CuteAlien »

Hm, check here: http://irrlicht.svn.sourceforge.net/vie ... p?view=log
Revision 3317 had to do with the animation system - but I didn't know about that problem when coding it, so not sure if this was affected.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply