Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::TileMap Class Reference

Graphics class that represent several tiles of the same size assembled into a grid This class is far more efficient than using a sprite for every tile. More...

Inheritance diagram for Nz::TileMap:
Nz::InstancedRenderable Nz::RefCounted

Public Member Functions

 TileMap (const Nz::Vector2ui &mapSize, const Nz::Vector2f &tileSize, std::size_t materialCount=1)
 Constructs a TileMap object, containing mapSize tileSize-sized tiles. More...
 
 TileMap (const TileMap &TileMap)=default
 
 TileMap (TileMap &&)=delete
 
void AddToRenderQueue (AbstractRenderQueue *renderQueue, const InstanceData &instanceData) const override
 Adds the TileMap to the rendering queue. More...
 
void DisableTile (const Vector2ui &tilePos)
 Disable the tile at position tilePos, disabling rendering at this location. More...
 
void DisableTiles ()
 Disable all tiles.
 
void DisableTiles (const Vector2ui *tilesPos, std::size_t tileCount)
 Disable tileCount tiles at positions contained at tilesPos location, disabling rendering at those locations. More...
 
void EnableIsometricMode (bool isometric)
 Enable/Disable isometric mode. More...
 
void EnableTile (const Vector2ui &tilePos, const Rectf &coords, const Color &color=Color::White, std::size_t materialIndex=0U)
 Enable and sets the tile at position tilePos. More...
 
void EnableTile (const Vector2ui &tilePos, const Rectui &rect, const Color &color=Color::White, std::size_t materialIndex=0U)
 Enable and sets the tile at position tilePos. More...
 
void EnableTiles (const Rectf &coords, const Color &color=Color::White, std::size_t materialIndex=0U)
 Enable and sets all the tiles. More...
 
void EnableTiles (const Rectui &rect, const Color &color=Color::White, std::size_t materialIndex=0U)
 Enable and sets all the tiles. More...
 
void EnableTiles (const Vector2ui *tilesPos, std::size_t tileCount, const Rectf &coords, const Color &color=Color::White, std::size_t materialIndex=0U)
 Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations. More...
 
void EnableTiles (const Vector2ui *tilesPos, std::size_t tileCount, const Rectui &rect, const Color &color=Color::White, std::size_t materialIndex=0U)
 Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations. More...
 
const Vector2uiGetMapSize () const
 Gets the tilemap size (i.e. number of tiles in each dimension) More...
 
Vector2f GetSize () const
 Returns the size of the tilemap in units (which is equivalent to GetMapSize() * GetTileSize()) More...
 
const Tile & GetTile (const Vector2ui &tilePos) const
 Returns informations about a particular tile. More...
 
const Vector2fGetTileSize () const
 Gets the tile size (i.e. number of units occupied by a tile in each dimension) More...
 
bool IsIsometricModeEnabled () const
 Gets the actual state of the isometric mode. More...
 
TileMapoperator= (const TileMap &TileMap)
 Sets the current TileMap with the content of the other one. More...
 
TileMapoperator= (TileMap &&TileMap)=delete
 
- Public Member Functions inherited from Nz::InstancedRenderable
 InstancedRenderable ()
 Constructs a InstancedRenderable object by default.
 
 InstancedRenderable (const InstancedRenderable &renderable)
 Constructs a InstancedRenderable object by assignation. More...
 
 InstancedRenderable (InstancedRenderable &&renderable)=delete
 
virtual ~InstancedRenderable ()
 Destructs the object and calls OnInstancedRenderableRelease. More...
 
virtual bool Cull (const Frustumf &frustum, const InstanceData &instanceData) const
 Culls the instanced if not in the frustum. More...
 
void EnsureBoundingVolumeUpdated () const
 Ensures that the bounding volume is up to date.
 
virtual const BoundingVolumefGetBoundingVolume () const
 Gets the bounding volume. More...
 
const MaterialRefGetMaterial (std::size_t matIndex=0) const
 Gets one of the material used by the object. More...
 
const MaterialRefGetMaterial (std::size_t skinIndex, std::size_t matIndex) const
 Gets one of the material used by the object, independently from the active skin. More...
 
std::size_t GetMaterialCount () const
 Gets the number of material per skin. More...
 
std::size_t GetSkin () const
 Gets the current active skin index. More...
 
std::size_t GetSkinCount () const
 Gets the number of skins this object has. More...
 
virtual void InvalidateData (InstanceData *instanceData, UInt32 flags) const
 Invalidates data for instanced. More...
 
void SetSkin (std::size_t skinIndex)
 Changes the active skin. More...
 
void SetSkinCount (std::size_t skinCount)
 Changes the maximum skin count of the object. More...
 
virtual void UpdateBoundingVolume (InstanceData *instanceData) const
 Updates the bounding volume. More...
 
InstancedRenderableoperator= (const InstancedRenderable &renderable)
 Sets the current instanced renderable with the content of the other one. More...
 
