FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
FIFE::CellGrid Class Referenceabstract

#include <cellgrid.h>

+ Inheritance diagram for FIFE::CellGrid:
+ Collaboration diagram for FIFE::CellGrid:

Public Member Functions

 CellGrid ()
 Constructor. More...
 
virtual ~CellGrid ()
 Destructor. More...
 
void getAccessibleCoordinates (const ModelCoordinate &curpos, std::vector< ModelCoordinate > &coordinates)
 Gets the coordinates that are accesible from given point only cells adjacent to given cell are considered in the evaluation. More...
 
virtual const std::string & getType () const =0
 Type of cellgrid. More...
 
virtual const std::string & getName () const =0
 Name of the cellgrid (DEPRECATED? -jwt) More...
 
virtual bool isAccessible (const ModelCoordinate &curpos, const ModelCoordinate &target)=0
 Tells if given target point is accessible from curpos only cells adjacent to curpos are considered in the evaluation. More...
 
virtual double getAdjacentCost (const ModelCoordinate &curpos, const ModelCoordinate &target)=0
 Returns distance const from curpos to target point only cells adjacent to curpos are considered in the evaluation. More...
 
virtual double getHeuristicCost (const ModelCoordinate &curpos, const ModelCoordinate &target)=0
 Returns distance const from curpos to target point. More...
 
virtual uint32_t getCellSideCount () const =0
 Gets the count of sides for a single cell. More...
 
ExactModelCoordinate toMapCoordinates (const ModelCoordinate &layer_coords)
 Transforms given point from layer coordinates to map coordinates. More...
 
virtual ExactModelCoordinate toMapCoordinates (const ExactModelCoordinate &layer_coords)=0
 Transforms given point from layer coordinates to map coordinates. More...
 
virtual ModelCoordinate toLayerCoordinates (const ExactModelCoordinate &map_coord)=0
 Transforms given point from map coordinates to layer coordinates. More...
 
virtual ExactModelCoordinate toExactLayerCoordinates (const ExactModelCoordinate &map_coord)=0
 Transforms given point from map coordinates to layer coordinates. More...
 
virtual ModelCoordinate toLayerCoordinatesFromExactLayerCoordinates (const ExactModelCoordinate &exact_layer_coords)=0
 Transforms given point from exact layer coordinates to cell precision layer coordinates. More...
 
virtual void getVertices (std::vector< ExactModelCoordinate > &vtx, const ModelCoordinate &cell)=0
 Fills given point vector with vertices from selected cell. More...
 
virtual std::vector< ModelCoordinatetoMultiCoordinates (const ModelCoordinate &position, const std::vector< ModelCoordinate > &orig, bool reverse=false)=0
 Returns point vector with coordinates for a multi object. More...
 
virtual std::vector< ModelCoordinategetCoordinatesInLine (const ModelCoordinate &start, const ModelCoordinate &end)=0
 Returns point vector with coordinates for a line from start to end. More...
 
void setXShift (const double &xshift)
 Set the cellgrid x shift. More...
 
const double getXShift () const
 Get the cellgrid x shift. More...
 
void setYShift (const double yshift)
 Set the cellgrid y shift. More...
 
const double getYShift () const
 Get the cellgrid y shift. More...
 
void setZShift (const double zshift)
 Set the cellgrid z shift. More...
 
const double getZShift () const
 Get the cellgrid z shift. More...
 
void setXScale (const double scale)
 Set the cellgrid x-scaling. More...
 
void setYScale (const double scale)
 Set the cellgrid y-scaling. More...
 
void setZScale (const double scale)
 Set the cellgrid z-scaling. More...
 
const double getXScale () const
 Get the cellgrid x-scaling. More...
 
const double getYScale () const
 Get the cellgrid y-scaling. More...
 
const double getZScale () const
 Get the cellgrid z-scaling. More...
 
void setRotation (const double rotation)
 Set the cellgrid rotation. More...
 
const double getRotation () const
 Get the cellgrid rotation. More...
 
void setAllowDiagonals (const bool allow_diagonals)
 Set whether diagonal cell access is allowed. More...
 
const bool getAllowDiagonals () const
 Get whether diagonal cell access is allowed. More...
 
virtual CellGridclone ()=0
 Returns clone of this cellgrid. More...
 
