00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ArmageTron_GRID_H
00029 #define ArmageTron_GRID_H
00030
00031 #include "defs.h"
00032 #include "eCoord.h"
00033 #include "tList.h"
00034 #include "eAxis.h"
00035
00036
00037
00038
00039 class ePoint;
00040 class eFace;
00041 class eHalfEdge;
00042 class eWall;
00043 class eGrid;
00044 class eWallView;
00045 class eCamera;
00046 class eAxis;
00047 class eGameObject;
00048
00049 class nNetObject;
00050
00051
00052 class eTempEdge: public tReferencable< eTempEdge >{
00053 friend class tReferencable< eTempEdge >;
00054 public:
00055 eTempEdge(ePoint *p1,ePoint *p2,eWall *W=NULL);
00056 eTempEdge(const eCoord &c1,const eCoord &c2,eWall *W=NULL);
00057
00058 eCoord Vec() const;
00059 eCoord& Coord(int i) const;
00060 ePoint* Point(int i) const;
00061 eFace* Face(int i) const;
00062 eHalfEdge* Edge(int i) const;
00063 eWall* Wall() const;
00064
00065 void SetWall( eWall* W ) const;
00066
00067 void CopyIntoGrid(eGrid *grid);
00068 protected:
00069 ~eTempEdge();
00070 private:
00071 tControlledPTR< eHalfEdge > halfEdges[2];
00072 private:
00073 };
00074
00075
00076 class eGrid: public tReferencable< eGrid >{
00077 friend class eCamera;
00078 friend class eFace;
00079 friend class eHalfEdge;
00080 friend class ePoint;
00081 friend class eGameObject;
00082 friend class eWall;
00083 friend class tReferencable< eGrid >;
00084
00085 protected:
00086 ~eGrid();
00087 eAxis axis;
00088
00089 public:
00090 eGrid();
00091
00092
00093 int WindingNumber() const {return axis.WindingNumber();}
00094
00095
00096 int DirectionWinding(const eCoord& dir);
00097
00098
00099 eCoord GetDirection(int winding);
00100
00101 void SetWinding(int number);
00102 void SetWinding(int number, eCoord directions[], bool normalise=true);
00103
00104
00105 void Turn(int ¤tWinding, int direction);
00106
00107
00108 void SimplifyNum(int e);
00109
00110
00111 void SimplifyAll(int count=1);
00112
00113
00114 void Check() const;
00115
00116
00117 void Create();
00118
00119
00120 void Clear();
00121
00122
00123 void Range(REAL range_squared);
00124
00125
00126 void Grow();
00127
00128
00129 void Render( eCamera* cam, int viewer, REAL& zNear );
00130
00131
00132 static eGrid *CurrentGrid();
00133
00134
00135
00136
00137
00138 ePoint* Insert(const eCoord& coord, eFace *guessFace=NULL);
00139
00140 eFace *FindSurroundingFace(const eCoord& coord, eFace *start=NULL) const;
00141
00142
00143
00144
00145
00146
00147 ePoint *DrawLine(ePoint* start, const eCoord& end, eWall *wal=NULL,bool change_grid=1);
00148
00149
00150 const tList<eCamera>& Cameras() const{return cameras;}
00151 const tList<eGameObject>& GameObjects() const{return gameObjects;}
00152 const tList<eGameObject>& GameObjectsInteresting() const{return gameObjectsInteresting;}
00153 const tList<eGameObject>& GameObjectsInactive() const{return gameObjectsInactive;}
00154
00155
00156 int NumberOfCameras();
00157 const eCoord& CameraPos(int i);
00158 eCoord CameraGlancePos(int i);
00159 const eCoord& CameraDir(int i);
00160 REAL CameraHeight(int i);
00161
00162
00163
00164
00165
00166
00167
00168
00169 void AddGameObjectInteresting (eGameObject *o);
00170 void RemoveGameObjectInteresting (eGameObject *o);
00171 void AddGameObjectInactive (eGameObject *o);
00172 void RemoveGameObjectInactive (eGameObject *o);
00173
00174 typedef void WallProcessor ( eWall* w );
00175 void ProcessWallsInRange ( WallProcessor* proc,
00176 const eCoord& pos ,
00177 REAL range,
00178 eFace* startFace );
00179
00180 protected:
00181
00182 void display_simple( int viewer,bool floor,
00183 bool sr_upperSky,bool sr_lowerSky,
00184 REAL flooralpha,
00185 bool eWalls,bool gameObjects,
00186 REAL& zNear );
00187
00188
00189
00190 void AddFace (eFace *f);
00191 void RemoveFace (eFace *f);
00192 void AddEdge (eHalfEdge *e);
00193 void RemoveEdge (eHalfEdge *e);
00194 void AddPoint (ePoint *p);
00195 void RemovePoint(ePoint *p);
00196
00197
00198 void KillFace (eFace* f);
00199 void KillEdge (eHalfEdge* e);
00200 void KillPoint(ePoint* p);
00201
00202
00203 tControlledPTR< eFace > ZombifyFace (eFace* f);
00204
00205
00206 void AddFaceAll (eFace *f);
00207
00208 bool requestCleanup;
00209
00210
00211 tJUST_CONTROLLED_PTR< ePoint > A,B,C;
00212 tJUST_CONTROLLED_PTR< eHalfEdge > a,b,c;
00213 REAL maxNormSquared;
00214 eCoord base;
00215
00216
00217 tList<eHalfEdge, false, true> edges;
00218 tList<ePoint, false, true> points;
00219 tList<eFace, false, true> faces;
00220
00221
00222 tList<eGameObject> gameObjects;
00223 tList<eGameObject> gameObjectsInactive;
00224 tList<eGameObject> gameObjectsInteresting;
00225
00226
00227 tList<eCamera> cameras;
00228
00229
00230
00231 tList<eWall> wallsNotYetInserted;
00232
00233 #ifdef DEBUG
00234 public:
00235 bool doCheck;
00236 #endif
00237 };
00238
00239
00240
00241 #endif
00242
00243
00244
00245