Pre-requisite:
Objectives:
- Refactor the ogre head and pack it into an object
Descriptions:
- Use Ogre AppWizard to create a new OGRE project
in the createScene method of your OgreApp
Code Block language cpp title Creating the ogrehead and the ambient light linenumbers true void Refactoring101::createScene(void) { Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(ogreHead); // Set ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); // Create a light Ogre::Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20,80,50); }
- Read the code : to display a 3D object, there needs to be an Entity and a Node
- A node can contain multiple entities.
- Entity cannot have the same name.
- Node can be unmaned, but it will be hard to retrieve.
- Node with same name is also not allowed.
- What we need is to put the ogrehead code into our custom class.