In this tutorial we load and display a 3D model in our Irrlicht application.
DOWNLOAD THE DEMO AND SOURCE CODE
One thing we want to do is to keep the logic that relates to the Irrlicht engine, like opening a window and managing the render loop, separate from the logic of the application itself, which in our case here is to display a 3D model. To do this we create a new class called ApplicationManager.
ApplicationManager.h / ApplicationManager.cpp
Just like the IrrlichtEngineManager class, the ApplicationManager is designed as a singleton, meaning there is only one instance of the object. This single object is accessed via the Instance function, or by using the APPLICATIONMANAGER definition.
In the Startup function we being by adding a FPS style camera to the scene by calling ENGINEMANAGER.GetSceneManager()->addCameraSceneNodeFPS(). This camera is controlled by the mouse and arrow keys, just like the controls for a standard FPS game.
The FPS camera records the movement of the mouse each frame, and then centres it in the middle of the screen again. This effectively locks the mouse in position, making it fairly useless, not to mention annoying, so we hide it by calling ENGINEMANAGER.GetIrrlichtDevice()->getCursorControl()->setVisible(false).
Now we load a 3D model of a ninja by calling ENGINEMANAGER.GetSceneManager()->getMesh("../../media/ninja.b3d"). Irrlicht can directly load a wide range of 3D model formats, and here we are loading a Blitz3d model.
If the file could not be found, mesh will be NULL, and we close the application by stopping the render loop through a call to ENGINEMANAGER.EndRenderLoop().
Otherwise we then add the loaded mesh to the scene by calling ENGINEMANAGER.GetSceneManager()->addAnimatedMeshSceneNode(mesh). We store the returned scene node pointer in a variable called model.
This scene node is then positioned so it is in front of the camera when the application starts.
We also disable the lighting by setting the EMF_LIGHTING flag to false. Because there are no lights in the scene, if we didn’t disable the lighting the model would appear black.
In the Shutdown function we remove the 3D model from the scene by calling remove(). Notice that we don’t call drop() because the object was not created with a function that started with “create”.
The last change we need to make is to call the ApplicationManager Startup and Shutdown functions from the WinMain function. This gives the ApplicationManager a chance to set itself up before the render loop is started, and to clean itself up before the Irrlicht 3D engine is shutdown.

In this article I introduce you to the series, Specifiers in C++....
In this article I introduce you to a tutorial series titled, Some Features of C++ Entities....
C++ is a computer language I want to teach in these tutorials. C++ is a very developed language...
In C++ an array is a set of consecutive objects of the same type, in memory. We see how to crea...
A database is a set of related tables. This is part 1, division 1 of a series I have on databas...
In this tutorial we add mouse interactivity to the scene....
In this tutorial we allow the view of the isometric scene to be moved with the mouse....
In this tutorial we show the height of an isometric object by adding a shadow....
In this tutorial we modify the appearance of the isometric cube at runtime....
In this tutorial we add some animated isometric boxes to the scene....