zShape Class Reference

#include <zShape.hpp>

Inheritance diagram for zShape:

Inheritance graph
[legend]
Collaboration diagram for zShape:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 zShape (eGrid *grid, unsigned short idZone)
 zShape (nMessage &m)
virtual ~zShape ()
virtual void WriteCreate (nMessage &m)
virtual void WriteSync (nMessage &m)
 writes sync data
virtual void ReadSync (nMessage &m)
 reads sync data
void animate (REAL time)
virtual bool isInteracting (eGameObject *target)
virtual void render (const eCamera *cam)
virtual void render2d (tCoord scale) const
void setPosX (const tFunction &x)
void setPosY (const tFunction &y)
void setRotation2 (const tPolynomial< nMessage > &r)
void setScale (const tFunction &s)
void setColor (const rColor &c)
void setColorNow (const rColor &c)
tFunction getPosX ()
tFunction getPosY ()
tFunction getScale ()
rColor getColor ()
void TimeStep (REAL time)
virtual bool isEmulatingOldZone ()
void setReferenceTime (REAL time)

Protected Member Functions

eCoord Position ()
void networkRead (nMessage &m)
void networkWrite (nMessage &m)
void setCreatedTime (REAL time)
void joinWithZone ()

Protected Attributes

tFunction posx_
 position need not be inside the shape.
tFunction posy_
 positoin need not be inside the shape.
tFunction scale_
 Used to affect the contour and not the position.
tPolynomial< nMessagerotation2
 Rotate the contour around the position at this rate.
rColor color_
REAL createdtime_
REAL referencetime_
REAL lasttime_
unsigned short idZone_
bool newIdZone_


Detailed Description

Definition at line 13 of file zShape.hpp.


Constructor & Destructor Documentation

zShape::zShape ( eGrid grid,
unsigned short  idZone 
)

Definition at line 5 of file zShape.cpp.

References joinWithZone().

00006         :eNetGameObject( grid, eCoord(0,0), eCoord(0,0), NULL, true ),
00007         posx_(),
00008         posy_(),
00009         scale_(),
00010         rotation2(),
00011         color_(),
00012         createdtime_(0.0),
00013         referencetime_(0.0),
00014         lasttime_(0.0),
00015         idZone_(idZone),
00016         newIdZone_(false)
00017 {
00018     joinWithZone();
00019 }

Here is the call graph for this function:

zShape::zShape ( nMessage m  ) 

Definition at line 21 of file zShape.cpp.

References idZone_, joinWithZone(), networkRead(), newIdZone_, REAL, and setCreatedTime().

00021                          :eNetGameObject(m)
00022 {
00023     REAL time;
00024     m >> time;
00025     setCreatedTime(time);
00026 
00027     networkRead(m);
00028 
00029     unsigned short anIdZone;
00030     m >> anIdZone;
00031     if(anIdZone != idZone_) {
00032         idZone_ = anIdZone;
00033         newIdZone_ = true;
00034         joinWithZone();
00035     }
00036 }

Here is the call graph for this function:

virtual zShape::~zShape (  )  [inline, virtual]

Definition at line 17 of file zShape.hpp.

00017 {};


Member Function Documentation

void zShape::WriteCreate ( nMessage m  )  [virtual]

Reimplemented from eNetGameObject.

Reimplemented in zShapeCircle, and zShapePolygon.

Definition at line 87 of file zShape.cpp.

References createdtime_, idZone_, networkWrite(), and eNetGameObject::WriteCreate().

Referenced by zShapePolygon::WriteCreate(), and zShapeCircle::WriteCreate().

00088 {
00089     eNetGameObject::WriteCreate(m);
00090 
00091     m << createdtime_;
00092 
00093     networkWrite(m);
00094 
00095     m << idZone_;
00096 }

Here is the call graph for this function:

Here is the caller graph for this function:

void zShape::WriteSync ( nMessage m  )  [virtual]

writes sync data

Reimplemented from eNetGameObject.

Reimplemented in zShapeCircle.

Definition at line 98 of file zShape.cpp.

References networkWrite().

Referenced by zShapeCircle::WriteSync().

00099 {
00100     networkWrite(m);
00101 }

Here is the call graph for this function:

Here is the caller graph for this function:

void zShape::ReadSync ( nMessage m  )  [virtual]

reads sync data

Reimplemented from eNetGameObject.

Reimplemented in zShapeCircle.

Definition at line 103 of file zShape.cpp.

References networkRead().

Referenced by zShapeCircle::ReadSync().

