We will use the code we created before and modify it a bit to see how a spotlight works:
Delete the code where we created the light and insert the following code to create a new scene node. Be careful not to delete the part of the code we used to create
LigthEnt
and then add the following code:Ogre::SceneNode* node2 = node->createChildSceneNode("node2"); node2->setPosition(0,100,0);
Again, create a light, but now set the type to spotlight:
Ogre::Light* light = mSceneMgr->createLight("Light1"); light->setType(Ogre::Light::LT_SPOTLIGHT);
Now set some parameters; we will discuss their meanings later:
light->setDirection(Ogre::Vector3(1,-1,0)); light->setSpotlightInnerAngle(Ogre::Degree(5.0f)); light->setSpotlightOuterAngle(Ogre::Degree(45.0f)); light->setSpotlightFalloff(0.0f);
Set the light color and add the light to the newly created scene node:
light->setDiffuseColour(Ogre::ColourValue(0.0f,1.0f,0.0f)); node2->attachObject...