Pre-transforms and batches up meshes for efficient use as static geometry in a scene.
More...
|
| StaticGeometry (SceneManager *owner, const String &name) |
| Constructor; do not use directly (. More...
|
|
virtual | ~StaticGeometry () |
| Destructor. More...
|
|
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. More...
|
|
virtual void | addSceneNode (const SceneNode *node) |
| Adds all the Entity objects attached to a SceneNode and all it's children to the static geometry. More...
|
|
virtual void | build (void) |
| Build the geometry. More...
|
|
virtual void | destroy (void) |
| Destroys all the built geometry state (reverse of build). More...
|
|
virtual void | dump (const String &filename) const |
| Dump the contents of this StaticGeometry to a file for diagnostic purposes. More...
|
|
virtual bool | getCastShadows (void) |
| Will the geometry from this object cast shadows? More...
|
|
const String & | getName (void) const |
| Get the name of this object. More...
|
|
virtual const Vector3 & | getOrigin (void) const |
| Gets the origin of this geometry. More...
|
|
virtual const Vector3 & | getRegionDimensions (void) const |
| Gets the size of a single batch of geometry. More...
|
|
RegionIterator | getRegionIterator (void) |
| Get an iterator over the regions in this geometry. More...
|
|
virtual Real | getRenderingDistance (void) const |
| Gets the distance at which batches are no longer rendered. More...
|
|
virtual uint8 | getRenderQueueGroup (void) const |
| Gets the queue group for this entity, see setRenderQueueGroup for full details. More...
|
|
virtual Real | getSquaredRenderingDistance (void) const |
| Gets the squared distance at which batches are no longer rendered. More...
|
|
uint32 | getVisibilityFlags () const |
| Returns the visibility flags of the regions. More...
|
|
virtual bool | isVisible (void) const |
| Are the batches visible? More...
|
|
void | operator delete (void *ptr) |
|
void | operator delete (void *ptr, const char *, int, const char *) |
|
void | operator delete (void *ptr, void *) |
|
void | operator delete[] (void *ptr) |
|
void | operator delete[] (void *ptr, const char *, int, const char *) |
|
void * | operator new (size_t sz) |
|
void * | operator new (size_t sz, const char *file, int line, const char *func) |
| operator new, with debug line info More...
|
|
void * | operator new (size_t sz, void *ptr) |
| placement operator new More...
|
|
void * | operator new[] (size_t sz) |
|
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
| array operator new, with debug line info More...
|
|
virtual void | reset (void) |
| Clears any of the entities / nodes added to this geometry and destroys anything which has already been built. More...
|
|
virtual void | setCastShadows (bool castShadows) |
| Sets whether this geometry should cast shadows. More...
|
|
virtual void | setOrigin (const Vector3 &origin) |
| Sets the origin of the geometry. More...
|
|
virtual void | setRegionDimensions (const Vector3 &size) |
| Sets the size of a single region of geometry. More...
|
|
virtual void | setRenderingDistance (Real dist) |
| Sets the distance at which batches are no longer rendered. More...
|
|
virtual void | setRenderQueueGroup (uint8 queueID) |
| Sets the render queue group this object will be rendered through. More...
|
|
void | setVisibilityFlags (uint32 flags) |
| Sets the visibility flags of all the regions at once. More...
|
|
virtual void | setVisible (bool visible) |
| Hides or shows all the batches. More...
|
|
Pre-transforms and batches up meshes for efficient use as static geometry in a scene.
- Therefore it is important when you are rendering a lot of geometry to batch things up into as few rendering calls as possible. This class allows you to build a batched object from a series of entities in order to benefit from this behaviour. Batching has implications of it's own though:
- Batched geometry cannot be subdivided; that means that the whole group will be displayed, or none of it will. This obivously has culling issues.
- A single world transform must apply to the entire batch. Therefore once you have batched things, you can't move them around relative to each other. That's why this class is most useful when dealing with static geometry (hence the name). In addition, geometry is effectively duplicated, so if you add 3 entities based on the same mesh in different positions, they will use 3 times the geometry space than the movable version (which re-uses the same geometry). So you trade memory and flexibility of movement for pure speed when using this class.
- A single material must apply for each batch. In fact this class allows you to use multiple materials, but you should be aware that internally this means that there is one batch per material. Therefore you won't gain as much benefit from the batching if you use many different materials; try to keep the number down.
- In order to retain some sort of culling, this class will batch up meshes in localised regions. The size and shape of these blocks is controlled by the SceneManager which constructs this object, since it makes sense to batch things up in the most appropriate way given the existing partitioning of the scene.
- The LOD settings of both the Mesh and the Materials used in constructing this static geometry will be respected. This means that if you use meshes/materials which have LOD, batches in the distance will have a lower polygon count or material detail to those in the foreground. Since each mesh might have different LOD distances, during build the furthest distance at each LOD level from all meshes
in that region is used. This means all the LOD levels change at the same time, but at the furthest distance of any of them (so quality is not degraded). Be aware that using Mesh LOD in this class will further increase the memory required. Only generated LOD is supported for meshes.
- There are 2 ways you can add geometry to this class; you can add Entity objects directly with predetermined positions, scales and orientations, or you can add an entire SceneNode and it's subtree, including all the objects attached to it. Once you've added everything you need to, you have to call build() the fix the geometry in place.
- Note
- This class is not a replacement for world geometry (
- See also
- SceneManager::setWorldGeometry). The single most efficient way to render large amounts of static geometry is to use a SceneManager which is specialised for dealing with that particular world structure. However, this class does provide you with a good 'halfway house' between generalised movable geometry (Entity) which works with all SceneManagers but isn't efficient when using very large numbers, and highly specialised world geometry which is extremely fast but not generic and typically requires custom world editors.
- You should not construct instances of this class directly; instead, cal SceneManager::createStaticGeometry, which gives the SceneManager the option of providing you with a specialised version of this class if it wishes, and also handles the memory management for you like other classes.
- Note
- Warning: this class only works with indexed triangle lists at the moment, do not pass it triangle strips, fans or lines / points, or unindexed geometry.