src/engine/eCamera.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_CAMERA_H
00029 #define ArmageTron_CAMERA_H
00030 
00031 typedef enum {CAMERA_IN=0, CAMERA_CUSTOM=1, CAMERA_FREE=2, CAMERA_FOLLOW=3,
00032               CAMERA_SMART=4, CAMERA_MER=5, CAMERA_SERVER_CUSTOM=6,
00033               CAMERA_SMART_IN=7, CAMERA_COUNT=8 } eCamMode;
00034 
00035 #include "eCoord.h"
00036 //#include "uInput.h"
00037 #include "rViewport.h"
00038 #include "tLinkedList.h"
00039 #include "tList.h"
00040 #include "nObserver.h"
00041 
00042 class ePlayer;
00043 class ePlayerNetID;
00044 class eGameObject;
00045 class eNetGameObject;
00046 class eCamera;
00047 class eGrid;
00048 class uActionCamera;
00049 class uGlanceAction;
00050 
00051 
00052 //extern REAL se_cameraRise; // how far down does the current camera look?
00053 //extern REAL se_cameraZ;
00054 
00055 // extern List<eCamera> se_cameras;
00056 
00057 class eGlanceRequest : public tListItem<eGlanceRequest> {
00058 public:
00059     eGlanceRequest() : tListItem<eGlanceRequest>() {}
00060     eCoord dir;
00061 };
00062 
00063 class eCamera{
00064 protected:
00065     enum { se_glances = 4 };
00066     static uActionCamera se_lookUp,se_lookDown,se_lookLeft,se_lookRight,
00067     se_moveLeft,se_moveRight,se_moveUp,se_moveDown,se_moveForward,se_moveBack,
00068     se_zoomIn,se_zoomOut, se_switchView;
00069     static uGlanceAction se_glance[se_glances];
00070 
00071     int id;
00072     //  tCHECKED_PTR(eGameObject) foot;
00073     tCHECKED_PTR(eGrid)           grid;
00074     //eGameObject *center;
00075     nObserverPtr< ePlayerNetID> netPlayer;
00076     tCHECKED_PTR(ePlayer)         localPlayer;
00077     // mutable nObserverPtr<eNetGameObject> center; // the game object we watch
00078     tJUST_CONTROLLED_PTR<eGameObject> center; // the game object we watch
00079 
00080     // mutable int  centerID; // the game id of the object we are watching
00081     //int        lastCenterID; // the game id of the object we are watching
00082     REAL         lastSwitch; // the last center switch
00083     REAL         zNear  ;        // near clipping plane
00084     eCamMode     mode   ;    // current view mode
00085 
00086     eCoord pos;       // Position
00087     eCoord lastPos;  // last rendered position
00088     eCoord dir;       // direction
00089     eCoord top;       // vector (top,1) is top of camera (limits views)
00090     REAL  z,rise;    // height above the floor and whether we look up or down
00091     REAL  fov;       // field of vision;
00092 
00093     REAL turning;   // number of turns in the last seconds
00094     REAL smoothTurning; //that value smoothed
00095 
00096 
00097     REAL distance;    // distance travelled so far
00098     REAL lastrendertime; // the time this was last rendered
00099 
00100     REAL smartcamSkewSmooth, smartcamIncamSmooth, smartcamFrontSmooth, centerSpeedSmooth;
00101     eCoord centerDirSmooth;
00102     eCoord centerDirLast;
00103     eCoord centerPos;
00104     eCoord centerPosSmooth;
00105 
00106     tCHECKED_PTR(rViewport) vp;
00107 
00108     eCoord centerPosLast, centerposLast;
00109     REAL  userCameraControl;
00110     REAL  centerIncam;
00111 
00112     eGlanceRequest* activeGlanceRequest;
00113     eGlanceRequest glanceRequests[se_glances];
00114 
00115     bool renderingMain_;        // flag indicating whether the current rendering process is the main process or just a mirror effect
00116 
00117     static bool InterestingToWatch(eGameObject const * g);
00118 
00124     static eCoord nextDirIfGlancing(eCoord const & dir, eCoord const & targetDir, REAL ts);
00125 
00126     void Bound( REAL dt ); 
00127     void Bound( REAL dt, eCoord & pos ); 
00128 
00129     void MyInit();
00130 public:
00131     bool CenterIncamOnTurn();
00132     bool WhobbleIncam();
00133     bool AutoSwitchIncam();
00134 
00135     bool RenderingMain() const { return renderingMain_;  }
00136     void SetRenderingMain( bool f ){ renderingMain_ = f; }
00137 
00138     const ePlayerNetID* Player() const;
00139     const ePlayer* LocalPlayer() const;
00140 
00141     eCamera(eGrid *grid, rViewport *vp,ePlayerNetID *owner,ePlayer *lp,eCamMode m=CAMERA_IN);
00142     virtual ~eCamera();
00143 
00144     eGameObject * Center() const;
00145 
00146     eCoord CenterPos() const;
00147     eCoord CenterDir() const;
00148     virtual eCoord CenterCycleDir() const;
00149 
00150     virtual REAL SpeedMultiplier() const { return 1; }
00151 
00152     eCoord CenterCamDir() const;
00153     eCoord CenterCamTop() const;
00154     eCoord CenterCamPos() const;
00155     REAL  CenterCamZ() const;
00156 
00157     REAL  CenterZ() const;
00158     REAL  CenterSpeed() const;
00159 
00160     const eCoord& CameraDir() const {return dir;}
00161     const eCoord& CameraPos() const {return pos;}
00162     eCoord        CameraGlancePos() const {return pos;}  
00163     REAL          CameraZ  () const {return z;}
00164 
00165     bool CenterAlive() const;
00166 
00167     bool CenterCockpitFixedBefore() const;
00168     void CenterCockpitFixedAfter() const;
00169 
00170     void SwitchView();
00171     void SwitchCenter(int d);
00172     bool Act(uActionCamera *act,REAL x);
00173 
00174     eCamMode GetCamMode() {return mode;}
00175 
00176 #ifndef DEDICATED
00177     void Render();
00178     //void SoundMix(unsigned char *dest,unsigned int len);
00179 private:
00180     //void SoundMixGameObject(unsigned char *dest,unsigned int len,eGameObject *go);
00181 public:
00182 #endif
00183 
00184     virtual void Timestep(REAL ts);
00185 
00186     REAL Dist(){return distance;}
00187 
00188     /*
00189     static int    Number(){return se_cameras.Len();}
00190     static const eCoord& PosNum(int i){
00191       if (i<se_cameras.Len())
00192         return se_cameras(i)->lastPos;
00193       else
00194         return se_zeroCoord;
00195     }
00196     static const eCoord& DirNum(int i){
00197       if (i<se_cameras.Len())
00198         return se_cameras(i)->dir;
00199       else
00200         return se_zeroCoord;
00201     }
00202 
00203     static REAL HeightNum(int i){
00204       if (i<se_cameras.Len())
00205         return se_cameras(i)->z;
00206       else
00207         return 0;
00208     }
00209     */
00210 
00211     static void s_Timestep(eGrid *grid, REAL time);
00212 
00213 private:
00215     bool Bound( REAL ratio, eCoord & pos, eCoord const & dirFromTarget, REAL & hitCache );
00216 
00217     enum HitCacheSize{ hitCacheSize = 3 };
00218     REAL hitCache_[hitCacheSize];
00219 };
00220 
00221 /*
00222 inline int    NumberOfCameras(){return eCamera::Number();}
00223 inline const eCoord& CameraPos(int i){return eCamera::PosNum(i);}
00224 inline const eCoord& CameraDir(int i){return eCamera::DirNum(i);}
00225 inline REAL CameraHeight(int i){return eCamera::HeightNum(i);}
00226 */
00227 
00228 
00229 #endif

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