gZone Class Reference

basic zone class: handles rendering and entwork syncing More...

#include <gWinZone.h>

Inheritance diagram for gZone:

Inheritance graph
[legend]
Collaboration diagram for gZone:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 gZone (eGrid *grid, const eCoord &pos)
 local constructor
 gZone (nMessage &m)
 network constructor
 ~gZone ()
 destructor
void SetReferenceTime ()
 sets the reference time to the current time
gZoneSetPosition (eCoord const &position)
 Sets the current position.
eCoord GetPosition (void) const
 Gets the current position.
gZone const & GetPosition (eCoord &position) const
 Gets the current position.
gZoneSetVelocity (eCoord const &velocity)
 Sets the current velocity.
eCoord GetVelocity (void) const
 Gets the current velocity.
gZone const & GetVelocity (eCoord &velocity) const
 Gets the current velocity.
gZoneSetRadius (REAL radius)
 Sets the current radius.
REAL GetRadius (void) const
 Gets the current radius.
gZone const & GetRadius (REAL &radius) const
 Gets the current radius.
gZoneSetExpansionSpeed (REAL expansionSpeed)
 Sets the current expansion speed.
REAL GetExpansionSpeed (void) const
 Gets the current expansion speed.
gZone const & GetExpansionSpeed (REAL &expansionSpeed) const
 Gets the current expansion speed.
gZoneSetRotationSpeed (REAL rotationSpeed)
 Sets the current rotation speed.
REAL GetRotationSpeed (void) const
 Gets the current rotation speed.
tCoord const & GetRotation (void) const
 Gets the current rotation state.
gZone const & GetRotationSpeed (REAL &rotationSpeed) const
 Gets the current rotation speed.
gZoneSetRotationAcceleration (REAL rotationAcceleration)
 Sets the current acceleration of the rotation.
REAL GetRotationAcceleration (void) const
 Gets the current acceleration of the rotation.
gZone const & GetRotationAcceleration (REAL &rotationAcceleration) const
 Gets the current acceleration of the rotation.
rColor const & GetColor (void) const
 Gets the current color.

Protected Member Functions

virtual bool Timestep (REAL currentTime)
 simulates behaviour up to currentTime
virtual void OnVanish ()
 called when the zone vanishes

Protected Attributes

rColor color_
 the zone's color
REAL createTime_
 the time the zone was created at
REAL referenceTime_
 reference time for function evaluations
tFunction posx_
 time dependence of x component of position
tFunction posy_
 time dependence of y component of position
tFunction radius_
 time dependence of radius
tFunction rotationSpeed_
 the zone's rotation speed
eCoord rotation_
 the current rotation state

Private Member Functions

virtual void WriteCreate (nMessage &m)
 writes data for network constructor
virtual void WriteSync (nMessage &m)
 writes sync data
virtual void ReadSync (nMessage &m)
 reads sync data
virtual void InteractWith (eGameObject *target, REAL time, int recursion=1)
 looks for objects inzide the zone and reacts on them
virtual void OnEnter (gCycle *target, REAL time)
 reacts on objects inside the zone
virtual nDescriptorCreatorDescriptor () const
 returns the descriptor to recreate this object over the network
REAL Radius () const
 returns the current radius
virtual void Render (const eCamera *cam)
 renders the zone
virtual void Render2D (tCoord scale) const
 renders the zone
virtual bool RendersAlpha () const
 returns whether the rendering uses alpha blending (massively, so sorting errors would show)
REAL EvaluateFunctionNow (tFunction const &f) const
 evaluates the given function with lastTime - referenceTime_ as argument
void SetFunctionNow (tFunction &f, REAL value) const
 makes sure EvaluateFunctionNow() returns the given value


Detailed Description

basic zone class: handles rendering and entwork syncing

Definition at line 51 of file gWinZone.h.


Constructor & Destructor Documentation

gZone::gZone ( eGrid grid,
const eCoord &  pos 
)

local constructor

Parameters:
grid Grid to put the zone into
pos Position to spawn the zone at

Definition at line 131 of file gWinZone.cpp.

