src/tron/zone/zShape.hpp

Go to the documentation of this file.
00001 #include "tValue.h"
00002 #include "rColor.h"
00003 #include <boost/shared_ptr.hpp>
00004 #include "eNetGameObject.h"
00005 #include "tSysTime.h"
00006 
00007 #include "tFunction.h"
00008 #include "tPolynomial.h"
00009 
00010 #ifndef Z_SHAPE_H
00011 #define Z_SHAPE_H
00012 
00013 class zShape : public eNetGameObject{
00014 public:
00015     zShape(eGrid* grid, unsigned short idZone);
00016     zShape(nMessage &m);
00017     virtual ~zShape() {};
00018     virtual void WriteCreate( nMessage & m );
00019     virtual void WriteSync(nMessage &m);   
00020     virtual void ReadSync(nMessage &m);    
00021 
00022     void animate( REAL time );
00023     virtual bool isInteracting(eGameObject * target);
00024     virtual void render(const eCamera * cam );
00025     virtual void render2d(tCoord scale) const;
00026 
00027     void setPosX(const tFunction &x);
00028     void setPosY(const tFunction &y);
00029     void setRotation2(const tPolynomial<nMessage> & r);
00030 
00031     void setScale(const tFunction &s);
00032     void setColor(const rColor &c);
00033 
00034     void setColorNow(const rColor &c);
00035 
00036   tFunction getPosX() {return posx_;};
00037   tFunction getPosY() {return posy_;};
00038   tFunction getScale() {return scale_;};
00039   rColor getColor() {return color_;};
00040 
00041     void TimeStep( REAL time );
00042     virtual bool isEmulatingOldZone() {return false;};
00043     void setReferenceTime(REAL time);
00044 
00045 protected:
00046     tFunction posx_; 
00047     tFunction posy_; 
00048     tFunction scale_; 
00049     tPolynomial<nMessage> rotation2; 
00050     rColor color_;
00051 
00052     eCoord Position() { return eCoord(posx_(lasttime_ - referencetime_), posy_(lasttime_ - referencetime_) ); };
00053 
00054     void networkRead(nMessage &m);
00055     void networkWrite(nMessage &m);
00056 
00057     void setCreatedTime(REAL time);
00058 
00059     void joinWithZone();
00060 
00061     REAL createdtime_; // The in-game time when this shape was first instantiated
00062     REAL referencetime_; // The in-game time when this shape's data was updated, used for evaluation
00063     REAL lasttime_; // What is to be considered as the current time for this shape
00064 
00065     unsigned short idZone_;
00066     bool newIdZone_;
00067 };
00068 
00069 class zShapeCircle : public zShape {
00070   // HACK 
00071   // Circle dont have a radius attribute per see.
00072   // They have a default radius of 1.0, and it get scaled
00073 public :
00074     zShapeCircle(eGrid *grid, unsigned short idZone);
00075     zShapeCircle(nMessage &m);
00076     ~zShapeCircle() {};
00077     void WriteCreate( nMessage & m );
00078     void WriteSync(nMessage &m);   
00079     void ReadSync(nMessage &m);    
00080 
00081     bool isInteracting(eGameObject * target);
00082     void render(const eCamera * cam );
00083         virtual void render2d(tCoord scale) const;
00084 
00085     bool isEmulatingOldZone() {return emulatingOldZone_;}; 
00086     bool emulatingOldZone_;
00087 
00088     void setRadius(tFunction radius) {this->radius = radius;};
00089 protected:
00090     tFunction radius;
00091 
00092 private:
00093     virtual nDescriptor& CreatorDescriptor() const; 
00094 };
00095 
00096 typedef std::pair<tFunction, tFunction> myPoint;
00097 
00098 class zShapePolygon : public zShape {
00099 public :
00100     zShapePolygon(eGrid *grid, unsigned short idZone);
00101     zShapePolygon(nMessage &n);
00102     ~zShapePolygon() {};
00103     void WriteCreate( nMessage & m );
00104   //    void WriteSync(nMessage &m);   //!< writes sync data
00105   //    void ReadSync(nMessage &m);    //!< reads sync data
00106 
00107     bool isInteracting(eGameObject * target);
00108     void render(const eCamera * cam );
00109     virtual void render2d(tCoord scale) const;
00110     void addPoint( myPoint const &aPoint) { points.push_back(aPoint);};
00111 
00112   bool isEmulatingOldZone() {return false;}; // zShapePolygon cant be used for emulation of old zones
00113 
00114 protected:
00115     std::vector< myPoint > points;
00116     bool isInside (eCoord anECoord);
00117     static void networkRead(nMessage &m, zShape *aShape);
00118 private:
00119     virtual nDescriptor& CreatorDescriptor() const; 
00120 };
00121 
00122 //typedef boost::shared_ptr<zShape> zShapePtr;
00123 #include "tSafePTR.h"
00124 typedef tJUST_CONTROLLED_PTR< zShape> zShapePtr;
00125 
00126 #include "tSysTime.h"
00127 
00128 
00129 #endif

Generated on Sat Mar 15 22:56:13 2008 for Armagetron Advanced by  doxygen 1.5.4