Time for action — printing the names

We only have to add one new line to get the names:

  1. At the end of the for loop body, add the following print statement:
    std::cout << node->getName() << "::" << ent->getName() << std::endl;
    
  2. Compile and run the application; there should be a long list of printed names. To be precise, there should be 2500 lines, because the for loop iterates 50 times 50 over our code. Here are the last lines:

    Unnamed_2488::Ogre/MO2487

    Unnamed_2489::Ogre/MO2488

    Unnamed_2490::Ogre/MO2489

    Unnamed_2491::Ogre/MO2490

    Unnamed_2492::Ogre/MO2491

    Unnamed_2493::Ogre/MO2492

    Unnamed_2494::Ogre/MO2493

    Unnamed_2495::Ogre/MO2494

    Unnamed_2496::Ogre/MO2495

    Unnamed_2497::Ogre/MO2496

    Unnamed_2498::Ogre/MO2497

    Unnamed_2499::Ogre/MO2498

    Unnamed_2500::Ogre/MO2499

What just happened?

We just printed the names of the scene node and the entity we created to understand the automatic naming scheme Ogre 3D uses when we don't give a name as a parameter. We see that scene node names use the following scheme: Unnamed_Nr, where Nr is a counter that get increased each time we create a new unnamed scene node. Entities use a similar scheme, but they use MO instead of Unnamed_; MO is the short form for movable object. A movable object is a class used as the base class for many different classes in Ogre 3D. Everything that can be moved using scene nodes inherits from a movable object. There are entities and lights, but there are a lot more classes that inherit from a movable object. Here is a picture from the Ogre 3D documentation that shows all the classes which inherit from MovableObject.

What just happened?

Source: http://www.ogre3d.org/docs/api/html/classOgre_1_1MovableObject.html

We see that even the camera is a movable object; this is necessary because otherwise we wouldn't be able to attach it to a scene node. Only a child class of MovableObject can be attached to a scene node. The difference in the numbers attached to the scene nodes names and the movable object names is due to the creation of an unnamed scene node we had done while adding our plane to the scene with the following code:

mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
..................Content has been hidden....................

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