Time for action — building a tree using scene nodes

This time, we are going to use another model besides Sinbad: the ninja.

  1. Remove all the code from the createScene() function.
  2. Create Sinbad like we always do:
    Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
    Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
    node->setPosition(10,10,0);
    mSceneMgr->getRootSceneNode()->addChild(node);
    node->attachObject(ent);
    
  3. Now create a ninja, which will follow Sinbad everywhere he goes:
    Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntitysNinja","ninja.mesh");
    Ogre::SceneNode* node2 = node->createChildSceneNode("node2");
    node2->setPosition(10,0,0);
    node2->setScale(0.02f,0.02f,0.02f);
    node2->attachObject(ent2);
    
  4. Compile and run the ...

Get Ogre 3D 1.7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.