ManualObject
From Ogre Wiki
With the ManualObject class you can create entities by code.
You don't need to load ressources and it's nice to create dynamic objects or simple ones.
To do so, you define the needed points (vertices), rendering type (points, lines, surfaces) and assign a material. To add it to the scene, it has to be attached to a SceneNode (e.g. the RootSceneNode).
Several begin / end blocks can be added to the same ManualObject, so you can use different materials and rendering types. As a result you can get lines, surfaces or a combination of it. Transparency is also possible (by using materials with transparency property). If several instances are needed, you have to create a mesh by using ManualObject::convertToMesh().
In some cases the identity projection can be interesting. With this the coordinates are in 2D screen space of the current camera. Useful for overlay rendering.
Example
A very minimal example that gives an outlined square (or quad):
ManualObject* manual = mSceneMgr->createManualObject("manual");
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_STRIP);
manual->position(-100.0, -100.0, 0.0);
manual->position( 100.0, -100.0, 0.0);
manual->position( 100.0, 100.0, 0.0);
manual->position(-100.0, 100.0, 0.0);
manual->end();
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(manual);
If you want to update (change) the ManualObject later or create a Mesh out of it, you have to add indices.
ManualObject* manual = mSceneMgr->createManualObject("manual");
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_STRIP);
manual->position(-100.0, -100.0, 0.0);
manual->position( 100.0, -100.0, 0.0);
manual->position( 100.0, 100.0, 0.0);
manual->position(-100.0, 100.0, 0.0);
manual->index(0);
manual->index(1);
manual->index(2);
manual->index(3);
manual->index(0);
manual->end();
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(manual);
Rendering Types
enum Ogre::RenderOperation::OperationType
| OT_POINT_LIST | A list of points | 1 vertex per point |
| OT_LINE_LIST | A list of lines | 2 vertices per line |
| OT_LINE_STRIP | A strip of connected lines | 1 start vertex and 1 vertex per line |
| OT_TRIANGLE_LIST | A list of triangles | 3 vertices per triangle |
| OT_TRIANGLE_STRIP | A strip of triangles | 3 vertices for the first triangle and 1 per triangle after that |
| OT_TRIANGLE_FAN | A fan of triangles | 3 vertices for the first triangle and 1 per triangle after that |
See also
- Line3D, DynamicLineDrawing, Circle3D, ManualObject 2D for other ManualObject examples
- MOGRE: Line 3D, Create Tetrahedron, Generating a grid
- A Crash Course in 3D Objects for some basics (e.g. index)
- Important remarks are in its API description
- API description of convertToMesh()
- API description of identity projection
- Materials
- How to create material by code: Line3D, MOGRE Line 3D


