PagedGeometry  1.2.0
Forests::DensityMap Class Reference

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

#include <PropertyMaps.h>

Public Member Functions

void unload ()
 
void setFilter (MapFilter filter)
 Sets the filtering mode used for this density map. More...
 
MapFilter getFilter ()
 Returns the filtering mode being used for this density map.
 
Ogre::PixelBox getPixelBox ()
 Gets a pointer to the pixel data of the density map. More...
 
Ogre::Real getDensityAt (Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
 Gets the density level at the specified position. More...
 
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 DensityMapload (const Ogre::String &fileName, MapChannel channel=CHANNEL_COLOR)
 
static DensityMapload (Ogre::TexturePtr texture, MapChannel channel=CHANNEL_COLOR)
 

Detailed 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.

Member Function Documentation

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.

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.

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.