上QQ阅读APP看书,第一时间看更新
- 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 added node2
, which holds MyEntity2
, to a scene node which already was at the position (10,0,0). We only needed to set the position of node2
to (0,10,20
). When both positions combine, MyEntity2
will be at (10,10,20
).
- We have the scene node
node1
at (0,20,0
) and we have a child scene nodenode2
, which has an entity attached to it. If we want the entity to be rendered at (10,10,10
), at which position would we need to setnode2?
a. (10,10,10)
b. (10,-10,10)
c. (-10,10,-10)