O'Reilly logo

Ogre 3D 1.7 by Felix Kerger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — creating a spotlight

We will use the code we created before and modify it a bit to see how a spotlight works:

  1. 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);
    
  2. Again, create a light, but now set the type to spotlight:
    Ogre::Light* light = mSceneMgr->createLight("Light1");
    light->setType(Ogre::Light::LT_SPOTLIGHT);
    
  3. 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)); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required