60 likes | 66 Views
Learn how to animate and move an entity in Ogre programming, including walking between predefined points and using quaternion for rotation. This tutorial covers setting up the scene, animating the robot based on its state, and translating it between locations.
E N D
Contents • Take an Entity • Animate it • Have it walk between predefined points. • Use Quaternion for rotation to keep the Entity facing the direction it is moving 2
Setting up the scene In DemoApplication::createScene: 1. Set the default lighting. 2. Create the entity for the robot 3. Create the scene node which is attached with an entity of the robot. 4. Create the walking list which consists of a set of locations (i.e. points) 5. Create objects for the locations specified by the walking list. 6. Set the camera to look at the scene.
Animating and Moving the Robot • In DemoFrameListener::frameStarted • There are three items that we have to do. • Animate the robot according to the state of the robot: • “idle” and “walk” • 2. Translate the robot from one location to another location • using interpolation method. • 3. If the facing direction of the robot is not consistent • with the walking direction, the orientation of the robot • should be changed.
Animating the robot based on its state Set state: AnimationState *mAnimationState; mAnimationState = mEntity->getAnimationState("Idle"); mAnimationState->setLoop(true); mAnimationState->setEnabled(true); Animate: mAnimationState->addTime(evt.timeSinceLastFrame); Remark: use OgreMeshViewer and view the mesh
References: http://www.ogre3d.org/wiki/index.php/Intermediate_Tutorial_1