OGRE  2.2.4
Object-Oriented Graphics Rendering Engine
Ogre::TerrainLayerBlendMap Class Reference

Class exposing an interface to a blend map for a given layer. More...

#include <OgreTerrainLayerBlendMap.h>

+ Inheritance diagram for Ogre::TerrainLayerBlendMap:

Public Member Functions

 TerrainLayerBlendMap (Terrain *parent, uint8 layerIndex, HardwarePixelBuffer *buf)
 Constructor. More...
 
virtual ~TerrainLayerBlendMap ()
 
void blit (const PixelBox &src, const Box &dstBox)
 Blits a set of values into a region on the blend map. More...
 
void blit (const PixelBox &src)
 Blits a set of values into the entire map. More...
 
void convertImageToTerrainSpace (size_t x, size_t y, Real *outX, Real *outY)
 Convert image space (0, imageSize) to terrain space values (0,1). More...
 
void convertImageToUVSpace (size_t x, size_t y, Real *outX, Real *outY)
 Convert image space (0, imageSize) to local space values (0,1). More...
 
void convertTerrainToImageSpace (Real x, Real y, size_t *outX, size_t *outY)
 Convert terrain space values (0,1) to image space (0, imageSize). More...
 
void convertUVToImageSpace (Real x, Real y, size_t *outX, size_t *outY)
 Convert local space values (0,1) to image space (0, imageSize). More...
 
void convertUVToWorldSpace (Real x, Real y, Vector3 *outWorldPos)
 Helper method - convert a point in local space to worldspace based on the terrain settings. More...
 
void convertWorldToUVSpace (const Vector3 &worldPos, Real *outX, Real *outY)
 Helper method - convert a point in world space to UV space based on the terrain settings. More...
 
void dirty ()
 Indicate that all of the blend data is dirty and needs updating. More...
 
void dirtyRect (const Rect &rect)
 Indicate that a portion of the blend data is dirty and needs updating. More...
 
float * getBlendPointer ()
 Get a pointer to the whole blend data. More...
 
float getBlendValue (size_t x, size_t y)
 Get a single value of blend information, in image space. More...
 
uint8 getLayerIndex () const
 Get the index of the layer this is targeting. More...
 
TerraingetParent () const
 Get the parent terrain. More...
 
void loadImage (const Image &img)
 Load an image into this blend layer. More...
 
void loadImage (DataStreamPtr &stream, const String &ext=BLANKSTRING)
 Load an image into this blend layer. More...
 
void loadImage (const String &filename, const String &groupName)
 Load an image into this blend layer. More...
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info More...
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *ptr)
 placement operator new More...
 
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info More...
 
void * operator new[] (size_t sz)
 
void setBlendValue (size_t x, size_t y, float val)
 Set a single value of blend information (0 = transparent, 255 = solid) More...
 
void update ()
 Publish any changes you made to the blend data back to the blend map. More...
 

Detailed Description

Class exposing an interface to a blend map for a given layer.

Each layer after the first layer in a terrain has a blend map which expresses how it is alpha blended with the layers beneath. Internally, this blend map is packed into one channel of an RGB or RGBA texture in order to use the smallest number of samplers, but this class allows a caller to manipulate the data more easily without worrying about this packing. Also, the values you use to interact with the blend map are floating point, which gives you full precision for updating, but in fact the values are packed into 8-bit integers in the actual blend map.

You shouldn't construct this class directly, use Terrain::getLayerBlendMap().

Constructor & Destructor Documentation

◆ TerrainLayerBlendMap()

Ogre::TerrainLayerBlendMap::TerrainLayerBlendMap ( Terrain parent,
uint8  layerIndex,
HardwarePixelBuffer *  buf 
)

Constructor.

Parameters
parentThe parent terrain
layerIndexThe layer index (should be 1 or higher)
bufThe buffer holding the data

◆ ~TerrainLayerBlendMap()

virtual Ogre::TerrainLayerBlendMap::~TerrainLayerBlendMap ( )
virtual

Member Function Documentation

◆ blit() [1/2]

void Ogre::TerrainLayerBlendMap::blit ( const PixelBox src,
const Box dstBox 
)

Blits a set of values into a region on the blend map.

Parameters
srcPixelBox containing the source pixels and format
dstBoxBox describing the destination region in this map
Remarks
The source and destination regions dimensions don't have to match, in which case scaling is done.
Note
You can call this method in a background thread if you want. You still need to call update() to commit the changes to the GPU.

◆ blit() [2/2]

void Ogre::TerrainLayerBlendMap::blit ( const PixelBox src)

Blits a set of values into the entire map.

The source data is scaled if needed.

Parameters
srcPixelBox containing the source pixels and format
Note
You can call this method in a background thread if you want. You still need to call update() to commit the changes to the GPU.