00104 {
00105     networkRead(m);
00106 }

Here is the call graph for this function:

Here is the caller graph for this function:

void zShape::animate ( REAL  time  ) 

Definition at line 144 of file zShape.cpp.

00144                                 {
00145     // Is this needed as the items are already animated?
00146 }

bool zShape::isInteracting ( eGameObject target  )  [virtual]

Reimplemented in zShapeCircle, and zShapePolygon.

Definition at line 164 of file zShape.cpp.

00164                                                {
00165     return false;
00166 }

void zShape::render ( const eCamera cam  )  [virtual]

Reimplemented in zShapeCircle, and zShapePolygon.

Definition at line 168 of file zShape.cpp.

00169 {}

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

Reimplemented in zShapeCircle, and zShapePolygon.

Definition at line 170 of file zShape.cpp.

00171     {}

void zShape::setPosX ( const tFunction x  ) 

Definition at line 108 of file zShape.cpp.

References posx_.

00108                                        {
00109     posx_ = x;
00110 }

void zShape::setPosY ( const tFunction y  ) 

Definition at line 112 of file zShape.cpp.

References posy_.

00112                                        {
00113     posy_ = y;
00114 }

void zShape::setRotation2 ( const tPolynomial< nMessage > &  r  ) 

Definition at line 116 of file zShape.cpp.

References nCLIENT, nNetObject::RequestSync(), rotation2, and sn_GetNetState().

00116                                                          {
00117   if(rotation2 == r) {
00118     // Empty: Nothing to do, no need to send an update
00119   }
00120   else {
00121     rotation2 = r;
00122     if (sn_GetNetState()!=nCLIENT)
00123         RequestSync();
00124   }
00125 }

Here is the call graph for this function:

void zShape::setScale ( const tFunction s  ) 

Definition at line 127 of file zShape.cpp.

References scale_.

00127                                         {
00128     scale_ = s;
00129 }

void zShape::setColor ( const rColor c  ) 

Definition at line 131 of file zShape.cpp.

References color_, nCLIENT, nNetObject::RequestSync(), and sn_GetNetState().

Referenced by setColorNow().

00131                                     {
00132     if(color_ != c) {
00133         color_ = c;
00134         if (sn_GetNetState()!=nCLIENT)
00135             RequestSync();
00136     }
00137 }

Here is the call graph for this function:

Here is the caller graph for this function:

void zShape::setColorNow ( const rColor c  ) 

Definition at line 139 of file zShape.cpp.

References setColor().

00139                                        {
00140     // TODO: make color slide with some fancy tFunc or something.
00141     setColor(c);
00142 }

Here is the call graph for this function:

tFunction zShape::getPosX (  )  [inline]

Definition at line 36 of file zShape.hpp.

References posx_.

00036 {return posx_;};

tFunction zShape::getPosY (  )  [inline]

Definition at line 37 of file zShape.hpp.

References posy_.

00037 {return posy_;};

tFunction zShape::getScale (  )  [inline]

Definition at line 38 of file zShape.hpp.

References scale_.

00038 {return scale_;};

rColor zShape::getColor (  )  [inline]

Definition at line 39 of file zShape.hpp.

References color_.

00039 {return color_;};

void zShape::TimeStep ( REAL  time  ) 

Definition at line 148 of file zShape.cpp.

References joinWithZone(), lasttime_, and newIdZone_.

00148                                  {
00149     lasttime_ = time;
00150     /*
00151     REAL scale = scale_.Evaluate(lasttime_ - referencetime_);
00152     if (scale < -1.0) // Allow shapes to keep existing for a while even though they are not physical
00153       {
00154         // The shape has collapsed and should be removed
00155       }
00156     */
00157 
00158     if(newIdZone_) {
00159         joinWithZone();
00160     }
00161 
00162 }

Here is the call graph for this function:

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

Reimplemented in zShapeCircle, and zShapePolygon.

Definition at line 42 of file zShape.hpp.

00042 {return false;};

void zShape::setReferenceTime ( REAL  time  ) 

Definition at line 48 of file zShape.cpp.

References referencetime_.

Referenced by networkRead().

00049 {
00050     referencetime_ = time;
00051     // Do not update lasttime_, referencetime_ might be set in the future for ease of equation writing.
00052 }

Here is the caller graph for this function:

eCoord zShape::Position (  )  [inline, protected]

Definition at line 52 of file zShape.hpp.

References eCoord, lasttime_, posx_, posy_, and referencetime_.

