Individual object animation control?

kevinlan

27-04-2007 09:34:34

How do I control object's animation individually ?
I create a teapod in max and assign a rotating animation and a sphere with jumping animation, then export scene to .osm file with "Export animations" checked ( but didn't add any scene global animation in animations dialog). When I load this .osm to Demo_oSceneLoader application. There are no animation acting on object. When I export osm with "Export animations" checked and add a scene global animation, animations on object are works fine.

Is it possiable to set up animation on each object in scene and control it with very simple function like "Play" and "Stop" in my app individually? So I can make teapod rotating and sphere freezing, or make teapod stop acting and sphere jumping .

Lioric

27-04-2007 17:41:28

You can create independent animations for each object (or for a specific objects groups)

In the "Object" setting panel you can defined the animation base name ("ObjectAnim name"), this base name when defined will create a separate animation(s) for the object or objects in the group (objects with the same "ObjectAnim name") using the list of global animations defined in the export dialog

In "Object Properties" page of the "Working with Scenes" chapter in the User's Guide there is more details on using object animation name

In your example, you have a global animation defined, lets call this animation "testAnimation"

As you noted, if you export without defining "ObjectAnim name" for any object or a group of objects, all animated entities in the scene will be part of this "testAnimation" and will be played as a global animation (i.e. in a cut scene animation)

But if you define "ObjectAnim name" for your sphere object in the scene (lets call this it "spheres"), when exporting your scene it will contain two animations, the global "testAnimation" where all other objects will be, and a "spheres_testAnimation" where the sphere object is, and you can manually control, enable, disable and set the animation time individually

kevinlan

28-04-2007 05:24:53

Thanks Lioric,
I should define both global animation and object animation name for individual control animation of object.

But when I check osm file, I found each animation in objects have the same length of animation and loop state with global animation settings. Can I separately setting length of animation and loop state on each objects ?

And how do I manual control animation in each object ? Seems Ogre3D does not have any direct way to doing this? For now, this is a way I found to control objects animation :

1.Load osm by oFusion loader.
2.Get all animations.
3.Manualy create AnimationState for each animation.
4.Control each object animation with AnimationState.
5.Set animation time in each AnimationState in frameStarted().

Is that right?

Lioric

28-04-2007 17:35:13

Currently the animation length cant be defined separately for global and group objects

We are creating a link between object groups (base animName) and group names (the animation group names in the animation export dialog), with this you can select the groups that each animation entry should export, in this case you can define a separately non-global animation for each object or object groups

To control an animation in your application you can get the animation pointer from the scene manager using the animation name, i.e. if your have a "testAnim" animation, use:


mScenMgr->getANimation("testAnim");


or if you want to use a per object animation (with the baseAnim name defined as "object01"), use:


mSceneMgr->getAnimation("object01_testAnim");


Or you can add an event to the post-process system when an animation is loaded, in this case your application will be notified of any animations being loaded

You can create an AnimationState to automatically control each of your animations, or control them directly with the Animation pointer, in this case, each frame you need to reset the node position and apply the animation time