Book Image

OGRE 3D 1.7 Beginner's Guide

Book Image

OGRE 3D 1.7 Beginner's Guide

Overview of this book

Want to make your own 3D applications, simulations, and games? OGRE 3D, an open source Object-Oriented 3D Graphics Rendering Engine written in C++, which can be utilized to create a variety of 3D applications and is commonly used in game creation, can help you to do so! OGRE 3D 1.7 Beginner's Guide, based on the latest version 1.7, makes it super easy for you to make your own monsters, spaceship shooters, weapons, enemies, and more!OGRE 3D 1.7 Beginner's Guide will teach you to develop 3D applications that are exciting and interesting and if used correctly can result in stunning games and simulations. You will start from the very beginning and then work your way up to complex scenes and stunning effects.In this book you will start with how to download and configure OGRE 3D, then create your first example scene. With the help of this sample scene, you will be introduced to several related topics each of which will be explained through several other examples and by do-it-yourself tasks. After each example there is a section that explains the theory behind the technique used for deeper understanding. You will also use what you learned in one example in another example and repeat each technique several times while learning new ones at the same time to strengthen the topics learned. Within no time you will master the art of game creation. Imagine how great you will feel when all your friends are playing the great-looking games you've created with OGRE 3D and this book.
Table of Contents (17 chapters)
Ogre 3D 1.7
Credits
About the Author
About the Reviewers
Preface
Index

Time for action — loading a model


Loading a model is easy. We just need to add two lines of code.

  1. Add the following two lines into the empty createScene() method:

    Ogre::Entity* ent =
    mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
    mSceneMgr->getRootSceneNode()->attachObject(ent);
    
  2. Compile your application again.

  3. Start your application. You will see a small green figure after starting the application.

  4. Navigate the camera with the mouse and WASD until you see the green figure better.

  5. Close the application.

What just happened?

With mSceneMgr->createEntity("MyEntity","Sinbad.mesh");,we told Ogre that we wanted a new instance of the Sinbad.mesh model. mSceneMgr is a pointer to the SceneManager of Ogre 3D, created for us by the ExampleApplication. To create a new entity, Ogre needs to know which model file to use, and we can give a name to the new instance. It is important that the name is unique; it can't be used twice. If this happens, Ogre 3D will throw an exception. If we don't specify a name, Ogre 3D will automatically generate one for us. We will examine this behavior in more detail later.

We now have an instance of a model, and to make it visible, we need to attach it to our scene. Attaching an entity is rather easy – just write the following line: mSceneMgr->getRootSceneNode()->attachObject(ent);

This attaches the entity to our scene so we can see it. And what we see is Sinbad, the mascot model of Ogre 3D. We will see this model a lot during the course of this book.

Pop quiz — ExampleApplication and how to display a model

Describe in your own words how to load a model and how to make it visible.