Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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.
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.
ManualObject. 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);