OpenMW
Public Member Functions | Private Types | Private Member Functions | Private Attributes
Terrain::Storage Class Reference

We keep storage of terrain data abstract here since we need different implementations for game and editor. More...

#include <storage.hpp>

List of all members.

Public Member Functions

virtual ~Storage ()
virtual Ogre::AxisAlignedBox getBounds ()=0
 Get bounds of the whole terrain in cell units.
bool getMinMaxHeights (float size, const Ogre::Vector2 &center, float &min, float &max)
void fillVertexBuffers (int lodLevel, float size, const Ogre::Vector2 &center, Ogre::HardwareVertexBufferSharedPtr vertexBuffer, Ogre::HardwareVertexBufferSharedPtr normalBuffer, Ogre::HardwareVertexBufferSharedPtr colourBuffer)
void getBlendmaps (float chunkSize, const Ogre::Vector2 &chunkCenter, bool pack, std::vector< Ogre::TexturePtr > &blendmaps, std::vector< LayerInfo > &layerList)
float getHeightAt (const Ogre::Vector3 &worldPos)

Private Types

typedef std::pair< short, short > UniqueTextureId

Private Member Functions

virtual ESM::LandgetLand (int cellX, int cellY)=0
virtual const ESM::LandTexturegetLandTexture (int index, short plugin)=0
void fixNormal (Ogre::Vector3 &normal, int cellX, int cellY, int col, int row)
void fixColour (Ogre::ColourValue &colour, int cellX, int cellY, int col, int row)
void averageNormal (Ogre::Vector3 &normal, int cellX, int cellY, int col, int row)
float getVertexHeight (const ESM::Land *land, int x, int y)
UniqueTextureId getVtexIndexAt (int cellX, int cellY, int x, int y)
std::string getTextureName (UniqueTextureId id)
LayerInfo getLayerInfo (const std::string &texture)

Private Attributes

std::map< std::string, LayerInfomLayerInfoMap

Detailed Description

We keep storage of terrain data abstract here since we need different implementations for game and editor.


Member Typedef Documentation

typedef std::pair<short, short> Terrain::Storage::UniqueTextureId [private]

Constructor & Destructor Documentation

virtual Terrain::Storage::~Storage ( ) [inline, virtual]

Member Function Documentation

void Terrain::Storage::averageNormal ( Ogre::Vector3 &  normal,
int  cellX,
int  cellY,
int  col,
int  row 
) [private]
void Terrain::Storage::fillVertexBuffers ( int  lodLevel,
float  size,
const Ogre::Vector2 &  center,
Ogre::HardwareVertexBufferSharedPtr  vertexBuffer,
Ogre::HardwareVertexBufferSharedPtr  normalBuffer,
Ogre::HardwareVertexBufferSharedPtr  colourBuffer 
)

Fill vertex buffers for a terrain chunk.

Parameters:
lodLevelLOD level, 0 = most detailed
sizesize of the terrain chunk in cell units
centercenter of the chunk in cell units
vertexBufferbuffer to write vertices
normalBufferbuffer to write vertex normals
colourBufferbuffer to write vertex colours
void Terrain::Storage::fixColour ( Ogre::ColourValue &  colour,
int  cellX,
int  cellY,
int  col,
int  row 
) [private]
void Terrain::Storage::fixNormal ( Ogre::Vector3 &  normal,
int  cellX,
int  cellY,
int  col,
int  row 
) [private]
void Terrain::Storage::getBlendmaps ( float  chunkSize,
const Ogre::Vector2 &  chunkCenter,
bool  pack,
std::vector< Ogre::TexturePtr > &  blendmaps,
std::vector< LayerInfo > &  layerList 
)

Create textures holding layer blend values for a terrain chunk.

Note:
The terrain chunk shouldn't be larger than one cell since otherwise we might have to do a ridiculous amount of different layers. For larger chunks, composite maps should be used.
Parameters:
chunkSizesize of the terrain chunk in cell units
chunkCentercenter of the chunk in cell units
packWhether to pack blend values for up to 4 layers into one texture (one in each channel) - otherwise, each texture contains blend values for one layer only. Shader-based rendering can utilize packing, FFP can't.
blendmapscreated blendmaps will be written here
layerListnames of the layer textures used will be written here
virtual Ogre::AxisAlignedBox Terrain::Storage::getBounds ( ) [pure virtual]

Get bounds of the whole terrain in cell units.

Implemented in MWRender::TerrainStorage.

float Terrain::Storage::getHeightAt ( const Ogre::Vector3 &  worldPos)
virtual ESM::Land* Terrain::Storage::getLand ( int  cellX,
int  cellY 
) [private, pure virtual]

Implemented in MWRender::TerrainStorage.

virtual const ESM::LandTexture* Terrain::Storage::getLandTexture ( int  index,
short  plugin 
) [private, pure virtual]

Implemented in MWRender::TerrainStorage.

LayerInfo Terrain::Storage::getLayerInfo ( const std::string &  texture) [private]
bool Terrain::Storage::getMinMaxHeights ( float  size,
const Ogre::Vector2 &  center,
float &  min,
float &  max 
)

Get the minimum and maximum heights of a terrain chunk.

Note:
Should only be called for chunks <= 1 cell, i.e. leafs of the quad tree. Larger chunks can simply merge AABB of children.
Parameters:
sizesize of the chunk in cell units
centercenter of the chunk in cell units
minmin height will be stored here
maxmax height will be stored here
Returns:
true if there was data available for this terrain chunk
Todo:
investigate if min/max heights should be stored at load time in ESM::Land instead
std::string Terrain::Storage::getTextureName ( UniqueTextureId  id) [private]
float Terrain::Storage::getVertexHeight ( const ESM::Land land,
int  x,
int  y 
) [private]
Storage::UniqueTextureId Terrain::Storage::getVtexIndexAt ( int  cellX,
int  cellY,
int  x,
int  y 
) [private]

Member Data Documentation

std::map<std::string, LayerInfo> Terrain::Storage::mLayerInfoMap [private]

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