Ogre::TerrainLayerBlendMap Class Reference
Terrain

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

`#include <OgreTerrainLayerBlendMap.h>`

Inheritance diagram for Ogre::TerrainLayerBlendMap:
[legend]

List of all members.

## Public Member Functions

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

## Protected Member Functions

void | download ()
void | upload ()

## Protected Attributes

Terrain * | mParent
uint8 | mLayerIdx
uint8 | mChannel
uint8 | mChannelOffset
Box | mDirtyBox
bool | mDirty
HardwarePixelBuffer * | mBuffer
float * | mData

## 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().

Definition at line 61 of file OgreTerrainLayerBlendMap.h.

## Constructor & Destructor Documentation

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

Constructor.

Parameters:

  parent | The parent terrain
  layerIndex | The layer index (should be 1 or higher)
  box | The region of the blend map to address (in image space)
  buf | The buffer holding the data

Ogre::TerrainLayerBlendMap::~TerrainLayerBlendMap | ( |  | ) |

## Member Function Documentation

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

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

Parameters:

  src | PixelBox containing the source pixels and format
  dstBox | Image::Box 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.

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

Blits a set of values into the entire map.

The source data is scaled if needed.

Parameters:

  src | PixelBox 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.

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

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

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

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

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,y | Local position, ranging from 0 to 1, top/bottom, left/right.
  outWorldPos | Pointer will be filled in with the world space value

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:

  worldPos | World position
  outX,outY | Pointers 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.

void Ogre::TerrainLayerBlendMap::dirty | ( |  | ) |

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

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

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

Parameters:

  rect | Rectangle in image space

void Ogre::TerrainLayerBlendMap::download | ( |  | ) | `[protected]`

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.

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

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

Parameters:

  x,y | Coordinates of the point of data to get, in image space (top down)

Returns:
  The blend data

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

Get the index of the layer this is targeting.

Definition at line 88 of file OgreTerrainLayerBlendMap.h.

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

Get the parent terrain.

Definition at line 86 of file OgreTerrainLayerBlendMap.h.

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

Load an image into this blend layer.

void Ogre::TerrainLayerBlendMap::loadImage | ( | DataStreamPtr & | stream,
|  | const String & | ext = `StringUtil::BLANK`
| ) |  |

Load an image into this blend layer.

Parameters:

  stream | Stream containing the image data
  ext | Extension identifying the image type, if the stream data doesn't identify

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

Load an image into this blend layer.

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr | ) | `[inherited]`

Definition at line 95 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | void * |
| ) |  | `[inherited]`

Definition at line 101 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  | `[inherited]`

Definition at line 107 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr | ) | `[inherited]`

Definition at line 112 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  | `[inherited]`

Definition at line 118 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  | `[inherited]`

operator new, with debug line info

Definition at line 67 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz | ) | `[inherited]`

Definition at line 72 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | void * | ptr
| ) |  | `[inherited]`

placement operator new

Definition at line 78 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  | `[inherited]`

array operator new, with debug line info

Definition at line 85 of file OgreMemoryAllocatedObject.h.

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz | ) | `[inherited]`

Definition at line 90 of file OgreMemoryAllocatedObject.h.

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,y | Coordinates of the point of data to get, in image space (top down)
  val | The blend value to set (0..1)

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.

void Ogre::TerrainLayerBlendMap::upload | ( |  | ) | `[protected]`

## Member Data Documentation

HardwarePixelBuffer* Ogre::TerrainLayerBlendMap::mBuffer`[protected]`

Definition at line 70 of file OgreTerrainLayerBlendMap.h.

uint8 Ogre::TerrainLayerBlendMap::mChannel`[protected]`

Definition at line 66 of file OgreTerrainLayerBlendMap.h.

uint8 Ogre::TerrainLayerBlendMap::mChannelOffset`[protected]`

Definition at line 67 of file OgreTerrainLayerBlendMap.h.

float* Ogre::TerrainLayerBlendMap::mData`[protected]`

Definition at line 71 of file OgreTerrainLayerBlendMap.h.

bool Ogre::TerrainLayerBlendMap::mDirty`[protected]`

Definition at line 69 of file OgreTerrainLayerBlendMap.h.

Box Ogre::TerrainLayerBlendMap::mDirtyBox`[protected]`

Definition at line 68 of file OgreTerrainLayerBlendMap.h.

uint8 Ogre::TerrainLayerBlendMap::mLayerIdx`[protected]`

Definition at line 65 of file OgreTerrainLayerBlendMap.h.

Terrain* Ogre::TerrainLayerBlendMap::mParent`[protected]`

Definition at line 64 of file OgreTerrainLayerBlendMap.h.

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

- OgreTerrainLayerBlendMap.h

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:44