- Public Member Functions inherited from FIFE::FifeClass
 FifeClass ()
 
virtual ~FifeClass ()
 
fifeid_t getFifeId ()
 Gets unique id of this instance inside the engine. More...
 

Protected Member Functions

void updateMatrices ()
 
bool ptInTriangle (const ExactModelCoordinate &pt, const ExactModelCoordinate &pt1, const ExactModelCoordinate &pt2, const ExactModelCoordinate &pt3)
 

Protected Attributes

DoubleMatrix m_matrix
 
DoubleMatrix m_inverse_matrix
 
double m_xshift
 
double m_yshift
 
double m_zshift
 
double m_xscale
 
double m_yscale
 
double m_zscale
 
double m_rotation
 
bool m_allow_diagonals
 

Private Member Functions

int32_t orientation (const ExactModelCoordinate &pt, const ExactModelCoordinate &pt1, const ExactModelCoordinate &pt2)
 

Detailed Description

Definition at line 40 of file cellgrid.h.

Constructor & Destructor Documentation

FIFE::CellGrid::CellGrid ( )

Constructor.

Definition at line 38 of file cellgrid.cpp.

References updateMatrices().

FIFE::CellGrid::~CellGrid ( )
virtual

Destructor.

Definition at line 53 of file cellgrid.cpp.

Member Function Documentation

virtual CellGrid* FIFE::CellGrid::clone ( )
pure virtual

Returns clone of this cellgrid.

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by getAllowDiagonals(), and FIFE::Model::getCellGrid().

+ Here is the caller graph for this function:

void FIFE::CellGrid::getAccessibleCoordinates ( const ModelCoordinate curpos,
std::vector< ModelCoordinate > &  coordinates 
)

Gets the coordinates that are accesible from given point only cells adjacent to given cell are considered in the evaluation.

Parameters
curposposition (coordinates) to evaluate
coordinatesaccessible coordinates

Definition at line 56 of file cellgrid.cpp.