Referenced by zShapeCircle::isInteracting().

Here is the caller graph for this function:

void zShape::networkRead ( nMessage m  )  [protected]

Definition at line 68 of file zShape.cpp.

References tColor::a_, tColor::b_, color_, tColor::g_, posx_, posy_, tColor::r_, REAL, rotation2, scale_, and setReferenceTime().

Referenced by ReadSync(), and zShape().

00069 {
00070     REAL time;
00071     m >> time;
00072     setReferenceTime(time);
00073     m >> posx_;
00074     m >> posy_;
00075     m >> scale_;
00076     m >> rotation2;
00077 
00078     m >> color_.r_;
00079     m >> color_.g_;
00080     m >> color_.b_;
00081     m >> color_.a_;
00082 }

Here is the call graph for this function:

Here is the caller graph for this function:

void zShape::networkWrite ( nMessage m  )  [protected]

Definition at line 54 of file zShape.cpp.

References tColor::a_, tColor::b_, color_, tColor::g_, posx_, posy_, tColor::r_, referencetime_, rotation2, and scale_.

Referenced by WriteCreate(), and WriteSync().

00055 {
00056 
00057     m << referencetime_;
00058     m << posx_;
00059     m << posy_;
00060     m << scale_;
00061     m << rotation2;
00062     m << color_.r_;
00063     m << color_.g_;
00064     m << color_.b_;
00065     m << color_.a_;
00066 }

Here is the caller graph for this function:

void zShape::setCreatedTime ( REAL  time  )  [protected]

Definition at line 39 of file zShape.cpp.

References createdtime_, and lasttime_.

Referenced by zShape().

00040 {
00041     createdtime_ = time;
00042 
00043     // Usefull when the nMessage creates the zone in the middle of a round
00044     if(lasttime_ < createdtime_)
00045         lasttime_ = createdtime_;
00046 }

Here is the caller graph for this function:

void zShape::joinWithZone (  )  [protected]

Definition at line 173 of file zShape.cpp.

References asdf, idZone_, newIdZone_, zZone::setShape(), and sn_netObjects.

Referenced by TimeStep(), and zShape().

00173                           {
00174     if(sn_netObjects[idZone_]) {
00175         zZone *asdf = dynamic_cast<zZone*>(&*sn_netObjects[idZone_]);
00176         asdf->setShape(zShapePtr(this));
00177         newIdZone_ = false;
00178     }
00179 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tFunction zShape::posx_ [protected]

position need not be inside the shape.

Definition at line 46 of file zShape.hpp.

Referenced by getPosX(), zShapePolygon::isInside(), networkRead(), networkWrite(), Position(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setPosX().

tFunction zShape::posy_ [protected]

positoin need not be inside the shape.

Definition at line 47 of file zShape.hpp.

Referenced by getPosY(), zShapePolygon::isInside(), networkRead(), networkWrite(), Position(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setPosY().

tFunction zShape::scale_ [protected]

Used to affect the contour and not the position.

Definition at line 48 of file zShape.hpp.

Referenced by getScale(), zShapePolygon::isInside(), zShapeCircle::isInteracting(), networkRead(), networkWrite(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setScale().

tPolynomial<nMessage> zShape::rotation2 [protected]

Rotate the contour around the position at this rate.

Definition at line 49 of file zShape.hpp.

Referenced by zShapePolygon::isInside(), networkRead(), networkWrite(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setRotation2().

rColor zShape::color_ [protected]

Definition at line 50 of file zShape.hpp.

Referenced by getColor(), networkRead(), networkWrite(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setColor().

REAL zShape::createdtime_ [protected]

Definition at line 61 of file zShape.hpp.

Referenced by setCreatedTime(), and WriteCreate().

REAL zShape::referencetime_ [protected]

Definition at line 62 of file zShape.hpp.

Referenced by zShapePolygon::isInside(), zShapeCircle::isInteracting(), networkWrite(), Position(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setReferenceTime().

REAL zShape::lasttime_ [protected]

Definition at line 63 of file zShape.hpp.

Referenced by zShapePolygon::isInside(), zShapeCircle::isInteracting(), Position(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), setCreatedTime(), and TimeStep().

unsigned short zShape::idZone_ [protected]

Definition at line 65 of file zShape.hpp.

Referenced by joinWithZone(), WriteCreate(), and zShape().

bool zShape::newIdZone_ [protected]

Definition at line 66 of file zShape.hpp.

Referenced by joinWithZone(), TimeStep(), and zShape().


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