~evan-nelson/armagetronad/armagetronad+pcm

« back to all changes in this revision

Viewing changes to src/engine/eCamera.h

Attempting to create a timeout for PLAYER_CENTER_MESSAGE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
*************************************************************************
4
 
 
5
 
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
 
Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
7
 
 
8
 
**************************************************************************
9
 
 
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.
14
 
 
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.
19
 
 
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.
23
 
  
24
 
***************************************************************************
25
 
 
26
 
*/
27
 
 
28
 
#ifndef ArmageTron_CAMERA_H
29
 
#define ArmageTron_CAMERA_H
30
 
 
31
 
typedef enum {CAMERA_IN=0, CAMERA_CUSTOM=1, CAMERA_FREE=2, CAMERA_FOLLOW=3,
32
 
              CAMERA_SMART=4,  CAMERA_SERVER_CUSTOM=5, CAMERA_SMART_IN=6, CAMERA_COUNT=7 } eCamMode;
33
 
 
34
 
#include "eCoord.h"
35
 
//#include "uInput.h"
36
 
#include "rViewport.h"
37
 
#include "tList.h"
38
 
#include "nObserver.h"
39
 
 
40
 
class ePlayer;
41
 
class ePlayerNetID;
42
 
class eGameObject;
43
 
class eNetGameObject;
44
 
class eCamera;
45
 
class eGrid;
46
 
class uActionCamera;
47
 
 
48
 
//extern REAL se_cameraRise; // how far down does the current camera look?
49
 
//extern REAL se_cameraZ;
50
 
 
51
 
// extern List<eCamera> se_cameras;
52
 
 
53
 
class eCamera{
54
 
protected:
55
 
    static uActionCamera se_lookUp,se_lookDown,se_lookLeft,se_lookRight,
56
 
    se_moveLeft,se_moveRight,se_moveUp,se_moveDown,se_moveForward,se_moveBack,
57
 
    se_zoomIn,se_zoomOut,se_glanceLeft,se_glanceRight,se_glanceBack,
58
 
    se_switchView;
59
 
 
60
 
 
61
 
    int id;
62
 
    //  tCHECKED_PTR(eGameObject) foot;
63
 
    tCHECKED_PTR(eGrid)           grid;
64
 
    //eGameObject *center;
65
 
    nObserverPtr< ePlayerNetID> netPlayer;
66
 
    tCHECKED_PTR(ePlayer)         localPlayer;
67
 
    // mutable nObserverPtr<eNetGameObject> center; // the game object we watch
68
 
    tJUST_CONTROLLED_PTR<eGameObject> center; // the game object we watch
69
 
 
70
 
    // mutable int  centerID; // the game id of the object we are watching
71
 
    //int        lastCenterID; // the game id of the object we are watching
72
 
    REAL         lastSwitch; // the last center switch
73
 
    REAL         zNear  ;        // near clipping plane
74
 
    eCamMode     mode   ;    // current view mode
75
 
 
76
 
    eCoord pos;       // Position
77
 
    eCoord lastPos;  // last rendered position
78
 
    eCoord dir;       // direction
79
 
    eCoord top;       // vector (top,1) is top of camera (limits views)
80
 
    REAL  z,rise;    // height above the floor and whether we look up or down
81
 
    REAL  fov;       // field of vision;
82
 
 
83
 
    REAL turning;   // number of turns in the last seconds
84
 
    REAL smoothTurning; //that value smoothed
85
 
 
86
 
 
87
 
    REAL distance;    // distance travelled so far
88
 
    REAL lastrendertime; // the time this was last rendered
89
 
 
90
 
    REAL smartcamSkewSmooth, smartcamIncamSmooth, smartcamFrontSmooth, centerSpeedSmooth;
91
 
    eCoord centerDirSmooth;
92
 
    eCoord centerDirLast;
93
 
    eCoord centerPos;
94
 
    eCoord centerPosSmooth;
95
 
 
96
 
    tCHECKED_PTR(rViewport) vp;
97
 
 
98
 
    eCoord centerPosLast;
99
 
    REAL  userCameraControl;
100
 
    REAL  centerIncam;
101
 
 
102
 
    bool glancingLeft,glancingRight,glancingBack;
103
 
    REAL glanceSmooth, glanceSmoothAbs;
104
 
    eCoord glanceDir_;
105
 
 
106
 
    bool renderingMain_;        // flag indicating whether the current rendering process is the main process or just a mirror effect
107
 
 
108
 
    static bool InterestingToWatch(eGameObject const * g);
109
 
 
110
 
