FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
#include <cellgrid.h>
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< ModelCoordinate > | toMultiCoordinates (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< ModelCoordinate > | getCoordinatesInLine (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 CellGrid * | clone ()=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) |
Definition at line 40 of file cellgrid.h.
FIFE::CellGrid::CellGrid | ( | ) |
|
virtual |
Destructor.
Definition at line 53 of file cellgrid.cpp.
|
pure virtual |
Returns clone of this cellgrid.
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
Referenced by getAllowDiagonals(), and FIFE::Model::getCellGrid().
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.
curpos | position (coordinates) to evaluate |
coordinates | accessible 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().
|
pure 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 |
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
Referenced by FIFE::CellCache::getAdjacentCost().
|
inline |
Get whether diagonal cell access is allowed.
Definition at line 240 of file cellgrid.h.
References clone(), m_allow_diagonals, ptInTriangle(), and updateMatrices().
|
pure virtual |
Gets the count of sides for a single cell.
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
|
pure virtual |
Returns point vector with coordinates for a line from start to end.
start | The start position |
end | The end position |
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
Referenced by FIFE::CellCache::getCellsInLine(), and FIFE::Layer::getInstancesInLine().
|
pure virtual |
Returns distance const from curpos to target point.
curpos | position (coordinates) to evaluate |
target | target coordinate to check |
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
Referenced by FIFE::SingleLayerSearch::updateSearch(), and FIFE::MultiLayerSearch::updateSearch().
|
pure virtual |
Name of the cellgrid (DEPRECATED? -jwt)
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
|
inline |
Get the cellgrid rotation.
Definition at line 228 of file cellgrid.h.
References m_rotation.
Referenced by FIFE::getAngleBetween(), FIFE::getFacing(), and FIFE::MapSaver::save().
|
pure virtual |
Type of cellgrid.
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
Referenced by FIFE::MapSaver::save().
|
pure virtual |
Fills given point vector with vertices from selected cell.
vtx | vertices for given cell |
cell | cell 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().
|
inline |
Get the cellgrid x-scaling.
Definition at line 205 of file cellgrid.h.
References m_xscale.
Referenced by FIFE::RoutePather::followRoute(), and FIFE::MapSaver::save().
|
inline |
Get the cellgrid x shift.
Definition at line 150 of file cellgrid.h.
References m_xshift.
Referenced by FIFE::MapSaver::save().
|
inline |
Get the cellgrid y-scaling.
Definition at line 210 of file cellgrid.h.
References m_yscale.
Referenced by FIFE::RoutePather::followRoute(), and FIFE::MapSaver::save().
|
inline |
Get the cellgrid y shift.
Definition at line 163 of file cellgrid.h.
References m_yshift.
Referenced by FIFE::MapSaver::save().
|
inline |
Get the cellgrid z-scaling.
Definition at line 215 of file cellgrid.h.
References m_zscale.
|
inline |
Get the cellgrid z shift.
Definition at line 176 of file cellgrid.h.
References m_zshift.
Referenced by FIFE::RoutePather::followRoute(), and FIFE::MapSaver::save().
|
pure 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 |
Implemented in FIFE::SquareGrid, and FIFE::HexGrid.
Referenced by FIFE::RoutePather::followRoute(), and getAccessibleCoordinates().
|
private |
Definition at line 79 of file cellgrid.cpp.
References FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by ptInTriangle().
|
protected |
Definition at line 89 of file cellgrid.cpp.
References FIFE::_log, FL_DBG, and orientation().
Referenced by getAllowDiagonals().
|
inline |
Set whether diagonal cell access is allowed.
allow_diagonals | True 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().
|
inline |
Set the cellgrid rotation.
rotation | The 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().
|
inline |
Set the cellgrid x-scaling.
scale | The 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().
|
inline |
Set the cellgrid x shift.
xshift | The 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().
|
inline |
Set the cellgrid y-scaling.
scale | The 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().
|
inline |
Set the cellgrid y shift.
yshift | The 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().
|
inline |
Set the cellgrid z-scaling.
scale | The z-scale of cellgrid |
Definition at line 197 of file cellgrid.h.
References m_zscale, and updateMatrices().
Referenced by FIFE::MapLoader::load().
|
inline |
Set the cellgrid z shift.
zshift | The 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().
|
pure virtual |
Transforms given point from map coordinates to layer coordinates.
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
Referenced by FIFE::Location::getExactLayerCoordinates(), and FIFE::Location::setMapCoordinates().
|
pure virtual |
Transforms given point from map coordinates to 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().
|
pure virtual |
Transforms given point from exact layer coordinates to cell precision layer coordinates.
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
Referenced by FIFE::Location::getLayerCoordinates().
ExactModelCoordinate FIFE::CellGrid::toMapCoordinates | ( | const ModelCoordinate & | layer_coords | ) |
Transforms given point from layer coordinates to map coordinates.
Definition at line 75 of file cellgrid.cpp.
References FIFE::intPt2doublePt().
Referenced by FIFE::CellCache::addInteractOnRuntime(), FIFE::CellCache::createCells(), FIFE::Location::getExactLayerCoordinates(), FIFE::Location::getLayerCoordinates(), FIFE::Camera::getLogicalCellDimensions(), FIFE::Location::getMapCoordinates(), FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), FIFE::CellCacheChangeListener::onLayerChanged(), FIFE::CellCache::removeInteractOnRuntime(), FIFE::GridRenderer::render(), FIFE::CellSelectionRenderer::render(), FIFE::BlockingInfoRenderer::render(), FIFE::CellRenderer::render(), FIFE::CellCache::resize(), and FIFE::RenderVisitor::visit().
|
pure virtual |
Transforms given point from layer coordinates to map coordinates.
Implemented in FIFE::HexGrid, and FIFE::SquareGrid.
|
pure 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 |
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().
|
protected |
Definition at line 68 of file cellgrid.cpp.
References FIFE::Matrix< T >::applyScale(), FIFE::Matrix< T >::applyTranslate(), FIFE::Matrix< T >::inverse(), FIFE::Matrix< T >::loadRotate(), m_inverse_matrix, m_matrix, m_rotation, m_xscale, m_xshift, m_yscale, m_yshift, m_zscale, and m_zshift.
Referenced by CellGrid(), getAllowDiagonals(), setRotation(), setXScale(), setXShift(), setYScale(), setYShift(), setZScale(), and setZShift().
|
protected |
Definition at line 259 of file cellgrid.h.
Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), getAllowDiagonals(), FIFE::SquareGrid::isAccessible(), and setAllowDiagonals().
|
protected |
Definition at line 251 of file cellgrid.h.
Referenced by FIFE::HexGrid::toExactLayerCoordinates(), FIFE::SquareGrid::toExactLayerCoordinates(), FIFE::HexGrid::toLayerCoordinates(), and updateMatrices().
|
protected |
Definition at line 250 of file cellgrid.h.
Referenced by FIFE::HexGrid::toMapCoordinates(), FIFE::SquareGrid::toMapCoordinates(), and updateMatrices().
|
protected |
Definition at line 258 of file cellgrid.h.
Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), getRotation(), setRotation(), and updateMatrices().
|
protected |
Definition at line 255 of file cellgrid.h.
Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), getXScale(), setXScale(), and updateMatrices().
|
protected |
Definition at line 252 of file cellgrid.h.
Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), getXShift(), setXShift(), and updateMatrices().
|
protected |
Definition at line 256 of file cellgrid.h.
Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), getYScale(), setYScale(), and updateMatrices().
|
protected |
Definition at line 253 of file cellgrid.h.
Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), getYShift(), setYShift(), and updateMatrices().
|
protected |
Definition at line 257 of file cellgrid.h.
Referenced by getZScale(), setZScale(), and updateMatrices().
|
protected |
Definition at line 254 of file cellgrid.h.
Referenced by FIFE::HexGrid::clone(), FIFE::SquareGrid::clone(), getZShift(), setZShift(), and updateMatrices().