References eGameObject::AddToList(), createTime_, eSoundMixer::GetMixer(), eGameObject::lastTime, eSoundMixer::PushButton(), referenceTime_, SetPosition(), sg_Zones, and ZONE_SPAWN.

00132         :eNetGameObject( grid, pos, eCoord( 0,0 ), NULL, true ), rotation_(1,0)
00133 {
00134     // store creation time
00135     referenceTime_ = createTime_ = lastTime = 0;
00136 
00137     // add to game grid
00138     this->AddToList();
00139 
00140     sg_Zones.push_back(this);
00141 
00142     // initialize position functions
00143     SetPosition( pos );
00144     eSoundMixer* mixer = eSoundMixer::GetMixer();
00145     mixer->PushButton(ZONE_SPAWN, pos);
00146 }

Here is the call graph for this function:

gZone::gZone ( nMessage m  ) 

network constructor

Parameters:
m Message to read creation data from

Definition at line 158 of file gWinZone.cpp.

References eGameObject::AddToList(), tColor::b_, color_, createTime_, tColor::g_, eSoundMixer::GetMixer(), eGameObject::lastTime, eGameObject::pos, eSoundMixer::PushButton(), tColor::r_, referenceTime_, SetPosition(), sg_Zones, and ZONE_SPAWN.

00159         :eNetGameObject( m ), rotation_(1,0)
00160 {
00161     // read creation time
00162     m >> createTime_;
00163     referenceTime_ = lastTime = createTime_;
00164 
00165     // initialize color to white, ReadSync will fill in the true value if available
00166     color_.r_ = color_.g_ = color_.b_ = 1.0f;
00167 
00168     // add to game grid
00169     this->AddToList();
00170 
00171     sg_Zones.push_back(this);
00172 
00173     // initialize position functions
00174     SetPosition( pos );
00175     eSoundMixer* mixer = eSoundMixer::GetMixer();
00176     mixer->PushButton(ZONE_SPAWN, pos);
00177 }

Here is the call graph for this function:

gZone::~gZone ( void   ) 

destructor

Definition at line 188 of file gWinZone.cpp.

References sg_Zones.

00189 {
00190     sg_Zones.erase(
00191         std::find_if(
00192             sg_Zones.begin(),
00193             sg_Zones.end(),
00194             std::bind2nd(
00195                 std::equal_to<gZone *>(),
00196                 this)
00197         )
00198     );
00199 }


Member Function Documentation

void gZone::SetReferenceTime ( void   ) 

sets the reference time to the current time

Definition at line 1429 of file gWinZone.cpp.

References EvaluateFunctionNow(), eGameObject::lastTime, posx_, posy_, radius_, referenceTime_, rotationSpeed_, and tFunction::SetOffset().

Referenced by gWinZoneHack::OnEnter(), sg_CreateWinDeathZone(), and gBaseZoneHack::Timestep().

01430 {
01431     // set offsets to current values
01432     this->posx_.SetOffset( EvaluateFunctionNow( this->posx_ ) );
01433     this->posy_.SetOffset( EvaluateFunctionNow( this->posy_ ) );
01434     this->radius_.SetOffset( EvaluateFunctionNow( this->radius_ ) );
01435     this->rotationSpeed_.SetOffset( EvaluateFunctionNow( this->rotationSpeed_ ) );
01436 
01437     // reset time
01438     this->referenceTime_ = lastTime;
01439 }

Here is the call graph for this function:

Here is the caller graph for this function:

gZone & gZone::SetPosition ( eCoord const &  position  ) 

Sets the current position.

Parameters:
position the current position to set
Returns:
A reference to this to allow chaining

Definition at line 1243 of file gWinZone.cpp.

References posx_, posy_, and SetFunctionNow().

Referenced by gZone(), ReadSync(), and SetVelocity().

01244 {
01245     SetFunctionNow( posx_, position.x );
01246     SetFunctionNow( posy_, position.y );
01247     return *this;
01248 }

Here is the call graph for this function:

Here is the caller graph for this function:

eCoord gZone::GetPosition ( void   )  const

Gets the current position.

Returns:
the current position

Definition at line 1207 of file gWinZone.cpp.

References eCoord.

Referenced by SetVelocity().

