OGRE 14.3
Object-Oriented Graphics Rendering Engine
|
Pre-transforms and batches up meshes for efficient use as static geometry in a scene. More...
#include <OgreStaticGeometry.h>
Classes | |
class | GeometryBucket |
A GeometryBucket is a the lowest level bucket where geometry with the same vertex & index format is stored. More... | |
class | LODBucket |
A LODBucket is a collection of smaller buckets with the same LOD. More... | |
class | MaterialBucket |
A MaterialBucket is a collection of smaller buckets with the same Material (and implicitly the same LOD). More... | |
class | OptimisedSubMeshGeometry |
Struct holding geometry optimised per SubMesh / LOD level, ready for copying to instances. More... | |
struct | QueuedGeometry |
Structure recording a queued geometry for low level builds. More... | |
struct | QueuedSubMesh |
Structure recording a queued submesh for the build. More... | |
class | Region |
The details of a topological region which is the highest level of partitioning for this class. More... | |
struct | SubMeshLodGeometryLink |
Saved link between SubMesh at a LOD and vertex/index data May point to original or optimised geometry. More... | |
Public Types | |
typedef std::list< OptimisedSubMeshGeometry * > | OptimisedSubMeshGeometryList |
typedef std::vector< QueuedGeometry * > | QueuedGeometryList |
typedef std::vector< QueuedSubMesh * > | QueuedSubMeshList |
typedef MapIterator< RegionMap > | RegionIterator |
Iterator for iterating over contained regions. | |
typedef std::map< uint32, Region * > | RegionMap |
Indexed region map based on packed x/y/z region index, 10 bits for each axis. | |
typedef std::map< SubMesh *, SubMeshLodGeometryLinkList * > | SubMeshGeometryLookup |
typedef std::vector< SubMeshLodGeometryLink > | SubMeshLodGeometryLinkList |
Public Member Functions | |
StaticGeometry (SceneManager *owner, const String &name) | |
Constructor; do not use directly (. | |
virtual | ~StaticGeometry () |
Destructor. | |
virtual void | addEntity (Entity *ent, const Vector3 &position, const Quaternion &orientation=Quaternion::IDENTITY, const Vector3 &scale=Vector3::UNIT_SCALE) |
Adds an Entity to the static geometry. | |
virtual void | addSceneNode (const SceneNode *node) |
Adds all the Entity objects attached to a SceneNode and all it's children to the static geometry. | |
virtual void | build (void) |
Build the geometry. | |
void | destroy (void) |
Destroys all the built geometry state (reverse of build). | |
virtual bool | getCastShadows (void) |
Will the geometry from this object cast shadows? | |
const String & | getName (void) const |
Get the name of this object. | |
virtual const Vector3 & | getOrigin (void) const |
Gets the origin of this geometry. | |
virtual const Vector3 & | getRegionDimensions (void) const |
Gets the size of a single batch of geometry. | |
RegionIterator | getRegionIterator (void) |
const RegionMap & | getRegions () const |
Get an list of the regions in this geometry. | |
virtual Real | getRenderingDistance (void) const |
Gets the distance at which batches are no longer rendered. | |
virtual uint8 | getRenderQueueGroup (void) const |
Gets the queue group for this entity, see setRenderQueueGroup for full details. | |
virtual Real | getSquaredRenderingDistance (void) const |
Gets the squared distance at which batches are no longer rendered. | |
uint32 | getVisibilityFlags () const |
Returns the visibility flags of the regions. | |
virtual bool | isVisible (void) const |
Are the batches visible? | |
void | reset (void) |
Clears any of the entities / nodes added to this geometry and destroys anything which has already been built. | |
virtual void | setCastShadows (bool castShadows) |
Sets whether this geometry should cast shadows. | |
virtual void | setOrigin (const Vector3 &origin) |
Sets the origin of the geometry. | |
virtual void | setRegionDimensions (const Vector3 &size) |
Sets the size of a single region of geometry. | |
virtual void | setRenderingDistance (Real dist) |
Sets the distance at which batches are no longer rendered. | |
virtual void | setRenderQueueGroup (uint8 queueID) |
Sets the render queue group this object will be rendered through. | |
void | setVisibilityFlags (uint32 flags) |
Sets the visibility flags of all the regions at once. | |
virtual void | setVisible (bool visible) |
Hides or shows all the batches. | |
void | visitRenderables (Renderable::Visitor *visitor, bool debugRenderables=false) |
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject will add to the render queue when asked, if any. | |
Pre-transforms and batches up meshes for efficient use as static geometry in a scene.
Modern graphics cards (GPUs) prefer to receive geometry in large batches. It is orders of magnitude faster to render 10 batches of 10,000 triangles than it is to render 10,000 batches of 10 triangles, even though both result in the same number of on-screen triangles.
typedef std::vector<QueuedSubMesh*> Ogre::StaticGeometry::QueuedSubMeshList |
typedef std::vector<QueuedGeometry*> Ogre::StaticGeometry::QueuedGeometryList |
typedef std::map<uint32, Region*> Ogre::StaticGeometry::RegionMap |
Indexed region map based on packed x/y/z region index, 10 bits for each axis.
Regions are indexed 0-1023 in all axes, where for example region 0 in the x axis begins at mOrigin.x + (mRegionDimensions.x * -512), and region 1023 ends at mOrigin + (mRegionDimensions.x * 512).
Iterator for iterating over contained regions.
Ogre::StaticGeometry::StaticGeometry | ( | SceneManager * | owner, |
const String & | name | ||
) |
Constructor; do not use directly (.
|
virtual |
Destructor.
|
virtual |
Adds an Entity to the static geometry.
This method takes an existing Entity and adds its details to the list of elements to include when building. Note that the Entity itself is not copied or referenced in this method; an Entity is passed simply so that you can change the materials of attached SubEntity objects if you want. You can add the same Entity instance multiple times with different material settings completely safely, and destroy the Entity before destroying this StaticGeometry if you like. The Entity passed in is simply used as a definition.
Adds all the Entity objects attached to a SceneNode and all it's children to the static geometry.
This method performs just like addEntity, except it adds all the entities attached to an entire sub-tree to the geometry. The position / orientation / scale parameters are taken from the node structure instead of being specified manually.
node | Pointer to the node to use to provide a set of Entity templates |
Build the geometry.
Based on all the entities which have been added, and the batching options which have been set, this method constructs the batched geometry structures required. The batches are added to the scene and will be rendered unless you specifically hide them.
Destroys all the built geometry state (reverse of build).
You can call build() again after this and it will pick up all the same entities / nodes you queued last time.
Clears any of the entities / nodes added to this geometry and destroys anything which has already been built.
Sets the distance at which batches are no longer rendered.
This lets you turn off batches at a given distance. This can be useful for things like detail meshes (grass, foliage etc) and could be combined with a shader which fades the geometry out beforehand to lessen the effect.
dist | Distance beyond which the batches will not be rendered (the default is 0, which means batches are always rendered). |
Gets the distance at which batches are no longer rendered.
Gets the squared distance at which batches are no longer rendered.
Hides or shows all the batches.
Sets whether this geometry should cast shadows.
No matter what the settings on the original entities, the StaticGeometry class defaults to not casting shadows. This is because, being static, unless you have moving lights you'd be better to use precalculated shadows of some sort. However, if you need them, you can enable them using this method. If the SceneManager is set up to use stencil shadows, edge lists will be copied from the underlying meshes on build. It is essential that all meshes support stencil shadows in this case.
Will the geometry from this object cast shadows?
Sets the size of a single region of geometry.
This method allows you to configure the physical world size of each region, so you can balance culling against batch size. Entities will be fitted within the batch they most closely fit, and the eventual bounds of each batch may well be slightly larger than this if they overlap a little. The default is Vector3(1000, 1000, 1000).
size | Vector3 expressing the 3D size of each region. |
Gets the size of a single batch of geometry.
Sets the origin of the geometry.
This method allows you to configure the world centre of the geometry, thus the place which all regions surround. You probably don't need to mess with this unless you have a seriously large world, since the default set up can handle an area 1024 * mRegionDimensions, and the sparseness of population is no issue when it comes to rendering. The default is Vector3(0,0,0).
origin | Vector3 expressing the 3D origin of the geometry. |
Gets the origin of this geometry.
Sets the visibility flags of all the regions at once.
uint32 Ogre::StaticGeometry::getVisibilityFlags | ( | ) | const |
Returns the visibility flags of the regions.
Sets the render queue group this object will be rendered through.
Render queues are grouped to allow you to more tightly control the ordering of rendered objects. If you do not call this method, all objects default to the default queue (RenderQueue::getDefaultQueueGroup), which is fine for most objects. You may want to alter this if you want to perform more complex rendering.
queueID | Enumerated value of the queue group to use. |
Gets the queue group for this entity, see setRenderQueueGroup for full details.
void Ogre::StaticGeometry::visitRenderables | ( | Renderable::Visitor * | visitor, |
bool | debugRenderables = false |
||
) |
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject will add to the render queue when asked, if any.
visitor | Pointer to a class implementing the Renderable::Visitor interface which will be called back for each Renderable which will be queued. Bear in mind that the state of the Renderable instances may not be finalised depending on when you call this. |
debugRenderables | If false, only regular renderables will be visited (those for normal display). If true, debug renderables will be included too. |
Get an list of the regions in this geometry.
RegionIterator Ogre::StaticGeometry::getRegionIterator | ( | void | ) |