Time for action — adding a point light
We will create a point light and add it to our scene to see the effect it has on our scene:
- Add the following code after setting the material for the plane:
Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1"); mSceneMgr->getRootSceneNode()->addChild(node);
- Create a light with the name
Light1
and tell Ogre 3D it's a point light:Ogre::Light* light1 = mSceneMgr->createLight("Light1"); light1->setType(Ogre::Light::LT_POINT);
- Set the light color and position:
light1->setPosition(0,20,0); light1->setDiffuseColour(1.0f,1.0f,1.0f);
- Create a sphere and set it at the position of the light, so we can see where the light is:
Ogre::Entity* LightEnt = mSceneMgr->createEntity("MyEntity","sphere.mesh"); Ogre::SceneNode* ...
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.