FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
#include <hexgrid.h>
Public Member Functions | |
HexGrid (bool axial=false) | |
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... | |
ModelCoordinate | toLayerCoordinatesFromExactLayerCoordinates (const ExactModelCoordinate &exact_layer_coords) |
Transforms given point from exact layer coordinates to cell precision layer coordinates. More... | |
void | getVertices (std::vector< ExactModelCoordinate > &vtx, const ModelCoordinate &cell) |
Fills given point vector with vertices from selected cell. More... | |
std::vector< ModelCoordinate > | toMultiCoordinates (const ModelCoordinate &position, const std::vector< ModelCoordinate > &orig, bool reverse) |
Returns point vector with coordinates for a multi object. More... | |
std::vector< ModelCoordinate > | getCoordinatesInLine (const ModelCoordinate &start, const ModelCoordinate &end) |
Returns point vector with coordinates for a line from start to end. More... | |
CellGrid * | clone () |
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) |
ModelCoordinate | toLayerCoordinatesHelper (const ExactModelCoordinate &coords) |
Private Attributes | |
bool | m_axial |
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 |
FIFE::HexGrid::HexGrid | ( | bool | axial = false | ) |
Definition at line 47 of file hexgrid.cpp.
References FIFE::_log, and FL_DBG.
Referenced by clone().
|
virtual |
Definition at line 71 of file hexgrid.cpp.
|
virtual |
Returns clone of this cellgrid.
Implements FIFE::CellGrid.
Definition at line 58 of file hexgrid.cpp.
References HexGrid(), FIFE::CellGrid::m_allow_diagonals, m_axial, FIFE::CellGrid::m_rotation, FIFE::CellGrid::m_xscale, FIFE::CellGrid::m_xshift, FIFE::CellGrid::m_yscale, FIFE::CellGrid::m_yshift, FIFE::CellGrid::m_zshift, FIFE::CellGrid::setAllowDiagonals(), FIFE::CellGrid::setRotation(), FIFE::CellGrid::setXScale(), FIFE::CellGrid::setXShift(), FIFE::CellGrid::setYScale(), FIFE::CellGrid::setYShift(), and FIFE::CellGrid::setZShift().
Referenced by getCellSideCount().
|
virtual |
Returns distance const from curpos to target point only cells adjacent to curpos are considered in the evaluation.
curpos | position (coordinates) to evaluate |
target | target coordinate to check |
Implements FIFE::CellGrid.
Definition at line 93 of file hexgrid.cpp.
|
inlinevirtual |
Gets the count of sides for a single cell.
Implements FIFE::CellGrid.
Definition at line 48 of file hexgrid.h.
References clone(), getCoordinatesInLine(), getVertices(), getXZigzagOffset(), toExactLayerCoordinates(), toLayerCoordinates(), toLayerCoordinatesFromExactLayerCoordinates(), toLayerCoordinatesHelper(), toMapCoordinates(), and toMultiCoordinates().
|
virtual |
Returns point vector with coordinates for a line from start to end.
start | The start position |
end | The end position |
Implements FIFE::CellGrid.
Definition at line 304 of file hexgrid.cpp.
References ABS, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by getCellSideCount().
|
virtual |
Returns distance const from curpos to target point.
curpos | position (coordinates) to evaluate |
target | target coordinate to check |
Implements FIFE::CellGrid.
Definition at line 100 of file hexgrid.cpp.
References ABS, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
|
virtual |
Name of the cellgrid (DEPRECATED? -jwt)
Implements FIFE::CellGrid.
Definition at line 114 of file hexgrid.cpp.
References m_axial.
|
virtual |
Type of cellgrid.
Implements FIFE::CellGrid.
Definition at line 104 of file hexgrid.cpp.
References m_axial.
|
virtual |
Fills given point vector with vertices from selected cell.
vtx | vertices for given cell |
cell | cell to get vertices from |
Implements FIFE::CellGrid.
Definition at line 223 of file hexgrid.cpp.
References FIFE::_log, ADD_PT, FL_DBG, getXZigzagOffset(), FIFE::HEX_EDGE_HALF, FIFE::HEX_TO_CORNER, FIFE::HEX_TO_EDGE, m_axial, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by getCellSideCount().
|
private |
Definition at line 124 of file hexgrid.cpp.
Referenced by getCellSideCount(), getVertices(), toExactLayerCoordinates(), toLayerCoordinatesFromExactLayerCoordinates(), and toMapCoordinates().
|
virtual |
Tells if given target point is accessible from curpos only cells adjacent to curpos are considered in the evaluation.
curpos | position (coordinates) to evaluate |
target | target coordinate to check |
Implements FIFE::CellGrid.
Definition at line 74 of file hexgrid.cpp.
References ABS, m_axial, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
|
virtual |
Transforms given point from map coordinates to layer coordinates.
Implements FIFE::CellGrid.
Definition at line 149 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.
Referenced by getCellSideCount().
|
virtual |
Transforms given point from map coordinates to layer coordinates.
Implements FIFE::CellGrid.
Definition at line 157 of file hexgrid.cpp.
References FIFE::_log, FL_DBG, FIFE::CellGrid::m_inverse_matrix, toLayerCoordinatesHelper(), FIFE::VERTICAL_MULTIP_INV, and FIFE::PointType3D< T >::y.
Referenced by getCellSideCount().
|
virtual |
Transforms given point from exact layer coordinates to cell precision layer coordinates.
Implements FIFE::CellGrid.
Definition at line 164 of file hexgrid.cpp.
References getXZigzagOffset(), toLayerCoordinatesHelper(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by getCellSideCount().
|
private |
Definition at line 170 of file hexgrid.cpp.
References ABS, m_axial, FIFE::PointType3D< T >::x, FIFE::PointType3D< T >::y, and FIFE::PointType3D< T >::z.
Referenced by getCellSideCount(), toLayerCoordinates(), and toLayerCoordinatesFromExactLayerCoordinates().
|
virtual |
Transforms given point from layer coordinates to map coordinates.
Implements FIFE::CellGrid.
Definition at line 140 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.
Referenced by getCellSideCount().
|
virtual |
Returns point vector with coordinates for a multi object.
position | The center position |
orig | The vector with the original coordinates from object |
reverse | If true the orig coordinates are subtracted otherwise they are added |
Implements FIFE::CellGrid.
Definition at line 267 of file hexgrid.cpp.
References FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by getCellSideCount().
|
private |
Definition at line 62 of file hexgrid.h.
Referenced by clone(), getName(), getType(), getVertices(), getXZigzagOffset(), isAccessible(), and toLayerCoordinatesHelper().