zShapeCircle Class Reference

#include <zShape.hpp>

Inheritance diagram for zShapeCircle:

Inheritance graph
[legend]
Collaboration diagram for zShapeCircle:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 zShapeCircle (eGrid *grid, unsigned short idZone)
 zShapeCircle (nMessage &m)
 ~zShapeCircle ()
void WriteCreate (nMessage &m)
void WriteSync (nMessage &m)
 writes sync data
void ReadSync (nMessage &m)
 reads sync data
bool isInteracting (eGameObject *target)
void render (const eCamera *cam)
virtual void render2d (tCoord scale) const
bool isEmulatingOldZone ()
void setRadius (tFunction radius)

Public Attributes

bool emulatingOldZone_

Protected Attributes

tFunction radius

Private Member Functions

virtual nDescriptor & CreatorDescriptor () const
 returns the descriptor to recreate this object over the network


Detailed Description

Definition at line 69 of file zShape.hpp.


Constructor & Destructor Documentation

zShapeCircle::zShapeCircle ( eGrid *  grid,
unsigned short  idZone 
)

Definition at line 181 of file zShape.cpp.

00181                                                             :
00182         zShape(grid, idZone),
00183         emulatingOldZone_(false),
00184         radius(1.0, 0.0)
00185 {}

zShapeCircle::zShapeCircle ( nMessage &  m  ) 

Definition at line 187 of file zShape.cpp.

References radius.

00187                                      :
00188         zShape(m),
00189         emulatingOldZone_(false),
00190         radius(1.0, 0.0)
00191 {
00192     m >> radius;
00193 }

zShapeCircle::~zShapeCircle (  )  [inline]

Definition at line 76 of file zShape.hpp.

00076 {};


Member Function Documentation

void zShapeCircle::WriteCreate ( nMessage &  m  )  [virtual]

Reimplemented from zShape.

Definition at line 198 of file zShape.cpp.

References radius, and zShape::WriteCreate().

00199 {
00200     zShape::WriteCreate(m);
00201 
00202     m << radius;
00203 }

Here is the call graph for this function:

void zShapeCircle::WriteSync ( nMessage &  m  )  [virtual]

writes sync data

Reimplemented from zShape.

Definition at line 205 of file zShape.cpp.

References radius, and zShape::WriteSync().

00206 {
00207     zShape::WriteSync(m);
00208     m << radius;
00209 }

Here is the call graph for this function:

void zShapeCircle::ReadSync ( nMessage &  m  )  [virtual]

reads sync data

Reimplemented from zShape.

Definition at line 211 of file zShape.cpp.

References radius, and zShape::ReadSync().

00212 {
00213     zShape::ReadSync(m);
00214     m >> radius;
00215 }

Here is the call graph for this function:

bool zShapeCircle::isInteracting ( eGameObject *  target  )  [virtual]

Reimplemented from zShape.

Definition at line 217 of file zShape.cpp.

References gCycleMovement::Alive(), tFunction::Evaluate(), zShape::lasttime_, eNetGameObject::Player(), zShape::Position(), eGameObject::Position(), radius, REAL, zShape::referencetime_, and zShape::scale_.

00218 {
00219     bool interact = false;
00220     gCycle* prey = dynamic_cast< gCycle* >( target );
00221     if ( prey )
00222     {
00223         if ( prey->Player() && prey->Alive() )
00224         {
00225             REAL effectiveRadius;
00226             effectiveRadius = scale_.Evaluate(lasttime_ - referencetime_) * radius.Evaluate(lasttime_ - referencetime_);
00227             // Is the player inside or outside the zone
00228             if ( (effectiveRadius >= 0.0) && ( prey->Position() - Position() ).NormSquared() < effectiveRadius*effectiveRadius )
00229             {
00230                 interact = true;
00231             }
00232         }
00233     }
00234     return interact;
00235 }

Here is the call graph for this function:

void zShapeCircle::render ( const eCamera *  cam  )  [virtual]

Reimplemented from zShape.

Definition at line 237 of file zShape.cpp.

References a, tColor::a_, rColor::Apply(), b, BeginLineStrip(), BeginQuads(), zShape::color_, cos(), eCoord, tFunction::Evaluate(), tPolynomial< T >::evaluate(), zShape::lasttime_, ModelMatrix(), zShape::posx_, zShape::posy_, radius, REAL, zShape::referencetime_, RenderEnd(), zShape::rotation2, zShape::scale_, sg_segments, sin(), and sr_alphaBlend.

