ASR::Building Class Reference

Class representing a Building belonging to a team. More...

#include <Building.h>

List of all members.

Public Member Functions

 Building (SceneNode *parentNode, String meshName, Vector3 position)
 Constructor.
 ~Building (void)
void scale (Real x, Real y, Real z)
 Scales the physical size of the building.
void translate (const Vector3 &vec)
 Moves the building, in relation to it's parents axis.
Vector3 getPosition ()
 Retrieves the position, in world coordinates?, of this building.
void setPosition (const Vector3 &pos)
 Sets the position of this building in relation to its parent.
void setDirection (const Vector3 &dir)
 Sets the direction this building is facing.
void setDirection (float x, float y, float z)
 Sets the direction this building is facing.

Private Attributes

String mName
 The unique ID name.
Entity * mEntity
 The physical appearance of this Building.
SceneNode * mNode
 The parent of this Building used for placement.

Static Private Attributes

static int mNumBuildings = 0


Detailed Description

Class representing a Building belonging to a team.

Remarks:
A Building can be used for many purposes such as the creation of units or for upgrading of weapons and defense.

Definition at line 30 of file Building.h.


Constructor & Destructor Documentation

ASR::Building::Building ( SceneNode *  parentNode,
String  meshName,
Vector3  position 
)

Constructor.

Parameters:
parentNode The node used for placing this Building.
meshName The name of the mesh used for the physical appearance
position The initial starting location of this Building

Definition at line 21 of file Building.cpp.

References ASR::Game::getSceneManager(), ASR::Level::getSingleton(), ASR::Game::getSingletonPtr(), mEntity, mName, mNode, mNumBuildings, and ASR::Level::occupyRegion().

00022         {
00023                 mNumBuildings++;
00024                 mName = "building_" + StringConverter::toString ( mNumBuildings );
00025 
00026                 SceneManager* sceneMgr = Game::getSingletonPtr ()->getSceneManager ();
00027 
00028                 mNode = parentNode->createChildSceneNode( mName + "_node" );
00029                 mEntity = sceneMgr->createEntity ( mName, meshName );
00030                 mNode->attachObject( mEntity );
00031 
00032                 mNode->translate ( position );
00033 
00034                 mNode->_updateBounds ();
00035                 AxisAlignedBox boundingBox = mNode->_getWorldAABB ();
00036                 Level::getSingleton ().occupyRegion ( boundingBox );
00037         }

ASR::Building::~Building ( void   ) 

Definition at line 41 of file Building.cpp.

00042         {
00043         }


Member Function Documentation

Vector3 ASR::Building::getPosition (  ) 

Retrieves the position, in world coordinates?, of this building.

Definition at line 78 of file Building.cpp.

References mNode.

00079         {
00080                 return mNode->getPosition ();
00081         }

void ASR::Building::scale ( Real  x,
Real  y,
Real  z 
)

Scales the physical size of the building.

Parameters:
x,y,z The size of the scales on the various axis.

Definition at line 47 of file Building.cpp.

References mNode.

00048         {
00049                 mNode->scale ( x, y, z );
00050         }

void ASR::Building::setDirection ( float  x,
float  y,
float  z 
)

Sets the direction this building is facing.

Parameters:
x 
y 
z The components that make up the "forward" vector.

Definition at line 99 of file Building.cpp.

References mNode.

00100         {
00101                 mNode->setDirection( x, y, z );
00102         }

void ASR::Building::setDirection ( const Vector3 &  dir  ) 

Sets the direction this building is facing.

Parameters:
dir The "forward" vector this building should face along.

Definition at line 92 of file Building.cpp.

References mNode.

00093         {
00094                 mNode->setDirection ( dir );
00095         }

void ASR::Building::setPosition ( const Vector3 &  pos  ) 

Sets the position of this building in relation to its parent.

Parameters:
pos The absolute position of this building in relation to its parent.

Definition at line 85 of file Building.cpp.

References mNode.

00086         {
00087                 mNode->setPosition ( pos );
00088         }

void ASR::Building::translate ( const Vector3 &  vec  ) 

Moves the building, in relation to it's parents axis.

Parameters:
vec A vector representing the amount of translation.

Definition at line 54 of file Building.cpp.

References ASR::BuildingPadding, ASR::Level::getSingleton(), mNode, ASR::Level::occupyRegion(), and ASR::Level::unoccupyRegion().

00055         {
00056                 Vector3 pad = Vector3(BuildingPadding, BuildingPadding, BuildingPadding );
00057 
00058                 // Unmark the nodes that this building was covering
00059                 mNode->_updateBounds ();
00060                 AxisAlignedBox boundingBox = mNode->_getWorldAABB ();
00061                 boundingBox.merge ( boundingBox.getMaximum () + pad );
00062                 boundingBox.merge ( boundingBox.getMinimum () - pad );
00063 
00064                 Level::getSingleton ().unoccupyRegion ( boundingBox );
00065 
00066                 mNode->translate ( vec );
00067 
00068                 // Mark the new nodes that this building covers
00069                 mNode->_updateBounds ();
00070                 boundingBox = mNode->_getWorldAABB ();
00071                 boundingBox.merge ( boundingBox.getMaximum () + pad );
00072                 boundingBox.merge ( boundingBox.getMinimum () - pad );
00073                 Level::getSingleton ().occupyRegion ( boundingBox );
00074         }


Member Data Documentation

Entity* ASR::Building::mEntity [private]

The physical appearance of this Building.

Definition at line 41 of file Building.h.

Referenced by Building().

String ASR::Building::mName [private]

The unique ID name.

Definition at line 38 of file Building.h.

Referenced by Building().

SceneNode* ASR::Building::mNode [private]

The parent of this Building used for placement.

Definition at line 44 of file Building.h.

Referenced by Building(), getPosition(), scale(), setDirection(), setPosition(), and translate().

int ASR::Building::mNumBuildings = 0 [static, private]

Definition at line 35 of file Building.h.

Referenced by Building().


The documentation for this class was generated from the following files:
Generated on Sun Jun 25 19:23:43 2006 for Valors End by  doxygen 1.4.7