◆ convertImageToTerrainSpace()

void Ogre::TerrainLayerBlendMap::convertImageToTerrainSpace ( size_t  x,
size_t  y,
Real outX,
Real outY 
)

Convert image space (0, imageSize) to terrain space values (0,1).

◆ convertImageToUVSpace()

void Ogre::TerrainLayerBlendMap::convertImageToUVSpace ( size_t  x,
size_t  y,
Real outX,
Real outY 
)

Convert image space (0, imageSize) to local space values (0,1).

◆ convertTerrainToImageSpace()

void Ogre::TerrainLayerBlendMap::convertTerrainToImageSpace ( Real  x,
Real  y,
size_t *  outX,
size_t *  outY 
)

Convert terrain space values (0,1) to image space (0, imageSize).

◆ convertUVToImageSpace()

void Ogre::TerrainLayerBlendMap::convertUVToImageSpace ( Real  x,
Real  y,
size_t *  outX,
size_t *  outY 
)

Convert local space values (0,1) to image space (0, imageSize).

◆ convertUVToWorldSpace()

void Ogre::TerrainLayerBlendMap::convertUVToWorldSpace ( Real  x,
Real  y,
Vector3 outWorldPos 
)

Helper method - convert a point in local space to worldspace based on the terrain settings.

Parameters
x,yLocal position, ranging from 0 to 1, top/bottom, left/right.
outWorldPosPointer will be filled in with the world space value

◆ convertWorldToUVSpace()

void Ogre::TerrainLayerBlendMap::convertWorldToUVSpace ( const Vector3 worldPos,
Real outX,
Real outY 
)

Helper method - convert a point in world space to UV space based on the terrain settings.

Parameters
worldPosWorld position
outX,outYPointers to variables which will be filled in with the local UV space value. Note they are deliberately signed Real values, because the point you supply may be outside of image space and may be between texels. The values will range from 0 to 1, top/bottom, left/right.

◆ dirty()

void Ogre::TerrainLayerBlendMap::dirty ( )

Indicate that all of the blend data is dirty and needs updating.

◆ dirtyRect()

void Ogre::TerrainLayerBlendMap::dirtyRect ( const Rect rect)

Indicate that a portion of the blend data is dirty and needs updating.

Parameters
rectRectangle in image space

◆ getBlendPointer()

float* Ogre::TerrainLayerBlendMap::getBlendPointer ( )

Get a pointer to the whole blend data.

Remarks
This method allows you to get a raw pointer to all the blend data, to update it as you like. However, you must then call dirtyRect manually if you want those changes to be recognised.

◆ getBlendValue()

float Ogre::TerrainLayerBlendMap::getBlendValue ( size_t  x,
size_t  y 
)

Get a single value of blend information, in image space.

Parameters
x,yCoordinates of the point of data to get, in image space (top down)
Returns
The blend data

◆ getLayerIndex()

uint8 Ogre::TerrainLayerBlendMap::getLayerIndex ( ) const
inline

Get the index of the layer this is targeting.

References Ogre::BLANKSTRING.

◆ getParent()

Terrain* Ogre::TerrainLayerBlendMap::getParent ( ) const
inline

Get the parent terrain.

◆ loadImage() [1/3]

void Ogre::TerrainLayerBlendMap::loadImage ( const Image img)

Load an image into this blend layer.

◆ loadImage() [2/3]

void Ogre::TerrainLayerBlendMap::loadImage ( DataStreamPtr stream,
const String ext = BLANKSTRING 
)

Load an image into this blend layer.

Parameters
streamStream containing the image data
extExtension identifying the image type, if the stream data doesn't identify

◆ loadImage() [3/3]

void Ogre::TerrainLayerBlendMap::loadImage ( const String filename,
const String groupName 
)

Load an image into this blend layer.

◆ operator delete() [1/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inlineinherited

◆ operator delete() [2/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
)
inlineinherited

◆ operator delete() [3/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

◆ operator delete[]() [1/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr)
inlineinherited

◆ operator delete[]() [2/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

◆ operator new() [1/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

operator new, with debug line info

◆ operator new() [2/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

◆ operator new() [3/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void *  ptr 
)
inlineinherited

placement operator new

◆ operator new[]() [1/2]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

array operator new, with debug line info

◆ operator new[]() [2/2]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

◆ setBlendValue()

void Ogre::TerrainLayerBlendMap::setBlendValue ( size_t  x,
size_t  y,
float  val 
)

Set a single value of blend information (0 = transparent, 255 = solid)

Parameters
x,yCoordinates of the point of data to get, in image space (top down)
valThe blend value to set (0..1)

◆ update()

void Ogre::TerrainLayerBlendMap::update ( )

Publish any changes you made to the blend data back to the blend map.

Note
Can only be called in the main render thread.

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