Time for action — rotating in different spaces

This time, we are going to rotate using different spaces, as follows:

  1. And again, we will start with a clean createScene() function, so delete all code inside this function.
  2. Add the reference model:
    Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","sinbad.mesh");
    Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
    mSceneMgr->getRootSceneNode()->addChild(node);
    node->attachObject(ent);
    
  3. Add a second model and rotate it the normal way:
    Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","sinbad.mesh");
    Ogre::SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node2");
    node2->setPosition(10,0,0);
    node2->yaw(Ogre::Degree(90));
    node2->roll(Ogre::Degree(90));
    node2->attachObject(ent2);
    
  4. Add a third model using world space:
    Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");
    Ogre::SceneNode* node3 = node->createChildSceneNode("node3");
    node3->setPosition(20,0,0);
    node3->yaw(Ogre::Degree(90),Ogre::Node::TS_WORLD);
    node3->roll(Ogre::Degree(90),Ogre::Node::TS_WORLD);
    node3->attachObject(ent3);
    
  5. Compile and run the application.
    Time for action — rotating in different spaces

What just happened?

Like always, we created our reference model, which is the left one in the picture. We rotated the second model first around the y-axis and then around the z-axis. Rotation uses the default space as the local space. This implies that after we rotated the first model 90 degrees around the y-axis, the orientation of z-axis is changed. The second model used the world coordination system and there the orientation of the z-axis stays the same, even when we rotated a scene node.

What just happened?

The model under number 1 is the original coordination system we had. Under number 2, we see the coordination system after we rotated 90 degrees around the y-axis. Under number 3, we rotated 90 degrees around the z-axis. Now let's look at the same rotations when we use world space instead of local space.

What just happened?

Here we are doing the same rotations, but because we always used world space, we didn't use the changed coordination system, and therefore we got a different result.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.12.124