The basic animation control of ogre is very simple. The operation for setting an animation is as follows:
// Set idle Animation
Manimationstate = ent-> getanimationstate ("idle ");
Manimationstate-> setloop (true );
Manimationstate-> setenabled (true );
(The above Code comes from intermediate tutorial1-Ogre wiki) Get the animationstate pointer from an entity object, and then set some attributes, which need to be called at each frame:
Manimationstate-> addtime (EVT. timesincelastframe );
Loading SKELETON:
In skeletalapplication: createscene ()
Skeletonptr skel = skeletonmanager: getsingleton (). Load ("jaiqua. Skeleton ",
Resourcegroupmanager: default_resource_group_name );
This statement is used to read the skeleton file. The read operation is in the "skeleton: loadimpl" function. This function mainly performs two steps: one is to call "skeletonserializer: importskeleton ()", and the other is "load any linked skeletons ". The animation information is stored in the "animationlist manimationslist" member variable of skeleton.
A "skeletonptr mskeleton" is stored in the mesh class, And skeletonptr is a derived class of "sharedptr <skeleton>. Load a mesh:
Meshserializerimpl: readmesh ()-case m_mesh_skeleton_link:
-Meshserializerimpl: readskeletonlink ()
-- "Mesh: setskeletonname ()
-ResourceManager: load ()-Get the skeleton pointer
The animation class object is "an animation sequence". All types of animation sequences are managed by this class. It manages three types of track lists: nodeanimationtrack, numericanimationtrack, and vertexanimationtrack.
In the constructor of entity, if the mesh contains a skeleton animation or vertex animation, an animationstateset object will be created and "mesh-> _ initanimationstate (manimationstate);" will be called );".
Animation computing:
Entity stores a skeletoninstance Object Pointer, which is a derived class of skeleton.
The main operation is in the "Void entity: updateanimation (void)" function.
À entity: cachebonematrices
À SKELETON: setanimationstate
This function first calls "skeleton: reset", finds the corresponding animation for each enabled animation state, and then calls Animation: Apply () to calculate the status of each bone.
The overall ogre animation management structure is chaotic. The dependency between entity, skeleton, animation, animationstate, and skeletoninstance is too complex and has circular dependencies.