Add this new line after the creation of the scene node:
node->setPosition(10,0,0);
To create a second entity, add this line at the end of the
createScene()
function:Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");
Then create a second scene node:
Ogre::SceneNode* node2 = mSceneMgr->createSceneNode("Node2");
Add the second node to the first one:
node->addChild(node2);
Set the position of the second node:
node2->setPosition(0,10,20);
Attach the second entity to the second node:
node2->attachObject(ent2);
Compile the program and you should see two instances of Sinbad:
We created a scene which matches the preceding diagram. The first new function we used was at step 1. Easily guessed, the function setPosition(x,y,z)
sets the position of the node to the given triple. Keep in mind that this position is relative to the parent. We wanted MyEntity2
to be at (10,10,20
), because we...