libProcTer::CTileSurface Class Reference

#include <ctilesurface.h>

List of all members.

Public Types

enum  eTextureType { eColor, eHeight, eTextureTypeMax }

Public Member Functions

 CTileSurface (const CPlanet *planet, const CGridPosition &pos, CTileSurface **parents)
virtual ~CTileSurface ()
 Destructor.
CTexturegetTexture (eTextureType type)
 Returns the texture of a certain type.
const CGridPositiongetPosition () const
 Returns the grid position of the tile of this surface, as given to the constructor.
CVector getTexCoords (CGridPosition pos) const
 Returns the texture coordinates at a grid position inside this tile.
double getAltAndSlope (const CGridPosition &pos, double &dzdx, double &dzdy) const
virtual CTileSurfacecreateChildSurface (const CGridPosition &pos, CTileSurface **parents) const
virtual bool load ()=0
virtual std::string getClassName () const =0
virtual const CMapBasegetInternalMap (const std::string &name) const
const CMapBasegetInternalMap (eTextureType type) const

Protected Member Functions

void updateTextures ()
double getTileSize () const
 Returns the physical size of the tile (in meters).
const CPlanetgetPlanet () const
 Returns a pointer to the planet object.
const CTileSurface *const * getParents () const
 Returns an array of four pointers to the parent surfaces.
void checkHeightmapValues () const
 Debugging function, to check whether the values in m_HeightMap make sense.

Protected Attributes

CMap< int > m_HeightMap
 The height map data. The height is a signed integer, given in millimeters.
CMap< SColorm_ColorMap
 The color map data.


Detailed Description

Author:
CJP <cornware-cjp@users.sourceforge.net>
Base class for all tile surfaces. CTileSurface-derived classes generate and contain all map data and textures. Landscape generator plugins provide derived classes of CTileSurface.

Member Enumeration Documentation

Identifiers for some common map and texture types. eTextureTypeMax is not an identifier, but instead is used in code that needs to iterate through all possible types.


Constructor & Destructor Documentation

libProcTer::CTileSurface::CTileSurface ( const CPlanet planet,
const CGridPosition pos,
CTileSurface **  parents 
)

Constructor.

Parameters:
planet The planet object for which this tile is created
pos The grid position of the tile of this surface. This is the position of the lower left corner of the tile.
parents The four parent surfaces of this surface

virtual libProcTer::CTileSurface::~CTileSurface (  )  [virtual]

Destructor.


Member Function Documentation

void libProcTer::CTileSurface::checkHeightmapValues (  )  const [protected]

Debugging function, to check whether the values in m_HeightMap make sense.

virtual CTileSurface* libProcTer::CTileSurface::createChildSurface ( const CGridPosition pos,
CTileSurface **  parents 
) const [virtual]

libProcTer calls this function to create new child surface of this tile surface.

The default implementation calls CPlanet::createSurface.

Parameters:
pos The grid position of the surface tile. This is the position of the lower left corner of the tile. This can usually be passed directly to the CTileSurface constructor.
parents The four parent surfaces of this surface. This can usually be passed directly to the CTileSurface constructor.
Returns:
A pointer to a new CTileSurface object. The object should be allocated with the 'new' statement. The returned object should already be loaded by calling CTileSurface::load on it, before returning it.

double libProcTer::CTileSurface::getAltAndSlope ( const CGridPosition pos,
double &  dzdx,
double &  dzdy 
) const

Returns the altitude and the slope of the surface at a grid position inside this tile.

Parameters:
pos The grid position
dzdx The partial derivative of altitude with x-position (longitudinal direction) is placed in this parameter
dzdy The partial derivative of altitude with y-position (latitudinal direction) is placed in this parameter
Returns:
The altitude in meters

virtual std::string libProcTer::CTileSurface::getClassName (  )  const [pure virtual]

Returns the name of the class. The main purpose is for child surfaces to be able to determine the type of parent surfaces.

Please try to use unique names to avoid confusion with other classes.

const CMapBase* libProcTer::CTileSurface::getInternalMap ( eTextureType  type  )  const

Returns internal map data based on a map identifier. Used primarily for passing standard map data (like color or height) from parent to child, for which there is an identifier in eTextureType.

Returns:
a pointer to the map object, or NULL on failure. The caller is responsible for casting the pointer to the correct type of CMap.

virtual const CMapBase* libProcTer::CTileSurface::getInternalMap ( const std::string &  name  )  const [virtual]

Returns internal map data based on a map name. Used primarily for passing custom map data from parent to child, for which there is no identifier in eTextureType.

Please try to use an unique name for each map type, and remain consistent in the type that is used for a certain map type, to avoid bugs.

Returns:
a pointer to the map object, or NULL on failure. The caller is responsible for casting the pointer to the correct type of CMap.

const CTileSurface* const* libProcTer::CTileSurface::getParents (  )  const [inline, protected]

Returns an array of four pointers to the parent surfaces.

const CPlanet* libProcTer::CTileSurface::getPlanet (  )  const [inline, protected]

Returns a pointer to the planet object.

const CGridPosition& libProcTer::CTileSurface::getPosition (  )  const [inline]

Returns the grid position of the tile of this surface, as given to the constructor.

CVector libProcTer::CTileSurface::getTexCoords ( CGridPosition  pos  )  const

Returns the texture coordinates at a grid position inside this tile.

CTexture* libProcTer::CTileSurface::getTexture ( eTextureType  type  ) 

Returns the texture of a certain type.

double libProcTer::CTileSurface::getTileSize (  )  const [inline, protected]

Returns the physical size of the tile (in meters).

virtual bool libProcTer::CTileSurface::load (  )  [pure virtual]

The terrain loading function. To be overloaded by derived classes. The overloaded function should do the following:

  • Generate all map data, and store it in CMap objects, like m_ColorMap and m_HeightMap
  • call updateTextures()

Returns:
True on succes, false on failure. If false is returned, the surface loading function may delete this object and try to load the surface with a different class.

void libProcTer::CTileSurface::updateTextures (  )  [protected]

Reads data from CMap objects (like m_ColorMap) and writes the data to CTexture objects.

After it has generated all map data, load() should call this function.


Member Data Documentation

The color map data.

The height map data. The height is a signed integer, given in millimeters.


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

Generated on Sun Aug 2 13:23:12 2009 for libprocter by  doxygen 1.5.8