01208 {
01209     eCoord ret;
01210     GetPosition( ret );
01211     return ret;
01212 }

Here is the caller graph for this function:

gZone const & gZone::GetPosition ( eCoord &  position  )  const

Gets the current position.

Parameters:
position the current position to fill
Returns:
A reference to this to allow chaining

Definition at line 1225 of file gWinZone.cpp.

References EvaluateFunctionNow(), posx_, and posy_.

01226 {
01227     position.x = EvaluateFunctionNow( posx_ );
01228     position.y = EvaluateFunctionNow( posy_ );
01229     return *this;
01230 }

Here is the call graph for this function:

gZone & gZone::SetVelocity ( eCoord const &  velocity  ) 

Sets the current velocity.

Parameters:
velocity the current velocity to set
Returns:
A reference to this to allow chaining

Definition at line 1298 of file gWinZone.cpp.

References eCoord, GetPosition(), eGameObject::pos, posx_, posy_, SetPosition(), and tFunction::SetSlope().

Referenced by ReadSync().

01299 {
01300     // backup position
01301     eCoord pos;
01302     GetPosition( pos );
01303 
01304     posx_.SetSlope( velocity.x );
01305     posy_.SetSlope( velocity.y );
01306 
01307     // restore position
01308     SetPosition( pos );
01309 
01310     return *this;
01311 }

Here is the call graph for this function:

Here is the caller graph for this function:

eCoord gZone::GetVelocity ( void   )  const

Gets the current velocity.

Returns:
the current velocity

Definition at line 1260 of file gWinZone.cpp.

References eCoord.

01261 {
01262     eCoord ret;
01263     GetVelocity( ret );
01264 
01265     return ret;
01266 }

gZone const & gZone::GetVelocity ( eCoord &  velocity  )  const

Gets the current velocity.

Parameters:
velocity the current velocity to fill
Returns:
A reference to this to allow chaining

Definition at line 1279 of file gWinZone.cpp.

References tFunction::GetSlope(), posx_, and posy_.

01280 {
01281     velocity.x = posx_.GetSlope();
01282     velocity.y = posy_.GetSlope();
01283 
01284     return *this;
01285 }

Here is the call graph for this function:

gZone & gZone::SetRadius ( REAL  radius  ) 

Sets the current radius.

Parameters:
radius the current radius to set
Returns:
A reference to this to allow chaining

Definition at line 1360 of file gWinZone.cpp.

References SetFunctionNow().

Referenced by gParser::parseZoneArthemis_v1(), SetExpansionSpeed(), and sg_CreateWinDeathZone().

01361 {
01362     SetFunctionNow( this->radius_, radius );
01363 
01364     return *this;
01365 }

Here is the call graph for this function:

Here is the caller graph for this function:

REAL gZone::GetRadius ( void   )  const

Gets the current radius.

Returns:
the current radius

Definition at line 1323 of file gWinZone.cpp.

References EvaluateFunctionNow(), and REAL.

Referenced by GetRadius(), gWinZoneHack::OnEnter(), Radius(), gBaseZoneHack::Timestep(), and Timestep().

01324 {
01325     REAL ret = EvaluateFunctionNow( this->radius_ );
01326     ret = ret > 0 ? ret : 0;
01327 
01328     return ret;
01329 }

Here is the call graph for this function:

Here is the caller graph for this function:

gZone const & gZone::GetRadius ( REAL radius  )  const

Gets the current radius.

Parameters:
radius the current radius to fill
Returns:
A reference to this to allow chaining

Definition at line 1342 of file gWinZone.cpp.

References GetRadius().

01343 {
01344     radius = GetRadius();
01345 
01346     return *this;
01347 }

Here is the call graph for this function:

gZone & gZone::SetExpansionSpeed ( REAL  expansionSpeed  ) 

Sets the current expansion speed.

Parameters:
expansionSpeed the current expansion speed to set
Returns:
A reference to this to allow chaining

Definition at line 1411 of file gWinZone.cpp.

References EvaluateFunctionNow(), radius_, REAL, SetRadius(), and tFunction::SetSlope().

