Time for action — building a field of grass

  1. We need several instances of our blades of grass, so convert the manual object into a mesh:
    manual->convertToMesh("BladesOfGrass");
    
  2. We want a field of grass which consists of 50 x 50 instances of our grass. So we need two for loops:
    for(int i=0;i<50;i++)
    {
    for(int j=0;j<50;j++)
    {
    
  3. Inside the for loops, create a nameless entity and a nameless scene node:
    Ogre::Entity * ent = mSceneMgr->createEntity("BladesOfGrass");
    Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(i*3,-10,j*3));
    node->attachObject(ent);
    
  4. Don't forget to close the for loops:
    }
    }
    
  5. Compile and run the application, and you should see a field of grass. Depending on your computer, this application might be ...

Get Ogre 3D 1.7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.