    eCoord Glance( eCoord const & in, eCoord const & glanceDir ) const;
111
 
 
112
 
    void Bound( REAL dt ); //!< make sure the camera is inside the arena and has clear line of sight
113
 
    void Bound( REAL dt, eCoord & pos ); //!< make sure pos is inside the arena and has clear line of sight
114
 
 
115
 
    void MyInit();
116
 
public:
117
 
    bool CenterIncamOnTurn();
118
 
    bool WhobbleIncam();
119
 
    bool AutoSwitchIncam();
120
 
 
121
 
    bool RenderingMain() const { return renderingMain_;  }
122
 
    void SetRenderingMain( bool f ){ renderingMain_ = f; }
123
 
 
124
 
    const ePlayerNetID* Player() const;
125
 
    const ePlayer* LocalPlayer() const;
126
 
 
127
 
    eCamera(eGrid *grid, rViewport *vp,ePlayerNetID *owner,ePlayer *lp,eCamMode m=CAMERA_IN);
128
 
    virtual ~eCamera();
129
 
 
130
 
    eGameObject * Center() const;
131
 
 
132
 
    eCoord CenterPos() const;
133
 
    eCoord CenterDir() const;
134
 
    virtual eCoord CenterCycleDir() const;
135
 
 
136
 
    virtual REAL SpeedMultiplier() const { return 1; }
137
 
 
138
 
    eCoord CenterCamDir() const;
139
 
    eCoord CenterCamTop() const;
140
 
    eCoord CenterCamPos() const;
141
 
    REAL  CenterCamZ() const;
142
 
 
143
 
    REAL  CenterZ() const;
144
 
    REAL  CenterSpeed() const;
145
 
 
146
 
    const eCoord& CameraDir() const {return dir;}
147
 
    const eCoord& CameraPos() const {return pos;}
148
 
    eCoord        CameraGlancePos() const {return Glance(pos, glanceDir_);}
149
 
    REAL          CameraZ  () const {return z;}
150
 
 
151
 
    bool CenterAlive() const;
152
 
 
153
 
    bool CenterCockpitFixedBefore() const;
154
 
    void CenterCockpitFixedAfter() const;
155
 
 
156
 
    void SwitchView();
157
 
    void SwitchCenter(int d);
158
 
    bool Act(uActionCamera *act,REAL x);
159
 
 
160
 
#ifndef DEDICATED
161
 
    void Render();
162
 
    void SoundMix(unsigned char *dest,unsigned int len);
163
 
private:
164
 
    void SoundMixGameObject(unsigned char *dest,unsigned int len,eGameObject *go);
165
 
public:
166
 
#endif
167
 
 
168
 
    virtual void Timestep(REAL ts);
169
 
 
170
 
    REAL Dist(){return distance;}
171
 
 
172
 
    /*
173
 
    static int    Number(){return se_cameras.Len();}
174
 
    static const eCoord& PosNum(int i){
175
 
      if (i<se_cameras.Len())
176
 
        return se_cameras(i)->lastPos;
177
 
      else
178
 
        return se_zeroCoord;
179
 
    }
180
 
    static const eCoord& DirNum(int i){
181
 
      if (i<se_cameras.Len())
182
 
        return se_cameras(i)->dir;
183
 
      else
184
 
        return se_zeroCoord;
185
 
    }
186
 
 
187
 
    static REAL HeightNum(int i){
188
 
      if (i<se_cameras.Len())
189
 
        return se_cameras(i)->z;
190
 
      else
191
 
        return 0;
192
 
    }
193
 
    */
194
 
 
195
 
    static void s_Timestep(eGrid *grid, REAL time);
196
 
 
197
 
private:
198
 
    //! make sure CenterPos() + dirFromTarget() is visible from pos
199
 
    bool Bound( REAL ratio, eCoord & pos, eCoord const & dirFromTarget, REAL & hitCache );
200
 
 
201
 
    enum HitCacheSize{ hitCacheSize = 3 };
202
 
    REAL hitCache_[hitCacheSize];
203
 
};
204
 
 
205
 
/*
206
 
inline int    NumberOfCameras(){return eCamera::Number();}
207
 
inline const eCoord& CameraPos(int i){return eCamera::PosNum(i);}
208
 
inline const eCoord& CameraDir(int i){return eCamera::DirNum(i);}
209
 
inline REAL CameraHeight(int i){return eCamera::HeightNum(i);}
210
 
*/
211
 
 
212
 
 
213
 
#endif