src/engine/eWall.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #ifndef ArmageTron_WALL_H
00029 #define ArmageTron_WALL_H
00030 
00031 // #include "eGrid.h"
00032 #include "tHeap.h"
00033 #include "eCoord.h"
00034 
00035 class eHalfEdge;
00036 
00037 // ******************************************************************
00038 
00039 
00040 // ******************************************************************
00041 
00042 // a class for the different types of eWalls or similar objects
00043 // (enery barriers, fault lines...) that may appear in the game
00044 
00045 //#ifdef WIN32
00046 // disable a hack that apparently only works with gcc 2.95.x
00047 //#define CAUTION_WALL
00048 //#endif
00049 
00050 // uncomment to disable evil hack for all architectures
00051 //#define CAUTION_WALL
00052 
00053 
00054 
00055 class eWall;
00056 class eWallHolder;
00057 class eGameObject;
00058 class eCamera;
00059 class eGrid;
00060 
00061 class eWallView:public tHeapElement{
00062     friend class eWall;
00063 protected:
00064     virtual tHeapBase *Heap() const;
00065 
00066 #ifdef CAUTION_WALL
00067     eWall *wall;
00068 #endif
00069 
00070     int  viewer;
00071 public:
00072     eWallView(){}
00073     ~eWallView();
00074 
00075     void Set(int view,eWall *mw){
00076         viewer=view;
00077 #ifdef CAUTION_WALL
00078         wall=mw;
00079 #endif
00080     }
00081 
00082     REAL Value(){return tHeapElement::Val();}
00083     void SetValue(REAL v);
00084 
00085     eWall *Belongs();  // to wich wall do we belong?
00086 
00087 };
00088 
00089 class eWall: public tReferencable< eWall >{
00090     friend class tReferencable< eWall >;
00091     //friend class eHalfEdge;
00092     //friend class eTempEdge;
00093     friend class eWallView;
00094     friend class eWallHolder;
00095 
00096     eWallView view[MAX_VIEWERS];
00097 protected:
00098     tCHECKED_PTR(eWallHolder)   holder_;
00099     tJUST_CONTROLLED_PTR<eGrid> grid;
00100     REAL                        len;
00101     int                         flipped;
00102 public:
00103     int id;
00104 
00105     eWall(eGrid *grid);
00106 
00107     /*
00108         virtual void AddRef();
00109         virtual void Release();
00110         int GetRefcount();
00111     */
00112 
00113     eHalfEdge* Edge()const;
00114 
00115     REAL Len() const {return len;}
00116 
00117     void CalcLen();
00118 
00119     const eCoord& EndPoint(int i) const; // returns the coordinates of the beginning (i=0) or end (i=1) of this wall
00120 
00121     eCoord Point( REAL a ) const; // returns the coordinates somewhere between beginning and end
00122 
00123     eCoord Vec() const; // returns the vector from the beginning to the end of the wall
00124 
00125     // flip the fall
00126     virtual void Flip(){flipped = 1-flipped;}
00127 
00128     // may we split the eWall in two?
00129     virtual bool Splittable() const;
00130 
00131     // can we delete the eWall now?
00132     virtual bool Deletable() const;
00133 
00134     // split the eWall in two with ratio a : 1-a
00135     virtual void Split(eWall *& w1,eWall *& w2,REAL a);
00136 
00137     // split the wall absolutely correctly; update the grid accordingly.
00138     void SplitComplete(eWall *& w1,eWall *& w2,REAL a);
00139 
00140     // is it still massive? (i.e. is the player it belongs to alive?)
00141     virtual bool Massive() const{return true;}
00142 
00143     // what happens to a gameobject that passes here?
00144     virtual void PassingGameObject(eGameObject *pass,REAL time,REAL pos,int recursion=1);
00145 
00146     // what happens if this wall, when layed out, turns out to cross another wall that was already there?
00147     virtual void SplitByActive( eWall * oldWall );
00148 
00149     // the same question for the old wall.
00150     virtual void SplitByPassive( eWall * newWall );
00151 
00152     // what happens if this wall, when layed out, turns out to be exactly parallel to another wall? The return value indicates if this operation is allowed.
00153     virtual bool RunsParallelActive( eWall * oldWall );
00154 
00155     // the same seen from the other wall
00156     virtual bool RunsParallelPassive( eWall * newWall );
00157 #ifndef DEDICATED
00158     //  static void Render_helper(eWall *w,REAL tBeg,REAL tEnd,REAL h=4,REAL hfrac=1,REAL bot=0);
00159 
00160     // draws it to the screen using OpenGL
00161     virtual void Render(const eCamera *cam){};
00162 #endif
00163 
00164     // can you see through it?
00165     virtual REAL Height() const{return 1;}
00166     virtual REAL BlockHeight() const{return 1;}
00167     virtual REAL SeeHeight() const{return 1;}
00168 
00169     inline void BlocksCamera( eCamera * cam, REAL height ) const; 
00170 
00171     void Insert();
00172     void Remove();
00173 
00174     void SetVisHeight(int v,REAL h);
00175 
00176 protected:
00177 
00178     virtual void OnBlocksCamera( eCamera * cam, REAL height ) const; 
00179 
00180     virtual ~eWall();
00181 private:
00182 };
00183 
00184 class eWallHolder
00185 {
00186     friend class eWall;
00187 public:
00188     void SetWall( eWall* wall );
00189     eWall* GetWall( void ) const;
00190 
00191 protected:
00192     eWallHolder();
00193     ~eWallHolder();
00194 
00195 private:
00196     tCONTROLLED_PTR( eWall ) wall_;
00197 };
00198 
00199 // TODO: get rid of these
00200 extern tHeap<eWallView>  se_wallsVisible[MAX_VIEWERS];
00201 
00202 // *******************************************************************************************
00203 // *
00204 // *    BlocksCamera
00205 // *
00206 // *******************************************************************************************
00211 // *******************************************************************************************
00212 
00213 void eWall::BlocksCamera( eCamera * cam, REAL height ) const
00214 {
00215     OnBlocksCamera( cam, height );
00216 }
00217 
00218 #endif
00219 

Generated on Sat Mar 15 22:55:48 2008 for Armagetron Advanced by  doxygen 1.5.4