Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Static Private Member Functions
Forests::BatchPage Class Reference

Description

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):

PagedGeometry::addDetailLevel<BatchPage>(farRange, transitionLength, Ogre::Any(LODLevel));

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)
 

Member Typedef Documentation

◆ TMaterials

typedef std::vector<Ogre::MaterialPtr> Forests::BatchPage::TMaterials
private

Definition at line 49 of file BatchPage.h.

Constructor & Destructor Documentation

◆ BatchPage()

BatchPage::BatchPage ( )

Default constructor.

Definition at line 42 of file BatchPage.cpp.

◆ ~BatchPage()

BatchPage::~BatchPage ( )

Definition at line 87 of file BatchPage.cpp.

Member Function Documentation

◆ _updateShaders()

void BatchPage::_updateShaders ( )
protectedvirtual

Definition at line 204 of file BatchPage.cpp.

◆ addEntity()

void BatchPage::addEntity ( Ogre::Entity *  ent,
const Ogre::Vector3 &  position,
const Ogre::Quaternion &  rotation,
const Ogre::Vector3 &  scale,
const Ogre::ColourValue &  color 
)
virtual

Add an entity to the page, at the specified position, rotation, and scale.

Parameters
entThe entity that is being added. Keep in mind that the same entity may be added multiple times.
positionThe 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.
rotationThe rotation which should be applied to the entity.
scaleThe scale which should be applied to the entity.
colorThe desired color to apply to the whole entity
Note
The entity does not have to actually appear in the scene until build() is called.

Implements Forests::GeometryPage.

Definition at line 96 of file BatchPage.cpp.

◆ addEntityToBoundingBox()

void Forests::BatchPage::addEntityToBoundingBox ( )
inline

Definition at line 67 of file BatchPage.h.

◆ build()

void BatchPage::build ( )
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.

Note
This function is not pure virtual, so you don't have to override it if you don't need to.

Reimplemented from Forests::GeometryPage.

Definition at line 124 of file BatchPage.cpp.

◆ clearBoundingBox()

void Forests::BatchPage::clearBoundingBox ( )
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.

See also
getBoundingBox() for important details.

Reimplemented from Forests::GeometryPage.

Definition at line 73 of file BatchPage.h.

◆ getBoundingBox()

const Ogre::AxisAlignedBox & Forests::BatchPage::getBoundingBox ( )
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.

◆ getUniqueID()

static Ogre::String Forests::BatchPage::getUniqueID ( const Ogre::String &  prefix)
inlinestaticprivate

Definition at line 85 of file BatchPage.h.

◆ init()

void BatchPage::init ( PagedGeometry *  geom,
const Ogre::Any &  data 
)
virtual

Replace pure virtual GeometryPage::init.

Implements Forests::GeometryPage.

Definition at line 58 of file BatchPage.cpp.

◆ removeEntities()

void BatchPage::removeEntities ( )
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.

◆ setFade()

void BatchPage::setFade ( bool  enabled,
Ogre::Real  visibleDist,
Ogre::Real  invisibleDist 
)
virtual

Sets fade behavior for this page.

Parameters
enabledWhether or not to enable fading
visibleDistThe distance where geometry will be fully opaque (alpha 1)
invisibleDistThe 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.

Note
invisibleDist may be greater than or less than visibleDist, depending on whether the geometry is fading out or in to the distance.

Implements Forests::GeometryPage.

Definition at line 178 of file BatchPage.cpp.

◆ setVisible()

void BatchPage::setVisible ( bool  visible)
virtual

Toggle the entire page's visibility.

Parameters
visibleWhether or not this page should be visible.

Implements Forests::GeometryPage.

Definition at line 170 of file BatchPage.cpp.

Field Documentation

◆ m_bFadeEnabled

bool Forests::BatchPage::m_bFadeEnabled
protected

Definition at line 96 of file BatchPage.h.

◆ m_bShadersSupported

bool Forests::BatchPage::m_bShadersSupported
protected

Definition at line 97 of file BatchPage.h.

◆ m_fInvisibleDist

Ogre::Real Forests::BatchPage::m_fInvisibleDist
protected

Definition at line 99 of file BatchPage.h.

◆ m_fVisibleDist

Ogre::Real Forests::BatchPage::m_fVisibleDist
protected

Definition at line 98 of file BatchPage.h.

◆ m_nLODLevel

size_t Forests::BatchPage::m_nLODLevel
protected

Definition at line 95 of file BatchPage.h.

◆ m_pBatchGeom

BatchedGeometry* Forests::BatchPage::m_pBatchGeom
protected

Definition at line 94 of file BatchPage.h.

◆ m_pPagedGeom

PagedGeometry* Forests::BatchPage::m_pPagedGeom
protected

Definition at line 92 of file BatchPage.h.

◆ m_pSceneMgr

Ogre::SceneManager* Forests::BatchPage::m_pSceneMgr
protected

Definition at line 93 of file BatchPage.h.

◆ m_vecUnfadedMaterials

TMaterials Forests::BatchPage::m_vecUnfadedMaterials
protected

Definition at line 100 of file BatchPage.h.

◆ s_nGUID

unsigned long BatchPage::s_nGUID = 0
staticprotected

Definition at line 104 of file BatchPage.h.

◆ s_nRefCount

unsigned long BatchPage::s_nRefCount = 0
staticprotected

Definition at line 103 of file BatchPage.h.


The documentation for this class was generated from the following files: