ASR::TeamUpdater Class Reference

#include <TeamUpdater.h>

Inheritance diagram for ASR::TeamUpdater:

Inheritance graph
[legend]
Collaboration diagram for ASR::TeamUpdater:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TeamUpdater (Team *team)
 ~TeamUpdater (void)
bool updateAfterFrame (const Ogre::FrameEvent &e, const Ogre::InputReader *inputDevice)
bool updateBeforeFrame (const Ogre::FrameEvent &e, const Ogre::InputReader *inputDevice)

Private Attributes

TeammTeam
float mFadeTime

Detailed Description

Definition at line 16 of file TeamUpdater.h.


Constructor & Destructor Documentation

ASR::TeamUpdater::TeamUpdater ( Team team  ) 

Definition at line 24 of file TeamUpdater.cpp.

References mFadeTime.

00025                 : mTeam ( team )
00026         {
00027                 mFadeTime = 0.0f;
00028         }

ASR::TeamUpdater::~TeamUpdater ( void   ) 

Definition at line 32 of file TeamUpdater.cpp.

00033         {
00034         }


Member Function Documentation

bool ASR::TeamUpdater::updateAfterFrame ( const Ogre::FrameEvent &  e,
const Ogre::InputReader *  inputDevice 
)

Definition at line 69 of file TeamUpdater.cpp.

References ASR::TeamUnits::findTargets(), ASR::TeamUnits::getUnit(), mTeam, ASR::Team::mUnits, and ASR::TeamUnits::performAttacks().

00070         {
00071                 // Only find the targets after the frame has passed so that each unit
00072                 // from each team is now in their final positions
00073                 mTeam->mUnits->findTargets ();
00074                 mTeam->mUnits->performAttacks ();
00075 
00076                 // HACK
00077                 //              Fade units out
00078                 static float alpha = 1.0f;
00079                 alpha -= ( 1.0f / 5.0f ) * e.timeSinceLastFrame;
00080                 if ( alpha < 0.0f )
00081                         alpha = 1.0f;
00082 
00083                 Unit* unit = mTeam->mUnits->getUnit ( 0 );
00084                 MaterialPtr mat = unit->getEntity ()->getSubEntity (0)->getMaterial ();
00085                 //mat->getSupportedTechnique (0)->getPass(0)->setSceneBlending ( Ogre::SBT_ADD );
00086                 //mat->getSupportedTechnique (0)->getPass(0)->setDiffuse ( alpha, alpha, alpha, alpha );
00087                 //mat->getSupportedTechnique (0)->getPass(0)->setAmbient ( alpha, alpha, alpha );
00088 
00089 
00090                 
00091                 /*
00092                 unsigned short i = 0, j;
00093                 ColourValue sc, dc; // Source colur, destination colour
00094                 Material::TechniqueIterator techniqueIt = mat->getTechniqueIterator ();
00095                 while (techniqueIt.hasMoreElements ())
00096                 {
00097                         Technique *t = techniqueIt.getNext ();
00098                         Technique::PassIterator passIt = t->getPassIterator ();
00099                         j = 0;
00100                         while (passIt.hasMoreElements ())
00101                         {
00102                                 sc = mat->getTechnique (i)->getPass (j)->getDiffuse ();
00103 
00104                                 Ogre::SceneBlendType mSBT = SBT_TRANSPARENT_ALPHA;
00105 
00106                                 switch (mSBT)
00107                                 {
00108                                 case SBT_ADD:
00109                                         dc = sc;
00110                                         dc.r -= sc.r * alpha;
00111                                         dc.g -= sc.g * alpha;
00112                                         dc.b -= sc.b * alpha;
00113                                         passIt.peekNext ()->setAmbient (ColourValue::Black);
00114                                         break;
00115                                 case SBT_TRANSPARENT_ALPHA:
00116                                 default:
00117                                         dc = sc;
00118                                         dc.a = sc.a * (1.0f - alpha);
00119                                         passIt.peekNext ()->setAmbient (mat->getTechnique (i)->getPass (j)->getAmbient ());
00120                                         break;
00121                                 }
00122                                 passIt.peekNext ()->setDiffuse (dc);
00123                                 passIt.moveNext ();
00124 
00125                                 ++j;
00126                         }
00127 
00128                         ++i;
00129                 }
00130                 */
00131                 
00132 
00133                 return true;
00134         }

bool ASR::TeamUpdater::updateBeforeFrame ( const Ogre::FrameEvent &  e,
const Ogre::InputReader *  inputDevice 
)

Definition at line 38 of file TeamUpdater.cpp.

References ASR::TeamUnits::animateUnits(), ASR::FogOfWar::fadeOut(), ASR::Team::getUnitIterator(), mFadeTime, ASR::Team::mFogOfWar, ASR::TeamUnits::moveUnits(), mTeam, ASR::Team::mUnits, ASR::FogOfWar::setVisible(), ASR::TeamUnits::updateSpatialGrid(), and ASR::FogOfWar::updateTexture().

00039         {
00040                 mTeam->mUnits->animateUnits( e.timeSinceLastFrame );
00041                 mTeam->mUnits->moveUnits ( e.timeSinceLastFrame );
00042 
00043                 mTeam->mUnits->updateSpatialGrid ();
00044 
00045                 // TODO
00046                 //              Make some constants for the timeToFadeOneUnit
00047                 // Update the fog of war
00048                 mFadeTime += e.timeSinceLastFrame;
00049                 if ( mFadeTime >= 0.05f )
00050                 {
00051                         mTeam->mFogOfWar->fadeOut ();
00052                         mFadeTime -= 0.05f;
00053                 }
00054 
00055                 TeamUnits::UnitIterator iter = mTeam->getUnitIterator ();
00056                 while ( iter.hasMoreElements () )
00057                 {
00058                         Unit* unit = iter.getNext ();
00059                         if ( !unit->isDead () )
00060                                 mTeam->mFogOfWar->setVisible ( unit->getPosition().x, unit->getPosition().z, unit->getSightRadius () );
00061                 }
00062                 mTeam->mFogOfWar->updateTexture ();
00063 
00064                 return true;
00065         }


Member Data Documentation

float ASR::TeamUpdater::mFadeTime [private]

Definition at line 22 of file TeamUpdater.h.

Referenced by TeamUpdater(), and updateBeforeFrame().

Team* ASR::TeamUpdater::mTeam [private]

Definition at line 21 of file TeamUpdater.h.

Referenced by updateAfterFrame(), and updateBeforeFrame().


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