Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. Managing Objects and Scenes > Creating manual objects

Creating manual objects

In this recipe, we'll show you how to create a Mebius mesh with multiple sections, using a ManualObject. We'll also add menu items to our application's user interface, so that the user can change the material used by each section at runtime.

Getting ready

To follow along with this recipe, open the solution located in the Recipes/Chapter03/ManualObject folder in the code bundle available on the Packt website.

How to do it...

  1. First, we create an MFC Ogre application named ManualObject.
  2. Next, we create a Mebius mesh with multiple sections using code similar to what we used in the Creating a custom resource manager recipe, from Chapter 1, Delving Deep into Application Design. The Materials array contains the names of all the materials we will be using.
    Ogre::String Materials[] = 
    {
      "Examples/SphereMappedRustySteel",
      "Examples/OgreLogo",
      "Examples/BeachStones",
      "Examples/TrippySkyBox",
      "Examples/SpaceSkyBox",
      "Examples/DynamicCubeMap",
      "Examples/RustySteel",
      "Examples/Chrome",
      "Examples/WaterStream",
      "Examples/Flare"
    };
    
    

    The code for creating the ManualObject is very similar to what we have used in previous recipes, except that we set the dynamic property to true, because we intend to change the mesh at runtime.

    m_MaterialIndex = 0;
    m_ManualObject = m_SceneManager->createManualObject("stl");
    m_ManualObject->setDynamic(true);
    m_ManualObject->begin(Materials[m_MaterialIndex++], 
      Ogre::RenderOperation::OT_TRIANGLE_LIST);
    
    

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial