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::ColorMap Class Reference

Description

A 2D greyscale image that is assigned to a certain region of your world to represent color 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 ColorMap class interface than you can with the standard GrassLayer color map functions, for example.

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

Definition at line 127 of file PropertyMaps.h.

Public Member Functions

void unload ()
 
void setFilter (MapFilter filter)
 
MapFilter getFilter ()
 
Ogre::PixelBox getPixelBox ()
 
Ogre::uint32 getColorAt (Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
 
Ogre::ColourValue getColorAt_Unpacked (Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
 

Static Public Member Functions

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

Private Member Functions

 ColorMap (Ogre::TexturePtr map, MapChannel channel)
 
 ~ColorMap ()
 
Ogre::uint32 _interpolateColor (Ogre::uint32 color1, Ogre::uint32 color2, Ogre::Real ratio, Ogre::Real ratioInv)
 
Ogre::uint32 _getColorAt (Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
 
Ogre::uint32 _getColorAt_Bilinear (Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
 

Private Attributes

Ogre::String selfKey
 
Ogre::uint32 refCount
 
MapFilter filter
 
Ogre::PixelBox * pixels
 
Ogre::TRect< Ogre::Real > mapBounds
 

Static Private Attributes

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

Constructor & Destructor Documentation

◆ ColorMap()

Forests::ColorMap::ColorMap ( Ogre::TexturePtr  map,
MapChannel  channel 
)
private

Definition at line 248 of file PropertyMaps.cpp.

◆ ~ColorMap()

Forests::ColorMap::~ColorMap ( )
private

Definition at line 238 of file PropertyMaps.cpp.

Member Function Documentation

◆ _getColorAt()

uint32 Forests::ColorMap::_getColorAt ( Ogre::Real  x,
Ogre::Real  z,
const Ogre::TRect< Ogre::Real > &  mapBounds 
)
private

Definition at line 320 of file PropertyMaps.cpp.

◆ _getColorAt_Bilinear()

uint32 Forests::ColorMap::_getColorAt_Bilinear ( Ogre::Real  x,
Ogre::Real  z,
const Ogre::TRect< Ogre::Real > &  mapBounds 
)
private

Definition at line 360 of file PropertyMaps.cpp.

◆ _interpolateColor()

uint32 Forests::ColorMap::_interpolateColor ( Ogre::uint32  color1,
Ogre::uint32  color2,
Ogre::Real  ratio,
Ogre::Real  ratioInv 
)
private

Definition at line 340 of file PropertyMaps.cpp.

◆ getColorAt()

Ogre::uint32 Forests::ColorMap::getColorAt ( Ogre::Real  x,
Ogre::Real  z,
const Ogre::TRect< Ogre::Real > &  mapBounds 
)
inline

Gets the color value at the specified position.

A RenderSystem-specific 32-bit packed color value is used, so it can be fed directly to the video card.

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

Definition at line 173 of file PropertyMaps.h.

◆ getColorAt_Unpacked()

Ogre::ColourValue Forests::ColorMap::getColorAt_Unpacked ( Ogre::Real  x,
Ogre::Real  z,
const Ogre::TRect< Ogre::Real > &  mapBounds 
)
inline

Gets the color value at the specified position.

The unpacks the 32-bit color value into an Ogre::ColourValue and returns it.

Definition at line 181 of file PropertyMaps.h.

◆ getFilter()

MapFilter Forests::ColorMap::getFilter ( )
inline

Returns the filtering mode being used for this color map.

Definition at line 146 of file PropertyMaps.h.

◆ getPixelBox()

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

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

You can use this function to access the pixel data of the color map. The PixelBox returned is an image in PF_A8R8G8B8 format when running with DirectX, and PF_A8B8G8R8 when running with OpenGL. 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 color 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 159 of file PropertyMaps.h.

◆ load() [1/2]

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

◆ load() [2/2]

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

◆ setFilter()

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

Sets the filtering mode used for this color map.

This function can be used to set the filtering mode used for your color map. By default, bilinear filtering is used (MAPFILTER_BILINEAR). If you disable filtering by using MAPFILTER_NONE, the resulting coloration may appear slightly pixelated, 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 pixelation.

Definition at line 143 of file PropertyMaps.h.

◆ unload()

void Forests::ColorMap::unload ( )

Definition at line 231 of file PropertyMaps.cpp.

Field Documentation

◆ filter

MapFilter Forests::ColorMap::filter
private

Definition at line 222 of file PropertyMaps.h.

◆ mapBounds

Ogre::TRect<Ogre::Real> Forests::ColorMap::mapBounds
private

Definition at line 224 of file PropertyMaps.h.

◆ pixels

Ogre::PixelBox* Forests::ColorMap::pixels
private

Definition at line 223 of file PropertyMaps.h.

◆ refCount

Ogre::uint32 Forests::ColorMap::refCount
private

Definition at line 211 of file PropertyMaps.h.

◆ selfKey

Ogre::String Forests::ColorMap::selfKey
private

Definition at line 210 of file PropertyMaps.h.

◆ selfList

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

Definition at line 209 of file PropertyMaps.h.


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