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

Description

A custom page type designed specifically for use with GrassLoader.

You can use this in your own project if you want, but remember that no optimizations are performed. The given entity is simply cloned and attached to a new scene node as quickly and simply as possible (this means there's no batching overhead as in BatchPage, but it also means potentially poor performance if you don't know what you're doing).

Definition at line 548 of file GrassLoader.h.

+ Inheritance diagram for Forests::GrassPage:

Public Member Functions

void init (PagedGeometry *geom, const Ogre::Any &data)
 
 ~GrassPage ()
 
void addEntity (Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color)
 
void removeEntities ()
 
void setFade (bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist)
 
void setVisible (bool visible)
 
- Public Member Functions inherited from Forests::GeometryPage
virtual void setRegion (Ogre::Real left, Ogre::Real top, Ogre::Real right, Ogre::Real bottom)
 
virtual void build ()
 
virtual void update ()
 
Ogre::Vector3 & getCenterPoint ()
 
bool isVisible ()
 
virtual const Ogre::AxisAlignedBox & getBoundingBox ()
 
virtual void addEntityToBoundingBox (Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale)
 
virtual void clearBoundingBox ()
 
virtual ~GeometryPage ()
 
 GeometryPage ()
 

Static Private Member Functions

static Ogre::String getUniqueID ()
 

Private Attributes

Ogre::SceneManager * sceneMgr
 
Ogre::SceneNode * rootNode
 
std::list< Ogre::SceneNode * > nodeList
 

Static Private Attributes

static unsigned long GUID = 0
 

Constructor & Destructor Documentation

◆ ~GrassPage()

Forests::GrassPage::~GrassPage ( )

Definition at line 1434 of file GrassLoader.cpp.

Member Function Documentation

◆ addEntity()

void Forests::GrassPage::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 1439 of file GrassLoader.cpp.

◆ getUniqueID()

static Ogre::String Forests::GrassPage::getUniqueID ( )
inlinestaticprivate

Definition at line 566 of file GrassLoader.h.

◆ init()

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

Prepare a geometry page for use.

Parameters
geomThe PagedGeometry object that's creating this GeometryPage.
dataA single parameter of custom data (optional).

This is called immediately after creating a new GeometryPage. It is never called more than once for a single instance of your geometry page.

The "data" parameter is set for all pages when PagedGeometry::addDetailLevel() is called. This parameter is optional and can be used for whatever you like if you need a constructor parameter of some kind. Be sure to document what kind of variable the user needs to supply and what it's purpose is in your GeometryPage implementation.

Note
If you need to get the current camera, scene manager, etc., use the geom parameter. The PagedGeometry class contains inline methods you can use to access the camera and scene manager.
Warning
Do NOT store a local copy of geom->getCamera()! The camera returned by this function may change at any time!

Implements Forests::GeometryPage.

Definition at line 1428 of file GrassLoader.cpp.

◆ removeEntities()

void Forests::GrassPage::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 1449 of file GrassLoader.cpp.

◆ setFade()

void Forests::GrassPage::setFade ( bool  enabled,
Ogre::Real  visibleDist,
Ogre::Real  invisibleDist 
)
inlinevirtual

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 556 of file GrassLoader.h.

◆ setVisible()

void Forests::GrassPage::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 1471 of file GrassLoader.cpp.

Field Documentation

◆ GUID

unsigned long Forests::GrassPage::GUID = 0
staticprivate

Definition at line 565 of file GrassLoader.h.

◆ nodeList

std::list<Ogre::SceneNode*> Forests::GrassPage::nodeList
private

Definition at line 563 of file GrassLoader.h.

◆ rootNode

Ogre::SceneNode* Forests::GrassPage::rootNode
private

Definition at line 561 of file GrassLoader.h.

◆ sceneMgr

Ogre::SceneManager* Forests::GrassPage::sceneMgr
private

Definition at line 560 of file GrassLoader.h.


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