InstancedRenderableoperator= (InstancedRenderable &&renderable)=delete
 
 NazaraSignal (OnInstancedRenderableInvalidateBoundingVolume, const InstancedRenderable *)
 
 NazaraSignal (OnInstancedRenderableInvalidateData, const InstancedRenderable *, UInt32)
 
 NazaraSignal (OnInstancedRenderableInvalidateMaterial, const InstancedRenderable *, std::size_t, std::size_t, const MaterialRef &)
 
 NazaraSignal (OnInstancedRenderableRelease, const InstancedRenderable *)
 
 NazaraSignal (OnInstancedRenderableResetMaterials, const InstancedRenderable *, std::size_t)
 
 NazaraSignal (OnInstancedRenderableSkinChange, const InstancedRenderable *, std::size_t)
 
- Public Member Functions inherited from Nz::RefCounted
 RefCounted (bool persistent=true)
 Constructs a RefCounted object with a persistance aspect. More...
 
 RefCounted (const RefCounted &)=delete
 
 RefCounted (RefCounted &&)=default
 
virtual ~RefCounted ()
 Destructs the object. More...
 
void AddReference () const
 Adds a reference to the object.
 
unsigned int GetReferenceCount () const
 Gets the number of references to the object. More...
 
bool IsPersistent () const
 Checks whether the object is persistent. More...
 
bool RemoveReference () const
 Removes a reference to the object. More...
 
bool SetPersistent (bool persistent=true, bool checkReferenceCount=false)
 Sets the persistence of the object. More...
 
RefCountedoperator= (const RefCounted &)=delete
 
RefCountedoperator= (RefCounted &&)=default
 

Static Public Member Functions

template<typename... Args>
static TileMapRef New (Args &&... args)
 Creates a new TileMap from the arguments. More...
 

Friends

class Graphics
 

Additional Inherited Members

- Protected Member Functions inherited from Nz::InstancedRenderable
void InvalidateBoundingVolume ()
 Invalidates the bounding volume.
 
void InvalidateInstanceData (UInt32 flags)
 Invalidates the instance data based on flags. More...
 
void ResetMaterials (std::size_t matCount, std::size_t skinCount=1)
 Resets the materials, material count and skin count. More...
 
void SetMaterial (std::size_t matIndex, MaterialRef material)
 Changes the material used at the specified index by another one. More...
 
void SetMaterial (std::size_t skinIndex, std::size_t matIndex, MaterialRef material)
 Changes the material used at the specified index by another one, independently from the active skin. More...
 
- Protected Attributes inherited from Nz::InstancedRenderable
BoundingVolumef m_boundingVolume
 

Detailed Description

Graphics class that represent several tiles of the same size assembled into a grid This class is far more efficient than using a sprite for every tile.

Constructor & Destructor Documentation

◆ TileMap()

Nz::TileMap::TileMap ( const Nz::Vector2ui mapSize,
const Nz::Vector2f tileSize,
std::size_t  materialCount = 1 
)
inline

Constructs a TileMap object, containing mapSize tileSize-sized tiles.

Parameters
mapSizeNumber of tiles in each dimension, must be
tileSizeSize of each tile of the TileMap
materialCountThe maximum number of differents Material this TileMap will use
Remarks
When constructed, a TileMap has no tile active and will not be rendered To use it, you have to enable some tiles.
The default material is used for every material requested

Member Function Documentation

◆ AddToRenderQueue()

void Nz::TileMap::AddToRenderQueue ( AbstractRenderQueue renderQueue,
const InstanceData &  instanceData 
) const
overridevirtual

Adds the TileMap to the rendering queue.

Parameters
renderQueueQueue to be added
instanceDataData for the instance

Implements Nz::InstancedRenderable.

◆ DisableTile()

void Nz::TileMap::DisableTile ( const Vector2ui tilePos)
inline

Disable the tile at position tilePos, disabling rendering at this location.

Parameters
tilePosPosition of the tile to disable
See also
DisableTiles

◆ DisableTiles()

void Nz::TileMap::DisableTiles ( const Vector2ui tilesPos,
std::size_t  tileCount 
)
inline

Disable tileCount tiles at positions contained at tilesPos location, disabling rendering at those locations.

This is equivalent to calling tileCount times DisableTile with the positions contained at tilesPos

Parameters
tilesPosPointer to a valid array of at least tileCount positions
tileCountNumber of tiles to disable
Remarks
if tileCount is zero, this is a no-op and the value of tilesPos is not used
See also
DisableTile

◆ EnableIsometricMode()

void Nz::TileMap::EnableIsometricMode ( bool  isometric)
inline

Enable/Disable isometric mode.

If enabled, every odd line will overlap by half the tile size with the upper line

Parameters
isometricShould the isometric mode be enabled for this TileMap
See also
IsIsometricModeEnabled

◆ EnableTile() [1/2]

void Nz::TileMap::EnableTile ( const Vector2ui tilePos,
const Rectf coords,
const Color color = Color::White,
std::size_t  materialIndex = 0U 
)
inline

Enable and sets the tile at position tilePos.

Setup the tile at position tilePos using color, normalized coordinates coords and materialIndex

