Time for action — adding a plane and a light

Everything we are going to add this time is going in the createScene() function:

  1. As we already know we need a plane definition, so add one:
    Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -5);
    Ogre::MeshManager::getSingleton().createPlane("plane",
    Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
    1500,1500,200,200,true,1,5,5,Ogre::Vector3::UNIT_Z);
    
  2. Then create an instance of this plane, add it to the scene, and change the material:
    Ogre::Entity* ground= _sceneManager->createEntity("LightPlaneEntity", "plane");
    _sceneManager->getRootSceneNode()->createChildSceneNode()->attachObject(ground);
    ground->setMaterialName("Examples/BeachStones");
    
  3. Also we would like to have some light in the scene; add one directional light:
    Ogre::Light* light = _sceneManager->createLight("Light1");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(Ogre::Vector3(1,-1,0));
    
  4. And some shadows would be nice:
    _sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
    
  5. Compile and run the application. You should see a plane with a stone texture and on top the Sinbad instance throwing a shadow on the plane.
    Time for action — adding a plane and a light

What just happened?

Again, we used our previously gained knowledge to create a plane, light, and add shadows to the scene.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.141.212