FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FIFE::HexGrid Class Reference

#include <hexgrid.h>

+ Inheritance diagram for FIFE::HexGrid:
+ Collaboration diagram for FIFE::HexGrid:

Public Member Functions

 HexGrid ()
 
virtual ~HexGrid ()
 
bool isAccessible (const ModelCoordinate &curpos, const ModelCoordinate &target)
 Tells if given target point is accessible from curpos only cells adjacent to curpos are considered in the evaluation. More...
 
const std::string & getType () const
 Type of cellgrid. More...
 
const std::string & getName () const
 Name of the cellgrid (DEPRECATED? -jwt) More...
 
double getAdjacentCost (const ModelCoordinate &curpos, const ModelCoordinate &target)
 Returns distance const from curpos to target point only cells adjacent to curpos are considered in the evaluation. More...
 
double getHeuristicCost (const ModelCoordinate &curpos, const ModelCoordinate &target)
 Returns distance const from curpos to target point. More...
 
uint32_t getCellSideCount () const
 Gets the count of sides for a single cell. More...
 
ExactModelCoordinate toMapCoordinates (const ExactModelCoordinate &layer_coords)
 Transforms given point from layer coordinates to map coordinates. More...
 
ModelCoordinate toLayerCoordinates (const ExactModelCoordinate &map_coord)
 Transforms given point from map coordinates to layer coordinates. More...
 
ExactModelCoordinate toExactLayerCoordinates (const ExactModelCoordinate &map_coord)
 Transforms given point from map coordinates to layer coordinates. More...
 
void getVertices (std::vector< ExactModelCoordinate > &vtx, const ModelCoordinate &cell)
 Fills given point vector with vertices from selected cell. More...
 
std::vector< ModelCoordinatetoMultiCoordinates (const ModelCoordinate &position, const std::vector< ModelCoordinate > &orig, bool reverse)
 Returns point vector with coordinates for a multi object. More...
 
CellGridclone ()
 Returns clone of this cellgrid. More...
 
- Public Member Functions inherited from FIFE::CellGrid
 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...
 
ExactModelCoordinate toMapCoordinates (const ModelCoordinate &layer_coords)
 Transforms given point from layer coordinates to map coordinates. 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...
 
- Public Member Functions inherited from FIFE::FifeClass
 FifeClass ()
 
virtual ~FifeClass ()
 
fifeid_t getFifeId ()
 Gets unique id of this instance inside the engine. More...
 

Private Member Functions

double getXZigzagOffset (double y)
 

Additional Inherited Members

- Protected Member Functions inherited from FIFE::CellGrid
void updateMatrices ()
 
bool ptInTriangle (const ExactModelCoordinate &pt, const ExactModelCoordinate &pt1, const ExactModelCoordinate &pt2, const ExactModelCoordinate &pt3)
 
- Protected Attributes inherited from FIFE::CellGrid
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
 

Detailed Description

Definition at line 38 of file hexgrid.h.

Constructor & Destructor Documentation

FIFE::HexGrid::HexGrid ( )

Definition at line 47 of file hexgrid.cpp.

References FIFE::_log, FL_DBG, FIFE::HEX_EDGE_HALF, FIFE::HEX_TO_CORNER, FIFE::HEX_TO_EDGE, FIFE::HEX_WIDTH, and FIFE::VERTICAL_MULTIP.

Referenced by clone().

+ Here is the caller graph for this function:

FIFE::HexGrid::~HexGrid ( )
virtual

Definition at line 70 of file hexgrid.cpp.

Member Function Documentation

double FIFE::HexGrid::getAdjacentCost ( const ModelCoordinate curpos,
const ModelCoordinate target 
)
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

Implements FIFE::CellGrid.

Definition at line 87 of file hexgrid.cpp.

uint32_t FIFE::HexGrid::getCellSideCount ( ) const
inlinevirtual

Gets the count of sides for a single cell.

Returns
count of sides for a single cell

Implements FIFE::CellGrid.

Definition at line 48 of file hexgrid.h.

double FIFE::HexGrid::getHeuristicCost ( const ModelCoordinate curpos,
const ModelCoordinate target 
)
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

Implements FIFE::CellGrid.

Definition at line 94 of file hexgrid.cpp.

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

const std::string & FIFE::HexGrid::getName ( ) const
virtual

Name of the cellgrid (DEPRECATED? -jwt)

Implements FIFE::CellGrid.

Definition at line 103 of file hexgrid.cpp.

const std::string & FIFE::HexGrid::getType ( ) const
virtual

Type of cellgrid.

Implements FIFE::CellGrid.

Definition at line 98 of file hexgrid.cpp.

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

Fills given point vector with vertices from selected cell.

Parameters
vtxvertices for given cell
cellcell to get vertices from

Implements FIFE::CellGrid.

Definition at line 183 of file hexgrid.cpp.

References FIFE::_log, ADD_PT, FL_DBG, getXZigzagOffset(), FIFE::HEX_EDGE_HALF, FIFE::HEX_TO_CORNER, FIFE::HEX_TO_EDGE, FIFE::VERTICAL_MULTIP_INV, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

double FIFE::HexGrid::getXZigzagOffset ( double  y)
private

Definition at line 108 of file hexgrid.cpp.

References ABS, and FIFE::HEX_TO_EDGE.

Referenced by getVertices(), toExactLayerCoordinates(), and toMapCoordinates().

+ Here is the caller graph for this function:

bool FIFE::HexGrid::isAccessible ( const ModelCoordinate curpos,
const ModelCoordinate target 
)
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

Implements FIFE::CellGrid.

Definition at line 73 of file hexgrid.cpp.

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

ExactModelCoordinate FIFE::HexGrid::toExactLayerCoordinates ( const ExactModelCoordinate map_coord)
virtual

Transforms given point from map coordinates to layer coordinates.

Returns
point in layer coordinates

Implements FIFE::CellGrid.

Definition at line 129 of file hexgrid.cpp.

References FIFE::_log, FL_DBG, getXZigzagOffset(), FIFE::CellGrid::m_inverse_matrix, FIFE::VERTICAL_MULTIP, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

ModelCoordinate FIFE::HexGrid::toLayerCoordinates ( const ExactModelCoordinate map_coord)
virtual

Transforms given point from map coordinates to layer coordinates.

Returns
point in layer coordinates

Implements FIFE::CellGrid.

Definition at line 137 of file hexgrid.cpp.

References FIFE::_log, ABS, FL_DBG, FIFE::HEX_EDGE_GRADIENT, FIFE::HEX_TO_CORNER, FIFE::CellGrid::m_inverse_matrix, FIFE::VERTICAL_MULTIP_INV, FIFE::PointType3D< T >::x, FIFE::PointType3D< T >::y, and FIFE::PointType3D< T >::z.

ExactModelCoordinate FIFE::HexGrid::toMapCoordinates ( const ExactModelCoordinate layer_coords)
virtual

Transforms given point from layer coordinates to map coordinates.

Returns
point in map coordinates

Implements FIFE::CellGrid.

Definition at line 120 of file hexgrid.cpp.

References FIFE::_log, FL_DBG, getXZigzagOffset(), FIFE::CellGrid::m_matrix, FIFE::VERTICAL_MULTIP, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

std::vector< ModelCoordinate > FIFE::HexGrid::toMultiCoordinates ( const ModelCoordinate position,
const std::vector< ModelCoordinate > &  orig,
bool  reverse 
)
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

Implements FIFE::CellGrid.

Definition at line 222 of file hexgrid.cpp.

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


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