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* node3 = node->createChildSceneNode("node3"); node3->setScale(0.1f,0.1f,0.1f); node3->setPosition(0,20,0); node3->attachObject(LightEnt);
Compile and run the application; you should see the stone texture lit...