![]() |
Rigs of Rods 2026.01
Soft-body Physics Simulation
|
The BatchPage class renders entities as StaticGeometry.
This is one of the geometry page types included in the StaticGeometry engine. These page types should be added to a PagedGeometry object with PagedGeometry::addDetailLevel() so the PagedGeometry will know how you want your geometry displayed.
To use this page type, use (the last parameter is optional):
This page type uses batched geometry (Ogre::StaticGeometry) to represent the entities. Batched geometry is generally much faster than plain entities, since video card state changes and transform calculations can be minimized. Batched geometry can be anywhere from 2 to 20 times faster than plain entities.
"LODLevel" can be used to specify a certain LOD level to use from the added entities. This would be useful, for example, if you wanted to add high-res batched trees near the camera, and low-res batched trees farther away.
Definition at line 47 of file BatchPage.h.
Inheritance diagram for Forests::BatchPage:Public Member Functions | |
| BatchPage () | |
| ~BatchPage () | |
| void | init (PagedGeometry *geom, const Ogre::Any &data) |
| void | addEntity (Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color) |
| void | removeEntities () |
| void | build () |
| void | setVisible (bool visible) |
| void | setFade (bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist) |
| void | addEntityToBoundingBox () |
| void | clearBoundingBox () |
| const Ogre::AxisAlignedBox & | getBoundingBox () |
Public Member Functions inherited from Forests::GeometryPage | |
| virtual void | setRegion (Ogre::Real left, Ogre::Real top, Ogre::Real right, Ogre::Real bottom) |
| virtual void | update () |
| Ogre::Vector3 & | getCenterPoint () |
| bool | isVisible () |
| virtual void | addEntityToBoundingBox (Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale) |
| virtual | ~GeometryPage () |
| GeometryPage () | |
Protected Member Functions | |
| virtual void | _updateShaders () |
Protected Attributes | |
| PagedGeometry * | m_pPagedGeom |
| Ogre::SceneManager * | m_pSceneMgr |
| BatchedGeometry * | m_pBatchGeom |
| size_t | m_nLODLevel |
| bool | m_bFadeEnabled |
| bool | m_bShadersSupported |
| Ogre::Real | m_fVisibleDist |
| Ogre::Real | m_fInvisibleDist |
| TMaterials | m_vecUnfadedMaterials |
Static Protected Attributes | |
| static unsigned long | s_nRefCount = 0 |
| static unsigned long | s_nGUID = 0 |
Private Types | |
| typedef std::vector< Ogre::MaterialPtr > | TMaterials |
Static Private Member Functions | |
| static Ogre::String | getUniqueID (const Ogre::String &prefix) |
|
private |
Definition at line 49 of file BatchPage.h.
| BatchPage::BatchPage | ( | ) |
Default constructor.
Definition at line 42 of file BatchPage.cpp.
| BatchPage::~BatchPage | ( | ) |
Definition at line 87 of file BatchPage.cpp.
|
protectedvirtual |
Definition at line 204 of file BatchPage.cpp.
|
virtual |
Add an entity to the page, at the specified position, rotation, and scale.
| ent | The entity that is being added. Keep in mind that the same entity may be added multiple times. |
| position | The position where the entity must be placed. Under normal circumstances, this will never be outside of the bounds supplied to init(). The only exception is when a PageLoader tries to add an entity outside of the bounds it was given. |
| rotation | The rotation which should be applied to the entity. |
| scale | The scale which should be applied to the entity. |
| color | The desired color to apply to the whole entity |
Implements Forests::GeometryPage.
Definition at line 96 of file BatchPage.cpp.
|
inline |
Definition at line 67 of file BatchPage.h.
|
virtual |
Perform any final steps to make added entities appear in the scene.
build() is automatically called right after all the entities have been added with addEntity(). Use this if there are any final steps that need to be performed after addEntity() has been called in order to display the entities.
Reimplemented from Forests::GeometryPage.
Definition at line 124 of file BatchPage.cpp.
|
inlinevirtual |
Advanced: Reset the bounding box used by addEntityToBoundingBox()
Advanced: Override this function only if your page implementation already computes a bounding box (local to the page center) for added entities. This way you can prevent the bounding box from being computed twice.
Reimplemented from Forests::GeometryPage.
Definition at line 73 of file BatchPage.h.
|
inlinevirtual |
Advanced: Return the bounding box computed with addEntityToBoundingBox()
Advanced: Override this function only if your page implementation already computes a bounding box (local to the page center) for added entities. This way you can prevent the bounding box from being computed twice.
When performing fade transitions, the page manager needs to know the actual boundaries of an entire page of entities in order to avoid entities "popping" into view without a smooth transition due to loose grid boundaries. Anyway, as long as this function returns the combined bounding box of all entities added to this page properly, fade transitions should work fairly smoothly.
Important: If you implement this function, you must also override addEntityToBoundingBox() and clearBoundingBox() (although you don't need to implement them as long as getBoundingBox() functions as expected). Otherwise the default implementations of these function will be used and therefore result in the bounding box being calculated twice.
Reimplemented from Forests::GeometryPage.
Definition at line 79 of file BatchPage.h.
|
inlinestaticprivate |
Definition at line 85 of file BatchPage.h.
|
virtual |
Replace pure virtual GeometryPage::init.
Implements Forests::GeometryPage.
Definition at line 58 of file BatchPage.cpp.
|
virtual |
Remove all geometry/entities from the page completely.
Make sure this completely reverses the effects of both build() and addEntity(). This is necessary, because after this is called, the entities will most likely be added again with addEntity() and build().
Do not leave any remains of the entities in memory after this function is called. One of the advantages of using paged geometry is that you can have near-infinite game worlds, which would normally exceed a computer's RAM capacity. This advantage would completely disappear if you did not clean up properly when the page manager calls this function.
Implements Forests::GeometryPage.
Definition at line 161 of file BatchPage.cpp.
|
virtual |
Sets fade behavior for this page.
| enabled | Whether or not to enable fading |
| visibleDist | The distance where geometry will be fully opaque (alpha 1) |
| invisibleDist | The distance where geometry will be invisible (alpha 0) |
This is called whenever a page needs fading enabled/disabled. The distance ranges given specify how the final alpha values should be calculated - geometry at visibleDist should have alpha values of 1, while geometry at invisibleDist should have alpha values of 0. Important: Distances must be calculated in the xz plane only - the y coordinate should be disregarded when calculating distance.
setFade() won't be called unless the user's computer supports vertex shaders.
Implements Forests::GeometryPage.
Definition at line 178 of file BatchPage.cpp.
|
virtual |
Toggle the entire page's visibility.
| visible | Whether or not this page should be visible. |
Implements Forests::GeometryPage.
Definition at line 170 of file BatchPage.cpp.
|
protected |
Definition at line 96 of file BatchPage.h.
|
protected |
Definition at line 97 of file BatchPage.h.
|
protected |
Definition at line 99 of file BatchPage.h.
|
protected |
Definition at line 98 of file BatchPage.h.
|
protected |
Definition at line 95 of file BatchPage.h.
|
protected |
Definition at line 94 of file BatchPage.h.
|
protected |
Definition at line 92 of file BatchPage.h.
|
protected |
Definition at line 93 of file BatchPage.h.
|
protected |
Definition at line 100 of file BatchPage.h.
|
staticprotected |
Definition at line 104 of file BatchPage.h.
|
staticprotected |
Definition at line 103 of file BatchPage.h.