Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
camera.h
Go to the documentation of this file.
1 /*
2  * Vega Strike
3  * Copyright (C) 2001-2002 Daniel Horn & Alan Shieh
4  *
5  * http://vegastrike.sourceforge.net/
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 #include "matrix.h"
23 #include "gfxlib.h"
24 #include "physics.h"
25 
26 #ifndef _CAMERA_H_
27 #define _CAMERA_H_
28 //class PlanetaryTransform; commented out by chuck_starchaser --never used
29 #include "cmd/container.h"
30 class Nebula;
31 
32 class Camera
33 {
34  QVector Coord;
35  Vector velocity;
36  Vector angular_velocity;
37  Vector accel;
38  Matrix planetview;
39  GFXBOOL changed;
40  QVector lastpos;
41  float x, y, xsize, ysize;
42  float zoom;
43  float fov;
44  float cockpit_offset;
45  UnitContainer nebula;
46 public:
47  void setCockpitOffset( float c )
48  {
49  cockpit_offset = c;
50  changed = GFXTRUE;
51  }
53  {
54  return cockpit_offset;
55  }
57  {
60  };
61 private:
62  ProjectionType projectionType;
63 // PlanetaryTransform *planet; commented out by chuck_starchaser; --never used
64 private:
65 //Last GFX Update, for partial updates
66  struct LastGFXUpdateStruct
67  {
68  GFXBOOL clip;
69  GFXBOOL updateFrustum;
70  GFXBOOL centerCamera;
71  GFXBOOL overrideZFrustum;
72  float overrideZNear, overrideZFar;
73  }
74  lastGFXUpdate;
75 public:
76  explicit Camera( ProjectionType proj = PERSPECTIVE );
77  void LookDirection( const Vector &forevec, const Vector &up );
78  Vector P, Q, R;
79  void SetNebula( Nebula *neb );
80  Nebula * GetNebula(); //this function can't be const, as it must return a non-const ptr --chuck_starchaser
81 /* PlanetaryTransform const * GetPlanetaryTransform() const commented out by chuck_starchaser; --never used
82  {
83  return planet;
84  }
85  void SetPlanetaryTransform( PlanetaryTransform *t )
86  {
87  planet = t;
88  }*/
91  void UpdateCameraSounds();
92  void GetView( Matrix& );
93  const Vector& GetR()
94  {
95  return R;
96  }
97  void GetPQR( Vector &p1, Vector &q1, Vector &r1 );
98  void UpdateGFX( GFXBOOL clip,
99  GFXBOOL updateFrustum,
100  GFXBOOL centerCamera,
101  GFXBOOL overrideZFrustum,
102  float overrideZNear,
103  float overrideZFar );
104  void UpdateGFX( GFXBOOL clip = GFXTRUE, GFXBOOL updateFrustum = GFXTRUE, GFXBOOL centerCamera = GFXFALSE )
105  {
106  UpdateGFX( clip,
107  updateFrustum,
108  centerCamera,
109  lastGFXUpdate.overrideZFrustum,
110  lastGFXUpdate.overrideZNear,
111  lastGFXUpdate.overrideZFar );
112  }
113  void UpdateGFXFrustum( GFXBOOL overrideZFrustum, float overrideZNear, float overrideZFar )
114  {
115  UpdateGFX( lastGFXUpdate.clip,
116  lastGFXUpdate.updateFrustum,
117  lastGFXUpdate.centerCamera,
118  overrideZFrustum,
119  overrideZNear,
120  overrideZFar );
121  }
123  {
124  UpdateGFX( lastGFXUpdate.clip,
125  lastGFXUpdate.updateFrustum,
126  lastGFXUpdate.centerCamera,
127  lastGFXUpdate.overrideZFrustum,
128  lastGFXUpdate.overrideZNear,
129  lastGFXUpdate.overrideZFar );
130  }
131  void UpdatePlanetGFX(); //clip true, frustum true at all times
132  Matrix * GetPlanetGFX();
133  void UpdateGLCenter();
134  void SetPosition( const QVector &origin, const Vector &velocity, const Vector &angular_velocity, const Vector &acceleration );
135  void GetPosition( QVector &vect )
136  {
137  vect = Coord;
138  }
140  {
141  return angular_velocity;
142  }
144  {
145  return velocity;
146  }
148  {
149  return accel;
150  }
152  {
153  p = P;
154  q = Q;
155  r = R;
156  }
157  const QVector& GetPosition() const
158  {
159  return Coord;
160  }
161  float GetZDist( const Vector &v ) const
162  {
163  return ::DotProduct( QVector( v )-Coord, QVector( R ) );
164  }
165  void SetOrientation( const Vector &p, const Vector &q, const Vector &r );
166  void SetSubwindow( float x, float y, float xsize, float ysize );
168  void SetZoom( float z );
169  float GetZoom() const;
170  void SetFov( float f );
171  float GetFov() const;
172  void Yaw( float rad );
173  void Pitch( float rad );
174  void Roll( float rad );
175  void XSlide( float factor );
176  void YSlide( float factor );
177  void ZSlide( float factor );
178  void RestoreViewPort( float xoffset, float yoffset );
179 };
180 
181 #endif
182