Referenced by gWinZoneHack::OnEnter(), gParser::parseZoneArthemis_v1(), sg_CreateWinDeathZone(), and gBaseZoneHack::Timestep().

01412 {
01413     REAL r = EvaluateFunctionNow( this->radius_ );
01414     this->radius_.SetSlope( expansionSpeed );
01415     SetRadius( r );
01416 
01417     return *this;
01418 }

Here is the call graph for this function:

Here is the caller graph for this function:

REAL gZone::GetExpansionSpeed ( void   )  const

Gets the current expansion speed.

Returns:
the current expansion speed

Definition at line 1377 of file gWinZone.cpp.

References tFunction::GetSlope(), and radius_.

Referenced by gWinZoneHack::OnEnter(), and Timestep().

01378 {
01379     return this->radius_.GetSlope();
01380 }

Here is the call graph for this function:

Here is the caller graph for this function:

gZone const & gZone::GetExpansionSpeed ( REAL expansionSpeed  )  const

Gets the current expansion speed.

Parameters:
expansionSpeed the current expansion speed to fill
Returns:
A reference to this to allow chaining

Definition at line 1393 of file gWinZone.cpp.

References tFunction::GetSlope(), and radius_.

01394 {
01395     expansionSpeed = this->radius_.GetSlope();
01396 
01397     return *this;
01398 }

Here is the call graph for this function:

gZone & gZone::SetRotationSpeed ( REAL  rotationSpeed  ) 

Sets the current rotation speed.

Parameters:
rotationSpeed The current rotation speed to set
Returns:
A reference to this to allow chaining

Definition at line 1499 of file gWinZone.cpp.

References SetFunctionNow().

Referenced by gParser::parseZoneArthemis_v1(), ReadSync(), SetRotationAcceleration(), sg_CreateWinDeathZone(), and gBaseZoneHack::Timestep().

01500 {
01501     SetFunctionNow( this->rotationSpeed_, rotationSpeed );
01502     return *this;
01503 }

Here is the call graph for this function:

Here is the caller graph for this function:

REAL gZone::GetRotationSpeed ( void   )  const

Gets the current rotation speed.

Returns:
The current rotation speed

Definition at line 1451 of file gWinZone.cpp.

References EvaluateFunctionNow(), and rotationSpeed_.

Referenced by GetRotationSpeed(), SetRotationAcceleration(), gBaseZoneHack::Timestep(), and Timestep().

01452 {
01453     return EvaluateFunctionNow( rotationSpeed_ );
01454 }

Here is the call graph for this function:

Here is the caller graph for this function:

tCoord const & gZone::GetRotation ( void   )  const

Gets the current rotation state.

Returns:
The current rotation position, as normalized x and y coordinates

Definition at line 1466 of file gWinZone.cpp.

References rotation_.

01467 {
01468     return rotation_;
01469 }

gZone const & gZone::GetRotationSpeed ( REAL rotationSpeed  )  const

Gets the current rotation speed.

Parameters:
rotationSpeed The current rotation speed to fill
Returns:
A reference to this to allow chaining

Definition at line 1482 of file gWinZone.cpp.

References GetRotationSpeed().

01483 {
01484     rotationSpeed = this->GetRotationSpeed();
01485     return *this;
01486 }

Here is the call graph for this function:

gZone & gZone::SetRotationAcceleration ( REAL  rotationAcceleration  ) 

Sets the current acceleration of the rotation.

Parameters:
rotationAcceleration the current acceleration of the rotation to set
Returns:
A reference to this to allow chaining

Definition at line 1563 of file gWinZone.cpp.

References GetRotationSpeed(), REAL, rotationSpeed_, SetRotationSpeed(), and tFunction::SetSlope().

Referenced by ReadSync(), and gBaseZoneHack::Timestep().

01564 {
01565     REAL omega = this->GetRotationSpeed();
01566     this->rotationSpeed_.SetSlope( rotationAcceleration );
01567     SetRotationSpeed( omega );
01568 
01569     return *this;
01570 }

Here is the call graph for this function:

Here is the caller graph for this function:

REAL gZone::GetRotationAcceleration ( void   )  const

Gets the current acceleration of the rotation.

Returns:
the current acceleration of the rotation

