Currently this is "no professional" page.
It contains some basic information, wich were replied to questions of an Ogre newcomer in the forum (here).
The question was how to load resources and what's the difference between the many related Ogre classes (e.g. Mesh, ManualObject, ResourceGroupManager, MeshManager, MeshSerializer, ...).
Here is an overview of classes which inherit from the abstract class MovableObject. Most of them are for display of something.
If you want to learn details about specific classes, have a look to the Ogre Class Reference, which describes the classes and lists the class members (e.g. functions). Here is the page from where I got the graphic. Just click onto a "block" in the graphic (e.g. Ogre::Entity) and your browser will load the related page of the class reference.
Well, now a little bit more practical notes for some important classes:
There are different kinds of resource files. 3D objects you call Mesh.
When you want to load a Mesh, you create an Entity which loads the 3D information of the Mesh.
An Entity is an instance of a mesh, and allow different material information for each entity.
Entities are often the most common object in a Ogre application.
Different Entities can have different materials, while sharing the same mesh.
It is possible to create Entities with different meshes too.
In order to move an Entity, attach it to a SceneNode, and move this SceneNode.
When you want to create a visible object by code then use ManualObject.
This is fine for creation of lines, triangles, boxes, or any other shapes. You can even create very complex 3D objects with several faces, textures, etc.
To make visible a Mesh, ManualObject, etc. you attach it to a SceneNode.
By "help" of the SceneNode you can scale, move, rotate and hide the attached objects.
It's just a "helper class". Common users don't need to care about this class. Ogre uses it internally to load the content of a mesh file. With this class, it's also possible to save 3D models from the memory to a file.
Now I try to explain how to load 3D objects:
Ogre needs to know where to search for "resource" files.
By default, the user defines the paths in the file resources.cfg.
Alternatively resources can be loaded by code:
// Add the location of the mesh to a resource group: ResourceGroupManager::getSingleton().addResourceLocation([path/to/folder], "FileSystem"); // Initialise the resource groups: ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); // Create an entity from the mesh: Entity *e = mSceneMgr->createEntity("MyEntity", [MeshFilename]); // Attach the entity to a SceneNode: SceneNode *sn = mSceneMgr->getRootSceneNode().createChildSceneNode("MySceneNode"); sn ->attachObject(e); // Note: This code was ported from C# to C++. // If it contains syntax errors, please correct it on this wiki page.
The ResourceManager of Ogre keeps them all in "mind".
When the user (programmer) wants to load a 3D object from a file, he doesn't need to know the directory of the file. He just indicates the name (e.g. myModel.mesh) to the resource manager.
If you have mesh files with the same name, you have two choices: make the file names unique (this I recommend) or use different resource groups for different mesh files. (e.g. for each directory which contains mesh files)
When a 3D object contains materials or textures, then this information is not inside the mesh file. Materials and textures are stored separately. The mesh file just contains its name as a reference (e.g. "myRedMaterial"). Material files and texture files are loaded similar to the mesh files. When a Mesh "needs" a material, it just asks the MaterialManager (a "helper" of the ResourceManager) for the material with the specified name (e.g. "myRedMaterial") and then it will be loaded. Important is to keep the material names unique to avoid conflicts.
The names of material files don't matter. Ogre just looks up the names, which are defined inside the material files. (One material file can contain several material definitions.)
I use Blender for creating mesh files. Inside of Blender I rename the default material names (e.g. "red.001") to a unique name (e.g. "myVehicleName_red"). To be sure it's unique, you can also add a random ID to the material name (e.g. "myVehicleName_red__825103").
Are you confused about the different Managers?
The SceneManager is responsible for managing any object that is loaded to a scene: its position, visibility, etc.
The ResourceManager is responsible for loading and handling different types of resources. It has several specialized "helpers". See the picture below:
This page was originally written by user Beauty in March 2011.
If you want to modify the content, just do it.
- Resources and ResourceManagers - Outlines in detail the process by which resources are loaded, unloaded, reloaded and destroyed. Shows how to create a new resource type, and a manager to go with it.
- Basic Tutorial 1 - An introduction to the most basic Ogre constructs: SceneManager, SceneNode, and Entity objects.
- Tutorials - Many useful tutorials, especially for beginners.