#include <cparentmap.h>
Public Member Functions | |
CParentMap (const CGridPosition &pos, const CTileSurface *const *parents, CTileSurface::eTextureType type) | |
T * | getLandel (int x, int y) |
Protected Attributes | |
CMap< T > * | m_Maps [4] |
The map pointers. | |
pixel shift (child scale) of the child origin w.r.t. m_Maps[0] | |
unsigned int | m_dx |
unsigned int | m_dy |
This class can be used in derived classes of CTileSurface, when landscape generation is to be based on map data of parent surfaces. This class accepts pointers to the parent surfaces, and translates pixel coordinates between the different levels to return the correct pixel value from the parent maps.
libProcTer::CParentMap< T >::CParentMap | ( | const CGridPosition & | pos, | |
const CTileSurface *const * | parents, | |||
CTileSurface::eTextureType | type | |||
) | [inline] |
Constructor.
pos | The grid position of the child tile. Can typically be obtained with CTileSurface::getPosition(). | |
parents | Array of pointers to the four parents. Can typically be obtained with CTileSurface::getParents(). | |
type | The type of surface that is used. CParentMap calls CTileSurface::getInternalMap on the parent surfaces to get pointers to the map data. As it needs to do some type-unsafe pointer conversions, the user of CParentMap is responsible for making sure that the template type of CParentMap corresponds to the actual data type of the map data in the parents. |
T * libProcTer::CParentMap< T >::getLandel | ( | int | x, | |
int | y | |||
) | [inline] |
Returns a pointer to the landel ('pixel') in the parent maps that corresponds to the child map coordinates (x,y).
The range of allowed values for x and y is [-PROCTER_TEX_RES, 2*PROCTER_TEX_RES).
As the parent maps have half the resolution of the child map, x and y should be even. If they are not, they are rounded down (e.g. 3 is interpreted as 2, and -1 is interpreted as -2).
CMap<T>* libProcTer::CParentMap< T >::m_Maps[4] [protected] |
The map pointers.