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_CAMERA_H
29
#define ArmageTron_CAMERA_H
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;
36
#include "rViewport.h"
38
#include "nObserver.h"
48
//extern REAL se_cameraRise; // how far down does the current camera look?
49
//extern REAL se_cameraZ;
51
// extern List<eCamera> se_cameras;
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,
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
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
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;
83
REAL turning; // number of turns in the last seconds
84
REAL smoothTurning; //that value smoothed
87
REAL distance; // distance travelled so far
88
REAL lastrendertime; // the time this was last rendered
90
REAL smartcamSkewSmooth, smartcamIncamSmooth, smartcamFrontSmooth, centerSpeedSmooth;
91
eCoord centerDirSmooth;
94
eCoord centerPosSmooth;
96
tCHECKED_PTR(rViewport) vp;
99
REAL userCameraControl;
102
bool glancingLeft,glancingRight,glancingBack;
103
REAL glanceSmooth, glanceSmoothAbs;
106
bool renderingMain_; // flag indicating whether the current rendering process is the main process or just a mirror effect
108
static bool InterestingToWatch(eGameObject const * g);
110
eCoord Glance( eCoord const & in, eCoord const & glanceDir ) const;
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
117
bool CenterIncamOnTurn();
119
bool AutoSwitchIncam();
121
bool RenderingMain() const { return renderingMain_; }
122
void SetRenderingMain( bool f ){ renderingMain_ = f; }
124
const ePlayerNetID* Player() const;
125
const ePlayer* LocalPlayer() const;
127
eCamera(eGrid *grid, rViewport *vp,ePlayerNetID *owner,ePlayer *lp,eCamMode m=CAMERA_IN);
130
eGameObject * Center() const;
132
eCoord CenterPos() const;
133
eCoord CenterDir() const;
134
virtual eCoord CenterCycleDir() const;
136
virtual REAL SpeedMultiplier() const { return 1; }
138
eCoord CenterCamDir() const;
139
eCoord CenterCamTop() const;
140
eCoord CenterCamPos() const;
141
REAL CenterCamZ() const;
143
REAL CenterZ() const;
144
REAL CenterSpeed() const;
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;}
151
bool CenterAlive() const;
153
bool CenterCockpitFixedBefore() const;
154
void CenterCockpitFixedAfter() const;
157
void SwitchCenter(int d);
158
bool Act(uActionCamera *act,REAL x);
162
void SoundMix(unsigned char *dest,unsigned int len);
164
void SoundMixGameObject(unsigned char *dest,unsigned int len,eGameObject *go);
168
virtual void Timestep(REAL ts);
170
REAL Dist(){return distance;}
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;
180
static const eCoord& DirNum(int i){
181
if (i<se_cameras.Len())
182
return se_cameras(i)->dir;
187
static REAL HeightNum(int i){
188
if (i<se_cameras.Len())
189
return se_cameras(i)->z;
195
static void s_Timestep(eGrid *grid, REAL time);
198
//! make sure CenterPos() + dirFromTarget() is visible from pos
199
bool Bound( REAL ratio, eCoord & pos, eCoord const & dirFromTarget, REAL & hitCache );
201
enum HitCacheSize{ hitCacheSize = 3 };
202
REAL hitCache_[hitCacheSize];
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);}