References isAccessible(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

Referenced by FIFE::CellCache::createCells(), and FIFE::CellCache::resize().

+ Here is the caller graph for this function:

virtual double FIFE::CellGrid::getAdjacentCost ( const ModelCoordinate curpos,
const ModelCoordinate target 
)
pure virtual

Returns distance const from curpos to target point only cells adjacent to curpos are considered in the evaluation.

Parameters
curposposition (coordinates) to evaluate
targettarget coordinate to check
Returns
distance cost from curpos to target

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::CellCache::getAdjacentCost().

+ Here is the caller graph for this function:

const bool FIFE::CellGrid::getAllowDiagonals ( ) const
inline

Get whether diagonal cell access is allowed.

Returns
True if diagonal access allowed, false if only cell edges allowed

Definition at line 240 of file cellgrid.h.

References clone(), m_allow_diagonals, ptInTriangle(), and updateMatrices().

virtual uint32_t FIFE::CellGrid::getCellSideCount ( ) const
pure virtual

Gets the count of sides for a single cell.

Returns
count of sides for a single cell

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

virtual std::vector<ModelCoordinate> FIFE::CellGrid::getCoordinatesInLine ( const ModelCoordinate start,
const ModelCoordinate end 
)
pure virtual

Returns point vector with coordinates for a line from start to end.

Parameters
startThe start position
endThe end position
Returns
vector with points

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::CellCache::getCellsInLine(), and FIFE::Layer::getInstancesInLine().

+ Here is the caller graph for this function:

virtual double FIFE::CellGrid::getHeuristicCost ( const ModelCoordinate curpos,
const ModelCoordinate target 
)
pure virtual

Returns distance const from curpos to target point.

Parameters
curposposition (coordinates) to evaluate
targettarget coordinate to check
Returns
distance cost from curpos to target

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::SingleLayerSearch::updateSearch(), and FIFE::MultiLayerSearch::updateSearch().

+ Here is the caller graph for this function:

virtual const std::string& FIFE::CellGrid::getName ( ) const
pure virtual

Name of the cellgrid (DEPRECATED? -jwt)

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

const double FIFE::CellGrid::getRotation ( ) const
inline

Get the cellgrid rotation.

Returns
rotation The rotation of the cellgrid

Definition at line 228 of file cellgrid.h.

References m_rotation.

Referenced by FIFE::getAngleBetween(), FIFE::getFacing(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

virtual const std::string& FIFE::CellGrid::getType ( ) const
pure virtual

Type of cellgrid.

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::MapSaver::save().

+ Here is the caller graph for this function:

virtual void FIFE::CellGrid::getVertices ( std::vector< ExactModelCoordinate > &  vtx,
const ModelCoordinate cell 
)
pure virtual

Fills given point vector with vertices from selected cell.

Parameters
vtxvertices for given cell
cellcell to get vertices from

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::Camera::getLogicalCellDimensions(), FIFE::GridRenderer::render(), FIFE::CellSelectionRenderer::render(), FIFE::BlockingInfoRenderer::render(), and FIFE::CellRenderer::render().

+ Here is the caller graph for this function:

const double FIFE::CellGrid::getXScale ( ) const
inline

Get the cellgrid x-scaling.

Returns
The x-scale of cellgrid

Definition at line 205 of file cellgrid.h.

References m_xscale.

Referenced by FIFE::RoutePather::followRoute(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

const double FIFE::CellGrid::getXShift ( ) const
inline

Get the cellgrid x shift.

Returns
The x shift

Definition at line 150 of file cellgrid.h.

References m_xshift.

Referenced by FIFE::MapSaver::save().

+ Here is the caller graph for this function:

const double FIFE::CellGrid::getYScale ( ) const
inline

Get the cellgrid y-scaling.

Returns
The y-scale of cellgrid

Definition at line 210 of file cellgrid.h.

References m_yscale.

Referenced by FIFE::RoutePather::followRoute(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

const double FIFE::CellGrid::getYShift ( ) const
inline

Get the cellgrid y shift.

Returns
The y shift in map coords

Definition at line 163 of file cellgrid.h.

References m_yshift.

Referenced by FIFE::MapSaver::save().

+ Here is the caller graph for this function:

const double FIFE::CellGrid::getZScale ( ) const
inline

Get the cellgrid z-scaling.

Returns
The z-scale of cellgrid

Definition at line 215 of file cellgrid.h.

References m_zscale.

const double FIFE::CellGrid::getZShift ( ) const
inline

Get the cellgrid z shift.

Returns
The z shift in map coords

Definition at line 176 of file cellgrid.h.

References m_zshift.

Referenced by FIFE::RoutePather::followRoute(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

virtual bool FIFE::CellGrid::isAccessible ( const ModelCoordinate curpos,
const ModelCoordinate target 
)
pure virtual

Tells if given target point is accessible from curpos only cells adjacent to curpos are considered in the evaluation.

Parameters
curposposition (coordinates) to evaluate
targettarget coordinate to check
Returns
true, if target is accessible from curpos, false otherwise

Implemented in FIFE::SquareGrid, and FIFE::HexGrid.

Referenced by FIFE::RoutePather::followRoute(), and getAccessibleCoordinates().

+ Here is the caller graph for this function:

int32_t FIFE::CellGrid::orientation ( const ExactModelCoordinate pt,
const ExactModelCoordinate pt1,
const ExactModelCoordinate pt2 
)
private

Definition at line 79 of file cellgrid.cpp.

References FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

Referenced by ptInTriangle().

+ Here is the caller graph for this function:

bool FIFE::CellGrid::ptInTriangle ( const ExactModelCoordinate pt,
const ExactModelCoordinate pt1,
const ExactModelCoordinate pt2,
const ExactModelCoordinate pt3 
)
protected

Definition at line 89 of file cellgrid.cpp.

References FIFE::_log, FL_DBG, and orientation().

Referenced by getAllowDiagonals().

+ Here is the caller graph for this function:

void FIFE::CellGrid::setAllowDiagonals ( const bool  allow_diagonals)
inline

Set whether diagonal cell access is allowed.

Parameters
allow_diagonalsTrue if diagonal access allowed, false if only cell edges allowed

Definition at line 233 of file cellgrid.h.

References m_allow_diagonals.

Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), and FIFE::Layer::setPathingStrategy().

+ Here is the caller graph for this function:

void FIFE::CellGrid::setRotation ( const double  rotation)
inline

Set the cellgrid rotation.

Parameters
rotationThe rotation of the cellgrid

Definition at line 220 of file cellgrid.h.

References m_rotation, and updateMatrices().

Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::CellGrid::setXScale ( const double  scale)
inline

Set the cellgrid x-scaling.

Parameters
scaleThe x-scale of cellgrid

Definition at line 181 of file cellgrid.h.

References m_xscale, and updateMatrices().

Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::CellGrid::setXShift ( const double &  xshift)
inline

Set the cellgrid x shift.

Parameters
xshiftThe shift in map coords

Definition at line 142 of file cellgrid.h.

References m_xshift, and updateMatrices().

Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::CellGrid::setYScale ( const double  scale)
inline

Set the cellgrid y-scaling.

Parameters
scaleThe y-scale of cellgrid

Definition at line 189 of file cellgrid.h.

References m_yscale, and updateMatrices().

Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::CellGrid::setYShift ( const double  yshift)
inline

Set the cellgrid y shift.

Parameters
yshiftThe shift in map coords

Definition at line 155 of file cellgrid.h.

References m_yshift, and updateMatrices().

Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::CellGrid::setZScale ( const double  scale)
inline

Set the cellgrid z-scaling.

Parameters
scaleThe z-scale of cellgrid

Definition at line 197 of file cellgrid.h.

References m_zscale, and updateMatrices().

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::CellGrid::setZShift ( const double  zshift)
inline

Set the cellgrid z shift.

Parameters
zshiftThe shift in map coords

Definition at line 168 of file cellgrid.h.

References m_zshift, and updateMatrices().

Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

virtual ExactModelCoordinate FIFE::CellGrid::toExactLayerCoordinates ( const ExactModelCoordinate map_coord)
pure virtual

Transforms given point from map coordinates to layer coordinates.

Returns
point in layer coordinates

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::Location::getExactLayerCoordinates(), and FIFE::Location::setMapCoordinates().

+ Here is the caller graph for this function:

virtual ModelCoordinate FIFE::CellGrid::toLayerCoordinates ( const ExactModelCoordinate map_coord)
pure virtual

Transforms given point from map coordinates to layer coordinates.

Returns
point in layer coordinates

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::CellCache::addInteractOnRuntime(), FIFE::Location::getLayerCoordinates(), FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), FIFE::CellCacheChangeListener::onLayerChanged(), and FIFE::CellCache::removeInteractOnRuntime().

+ Here is the caller graph for this function:

virtual ModelCoordinate FIFE::CellGrid::toLayerCoordinatesFromExactLayerCoordinates ( const ExactModelCoordinate exact_layer_coords)
pure virtual

Transforms given point from exact layer coordinates to cell precision layer coordinates.

Returns
point in layer coordinates

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::Location::getLayerCoordinates().

+ Here is the caller graph for this function:

virtual ExactModelCoordinate FIFE::CellGrid::toMapCoordinates ( const ExactModelCoordinate layer_coords)
pure virtual

Transforms given point from layer coordinates to map coordinates.

Returns
point in map coordinates

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

virtual std::vector<ModelCoordinate> FIFE::CellGrid::toMultiCoordinates ( const ModelCoordinate position,
const std::vector< ModelCoordinate > &  orig,
bool  reverse = false 
)
pure virtual

Returns point vector with coordinates for a multi object.

Parameters
positionThe center position
origThe vector with the original coordinates from object
reverseIf true the orig coordinates are subtracted otherwise they are added

Implemented in FIFE::HexGrid, and FIFE::SquareGrid.

Referenced by FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), FIFE::CellCacheChangeListener::onLayerChanged(), FIFE::SingleLayerSearch::updateSearch(), and FIFE::MultiLayerSearch::updateSearch().

+ Here is the caller graph for this function:

Member Data Documentation

bool FIFE::CellGrid::m_allow_diagonals
protected
DoubleMatrix FIFE::CellGrid::m_matrix
protected
double FIFE::CellGrid::m_rotation
protected
double FIFE::CellGrid::m_xscale
protected
double FIFE::CellGrid::m_xshift
protected
double FIFE::CellGrid::m_yscale
protected
double FIFE::CellGrid::m_yshift
protected
double FIFE::CellGrid::m_zscale
protected

Definition at line 257 of file cellgrid.h.

Referenced by getZScale(), setZScale(), and updateMatrices().

double FIFE::CellGrid::m_zshift
protected

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