3
*************************************************************************
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
8
**************************************************************************
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
***************************************************************************
28
#ifndef ArmageTron_GRID_H
29
#define ArmageTron_GRID_H
35
//#include "eGameObject.h"
37
//#include "eCamera.h"
51
// edge class for temporary variables; automatically creates two halfeges.
52
class eTempEdge: public tReferencable< eTempEdge >{
53
friend class tReferencable< eTempEdge >;
55
eTempEdge(ePoint *p1,ePoint *p2,eWall *W=NULL);
56
eTempEdge(const eCoord &c1,const eCoord &c2,eWall *W=NULL);
59
eCoord& Coord(int i) const;
60
ePoint* Point(int i) const;
61
eFace* Face(int i) const;
62
eHalfEdge* Edge(int i) const;
65
void SetWall( eWall* W ) const;
67
void CopyIntoGrid(eGrid *grid);
71
tControlledPTR< eHalfEdge > halfEdges[2];
76
class eGrid: public tReferencable< eGrid >{
79
friend class eHalfEdge;
81
friend class eGameObject;
83
friend class tReferencable< eGrid >;
92
// get the number of directions a cycle can drive in on this grid
93
int WindingNumber() const {return axis.WindingNumber();}
95
// get the number corresponding to a particular direction
96
int DirectionWinding(const eCoord& dir);
98
// get the direction associated with a winding number
99
eCoord GetDirection(int winding);
101
void SetWinding(int number);
102
void SetWinding(int number, eCoord directions[], bool normalise=true);
103
float GetWindingAngle(int winding);
105
// Ask the grid to turn a winding
106
void Turn(int ¤tWinding, int direction);
108
// try to get rid of eEdge number e
109
void SimplifyNum(int e);
111
// try to get rid of count edges
112
void SimplifyAll(int count=1);
117
// create a new grid with a basic topology
123
// make sure the circle with given radius lies inside the grid
124
void Range(REAL range_squared);
126
// grows the grid one step
129
// displays the grid, eWalls and gameobjects
130
void Render( eCamera* cam, int viewer, REAL& zNear );
132
// get the currently active grid (OBSOLETE)
133
static eGrid *CurrentGrid();
136
void ResetVisibles(int viewer); // reset the visibility information
139
ePoint* Insert(const eCoord& coord, eFace *guessFace=NULL); // inserts a point at the given coordinates
141
eFace *FindSurroundingFace(const eCoord& coord, eFace *start=NULL) const;
143
// adds a new Point end, adds an eEdge from start to end with
144
// type wall. Modifies other faces and non-eWall-edges;
145
// if change_grid is set to 0, no edges will be flipped.
146
// start must already be part of the grid.
148
ePoint *DrawLine(ePoint* start, const eCoord& end, eWall *wal=NULL,bool change_grid=1);
151
const tList<eCamera>& Cameras() const{return cameras;}
152
const tList<eGameObject>& GameObjects() const{return gameObjects;}
153
const tList<eGameObject>& GameObjectsInteresting() const{return gameObjectsInteresting;}
154
const tList<eGameObject>& GameObjectsInactive() const{return gameObjectsInactive;}
157
int NumberOfCameras();
158
const eCoord& CameraPos(int i);
159
eCoord CameraGlancePos(int i);
160
const eCoord& CameraDir(int i);
161
REAL CameraHeight(int i);
164
// int NumberOfCameras(){return eCamera::Number();}
165
// const eCoord& CameraPos(int i){return eCamera::PosNum(i);}
166
// const eCoord& CameraDir(int i){return eCamera::DirNum(i);}
167
// REAL CameraHeight(int i){return eCamera::HeightNum(i);}
170
void AddGameObjectInteresting (eGameObject *o);
171
void RemoveGameObjectInteresting (eGameObject *o);
172
void AddGameObjectInactive (eGameObject *o);
173
void RemoveGameObjectInactive (eGameObject *o);
175
typedef void WallProcessor ( eWall* w ); // function prototype for wall query functions
176
void ProcessWallsInRange ( WallProcessor* proc,
179
eFace* startFace ); // call WallProcessor for all walls closer than range to pos
183
void display_simple( int viewer,bool floor,
184
bool sr_upperSky,bool sr_lowerSky,
186
bool eWalls,bool gameObjects,
190
// normal list management
191
void AddFace (eFace *f);
192
void RemoveFace (eFace *f);
193
void AddEdge (eHalfEdge *e);
194
void RemoveEdge (eHalfEdge *e);
195
void AddPoint (ePoint *p);
196
void RemovePoint(ePoint *p);
198
// completely unlink:
199
void KillFace (eFace* f);
200
void KillEdge (eHalfEdge* e);
201
void KillPoint(ePoint* p);
203
// unlink face, but keep it alive for recycling ( so all gameobjects that live on it won't have to find a new face )
204
tControlledPTR< eFace > ZombifyFace (eFace* f);
206
// adds the face, its edges and vertives to the grid
207
void AddFaceAll (eFace *f);
209
bool requestCleanup; // triggered when the data structures have gone bonkers
211
// for the grid growth
212
tJUST_CONTROLLED_PTR< ePoint > A,B,C;
213
tJUST_CONTROLLED_PTR< eHalfEdge > a,b,c;
218
tList<eHalfEdge, false, true> edges;
219
tList<ePoint, false, true> points;
220
tList<eFace, false, true> faces;
223
tList<eGameObject> gameObjects;
224
tList<eGameObject> gameObjectsInactive;
225
tList<eGameObject> gameObjectsInteresting;
228
tList<eCamera> cameras;
231
// tHeap<eWallView> wallsVisible[MAX_VIEWERS];
232
tList<eWall> wallsNotYetInserted;