Parameters
tilePosPosition of the tile to enable
coordsNormalized coordinates ([0..1]) used to specify which region of the material textures will be used
colorThe multiplicative color applied to the tile
materialIndexThe material which will be used for rendering this tile
See also
EnableTiles

◆ EnableTile() [2/2]

void Nz::TileMap::EnableTile ( const Vector2ui tilePos,
const Rectui rect,
const Color color = Color::White,
std::size_t  materialIndex = 0U 
)
inline

Enable and sets the tile at position tilePos.

Setup the tile at position tilePos using color, unnormalized coordinates rect and materialIndex

Parameters
tilePosPosition of the tile to enable
coordsUnnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
colorThe multiplicative color applied to the tile
materialIndexThe material which will be used for rendering this tile
Remarks
The material at [materialIndex] must have a valid diffuse map before using this function, as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
See also
EnableTiles

◆ EnableTiles() [1/4]

void Nz::TileMap::EnableTiles ( const Rectf coords,
const Color color = Color::White,
std::size_t  materialIndex = 0U 
)
inline

Enable and sets all the tiles.

Setup all tiles using color, normalized coordinates coords and materialIndex

Parameters
coordsNormalized coordinates ([0..1]) used to specify which region of the material textures will be used
colorThe multiplicative color applied to the tile
materialIndexThe material which will be used for rendering this tile
Remarks
The material at [materialIndex] must have a valid diffuse map before using this function, as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
See also
EnableTile

◆ EnableTiles() [2/4]

void Nz::TileMap::EnableTiles ( const Rectui rect,
const Color color = Color::White,
std::size_t  materialIndex = 0U 
)
inline

Enable and sets all the tiles.

Setup all tiles using color, unnormalized coordinates coords and materialIndex

Parameters
coordsUnnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
colorThe multiplicative color applied to the tile
materialIndexThe material which will be used for rendering this tile
Remarks
The material at [materialIndex] must have a valid diffuse map before using this function, as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
See also
EnableTile

◆ EnableTiles() [3/4]

void Nz::TileMap::EnableTiles ( const Vector2ui tilesPos,
std::size_t  tileCount,
const Rectf coords,
const Color color = Color::White,
std::size_t  materialIndex = 0U 
)
inline

Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations.

Setup all tiles using color, normalized coordinates coords and materialIndex

Parameters
tilesPosPointer to a valid array of at least tileCount positions
tileCountNumber of tiles to enable
coordsNormalized coordinates ([0..1]) used to specify which region of the material textures will be used
colorThe multiplicative color applied to the tile
materialIndexThe material which will be used for rendering this tile
See also
EnableTile

◆ EnableTiles() [4/4]

void Nz::TileMap::EnableTiles ( const Vector2ui tilesPos,
std::size_t  tileCount,
const Rectui rect,
const Color color = Color::White,
std::size_t  materialIndex = 0U 
)
inline

Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations.

Setup all tiles using color, unnormalized coordinates coords and materialIndex

Parameters
tilesPosPointer to a valid array of at least tileCount positions
tileCountNumber of tiles to enable
coordsUnnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
colorThe multiplicative color applied to the tile
materialIndexThe material which will be used for rendering this tile
Remarks
The material at [materialIndex] must have a valid diffuse map before using this function, as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
See also
EnableTile

◆ GetMapSize()

const Vector2ui & Nz::TileMap::GetMapSize ( ) const
inline

Gets the tilemap size (i.e. number of tiles in each dimension)

Returns
Number of tiles in each dimension
See also
GetSize
GetTileSize

◆ GetSize()

Vector2f Nz::TileMap::GetSize ( ) const
inline

Returns the size of the tilemap in units (which is equivalent to GetMapSize() * GetTileSize())

Returns
Maximum size in units occupied by this tilemap
See also
GetMapSize
GetTileSize

◆ GetTile()

const TileMap::Tile & Nz::TileMap::GetTile ( const Vector2ui tilePos) const
inline

Returns informations about a particular tile.

Parameters
tilePosPosition of the tile to get (enabled or not)
Returns
Maximum size in units occupied by this tilemap

◆ GetTileSize()

const Vector2f & Nz::TileMap::GetTileSize ( ) const
inline

Gets the tile size (i.e. number of units occupied by a tile in each dimension)

Returns
Tile size in each dimension
See also
GetMapSize
GetSize

◆ IsIsometricModeEnabled()

bool Nz::TileMap::IsIsometricModeEnabled ( ) const
inline

Gets the actual state of the isometric mode.

Returns
True if the isometric mode is enabled
See also
EnableIsometricMode

◆ New()

template<typename... Args>
TileMapRef Nz::TileMap::New ( Args &&...  args)
static

Creates a new TileMap from the arguments.

Returns
A reference to the newly created TileMap
Parameters
argsArguments for the TileMap

◆ operator=()

TileMap & Nz::TileMap::operator= ( const TileMap tileMap)
inline

Sets the current TileMap with the content of the other one.

Returns
A reference to this
Parameters
TileMapThe other TileMap

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