Definition at line 1515 of file gWinZone.cpp.

References tFunction::GetSlope(), and rotationSpeed_.

Referenced by GetRotationAcceleration(), and gBaseZoneHack::Timestep().

01516 {
01517     return this->rotationSpeed_.GetSlope();
01518 }

Here is the call graph for this function:

Here is the caller graph for this function:

gZone const & gZone::GetRotationAcceleration ( REAL rotationAcceleration  )  const

Gets the current acceleration of the rotation.

Parameters:
rotationAcceleration the current acceleration of the rotation to fill
Returns:
A reference to this to allow chaining

Definition at line 1531 of file gWinZone.cpp.

References GetRotationAcceleration().

01532 {
01533     rotationAcceleration = this->GetRotationAcceleration();
01534     return *this;
01535 }

Here is the call graph for this function:

rColor const & gZone::GetColor ( void   )  const

Gets the current color.

Returns:
the current color of the zone

Definition at line 1547 of file gWinZone.cpp.

References color_.

01548 {
01549     return color_;
01550 }

bool gZone::Timestep ( REAL  time  )  [protected, virtual]

simulates behaviour up to currentTime

Parameters:
time the current time

Reimplemented from eNetGameObject.

Reimplemented in gBaseZoneHack.

Definition at line 315 of file gWinZone.cpp.

References cos(), dt, eCoord, GetExpansionSpeed(), GetRadius(), GetRotationSpeed(), eGameObject::lastTime, eGameObject::Move(), OnVanish(), posx_, posy_, REAL, referenceTime_, rotation_, and sin().

Referenced by gBaseZoneHack::Timestep().

