OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
Terrain::Storage Class Referenceabstract

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

#include <storage.hpp>

Inheritance diagram for Terrain::Storage:
Collaboration diagram for Terrain::Storage:

Public Types

typedef std::vector
< osg::ref_ptr< osg::Image > > 
ImageVector
 

Public Member Functions

virtual ~Storage ()
 
virtual void getBounds (float &minX, float &maxX, float &minY, float &maxY)=0
 Get bounds of the whole terrain in cell units. More...
 
virtual bool getMinMaxHeights (float size, const osg::Vec2f &center, float &min, float &max)=0
 
virtual void fillVertexBuffers (int lodLevel, float size, const osg::Vec2f &center, osg::ref_ptr< osg::Vec3Array > positions, osg::ref_ptr< osg::Vec3Array > normals, osg::ref_ptr< osg::Vec4Array > colours)=0
 
virtual void getBlendmaps (float chunkSize, const osg::Vec2f &chunkCenter, bool pack, ImageVector &blendmaps, std::vector< LayerInfo > &layerList)=0
 
virtual float getHeightAt (const osg::Vec3f &worldPos)=0
 
virtual LayerInfo getDefaultLayer ()=0
 
virtual float getCellWorldSize ()=0
 Get the transformation factor for mapping cell units to world units. More...
 
virtual int getCellVertices ()=0
 Get the number of vertices on one side for each cell. Should be (power of two)+1. More...
 

Detailed Description

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

Member Typedef Documentation

typedef std::vector<osg::ref_ptr<osg::Image> > Terrain::Storage::ImageVector

Constructor & Destructor Documentation

virtual Terrain::Storage::~Storage ( )
inlinevirtual

Member Function Documentation

virtual void Terrain::Storage::fillVertexBuffers ( int  lodLevel,
float  size,
const osg::Vec2f &  center,
osg::ref_ptr< osg::Vec3Array >  positions,
osg::ref_ptr< osg::Vec3Array >  normals,
osg::ref_ptr< osg::Vec4Array >  colours 
)
pure virtual

Fill vertex buffers for a terrain chunk.

Note
May be called from background threads. Make sure to only call thread-safe functions from here!
returned colors need to be in render-system specific format! Use RenderSystem::convertColourValue.
Vertices should be written in row-major order (a row is defined as parallel to the x-axis). The specified positions should be in local space, i.e. relative to the center of the terrain chunk.
Parameters
lodLevelLOD level, 0 = most detailed
sizesize of the terrain chunk in cell units
centercenter of the chunk in cell units
positionsbuffer to write vertices
normalsbuffer to write vertex normals
coloursbuffer to write vertex colours

Implemented in ESMTerrain::Storage.

Here is the caller graph for this function:

virtual void Terrain::Storage::getBlendmaps ( float  chunkSize,
const osg::Vec2f &  chunkCenter,
bool  pack,
ImageVector blendmaps,
std::vector< LayerInfo > &  layerList 
)
pure virtual

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.
May be called from background threads. Make sure to only call thread-safe functions from here!
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

Implemented in ESMTerrain::Storage.

Here is the caller graph for this function:

virtual void Terrain::Storage::getBounds ( float &  minX,
float &  maxX,
float &  minY,
float &  maxY 
)
pure virtual

Get bounds of the whole terrain in cell units.

Implemented in ESMTerrain::Storage, CSVRender::TerrainStorage, and MWRender::TerrainStorage.

virtual int Terrain::Storage::getCellVertices ( )
pure virtual

Get the number of vertices on one side for each cell. Should be (power of two)+1.

Implemented in ESMTerrain::Storage.

virtual float Terrain::Storage::getCellWorldSize ( )
pure virtual

Get the transformation factor for mapping cell units to world units.

Implemented in ESMTerrain::Storage.

Here is the caller graph for this function:

virtual LayerInfo Terrain::Storage::getDefaultLayer ( )
pure virtual

Implemented in ESMTerrain::Storage.

virtual float Terrain::Storage::getHeightAt ( const osg::Vec3f &  worldPos)
pure virtual

Implemented in ESMTerrain::Storage.

Here is the caller graph for this function:

virtual bool Terrain::Storage::getMinMaxHeights ( float  size,
const osg::Vec2f &  center,
float &  min,
float &  max 
)
pure virtual

Get the minimum and maximum heights of a terrain region.

Note
Will only be called for chunks with size = minBatchSize, 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

Implemented in ESMTerrain::Storage.

Here is the caller graph for this function:


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