Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

Eris::TerrainMod Class Reference

Wrapper class that envelopes a Mercator::TerrainMod. This class is mainly responsible for parsing atlas data and create or update an instance of Mercator::TerrainMod with the correct data. The actual application of the Mercator::TerrainMod to the terrain and the subsequent update of the rendering display (i.e. the Ogre terrain) is handled mainly by TerrainGenerator, which reacts to the events emitted by this class whenever a terrain mod changes or is moved. After you've created an instance of this you must call the init() method. More...

#include <TerrainMod.h>

List of all members.

Public Member Functions

 TerrainMod (Entity *entity)
 Ctor.
virtual ~TerrainMod ()
 Dtor.
virtual bool init (bool alwaysObserve=false)
 Sets up the observation of the entity, and parses the mod info, creating the initial mod instance.
Mercator::TerrainMod * getMod () const
 Used to retrieve a pointer to this modifier.
EntitygetEntity () const
 Accessor for the entity to which this terrain mod belongs.

Public Attributes

sigc::signal< void > ModChanged
 Emitted whenever the modifier is changed or moved.
sigc::signal< void > ModDeleted
 Emitted just before the entity owning this mod is deleted.

Protected Member Functions

virtual void onModChanged ()
 Called before the ModChanged signal is emitted.
virtual void onModDeleted ()
 Called before the ModDeleted signal is emitted.
void attributeChanged (const Atlas::Message::Element &attributeValue)
 Called whenever a modifier is changed and handles the update.
void entity_Moved ()
 Called whenever a modifier is moved and handles the update.
void entity_Deleted ()
 Called whenever the entity holding a modifier is deleted and handles removing the mod from the terrain.
virtual void observeEntity ()
 Sets up the previous three handler functions to be called when a change is made to the entity holding the modifier.
virtual bool parseMod ()
 Parses the Atlas data for a modifier.
virtual void reparseMod ()
 If an existing mod changes we need to reparse it.

Protected Attributes

EntitymEntity
 The owner of this modifier.
Entity::AttrChangedSlot mAttrChangedSlot
 Slot used to listen for changes to attributes in the Entity to which this mod belongs to.
InnerTerrainModmInnerMod
 The inner terrain mod instance which holds the actual Mercator::TerrainMod instance and handles the parsing of it.

Detailed Description

Wrapper class that envelopes a Mercator::TerrainMod. This class is mainly responsible for parsing atlas data and create or update an instance of Mercator::TerrainMod with the correct data. The actual application of the Mercator::TerrainMod to the terrain and the subsequent update of the rendering display (i.e. the Ogre terrain) is handled mainly by TerrainGenerator, which reacts to the events emitted by this class whenever a terrain mod changes or is moved. After you've created an instance of this you must call the init() method.

Author:
Tamas Bates
Erik Hjortsberg

Constructor & Destructor Documentation

Eris::TerrainMod::TerrainMod ( Entity entity  ) 

Ctor.

Parameters:
entity The entity to which this mod belongs.

Member Function Documentation

void Eris::TerrainMod::attributeChanged ( const Atlas::Message::Element &  attributeValue  )  [protected]

Called whenever a modifier is changed and handles the update.

Parameters:
attributeValue The new Atlas data for the terrain mod
Entity * Eris::TerrainMod::getEntity (  )  const

Accessor for the entity to which this terrain mod belongs.

Returns:
A pointer to the entity to which this terrain mod belongs.
Mercator::TerrainMod * Eris::TerrainMod::getMod (  )  const [inline]

Used to retrieve a pointer to this modifier.

Returns:
a pointer to this modifier

References Eris::InnerTerrainMod::getModifier(), and mInnerMod.

bool Eris::TerrainMod::init ( bool  alwaysObserve = false  )  [virtual]

Sets up the observation of the entity, and parses the mod info, creating the initial mod instance.

Parameters:
alwaysObserve If set to true, the observation of the entity will be set up even if the parsing failed. If false however, if there was an error during the parsing no observation will be set up. The calling code is then expected to delete this instance.
Returns:
True if the atlas data was conformant and successfully parsed.
bool Eris::TerrainMod::parseMod (  )  [protected, virtual]

Parses the Atlas data for a modifier.

Returns:
True if it was able to successfully create a Mercator::TerrainMod, False otherwise All work specific to a certain kind of TerrainMod is handled by the functions below.

Don't log anything since it's expected that instances of this can be attached to entities where not terrainmod is present.

References observeEntity().

void Eris::TerrainMod::reparseMod (  )  [protected, virtual]

If an existing mod changes we need to reparse it.

Call this method in those cases. If there's already an existing mod, that will be deleted. If the changes to the entity results in an invalid parsing, the Deleted signal will be emitted. If the parsing was successful however the Changed signal will be emitted.

If the parsing failed and there was an old mod, we need to temporarily set the inner mod to the old one while we emit the deleted event.

Referenced by entity_Deleted(), and entity_Moved().


Member Data Documentation

The inner terrain mod instance which holds the actual Mercator::TerrainMod instance and handles the parsing of it.

In order to be able to better support different types of mods the actual instance will be any of the subclasses of InnerTerrainMod, depending on the type of the mod.

Referenced by getMod(), and observeEntity().

sigc::signal<void> Eris::TerrainMod::ModChanged

Emitted whenever the modifier is changed or moved.

Should be caught by a listener to apply the change to the terrain.

sigc::signal<void> Eris::TerrainMod::ModDeleted

Emitted just before the entity owning this mod is deleted.

Should be caught by a listener to remove this mod from the terrain.

Referenced by onModChanged().


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