00316 {
00317     // rotate
00318     REAL speed = GetRotationSpeed();
00319     REAL angle = ( time - lastTime ) * speed;
00320     // angle /= ( 1 + 2 * 3.14159 * angle/sg_segments );
00321     rotation_ = rotation_.Turn( cos( angle ), sin( angle ) );
00322 
00323     // move to new position
00324     REAL dt = time - referenceTime_;
00325     Move( eCoord( posx_( dt ), posy_( dt ) ), lastTime, time );
00326 
00327     // update time
00328     lastTime = time;
00329 
00330     // kill this zone if it shrunk down to zero radius
00331     if ( GetExpansionSpeed() < 0 && GetRadius() <= 0 )
00332     {
00333         OnVanish();
00334         return true;
00335     }
00336 
00337     return false;
00338 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gZone::OnVanish ( void   )  [protected, virtual]

called when the zone vanishes

Reimplemented in gBaseZoneHack.

Definition at line 349 of file gWinZone.cpp.

Referenced by Timestep().

00350 {
00351 }

Here is the caller graph for this function:

void gZone::WriteCreate ( nMessage m  )  [private, virtual]

writes data for network constructor

Parameters:
m Message to write creation data to

Reimplemented from eNetGameObject.

Definition at line 211 of file gWinZone.cpp.

References createTime_, and eNetGameObject::WriteCreate().

00212 {
00213     // delegate
00214     eNetGameObject::WriteCreate( m );
00215 
00216     m << createTime_;
00217 }

Here is the call graph for this function:

void gZone::WriteSync ( nMessage m  )  [private, virtual]

writes sync data

Parameters:
m Message to write sync data to

Reimplemented from eNetGameObject.

Definition at line 229 of file gWinZone.cpp.

References tColor::b_, color_, tColor::g_, posx_, posy_, tColor::r_, radius_, referenceTime_, rotationSpeed_, and eNetGameObject::WriteSync().

00230 {
00231     // delegate
00232     eNetGameObject::WriteSync( m );
00233 
00234     // write color
00235     m << color_.r_;
00236     m << color_.g_;
00237     m << color_.b_;
00238 
00239     // write reference time and functions
00240     m << referenceTime_;
00241     m << posx_;
00242     m << posy_;
00243     m << radius_;
00244 
00245     // write rotation speed
00246     m << rotationSpeed_;
00247 }

Here is the call graph for this function:

void gZone::ReadSync ( nMessage m  )  [private, virtual]

reads sync data

Parameters:
m Message to read sync data from

Reimplemented from eNetGameObject.

Definition at line 259 of file gWinZone.cpp.

References tColor::b_, color_, createTime_, eCoord, nMessage::End(), tColor::g_, eGameObject::pos, posx_, posy_, tColor::r_, radius_, eNetGameObject::ReadSync(), referenceTime_, rotationSpeed_, se_MakeColorValid(), tFunction::SetOffset(), SetPosition(), SetRotationAcceleration(), SetRotationSpeed(), tFunction::SetSlope(), SetVelocity(), sg_expansionSpeed, and sg_initialSize.

00260 {
00261     // delegage
00262     eNetGameObject::ReadSync( m );
00263 
00264     // read color
00265     if (!m.End())
00266     {
00267         m >> color_.r_;
00268         m >> color_.g_;
00269         m >> color_.b_;
00270         se_MakeColorValid(color_.r_, color_.g_, color_.b_, 1.0f);
00271     }
00272 
00273     // read reference time and functions
00274     if (!m.End())
00275     {
00276         m >> referenceTime_;
00277         m >> posx_;
00278         m >> posy_;
00279         m >> radius_;
00280     }
00281     else
00282     {
00283         referenceTime_ = createTime_;
00284 
00285         // take old default values
00286         this->radius_.SetOffset( sg_initialSize );
00287         this->radius_.SetSlope( sg_expansionSpeed );
00288         SetPosition( pos );
00289         SetVelocity( eCoord() );
00290     }
00291 
00292     // read rotation speed
00293     if (!m.End())
00294     {
00295         m >> rotationSpeed_;
00296     }
00297     else
00298     {
00299         // set fixed values
00300         SetRotationSpeed( .3f );
00301         SetRotationAcceleration( 0.0f );
00302     }
00303 }

Here is the call graph for this function:

void gZone::InteractWith ( eGameObject target,
REAL  time,
int  recursion = 1 
) [private, virtual]

looks for objects inzide the zone and reacts on them

Parameters:
target the other game object
time the current time
recursion if set to true, don't recurse into other InteractWith functions (quite silly now that I think about it...)

Reimplemented from eGameObject.

Definition at line 365 of file gWinZone.cpp.

References gCycleMovement::Alive(), OnEnter(), eNetGameObject::Player(), eGameObject::Position(), Radius(), and REAL.

00366 {
00367     gCycle* prey = dynamic_cast< gCycle* >( target );
00368     if ( prey )
00369     {
00370         REAL r = this->Radius();
00371         if ( ( prey->Position() - this->Position() ).NormSquared() < r*r )
00372         {
00373             if ( prey->Player() && prey->Alive() )
00374             {
00375                 OnEnter( prey, time );
00376             }
00377         }
00378     }
00379 }

Here is the call graph for this function:

void gZone::OnEnter ( gCycle target,
REAL  time 
) [private, virtual]

reacts on objects inside the zone

Parameters:
target the cycle that has been found inside the zone
time the current time

Reimplemented in gWinZoneHack, gDeathZoneHack, and gBaseZoneHack.

Definition at line 392 of file gWinZone.cpp.

Referenced by InteractWith().

00393 {
00394 }

Here is the caller graph for this function:

nDescriptor & gZone::CreatorDescriptor ( void   )  const [private, virtual]

returns the descriptor to recreate this object over the network

Returns:

Implements nNetObject.

Definition at line 409 of file gWinZone.cpp.

References zone_init.

00410 {
00411     return zone_init;
00412 }

REAL gZone::Radius ( void   )  const [private]

returns the current radius

Returns:

Definition at line 424 of file gWinZone.cpp.

References GetRadius().

Referenced by InteractWith(), Render(), and Render2D().

00425 {
00426     return GetRadius();
00427 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gZone::Render ( const eCamera cam  )  [private, virtual]

renders the zone

Parameters:
cam the camera used for rendering

Reimplemented from eGameObject.

Definition at line 439 of file gWinZone.cpp.

References a, tColor::a_, rColor::Apply(), b, BeginLineStrip(), BeginQuads(), color_, cos(), createTime_, eGameObject::lastTime, ModelMatrix(), eGameObject::pos, Radius(), REAL, RenderEnd(), rotation_, sg_segments, sin(), and sr_alphaBlend.

00440 {
00441 #ifndef DEDICATED
00442 
00443     color_.a_ = ( lastTime - createTime_ ) * .2f;
00444     if ( color_.a_ > .7f )
00445         color_.a_ = .7f;
00446     if ( color_.a_ <= 0 )
00447         return;
00448 
00449     GLfloat m[4][4]={{rotation_.x,rotation_.y,0,0},
00450                      {-rotation_.y,rotation_.x,0,0},
00451                      {0,0,1,0},
00452                      {pos.x,pos.y,0,1}};
00453 
00454     ModelMatrix();
00455     glPushMatrix();
00456 
00457     glDisable(GL_LIGHT0);
00458     glDisable(GL_LIGHT1);
00459     glDisable(GL_LIGHTING);
00460     glDisable(GL_CULL_FACE);
00461     glDepthMask(GL_FALSE);
00462     glBlendFunc( GL_SRC_ALPHA, GL_ONE );
00463 
00464     //glDisable(GL_TEXTURE);
00465     glDisable(GL_TEXTURE_2D);
00466 
00467     //  glTranslatef(pos.x,pos.y,0);
00468 
00469     glMultMatrixf(&m[0][0]);
00470     //  glScalef(.5,.5,.5);
00471 
00472     if ( sr_alphaBlend )
00473         BeginQuads();
00474     else
00475         BeginLineStrip();
00476 
00477     const REAL seglen = .2f;
00478     const REAL bot = 0.0f;
00479     const REAL top = 5.0f; // + ( lastTime - createTime_ ) * .1f;
00480 
00481     color_.Apply();
00482 
00483     REAL r = Radius();
00484     for ( int i = sg_segments - 1; i>=0; --i )
00485     {
00486         REAL a = i * 2 * 3.14159 / REAL( sg_segments );
00487         REAL b = a + seglen;
00488 
00489         REAL sa = r * sin(a);
00490         REAL ca = r * cos(a);
00491         REAL sb = r * sin(b);
00492         REAL cb = r * cos(b);
00493 
00494         glVertex3f(sa, ca, bot);
00495         glVertex3f(sa, ca, top);
00496         glVertex3f(sb, cb, top);
00497         glVertex3f(sb, cb, bot);
00498 
00499         if ( !sr_alphaBlend )
00500         {
00501             glVertex3f(sa, ca, bot);
00502             RenderEnd();
00503             BeginLineStrip();
00504         }
00505     }
00506 
00507     RenderEnd();
00508 
00509     glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
00510     glDepthMask(GL_TRUE);
00511 
00512     glPopMatrix();
00513 #endif
00514 }

Here is the call graph for this function:

void gZone::Render2D ( tCoord  scale  )  const [private, virtual]

renders the zone

Reimplemented from eGameObject.

Definition at line 516 of file gWinZone.cpp.

References a, tColor::a_, rColor::Apply(), b, BeginLines(), color_, cos(), ModelMatrix(), eGameObject::pos, Radius(), REAL, RenderEnd(), rotation_, sg_segments, and sin().

00516                                  {
00517 #ifndef DEDICATED
00518     if ( color_.a_ <= 0 )
00519         return;
00520 
00521     GLfloat m[4][4]={{rotation_.x,rotation_.y,0,0},
00522                      {-rotation_.y,rotation_.x,0,0},
00523                      {0,0,1,0},
00524                      {pos.x,pos.y,0,1}};
00525 
00526     ModelMatrix();
00527     glPushMatrix();
00528 
00529     glMultMatrixf(&m[0][0]);
00530     //  glScalef(.5,.5,.5);
00531 
00532     BeginLines();
00533 
00534     const REAL seglen = .2f;
00535 
00536     color_.Apply();
00537 
00538     REAL r = Radius();
00539     for ( int i = sg_segments - 1; i>=0; --i )
00540     {
00541         REAL a = i * 2 * 3.14159 / REAL( sg_segments );
00542         REAL b = a + seglen;
00543 
00544         REAL sa = r * sin(a);
00545         REAL ca = r * cos(a);
00546         REAL sb = r * sin(b);
00547         REAL cb = r * cos(b);
00548 
00549         glVertex2f(sa, ca);
00550         glVertex2f(sb, cb);
00551     }
00552 
00553     RenderEnd();
00554 
00555     glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
00556     glDepthMask(GL_TRUE);
00557 
00558     glPopMatrix();
00559 #endif
00560 }

Here is the call graph for this function:

bool gZone::RendersAlpha (  )  const [private, virtual]

returns whether the rendering uses alpha blending (massively, so sorting errors would show)

Returns:
True if alpha blending is used

Reimplemented from eGameObject.

Definition at line 572 of file gWinZone.cpp.

References sr_alphaBlend.

00573 {
00574         return sr_alphaBlend;
00575 }

REAL gZone::EvaluateFunctionNow ( tFunction const &  f  )  const [inline, private]

evaluates the given function with lastTime - referenceTime_ as argument

Parameters:
f function to evaluate
Returns:
the function's value at lastTime - referenceTime_

Definition at line 99 of file gWinZone.cpp.

References eGameObject::lastTime, and referenceTime_.

Referenced by GetPosition(), GetRadius(), GetRotationSpeed(), SetExpansionSpeed(), and SetReferenceTime().

00100 {
00101     return f( lastTime - referenceTime_ );
00102 }

Here is the caller graph for this function:

void gZone::SetFunctionNow ( tFunction f,
REAL  value 
) const [inline, private]

makes sure EvaluateFunctionNow() returns the given value

Parameters:
f function to modify
value value the function should have at lastTime - referenceTime_

Definition at line 115 of file gWinZone.cpp.

References tFunction::GetSlope(), eGameObject::lastTime, referenceTime_, and tFunction::SetOffset().

Referenced by SetPosition(), SetRadius(), and SetRotationSpeed().

00116 {
00117     f.SetOffset( value + f.GetSlope() * ( referenceTime_ - lastTime ) );
00118 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

rColor gZone::color_ [protected]

the zone's color

Definition at line 81 of file gWinZone.h.

Referenced by gDeathZoneHack::gDeathZoneHack(), GetColor(), gWinZoneHack::gWinZoneHack(), gZone(), ReadSync(), Render(), Render2D(), gBaseZoneHack::Timestep(), and WriteSync().

REAL gZone::createTime_ [protected]

the time the zone was created at

Definition at line 82 of file gWinZone.h.

Referenced by gZone(), ReadSync(), Render(), and WriteCreate().

REAL gZone::referenceTime_ [protected]

reference time for function evaluations

Definition at line 84 of file gWinZone.h.

Referenced by EvaluateFunctionNow(), gZone(), ReadSync(), SetFunctionNow(), SetReferenceTime(), Timestep(), and WriteSync().

tFunction gZone::posx_ [protected]

time dependence of x component of position

Definition at line 85 of file gWinZone.h.

Referenced by GetPosition(), GetVelocity(), ReadSync(), SetPosition(), SetReferenceTime(), SetVelocity(), Timestep(), and WriteSync().

tFunction gZone::posy_ [protected]

time dependence of y component of position

Definition at line 86 of file gWinZone.h.

Referenced by GetPosition(), GetVelocity(), ReadSync(), SetPosition(), SetReferenceTime(), SetVelocity(), Timestep(), and WriteSync().

tFunction gZone::radius_ [protected]

time dependence of radius

Definition at line 87 of file gWinZone.h.

Referenced by GetExpansionSpeed(), ReadSync(), SetExpansionSpeed(), SetReferenceTime(), and WriteSync().

tFunction gZone::rotationSpeed_ [protected]

the zone's rotation speed

Definition at line 88 of file gWinZone.h.

Referenced by GetRotationAcceleration(), GetRotationSpeed(), ReadSync(), SetReferenceTime(), SetRotationAcceleration(), and WriteSync().

eCoord gZone::rotation_ [protected]

the current rotation state

Definition at line 89 of file gWinZone.h.

Referenced by GetRotation(), Render(), Render2D(), and Timestep().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:46:24 2008 for Armagetron Advanced by  doxygen 1.5.4