00238 {
00239 #ifndef DEDICATED
00240 
00241     // HACK
00242     int sg_segments = 11;
00243     bool sr_alphaBlend = true;
00244     // HACK
00245 
00246     if ( color_.a_ > .7f )
00247         color_.a_ = .7f;
00248     if ( color_.a_ <= 0 )
00249         return;
00250 
00251     REAL currAngle = rotation2.evaluate(lasttime_);
00252     eCoord rot( cos(currAngle), sin(currAngle) );
00253 
00254     GLfloat m[4][4]={{rot.x,rot.y,0,0},
00255                      {-rot.y,rot.x,0,0},
00256                      {0,0,1,0},
00257                      {posx_.Evaluate(lasttime_ - referencetime_), posy_.Evaluate(lasttime_ - referencetime_), 0,1}};
00258 
00259     ModelMatrix();
00260     glPushMatrix();
00261 
00262     glDisable(GL_LIGHT0);
00263     glDisable(GL_LIGHT1);
00264     glDisable(GL_LIGHTING);
00265     glDisable(GL_CULL_FACE);
00266     glBlendFunc( GL_SRC_ALPHA, GL_ONE );
00267 
00268     //glDisable(GL_TEXTURE);
00269     glDisable(GL_TEXTURE_2D);
00270 
00271     //  glTranslatef(pos.x,pos.y,0);
00272 
00273     glMultMatrixf(&m[0][0]);
00274     //  glScalef(.5,.5,.5);
00275 
00276     if ( sr_alphaBlend ) {
00277         glDepthMask(GL_FALSE);
00278         BeginQuads();
00279     } else {
00280         glDepthMask(GL_TRUE);
00281         BeginLineStrip();
00282     }
00283 
00284     const REAL seglen = .2f;
00285     const REAL bot = 0.0f;
00286     const REAL top = 5.0f; // + ( lastTime - referenceTime_ ) * .1f;
00287 
00288     color_.Apply();
00289 
00290     REAL effectiveRadius;
00291     effectiveRadius = scale_.Evaluate(lasttime_ - referencetime_) * radius.Evaluate(lasttime_ - referencetime_);
00292     if (effectiveRadius >= 0.0)
00293     {
00294         for ( int i = sg_segments - 1; i>=0; --i )
00295         {
00296             REAL a = i * 2 * 3.14159 / REAL( sg_segments );
00297             REAL b = a + seglen;
00298 
00299             REAL sa = effectiveRadius * sin(a);
00300             REAL ca = effectiveRadius * cos(a);
00301             REAL sb = effectiveRadius * sin(b);
00302             REAL cb = effectiveRadius * cos(b);
00303 
00304             glVertex3f(sa, ca, bot);
00305             glVertex3f(sa, ca, top);
00306             glVertex3f(sb, cb, top);
00307             glVertex3f(sb, cb, bot);
00308 
00309             if ( !sr_alphaBlend )
00310             {
00311                 glVertex3f(sa, ca, bot);
00312                 RenderEnd();
00313                 BeginLineStrip();
00314             }
00315         }
00316     }
00317 
00318     RenderEnd();
00319 
00320     glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
00321     glDepthMask(GL_TRUE);
00322 
00323     glPopMatrix();
00324 #endif
00325 
00326 }

Here is the call graph for this function:

void zShapeCircle::render2d ( tCoord  scale  )  const [virtual]

Reimplemented from zShape.

Definition at line 330 of file zShape.cpp.

References a, tColor::a_, rColor::Apply(), b, BeginLines(), zShape::color_, cos(), eCoord, tFunction::Evaluate(), tPolynomial< T >::evaluate(), zShape::lasttime_, M_PI, ModelMatrix(), zShape::posx_, zShape::posy_, radius, REAL, zShape::referencetime_, RenderEnd(), zShape::rotation2, zShape::scale_, sg_segments, and sin().

00330                                               {
00331 #ifndef DEDICATED
00332 
00333     // HACK
00334     int sg_segments = 8;
00335     // HACK
00336 
00337     //if ( color_.a_ > .7f )
00338     //    color_.a_ = .7f;
00339     if ( color_.a_ <= 0 )
00340         return;
00341 
00342     REAL currAngle = rotation2.evaluate(lasttime_);
00343     eCoord rot( cos(currAngle), sin(currAngle) );
00344 
00345     GLfloat m[4][4]={{rot.x,rot.y,0,0},
00346                      {-rot.y,rot.x,0,0},
00347                      {0,0,1,0},
00348                      {posx_.Evaluate(lasttime_ - referencetime_), posy_.Evaluate(lasttime_ - referencetime_), 0,1}};
00349 
00350     ModelMatrix();
00351     glPushMatrix();
00352 
00353     glMultMatrixf(&m[0][0]);
00354 
00355     BeginLines();
00356 
00357     const REAL seglen = M_PI / sg_segments;
00358 
00359     color_.Apply();
00360 
00361     REAL effectiveRadius;
00362     effectiveRadius = scale_.Evaluate(lasttime_ - referencetime_) * radius.Evaluate(lasttime_ - referencetime_);
00363     if (effectiveRadius >= 0.0)
00364     {
00365         for ( int i = sg_segments - 1; i>=0; --i )
00366         {
00367             REAL a = i * 2 * 3.14159 / REAL( sg_segments );
00368             REAL b = a + seglen;
00369 
00370             REAL sa = effectiveRadius * sin(a);
00371             REAL ca = effectiveRadius * cos(a);
00372             REAL sb = effectiveRadius * sin(b);
00373             REAL cb = effectiveRadius * cos(b);
00374 
00375             glVertex2f(sa, ca);
00376             glVertex2f(sb, cb);
00377         }
00378     }
00379     RenderEnd();
00380     glPopMatrix();
00381 #endif
00382 }

Here is the call graph for this function:

bool zShapeCircle::isEmulatingOldZone (  )  [inline, virtual]

Reimplemented from zShape.

Definition at line 85 of file zShape.hpp.

References emulatingOldZone_.

00085 {return emulatingOldZone_;}; 

void zShapeCircle::setRadius ( tFunction  radius  )  [inline]

Definition at line 88 of file zShape.hpp.

00088 {this->radius = radius;};

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

returns the descriptor to recreate this object over the network

Implements nNetObject.

Definition at line 644 of file zShape.cpp.

References zoneCircle_init.

00645 {
00646     return zoneCircle_init;
00647 }


Member Data Documentation

bool zShapeCircle::emulatingOldZone_

Definition at line 85 of file zShape.hpp.

Referenced by isEmulatingOldZone().

tFunction zShapeCircle::radius [protected]

Definition at line 88 of file zShape.hpp.

Referenced by isInteracting(), ReadSync(), render(), render2d(), WriteCreate(), WriteSync(), and zShapeCircle().


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 00:02:18 2008 for Armagetron Advanced by  doxygen 1.5.4