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

Description

A 2D greyscale image that is assigned to a certain region of your world to represent density levels.

This class is used by various PagedLoader's internally, so it's not necessary to learn anything about this class. However, you can achieve more advanced effects through the DensityMap class interface than you can with the standard GrassLayer density map functions, for example.

Probably the most useful function in this class is getPixelBox(), which you can use to directly manipulate the density map pixels in real-time.

Definition at line 54 of file PropertyMaps.h.

Public Member Functions

void unload ()
 
void setFilter (MapFilter filter)
 
MapFilter getFilter ()
 
Ogre::PixelBox getPixelBox ()
 
Ogre::Real getDensityAt (Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
 
Ogre::Real _getDensityAt_Unfiltered (Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
 
Ogre::Real _getDensityAt_Bilinear (Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
 

Static Public Member Functions

static DensityMap * load (const Ogre::String &fileName, MapChannel channel=CHANNEL_COLOR)
 
static DensityMap * load (Ogre::TexturePtr texture, MapChannel channel=CHANNEL_COLOR)
 

Private Member Functions

 DensityMap (Ogre::TexturePtr texture, MapChannel channel)
 
 ~DensityMap ()
 

Private Attributes

Ogre::String selfKey
 
Ogre::uint32 refCount
 
MapFilter filter
 
Ogre::PixelBox * pixels
 

Static Private Attributes

static std::map< Ogre::String, DensityMap * > selfList
 

Constructor & Destructor Documentation

◆ DensityMap()

Forests::DensityMap::DensityMap ( Ogre::TexturePtr  texture,
MapChannel  channel 
)
private

Definition at line 73 of file PropertyMaps.cpp.

◆ ~DensityMap()

Forests::DensityMap::~DensityMap ( )
private

Definition at line 63 of file PropertyMaps.cpp.

Member Function Documentation

◆ _getDensityAt_Bilinear()

Ogre::Real Forests::DensityMap::_getDensityAt_Bilinear ( Ogre::Real  x,
Ogre::Real  z,
const Ogre::TRect< Ogre::Real > &  mapBounds 
)

Definition at line 154 of file PropertyMaps.cpp.

◆ _getDensityAt_Unfiltered()

Ogre::Real Forests::DensityMap::_getDensityAt_Unfiltered ( Ogre::Real  x,
Ogre::Real  z,
const Ogre::TRect< Ogre::Real > &  mapBounds 
)

Definition at line 127 of file PropertyMaps.cpp.

◆ getDensityAt()

Ogre::Real Forests::DensityMap::getDensityAt ( Ogre::Real  x,
Ogre::Real  z,
const Ogre::TRect< Ogre::Real > &  mapBounds 
)
inline

Gets the density level at the specified position.

The boundary given defines the area where this density map takes effect. Normally this is set to your terrain's bounds so the density map is aligned to your heightmap, but you could apply it anywhere you want.

Definition at line 96 of file PropertyMaps.h.

◆ getFilter()

MapFilter Forests::DensityMap::getFilter ( )
inline

Returns the filtering mode being used for this density map.

Definition at line 73 of file PropertyMaps.h.

◆ getPixelBox()

Ogre::PixelBox Forests::DensityMap::getPixelBox ( )
inline

Gets a pointer to the pixel data of the density map.

You can use this function to access the pixel data of the density map. The PixelBox returned is an image in PF_BYTE_L (aka. PF_L8) byte format. You can modify this image any way you like in real-time, so long as you do not change the byte format.

This function is useful in editors where the density map needs to be changed dynamically. Note that although you can change this map in real-time, the changes won't be uploaded to your video card until you call PagedGeometry::reloadGeometry(). If you don't, the grass you see will remain unchanged.

Definition at line 85 of file PropertyMaps.h.

◆ load() [1/2]

static DensityMap * Forests::DensityMap::load ( const Ogre::String &  fileName,
MapChannel  channel = CHANNEL_COLOR 
)
static

◆ load() [2/2]

static DensityMap * Forests::DensityMap::load ( Ogre::TexturePtr  texture,
MapChannel  channel = CHANNEL_COLOR 
)
static

◆ setFilter()

void Forests::DensityMap::setFilter ( MapFilter  filter)
inline

Sets the filtering mode used for this density map.

This function can be used to set the filtering mode used for your density map. By default, bilinear filtering is used (MAPFILTER_BILINEAR). If you disable filtering by using MAPFILTER_NONE, the resulting effect of the density map may look square and blocky, depending on the resolution of the map.

MAPFILTER_NONE is slightly faster than MAPFILTER_BILINEAR, so use it if you don't notice any considerable blockyness.

Definition at line 70 of file PropertyMaps.h.

◆ unload()

void Forests::DensityMap::unload ( )

Definition at line 56 of file PropertyMaps.cpp.

Field Documentation

◆ filter

MapFilter Forests::DensityMap::filter
private

Definition at line 115 of file PropertyMaps.h.

◆ pixels

Ogre::PixelBox* Forests::DensityMap::pixels
private

Definition at line 116 of file PropertyMaps.h.

◆ refCount

Ogre::uint32 Forests::DensityMap::refCount
private

Definition at line 113 of file PropertyMaps.h.

◆ selfKey

Ogre::String Forests::DensityMap::selfKey
private

Definition at line 112 of file PropertyMaps.h.

◆ selfList

std::map< String, DensityMap * > Forests::DensityMap::selfList
staticprivate

Definition at line 111 of file PropertyMaps.h.


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