Browse Source

Touched up documentation

Thomas Buck 10 years ago
parent
commit
0039d47aae
12 changed files with 703 additions and 1772 deletions
  1. 1
    1
      Makefile
  2. 156
    308
      include/Quaternion.h
  3. 97
    206
      include/SDLSystem.h
  4. 68
    222
      include/Tree.h
  5. 106
    244
      include/Vector3d.h
  6. 127
    242
      include/ViewVolume.h
  7. 0
    4
      include/World.h
  8. 1
    1
      src/Network.cpp
  9. 44
    150
      src/Quaternion.cpp
  10. 41
    131
      src/SDLSystem.cpp
  11. 26
    112
      src/Vector3d.cpp
  12. 36
    151
      src/ViewVolume.cpp

+ 1
- 1
Makefile View File

@@ -296,7 +296,7 @@ endif
296 296
 #################################################################
297 297
 # Unit Test builds
298 298
 #################################################################
299
-TEST_FLAGS=$(FLAGS_ALL) -g -O0 -DDEBUG -lstdc++ -Iinclude
299
+TEST_FLAGS=$(FLAGS_ALL) -g -O0 -DDEBUG -DUNIT_TEST -lstdc++ -Iinclude
300 300
 
301 301
 TEST_MAP_TR5=~/.OpenRaider/paks/tr5/demo.trc
302 302
 TEST_MAP_TR4=~/.OpenRaider/paks/tr4/angkor1.tr4

+ 156
- 308
include/Quaternion.h View File

@@ -1,365 +1,213 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file include/Quaternion.h
3
+ * \brief Quaternion
3 4
  *
4
- * Project : Hel
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Quaternion
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: Quaternion now in C++ class form fresh from the grove
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- Test Defines -----------------------------------------------
17
- *
18
- * UNIT_TEST_QUATERNION - Builds Quaternion class as a console unit test
19
- *
20
- *-- History ------------------------------------------------
21
- *
22
- * 2002.12.16:
23
- * Mongoose - Created, based on mtk3d ( freyja )
24
- ================================================================*/
25
-
5
+ * \author Mongoose
6
+ */
26 7
 
27 8
 #ifndef _QUATERNION_H_
28 9
 #define _QUATERNION_H_
29 10
 
30 11
 #include <MatMath.h>
31 12
 
32
-class Quaternion
33
-{
34
- public:
35
-
36
-    ////////////////////////////////////////////////////////////
37
-    // Constructors
38
-    ////////////////////////////////////////////////////////////
13
+/*!
14
+ * \brief Quaternion
15
+ */
16
+class Quaternion {
17
+public:
39 18
 
19
+    /*!
20
+     * \brief Constructs an object of Quaternion
21
+     */
40 22
     Quaternion();
41
-    /*------------------------------------------------------
42
-     * Pre  :
43
-     * Post : Constructs an object of Quaternion
44
-     *
45
-     *-- History ------------------------------------------
46
-     *
47
-     * 2002.12.16:
48
-     * Mongoose - Created
49
-     ------------------------------------------------------*/
50 23
 
24
+    /*!
25
+     * \brief Constructs an object of Quaternion
26
+     * \param w W part of new Quaternion
27
+     * \param x X part of new Quaternion
28
+     * \param y Y part of new Quaternion
29
+     * \param z Z part of new Quaternion
30
+     */
51 31
     Quaternion(vec_t w, vec_t x, vec_t y, vec_t z);
52
-    /*------------------------------------------------------
53
-     * Pre  :
54
-     * Post : Constructs an object of Quaternion
55
-     *
56
-     *-- History ------------------------------------------
57
-     *
58
-     * 2002.12.16:
59
-     * Mongoose - Created
60
-     ------------------------------------------------------*/
61 32
 
33
+    /*!
34
+     * \brief Constructs an object of Quaternion
35
+     * \param v contents of new Quaternion
36
+     */
62 37
     Quaternion(vec4_t v);
63
-    /*------------------------------------------------------
64
-     * Pre  : v { w, x, y, z }
65
-     * Post : Constructs an object of Quaternion
66
-     *
67
-     *-- History ------------------------------------------
68
-     *
69
-     * 2002.12.16:
70
-     * Mongoose - Created
71
-     ------------------------------------------------------*/
72 38
 
39
+    /*!
40
+     * \brief Deconstructs an object of Quaternion
41
+     */
73 42
     ~Quaternion();
74
-    /*------------------------------------------------------
75
-     * Pre  : Quaternion object is allocated
76
-     * Post : Deconstructs an object of Quaternion
77
-     *
78
-     *-- History ------------------------------------------
79
-     *
80
-     * 2002.12.16:
81
-     * Mongoose - Created
82
-     ------------------------------------------------------*/
83
-
84
-
85
-    ////////////////////////////////////////////////////////////
86
-    // Public Accessors
87
-    ////////////////////////////////////////////////////////////
88 43
 
44
+    /*!
45
+     * \brief Get column order matrix equivalent of this quaternion
46
+     * \param m where matrix will be stored
47
+     */
89 48
     void getMatrix(matrix_t m);
90
-    /*------------------------------------------------------
91
-     * Pre  : Matrix is valid
92
-     * Post : Returns col order matrix equiv of this quaternion
93
-     *
94
-     *-- History ------------------------------------------
95
-     *
96
-     * 2002.05.08:
97
-     * Mongoose - Created
98
-     ------------------------------------------------------*/
99 49
 
50
+    /*!
51
+     * \brief Assign q to this quaternion
52
+     * \param q what to assign this quaternion to
53
+     * \returns this quaternion
54
+     */
100 55
     Quaternion &operator =(const Quaternion &q);
101
-    /*------------------------------------------------------
102
-     * Pre  :
103
-     * Post : Asigns Q to this quaternion
104
-     *        returns (this) resultant quaternion
105
-     *
106
-     *-- History ------------------------------------------
107
-     *
108
-     * 2002.05.08:
109
-     * Mongoose - Created
110
-     ------------------------------------------------------*/
111 56
 
112
-    Quaternion operator *(const Quaternion &q);
113
-    /*------------------------------------------------------
114
-     * Pre  :
115
-     * Post : Multiplies Q and this quaternion
116
-     *        returns resultant quaternion
117
-     *        ( Use normalize() call for unit quaternion )
57
+    /*!
58
+     * \brief Multiplies this quaternion.
118 59
      *
119
-     *-- History ------------------------------------------
60
+     * Use normalize() call for unit quaternion.
120 61
      *
121
-     * 2002.05.08:
122
-     * Mongoose - Created
123
-     ------------------------------------------------------*/
62
+     * \param q what to multiply this quaternion with
63
+     * \returns resultant quaternion
64
+     * \sa Quaternion::normalize()
65
+     */
66
+    Quaternion operator *(const Quaternion &q);
124 67
 
68
+    /*!
69
+     * \brief Divide from this quaternion
70
+     * \param q what to divide from this quaternion
71
+     * \returns resultant quaternion
72
+     */
125 73
     Quaternion operator /(const Quaternion &q);
126
-    /*------------------------------------------------------
127
-     * Pre  :
128
-     * Post : Dividess Q from this quaternion
129
-     *        returns quotient quaternion
130
-     *
131
-     *-- History ------------------------------------------
132
-     *
133
-     * 2002.05.08:
134
-     * Mongoose - Created
135
-     ------------------------------------------------------*/
136 74
 
75
+    /*!
76
+     * \brief Add to this quaternion
77
+     * \param q what to add to this quaternion
78
+     * \returns resultant quaternion
79
+     */
137 80
     Quaternion operator +(const Quaternion &q);
138
-    /*------------------------------------------------------
139
-     * Pre  :
140
-     * Post : Adds Q and this quaternion
141
-     *        returns resultant quaternion
142
-     *
143
-     *-- History ------------------------------------------
144
-     *
145
-     * 2002.05.08:
146
-     * Mongoose - Created
147
-     ------------------------------------------------------*/
148 81
 
82
+    /*!
83
+     * \brief Subtract from this quaternion
84
+     * \param q what to subtract from this quaternion
85
+     * \returns resultant quaternion
86
+     */
149 87
     Quaternion operator -(const Quaternion &q);
150
-    /*------------------------------------------------------
151
-     * Pre  :
152
-     * Post : Subtracts Q from this quaternion
153
-     *        returns resultant quaternion
154
-     *
155
-     *-- History ------------------------------------------
156
-     *
157
-     * 2002.05.08:
158
-     * Mongoose - Created
159
-     ------------------------------------------------------*/
160 88
 
89
+    /*!
90
+     * \brief Compares q to this quaternion
91
+     * \param q what to compare this quaternion to
92
+     * \returns true if equal, false otherwise
93
+     */
161 94
     bool operator ==(const Quaternion &q);
162
-    /*------------------------------------------------------
163
-     * Pre  :
164
-     * Post : Compares Q to this quaternion
165
-     *        returns boolean true if equal, otherwise false
166
-     *
167
-     *-- History ------------------------------------------
168
-     *
169
-     * 2002.05.08:
170
-     * Mongoose - Created
171
-     ------------------------------------------------------*/
172 95
 
96
+    /*!
97
+     * \brief Conjugate this quaternion
98
+     * \returns Conjugate of this quaternion
99
+     */
173 100
     Quaternion conjugate();
174
-    /*------------------------------------------------------
175
-     * Pre  :
176
-     * Post : Returns conjugate of this quaternion
177
-     *
178
-     *-- History ------------------------------------------
179
-     *
180
-     * 2002.05.08:
181
-     * Mongoose - Created
182
-     ------------------------------------------------------*/
183 101
 
102
+    /*!
103
+     * \brief Scale this quaternion
104
+     * \param s scaling factor
105
+     * \returns Scaled result of this quaternion
106
+     */
184 107
     Quaternion scale(vec_t s);
185
-    /*------------------------------------------------------
186
-     * Pre  :
187
-     * Post : Returns scaled result of this quaternion
188
-     *
189
-     *-- History ------------------------------------------
190
-     *
191
-     * 2002.05.08:
192
-     * Mongoose - Created
193
-     ------------------------------------------------------*/
194 108
 
109
+    /*!
110
+     * \brief Inverse this quaternion
111
+     * \brief Returns inverse of this quaternion
112
+     */
195 113
     Quaternion inverse();
196
-    /*------------------------------------------------------
197
-     * Pre  :
198
-     * Post : Returns inverse of this quaternion
199
-     *
200
-     *-- History ------------------------------------------
201
-     *
202
-     * 2002.05.08:
203
-     * Mongoose - Created
204
-     ------------------------------------------------------*/
205 114
 
115
+    /*!
116
+     * \brief Dot Product of quaternions
117
+     * \param a first argument to dot product
118
+     * \param b second argument to dot product
119
+     * \returns dot product between a and b quaternions
120
+     */
206 121
     static vec_t dot(Quaternion a, Quaternion b);
207
-    /*------------------------------------------------------
208
-     * Pre  :
209
-     * Post : Returns dot product of A and B quaternions
210
-     *
211
-     *-- History ------------------------------------------
212
-     *
213
-     * 2002.05.08:
214
-     * Mongoose - Created
215
-     ------------------------------------------------------*/
216 122
 
123
+    /*!
124
+     * \brief Magnitude of this quaternion
125
+     * \returns Magnitude of this quaternion
126
+     */
217 127
     vec_t magnitude();
218
-    /*------------------------------------------------------
219
-     * Pre  :
220
-     * Post : Returns magnitude this quaternion
221
-     *
222
-     *-- History ------------------------------------------
223
-     *
224
-     * 2002.05.08:
225
-     * Mongoose - Created
226
-     ------------------------------------------------------*/
227 128
 
228
-    static Quaternion slerp(Quaternion a, Quaternion b, vec_t time);
229
-    /*------------------------------------------------------
230
-     * Pre  :
231
-     * Post : Interpolates between A and B rotations and
232
-     *        returns resultant quaternion using
233
-     *        spherical linear interpolation:
234
-     *
235
-     *        I = (((B . A)^ -1)^ Time) A
129
+    /*!
130
+     * \brief Interpolates between a and b rotations.
236 131
      *
237
-     *-- History ------------------------------------------
132
+     * Using spherical linear interpolation:
133
+     * `I = (((B . A)^-1)^Time)A`
238 134
      *
239
-     * 2002.05.08:
240
-     * Mongoose - Created
241
-     ------------------------------------------------------*/
242
-
243
-
244
-    ////////////////////////////////////////////////////////////
245
-    // Public Mutators
246
-    ////////////////////////////////////////////////////////////
135
+     * \param a first argument for slerp
136
+     * \param b second argument for slerp
137
+     * \param t time argument for slerp
138
+     * \returns resultant quaternion
139
+     */
140
+    static Quaternion slerp(Quaternion a, Quaternion b, vec_t time);
247 141
 
142
+    /*!
143
+     * \brief Sets this quaternion to identity
144
+     */
248 145
     void setIdentity();
249
-    /*------------------------------------------------------
250
-     * Pre  :
251
-     * Post : Sets this quaternion to identity
252
-     *
253
-     *-- History ------------------------------------------
254
-     *
255
-     * 2002.05.08:
256
-     * Mongoose - Created
257
-     ------------------------------------------------------*/
258 146
 
147
+    /*!
148
+     * \brief Sets this quaternion
149
+     * \param angle new angle
150
+     * \param x new X coordinate
151
+     * \param y new Y coordinate
152
+     * \param z new Z coordinate
153
+     */
259 154
     void set(vec_t angle, vec_t x, vec_t y, vec_t z);
260
-    /*------------------------------------------------------
261
-     * Pre  :
262
-     * Post : Sets this quaternion
263
-     *
264
-     *-- History ------------------------------------------
265
-     *
266
-     * 2002.05.08:
267
-     * Mongoose - Created
268
-     ------------------------------------------------------*/
269 155
 
156
+    /*!
157
+     * \brief Normalize this quaternion
158
+     */
270 159
     void normalize();
271
-    /*------------------------------------------------------
272
-     * Pre  :
273
-     * Post : Normalize this quaternion
274
-     *
275
-     *-- History ------------------------------------------
276
-     *
277
-     * 2002.05.08:
278
-     * Mongoose - Created
279
-     ------------------------------------------------------*/
280 160
 
161
+    /*!
162
+     * \brief Set this quaternion
163
+     * \param q will be copied into this quaternion
164
+     */
281 165
     void copy(Quaternion q);
282
-    /*------------------------------------------------------
283
-     * Pre  :
284
-     * Post : Set this quaternion using q
285
-     *
286
-     *-- History ------------------------------------------
287
-     *
288
-     * 2002.05.08:
289
-     * Mongoose - Created
290
-     ------------------------------------------------------*/
291 166
 
167
+    /*!
168
+     * \brief Sets matrix equivalent of this quaternion
169
+     * \param m matrix in valid column order
170
+     */
292 171
     void setByMatrix(matrix_t m);
293
-    /*------------------------------------------------------
294
-     * Pre  : Matrix is valid column order
295
-     * Post : Sets matrix equiv of this quaternion
296
-     *
297
-     *-- History ------------------------------------------
298
-     *
299
-     * 2002.05.08:
300
-     * Mongoose - Created
301
-     ------------------------------------------------------*/
302
-
303
-
304
- private:
305
-
306
-    ////////////////////////////////////////////////////////////
307
-    // Private Accessors
308
-    ////////////////////////////////////////////////////////////
309
-
310
-    Quaternion multiply(Quaternion a, Quaternion b);
311
-    /*------------------------------------------------------
312
-     * Pre  :
313
-     * Post : Multiplies A and B quaternions
314
-     *        returns resultant quaternion
315
-     *
316
-     *-- History ------------------------------------------
317
-     *
318
-     * 2002.05.08:
319
-     * Mongoose - Created
320
-     ------------------------------------------------------*/
321
-
322
-    Quaternion divide(Quaternion a, Quaternion b);
323
-    /*------------------------------------------------------
324
-     * Pre  :
325
-     * Post : Divides B from A quaternion
326
-     *        returns quotient quaternion
327
-     *
328
-     *-- History ------------------------------------------
329
-     *
330
-     * 2002.05.08:
331
-     * Mongoose - Created
332
-     ------------------------------------------------------*/
333
-
334
-    Quaternion add(Quaternion a, Quaternion b);
335
-    /*------------------------------------------------------
336
-     * Pre  :
337
-     * Post : Adds A and B quaternions
338
-     *        returns resultant quaternion
339
-     *
340
-     *-- History ------------------------------------------
341
-     *
342
-     * 2002.05.08:
343
-     * Mongoose - Created
344
-     ------------------------------------------------------*/
345
-
346
-    Quaternion subtract(Quaternion a, Quaternion b);
347
-    /*------------------------------------------------------
348
-     * Pre  :
349
-     * Post : Subtracts B from A quaternion
350
-     *        returns resultant quaternion
351
-     *
352
-     *-- History ------------------------------------------
353
-     *
354
-     * 2002.05.08:
355
-     * Mongoose - Created
356
-     ------------------------------------------------------*/
357
-
358
-    ////////////////////////////////////////////////////////////
359
-    // Private Mutators
360
-    ////////////////////////////////////////////////////////////
361 172
 
362
-    vec_t mW, mX, mY, mZ;          /* Quaternion */
173
+private:
174
+
175
+    /*!
176
+     * \brief Multiplies two quaternions
177
+     * \param a first argument to multiplication
178
+     * \param b second argument to multiplication
179
+     * \returns resultant quaternion
180
+     */
181
+    static Quaternion multiply(Quaternion a, Quaternion b);
182
+
183
+    /*!
184
+     * \brief Divides B from A quaternion
185
+     * \param a first argument to division
186
+     * \param b second argument to division
187
+     * \returns quotient quaternion
188
+     */
189
+    static Quaternion divide(Quaternion a, Quaternion b);
190
+
191
+    /*!
192
+     * \brief Adds A and B quaternions
193
+     * \param a first argument to addition
194
+     * \param b second argument to addition
195
+     * \returns resultant quaternion
196
+     */
197
+    static Quaternion add(Quaternion a, Quaternion b);
198
+
199
+    /*!
200
+     * \brief Subtracts B from A quaternion
201
+     * \param a first argument to subtraction
202
+     * \param b second argument to subtraction
203
+     * \returns resultant quaternion
204
+     */
205
+    static Quaternion subtract(Quaternion a, Quaternion b);
206
+
207
+    vec_t mW; //!< Quaternion, W part
208
+    vec_t mX; //!< Quaternion, X part
209
+    vec_t mY; //!< Quaternion, Y part
210
+    vec_t mZ; //!< Quaternion, Z part
363 211
 };
364 212
 
365 213
 #endif

+ 97
- 206
include/SDLSystem.h View File

@@ -1,238 +1,129 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file include/SDLSystem.h
3
+ * \brief SDL System interface implementation
3 4
  *
4
- * Project : OpenRaider
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : SDLSystem
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments:
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History ------------------------------------------------
17
- *
18
- * 2002.06.06:
19
- * Mongoose - Created
20
- ================================================================*/
21
-
5
+ * \author Mongoose
6
+ */
22 7
 
23 8
 #ifndef _SDLSYSTEM_H_
24 9
 #define _SDLSYSTEM_H_
25 10
 
26 11
 #include <SDL/SDL.h>
27
-
28 12
 #include <System.h>
29 13
 
30
-class SDLSystem : public System
31
-{
32
- public:
33
-
34
-    ////////////////////////////////////////////////////////////
35
-    // Constructors
36
-    ////////////////////////////////////////////////////////////
14
+/*!
15
+ * \brief SDL System interface implementation
16
+ */
17
+class SDLSystem : public System {
18
+public:
37 19
 
20
+    /*!
21
+     * \brief Constructs an object of SDLSystem
22
+     */
38 23
     SDLSystem();
39
-    /*------------------------------------------------------
40
-     * Pre  :
41
-     * Post : Constructs an object of SDLSystem
42
-     *
43
-     *-- History ------------------------------------------
44
-     *
45
-     * 2002.06.06:
46
-     * Mongoose - Created
47
-     ------------------------------------------------------*/
48 24
 
25
+    /*!
26
+     * \brief Deconstructs an object of SDLSystem
27
+     */
49 28
     virtual ~SDLSystem();
50
-    /*------------------------------------------------------
51
-     * Pre  : SDL object is allocated
52
-     * Post : Deconstructs an object of SDLSystem
53
-     *
54
-     *-- History ------------------------------------------
55
-     *
56
-     * 2002.06.06:
57
-     * Mongoose - Created
58
-     ------------------------------------------------------*/
59
-
60
-
61
-    ////////////////////////////////////////////////////////////
62
-    // Public Accessors
63
-    ////////////////////////////////////////////////////////////
64 29
 
30
+    /*!
31
+     * \brief Get ticks
32
+     * \returns number of milliseconds since start of program
33
+     */
65 34
     virtual unsigned int getTicks();
66
-    /*------------------------------------------------------
67
-     * Pre  :
68
-     * Post : Returns number of milliseconds since start of
69
-     *        program
70
-     *
71
-     *-- History ------------------------------------------
72
-     *
73
-     * 2002.06.06:
74
-     * Mongoose - Created
75
-     ------------------------------------------------------*/
76
-
77
-
78
-    ////////////////////////////////////////////////////////////
79
-    // Public Mutators
80
-    ////////////////////////////////////////////////////////////
81
-
82
-    //FIXME: void bindKeyCommand(const char *cmd, int key, int event);
83
-    /*------------------------------------------------------
84
-     * Pre  : <Cmd> is a valid command string
85
-     *        <Key> is a valid keyboard code
86
-     *        <Event> is a valid game event Id
87
-     *
88
-     * Post : Sets <Event> binding <Cmd> to <Key> press
89
-     *
90
-     *-- History ------------------------------------------
91
-     *
92
-     * 2003.06.03:
93
-     * Mongoose - Created
94
-     ------------------------------------------------------*/
95
-
96
-   void glPrintf2d(float x, float y, char *string);
97
-   /*------------------------------------------------------
98
-    * Pre  : <X>, and <Y> are valid world coordinates
99
-     *        <String> is a valid string
100
-     *
101
-     *        Requires glEnterMode2d() call before entry
102
-     *
103
-     *        System::bufferString(..) can cache printf()
104
-     *        style calls for use with this method
105
-     *
106
-    * Post : Renders string in OpenGL ( 2d projection )
107
-     *
108
-     *        Call glExitMode2d() after finishing calls
109
-     *        to this method and other 2d rendering
110
-    *
111
-    *-- History ------------------------------------------
112
-    *
113
-     * 2003.06.03:
114
-     * Mongoose - Ported to SDL_TTF
115
-     *
116
-    * 2001.12.31:
117
-    * Mongoose - Created
118
-    ------------------------------------------------------*/
119
-
120
-   void glPrintf3d(float x, float y, float z, char *string);
121
-   /*------------------------------------------------------
122
-    * Pre  : <X>, <Y>, and <Z> are valid world coordinates
123
-     *        <String> is a valid string
124
-     *
125
-     *        System::bufferString(..) can cache printf()
126
-     *        style calls for use with this method
127
-     *
128
-    * Post : Renders string in OpenGL ( 3d projection )
129
-    *
130
-    *-- History ------------------------------------------
131
-    *
132
-     * 2003.06.03:
133
-     * Mongoose - Ported to SDL_TTF
134
-     *
135
-    * 2001.12.31:
136
-    * Mongoose - Created
137
-    ------------------------------------------------------*/
138
-
139
-    void initVideo(unsigned int width, unsigned int height,
140
-                        bool fullscreen);
141
-    /*------------------------------------------------------
142
-     * Pre  : Video mode request <Width> x <Height>
143
-     *        <Fullscreen> enables fullscreen rendering
144
-     *
145
-     * Post : Start up video subsystem
146
-     *
147
-     *-- History ------------------------------------------
148
-     *
149
-     * 2002.06.06:
150
-     * Mongoose - Created
151
-     ------------------------------------------------------*/
152 35
 
36
+    /*
37
+     * \brief Sets Event binding Cmd to Key press
38
+     * \param cmd valid command string
39
+     * \param key valid keyboard code
40
+     * \param event valid game event id
41
+     */
42
+    //! \fixme void bindKeyCommand(const char *cmd, int key, int event);
43
+
44
+    /*!
45
+     * \brief Renders string in OpenGL (2D projection).
46
+     *
47
+     * Requires Texture::glEnterMode2d() call before entry.
48
+     *
49
+     * System::bufferString(..) can cache printf() style calls
50
+     * for use with this method.
51
+     *
52
+     * Call Texture::glExitMode2d after finishing calls to this method
53
+     * and other 2D rendering.
54
+     *
55
+     * \param x valid X world coordinate
56
+     * \param y valid Y world coordinate
57
+     * \param string valid string
58
+     *
59
+     * \sa System::bufferString()
60
+     * \sa Texture::glEnterMode2d()
61
+     * \sa Texture::glExitMode2d()
62
+     */
63
+    void glPrintf2d(float x, float y, char *string);
64
+
65
+    /*!
66
+     * \brief Renders string in OpenGL (3D projection).
67
+     *
68
+     * System::bufferString(..) can cache printf() style calls
69
+     * for use with this method.
70
+     *
71
+     * \param x valid X world coordinate
72
+     * \param y valid Y world coordinate
73
+     * \param z valid Z world coordinate
74
+     * \param string valid string
75
+     *
76
+     * \sa System::bufferString()
77
+     */
78
+    void glPrintf3d(float x, float y, float z, char *string);
79
+
80
+    /*!
81
+     * \brief Start up video subsystem
82
+     * \param width valid video mode width
83
+     * \param height valid video mode height
84
+     * \param fullscreen enables fullscreen rendering
85
+     */
86
+    void initVideo(unsigned int width, unsigned int height, bool fullscreen);
87
+
88
+    /*!
89
+     * \brief Resizes game window
90
+     * \param width new width
91
+     * \param height new height
92
+     */
153 93
     void resize(unsigned int width, unsigned int height);
154
-    /*------------------------------------------------------
155
-     * Pre  :
156
-     * Post : Resizes game window
157
-     *
158
-     *-- History ------------------------------------------
159
-     *
160
-     * 2002.06.06:
161
-     * Mongoose - Created, from old SDLUnitTest code
162
-     ------------------------------------------------------*/
163 94
 
95
+    /*!
96
+     * \brief Start game loop
97
+     */
164 98
     void runGame();
165
-    /*------------------------------------------------------
166
-     * Pre  :
167
-     * Post : Start game loop
168
-     *
169
-     *-- History ------------------------------------------
170
-     *
171
-     * 2002.06.06:
172
-     * Mongoose - Created
173
-     ------------------------------------------------------*/
174 99
 
175 100
     void setGrabMouse(bool on);
176
-    /*------------------------------------------------------
177
-     * Pre  :
178
-     * Post :
179
-     *
180
-     *-- History ------------------------------------------
181
-     *
182
-     * 2003.01.05:
183
-     * Mongoose - Created
184
-     ------------------------------------------------------*/
185 101
 
102
+    /*!
103
+     * \brief Shuts down the game subsystems, exits game loop
104
+     * \param i exit code
105
+     */
186 106
     void shutdown(int i);
187
-    /*------------------------------------------------------
188
-     * Pre  :
189
-     * Post : Shutsdown the game subsystems, exits game loop
190
-     *
191
-     *-- History ------------------------------------------
192
-     *
193
-     * 2002.06.06:
194
-     * Mongoose - Created
195
-     ------------------------------------------------------*/
196 107
 
108
+    /*!
109
+     * \brief Swaps OpenGL buffers.
110
+     * Call at end of frame.
111
+     */
197 112
     void swapBuffersGL();
198
-    /*------------------------------------------------------
199
-     * Pre  :
200
-     * Post : Swaps OpenGL buufers ( call at end of frame )
201
-     *
202
-     *-- History ------------------------------------------
203
-     *
204
-     * 2002.06.06:
205
-     * Mongoose - Created
206
-     ------------------------------------------------------*/
207 113
 
114
+    /*!
115
+     * \brief Toggle fullscreen windowing mode
116
+     */
208 117
     void toggleFullscreen();
209
-    /*------------------------------------------------------
210
-     * Pre  :
211
-     * Post : Toggle fullscreen windowing mode
212
-     *
213
-     *-- History ------------------------------------------
214
-     *
215
-     * 2002.06.06:
216
-     * Mongoose - Created
217
-     ------------------------------------------------------*/
218 118
 
219
- protected:
119
+protected:
220 120
     int m_old_width;
221 121
     int m_old_height;
222
-    bool mFirstMouseEvent; // Filter first mouse event (SDL bug)
223
-    bool mFullscreen; //!< Current Fullscreen/Windowed mode
224
-
225
- private:
226
-
227
-    ////////////////////////////////////////////////////////////
228
-    // Private Accessors
229
-    ////////////////////////////////////////////////////////////
122
+    bool mFirstMouseEvent; //!< Filter first mouse event (SDL bug)
123
+    bool mFullscreen;      //!< Current Fullscreen/Windowed mode
230 124
 
231
-
232
-    ////////////////////////////////////////////////////////////
233
-    // Private Mutators
234
-    ////////////////////////////////////////////////////////////
235
-
236
-    SDL_Surface *mWindow;   /* This is the pointer to the SDL surface */
125
+private:
126
+    SDL_Surface *mWindow;  //!< This is the pointer to the SDL surface
237 127
 };
128
+
238 129
 #endif

+ 68
- 222
include/Tree.h View File

@@ -658,116 +658,77 @@ public:
658 658
 
659 659
 private:
660 660
 
661
-    TreeNode<Key, Data> *GetSuccessor(TreeNode<Key, Data> *tree)
662
-    {
661
+    TreeNode<Key, Data> *GetSuccessor(TreeNode<Key, Data> *tree) {
663 662
         TreeNode<Key, Data> *successor;
664
-
665
-
666 663
         successor = tree->GetRight();
667 664
 
668
-        if (successor)
669
-        {
665
+        if (successor) {
670 666
             while (successor->GetLeft())
671
-            {
672 667
                 successor = successor->GetLeft();
673
-            }
674
-
675
-            return successor;
676
-        }
677
-        else
678
-        {
668
+        } else {
679 669
             successor = tree->GetParent();
680 670
 
681
-            while (tree == successor->GetRight())
682
-            {
671
+            while (tree == successor->GetRight()) {
683 672
                 tree = successor;
684 673
                 successor = successor->GetParent();
685 674
             }
686 675
 
687 676
             if (successor == _root)
688
-            {
689 677
                 return NULL;
690
-            }
691
-
692
-            return successor;
693 678
         }
694
-    }
695 679
 
680
+        return successor;
681
+    }
696 682
 
697
-    TreeNode<Key, Data> *GetPredecessor(TreeNode<Key, Data> *tree)
698
-    {
683
+    TreeNode<Key, Data> *GetPredecessor(TreeNode<Key, Data> *tree) {
699 684
         TreeNode<Key, Data> *predecessor;
700
-
701
-
702 685
         predecessor = tree->GetLeft();
703 686
 
704
-        if (predecessor)
705
-        {
687
+        if (predecessor) {
706 688
             while (predecessor->GetRight())
707
-            {
708 689
                 predecessor = predecessor->GetRight();
709
-            }
710
-
711
-            return predecessor;
712
-        }
713
-        else
714
-        {
690
+        } else {
715 691
             predecessor = tree->GetParent();
716 692
 
717
-            while (tree == predecessor->GetLeft())
718
-            {
693
+            while (tree == predecessor->GetLeft()) {
719 694
                 if (predecessor == _root)
720
-                {
721 695
                     return NULL;
722
-                }
723 696
 
724 697
                 tree = predecessor;
725 698
                 predecessor = predecessor->GetParent();
726 699
             }
727
-
728
-            return predecessor;
729 700
         }
730
-    }
731 701
 
702
+        return predecessor;
703
+    }
732 704
 
733
-    bool IsValidRedBlackTreeCheck(TreeNode<Key, Data> *current, bool valid)
734
-    {
705
+    bool IsValidRedBlackTreeCheck(TreeNode<Key, Data> *current, bool valid) {
735 706
         TreeNode<Key, Data> *right, *left;
736 707
         _tree_h_color_t color_red;
737 708
 
738 709
         if (!current)
739
-        {
740 710
             return valid;
741
-        }
742 711
 
743 712
         // Mongoose 2002.02.19, Check for a red root
744 713
         if (!current->GetParent() && current->GetColor() == _tree_h_red)
745
-        {
746 714
             return false;
747
-        }
748 715
 
749 716
         color_red = (current->GetColor() == _tree_h_red);
750 717
         left = current->GetLeft();
751 718
         right = current->GetRight();
752 719
 
753 720
         // Mongoose 2002.02.19, Check for adj red nodes
754
-        if (left)
755
-        {
721
+        if (left) {
756 722
             if (color_red && left->GetColor() == _tree_h_red)
757
-            {
758 723
                 return false;
759
-            }
760 724
 
761 725
             if (!IsValidRedBlackTreeCheck(left, valid))
762 726
                 return false;
763 727
         }
764 728
 
765
-        if (right)
766
-        {
729
+        if (right) {
767 730
             if (color_red && right->GetColor() == _tree_h_red)
768
-            {
769 731
                 return false;
770
-            }
771 732
 
772 733
             if (!IsValidRedBlackTreeCheck(right, valid))
773 734
                 return false;
@@ -776,16 +737,11 @@ private:
776 737
         return true;
777 738
     }
778 739
 
779
-
780
-    void RotateLeft(TreeNode<Key, Data> *tree)
781
-    {
740
+    void RotateLeft(TreeNode<Key, Data> *tree) {
782 741
         TreeNode<Key, Data> *right, *right_leftchild, *parent, *uncle;
783 742
 
784
-
785 743
         if (!tree || !_root)
786
-        {
787 744
             return;
788
-        }
789 745
 
790 746
         // Get tree's right node
791 747
         right = tree->GetRight();
@@ -794,207 +750,142 @@ private:
794 750
         right_leftchild = NULL;
795 751
 
796 752
         if (right)
797
-        {
798 753
             right_leftchild = right->GetLeft();
799
-        }
800 754
 
801 755
         // Set tree's right node to right's left child
802 756
         tree->SetRight(right_leftchild);
803 757
 
804 758
         // Child now has a new parent
805 759
         if (right_leftchild)
806
-        {
807 760
             right_leftchild->SetParent(tree);
808
-        }
809 761
 
810 762
         // Right also has a new parent
811 763
         if (right)
812
-        {
813
-        right->SetParent(tree->GetParent());
814
-        }
764
+            right->SetParent(tree->GetParent());
815 765
 
816 766
         // Get parent
817 767
         parent = tree->GetParent();
818 768
 
819
-        if (parent)  // Not root
820
-        {
769
+        if (parent) { // Not root
821 770
             uncle = parent->GetLeft();
822 771
 
823 772
             // Mix up at hosptial, switch parent's children!
824 773
             if (tree == uncle)
825
-            {
826 774
                 parent->SetLeft(right);
827
-            }
828 775
             else
829
-            {
830 776
                 parent->SetRight(right);
831
-            }
832
-        }
833
-        else // TreeNode 'tree' was root, so now right is root
834
-        {
777
+        } else { // TreeNode 'tree' was root, so now right is root
835 778
             _root = right;
836 779
         }
837 780
 
838
-        if (right)
839
-        {
781
+        if (right) {
840 782
             // TreeNode 'tree' is now right's left child
841 783
             right->SetLeft(tree);
842 784
 
843 785
             if (tree)
844
-            {
845 786
                 tree->SetParent(right);
846
-            }
847 787
         }
848 788
     }
849 789
 
850
-
851
-    void RotateRight(TreeNode<Key, Data> *tree)
852
-    {
790
+    void RotateRight(TreeNode<Key, Data> *tree) {
853 791
         TreeNode<Key, Data> *left, *left_rightchild, *parent, *uncle;
854 792
 
855
-
856 793
         if (!tree || !_root)
857
-        {
858 794
             return;
859
-        }
860 795
 
861 796
         left = tree->GetLeft();
862 797
 
863 798
         left_rightchild = NULL;
864 799
 
865 800
         if (left)
866
-        {
867 801
             left_rightchild = left->GetRight();
868
-        }
869 802
 
870 803
         tree->SetLeft(left_rightchild);
871 804
 
872 805
         if (left_rightchild)
873
-        {
874
-        left_rightchild->SetParent(tree);
875
-        }
806
+            left_rightchild->SetParent(tree);
876 807
 
877 808
         if (left)
878
-        {
879
-        left->SetParent(tree->GetParent());
880
-        }
809
+            left->SetParent(tree->GetParent());
881 810
 
882 811
         parent = tree->GetParent();
883 812
 
884
-        if (parent)    //if node is not the root
885
-        {
813
+        if (parent) { //if node is not the root
886 814
             uncle = parent->GetRight();
887 815
 
888 816
             if (tree == uncle)
889
-            {
890 817
                 parent->SetRight(left);
891
-            }
892 818
             else
893
-            {
894 819
                 parent->SetLeft(left);
895
-            }
896
-        }
897
-        else
898
-        {
820
+        } else {
899 821
         _root = left;
900 822
         }
901 823
 
902 824
         left->SetRight(tree);
903 825
 
904 826
         if (tree)
905
-        {
906
-        tree->SetParent(left);
907
-        }
827
+            tree->SetParent(left);
908 828
     }
909 829
 
910 830
 
911 831
     void TreeNodeShallowCopy(TreeNode<Key, Data> *src,
912
-                                     TreeNode<Key, Data> *dest, bool no_links)
913
-    {
832
+                                TreeNode<Key, Data> *dest, bool no_links) {
914 833
         if (!src || !dest)
915
-        {
916 834
             return;
917
-        }
918 835
 
919 836
         dest->SetKey(src->GetKey());
920 837
         dest->SetData(src->GetData());
921 838
         dest->SetColor(src->GetColor());
922 839
 
923
-        if (!no_links)
924
-        {
840
+        if (!no_links) {
925 841
             dest->SetRight(src->GetRight());
926 842
             dest->SetLeft(src->GetLeft());
927 843
             dest->SetParent(src->GetParent());
928 844
         }
929 845
     }
930 846
 
931
-
932
-    void Remove(TreeNode<Key, Data> *tree)
933
-    {
847
+    void Remove(TreeNode<Key, Data> *tree) {
934 848
         TreeNode<Key, Data> *left, *right, *parent, *prev, *cur;
935 849
 
936
-
937 850
         // Mongoose 2002.02.16, Nothing to remove
938 851
         if (!tree || !_root)
939
-        {
940 852
             return;
941
-        }
942 853
 
943 854
         left = tree->GetLeft();
944 855
         right = tree->GetRight();
945 856
         parent = tree->GetParent();
946 857
 
947
-
948 858
         if (!left || !right)
949
-        {
950 859
             prev = tree;
951
-        }
952 860
         else
953
-        {
954 861
             prev = GetSuccessor(tree);
955
-        }
956 862
 
957 863
         if (!prev)
958 864
             return; // Probably a good idea, as there's a check if(prev) later
959 865
 
960 866
         if (prev->GetLeft())
961
-        {
962 867
             cur = prev->GetLeft();
963
-        }
964 868
         else
965
-        {
966 869
             cur = prev->GetRight();
967
-        }
968 870
 
969 871
         if (cur)
970
-        {
971 872
             cur->SetParent(prev->GetParent());
972
-        }
973 873
 
974
-        if (!prev->GetParent())
975
-        {
874
+        if (!prev->GetParent()) {
976 875
             _root = cur;
977
-        }
978
-        else
979
-        {
876
+        } else {
980 877
             parent = prev->GetParent();
981 878
 
982 879
             if (prev == parent->GetLeft())
983
-            {
984 880
                 parent->SetLeft(cur);
985
-            }
986 881
             else
987
-            {
988 882
                 parent->SetRight(cur);
989
-            }
990 883
         }
991 884
 
992
-        if (prev != tree)
993
-        {
885
+        if (prev != tree) {
994 886
             TreeNodeShallowCopy(prev, tree, true);
995 887
 
996
-            if (prev->GetParent())
997
-            {
888
+            if (prev->GetParent()) {
998 889
                 if (prev == (prev->GetParent())->GetLeft())
999 890
                     (prev->GetParent())->SetLeft(tree);
1000 891
                 else if (prev == (prev->GetParent())->GetRight())
@@ -1004,8 +895,7 @@ private:
1004 895
 
1005 896
         --_num_elements;
1006 897
 
1007
-        if (prev)
1008
-        {
898
+        if (prev) {
1009 899
             prev->SetRight(NULL);
1010 900
             prev->SetParent(NULL);
1011 901
             prev->SetLeft(NULL);
@@ -1014,58 +904,41 @@ private:
1014 904
         }
1015 905
 
1016 906
         if (tree->GetColor() == _tree_h_black)
1017
-        {
1018 907
             RestoreRedBlackAfterRemove(cur);
1019
-        }
1020 908
     }
1021 909
 
1022
-
1023
-    void RestoreRedBlackAfterRemove(TreeNode<Key, Data> *tree)
1024
-    {
910
+    void RestoreRedBlackAfterRemove(TreeNode<Key, Data> *tree) {
1025 911
         TreeNode<Key, Data> *parent, *sibling, *sleft, *sright;
1026 912
 
1027
-
1028 913
         if (!tree || !_root)
1029
-        {
1030 914
             return;
1031
-        }
1032 915
 
1033 916
         parent = tree->GetParent();
1034 917
 
1035
-        while ((tree != _root) && (parent->GetColor() == _tree_h_black))
1036
-        {
1037
-            if (tree == parent->GetLeft())
1038
-            {
918
+        while ((tree != _root) && (parent->GetColor() == _tree_h_black)) {
919
+            if (tree == parent->GetLeft()) {
1039 920
                 sibling = parent->GetRight();
1040 921
 
1041
-                if (sibling && sibling->GetColor() == _tree_h_red)
1042
-                {
922
+                if (sibling && sibling->GetColor() == _tree_h_red) {
1043 923
                     sibling->SetColor(_tree_h_black);
1044 924
                     parent->SetColor(_tree_h_red);
1045 925
                     RotateLeft(parent);
1046 926
                     sibling = parent->GetRight();
1047 927
                 }
1048 928
 
1049
-                if (sibling)
1050
-                {
929
+                if (sibling) {
1051 930
                     sleft = sibling->GetLeft();
1052 931
                     sright = sibling->GetRight();
1053
-                }
1054
-                else
1055
-                {
932
+                } else {
1056 933
                     sleft = sright = NULL;
1057 934
                 }
1058 935
 
1059 936
                 if (sright && sright->GetColor() == _tree_h_black &&
1060
-                     sleft && sleft->GetColor() ==_tree_h_black)
1061
-                {
937
+                        sleft && sleft->GetColor() ==_tree_h_black) {
1062 938
                     sibling->SetColor(_tree_h_red);
1063 939
                     tree = parent;
1064
-                }
1065
-                else
1066
-                {
1067
-                    if (sright && sright->GetColor() == _tree_h_black)
1068
-                    {
940
+                } else {
941
+                    if (sright && sright->GetColor() == _tree_h_black) {
1069 942
                         sibling->SetColor(_tree_h_red);
1070 943
                         sleft->SetColor(_tree_h_black);
1071 944
                         RotateRight(sibling);
@@ -1078,39 +951,29 @@ private:
1078 951
                     RotateLeft(parent);
1079 952
                     tree = _root;
1080 953
                 }
1081
-            }
1082
-            else
1083
-            {
954
+            } else {
1084 955
                 sibling = parent->GetLeft();
1085 956
 
1086
-                if (sibling && sibling->GetColor() == _tree_h_red)
1087
-                {
957
+                if (sibling && sibling->GetColor() == _tree_h_red) {
1088 958
                     sibling->SetColor(_tree_h_black);
1089 959
                     parent->SetColor(_tree_h_red);
1090 960
                     RotateLeft(parent);
1091 961
                     sibling = parent->GetLeft();
1092 962
                 }
1093 963
 
1094
-                if (sibling)
1095
-                {
964
+                if (sibling) {
1096 965
                     sleft = sibling->GetLeft();
1097 966
                     sright = sibling->GetRight();
1098
-                }
1099
-                else
1100
-                {
967
+                } else {
1101 968
                     sleft = sright = NULL;
1102 969
                 }
1103 970
 
1104 971
                 if (sright && sright->GetColor() == _tree_h_black &&
1105
-                     sleft && sleft->GetColor() ==_tree_h_black)
1106
-                {
972
+                     sleft && sleft->GetColor() ==_tree_h_black) {
1107 973
                     sibling->SetColor(_tree_h_red);
1108 974
                     tree = parent;
1109
-                }
1110
-                else
1111
-                {
1112
-                    if (sleft && sleft->GetColor() == _tree_h_black)
1113
-                    {
975
+                } else {
976
+                    if (sleft && sleft->GetColor() == _tree_h_black) {
1114 977
                         sibling->SetColor(_tree_h_red);
1115 978
                         sright->SetColor(_tree_h_black);
1116 979
                         RotateLeft(sibling);
@@ -1131,43 +994,32 @@ private:
1131 994
         tree->SetColor(_tree_h_black);
1132 995
     }
1133 996
 
1134
-
1135
-    void RestoreRedBlackAfterInsert(TreeNode<Key, Data> *tree)
1136
-    {
997
+    void RestoreRedBlackAfterInsert(TreeNode<Key, Data> *tree) {
1137 998
         TreeNode<Key, Data> *parent, *grandparent, *uncle;
1138 999
 
1139
-
1140 1000
         if (!tree || !_root || tree == _root)
1141
-        {
1142 1001
             return;
1143
-        }
1144 1002
 
1145 1003
         tree->SetColor(_tree_h_red);
1146 1004
 
1147 1005
         parent = tree->GetParent();
1148 1006
 
1149
-        while ((tree != _root) && (parent->GetColor() == _tree_h_red))
1150
-        {
1007
+        while ((tree != _root) && (parent->GetColor() == _tree_h_red)) {
1151 1008
             grandparent = parent->GetParent();
1152 1009
 
1153
-            if (parent == grandparent->GetLeft())
1154
-            {
1010
+            if (parent == grandparent->GetLeft()) {
1155 1011
                 uncle = grandparent->GetRight();
1156 1012
 
1157
-                if (uncle && uncle->GetColor() == _tree_h_red)
1158
-                {
1159
-               // Case 1 - Change the colors
1160
-               parent->SetColor(_tree_h_black);
1013
+                if (uncle && uncle->GetColor() == _tree_h_red) {
1014
+                    // Case 1 - Change the colors
1015
+                    parent->SetColor(_tree_h_black);
1161 1016
                     uncle->SetColor(_tree_h_black);
1162 1017
                     grandparent->SetColor(_tree_h_red);
1163 1018
 
1164
-               // Move up the tree
1165
-               tree = grandparent;
1166
-                }
1167
-                else // Uncle is a black node
1168
-                {
1169
-               if (tree == parent->GetRight())
1170
-                    {
1019
+                    // Move up the tree
1020
+                    tree = grandparent;
1021
+                } else { // Uncle is a black node
1022
+                    if (tree == parent->GetRight()) {
1171 1023
                         // Case 2 - Move up and rotate
1172 1024
                         tree = parent;
1173 1025
                         RotateLeft(tree);
@@ -1180,25 +1032,19 @@ private:
1180 1032
                     grandparent->SetColor(_tree_h_red);
1181 1033
                     RotateRight(grandparent);
1182 1034
                 }
1183
-            }
1184
-            else // TreeNode 'tree' is in right subtree
1185
-            {
1035
+            } else { // TreeNode 'tree' is in right subtree
1186 1036
                 uncle = grandparent->GetLeft();
1187 1037
 
1188
-                if (uncle && uncle->GetColor() == _tree_h_red)
1189
-                {
1190
-               // Case 1 - Change the colors
1191
-               parent->SetColor(_tree_h_black);
1038
+                if (uncle && uncle->GetColor() == _tree_h_red) {
1039
+                    // Case 1 - Change the colors
1040
+                    parent->SetColor(_tree_h_black);
1192 1041
                     uncle->SetColor(_tree_h_black);
1193 1042
                     grandparent->SetColor(_tree_h_red);
1194 1043
 
1195
-               // Move up the tree
1196
-               tree = grandparent;
1197
-                }
1198
-                else // Uncle is a black node
1199
-                {
1200
-               if (tree == parent->GetLeft())
1201
-                    {
1044
+                    // Move up the tree
1045
+                    tree = grandparent;
1046
+                } else { // Uncle is a black node
1047
+                    if (tree == parent->GetLeft()) {
1202 1048
                         // Case 2 - Move up and rotate
1203 1049
                         tree = parent;
1204 1050
                         RotateRight(tree);

+ 106
- 244
include/Vector3d.h View File

@@ -1,297 +1,159 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file include/Vector3d.h
3
+ * \brief 3D Math vector
3 4
  *
4
- * Project : Hel
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Vector3d
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: Math vector
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- Test Defines -----------------------------------------------
17
- *
18
- * UNIT_TEST_VECTOR3D - Builds Vector3d class as a console unit test
19
- *
20
- *-- History ------------------------------------------------
21
- *
22
- * 2002.12.24:
23
- * Mongoose - Created
24
- ================================================================*/
25
-
5
+ * \author Mongoose
6
+ */
26 7
 
27 8
 #ifndef _VECTOR3D_H_
28 9
 #define _VECTOR3D_H_
29 10
 
30
-
31 11
 #include <MatMath.h>
32 12
 
33
-class Vector3d
34
-{
35
- public:
36
-
37
-    ////////////////////////////////////////////////////////////
38
-    // Constructors
39
-    ////////////////////////////////////////////////////////////
13
+/*!
14
+ * \brief 3D Math Vector
15
+ */
16
+class Vector3d {
17
+public:
40 18
 
19
+    /*!
20
+     * \brief Constructs an object of Vector3d
21
+     */
41 22
     Vector3d();
42
-    /*------------------------------------------------------
43
-     * Pre  :
44
-     * Post : Constructs an object of Vector3d
45
-     *
46
-     *-- History ------------------------------------------
47
-     *
48
-     * 2002.12.24:
49
-     * Mongoose - Created
50
-     ------------------------------------------------------*/
51 23
 
24
+    /*!
25
+     * \brief Constructs an object of Vector3d
26
+     * \param v data to load into new Vector3d
27
+     */
52 28
     Vector3d(vec3_t v);
53
-    /*------------------------------------------------------
54
-     * Pre  :
55
-     * Post : Constructs an object of Vector3d
56
-     *
57
-     *-- History ------------------------------------------
58
-     *
59
-     * 2002.12.24:
60
-     * Mongoose - Created
61
-     ------------------------------------------------------*/
62 29
 
30
+    /*!
31
+     * \brief Constructs an object of Vector3d
32
+     * \param x X part of new Vector3d
33
+     * \param y Y part of new Vector3d
34
+     * \param z Z part of new Vector3d
35
+     */
63 36
     Vector3d(vec_t x, vec_t y, vec_t z);
64
-    /*------------------------------------------------------
65
-     * Pre  :
66
-     * Post : Constructs an object of Vector3d
67
-     *
68
-     *-- History ------------------------------------------
69
-     *
70
-     * 2002.12.24:
71
-     * Mongoose - Created
72
-     ------------------------------------------------------*/
73 37
 
38
+    /*!
39
+     * \brief Deconstructs an object of Vector3d
40
+     */
74 41
     ~Vector3d();
75
-    /*------------------------------------------------------
76
-     * Pre  : Vector3d object is allocated
77
-     * Post : Deconstructs an object of Vector3d
78
-     *
79
-     *-- History ------------------------------------------
80
-     *
81
-     * 2002.12.24:
82
-     * Mongoose - Created
83
-     ------------------------------------------------------*/
84
-
85
-
86
-    ////////////////////////////////////////////////////////////
87
-    // Public Accessors
88
-    ////////////////////////////////////////////////////////////
89 42
 
43
+    /*!
44
+     * \brief Calculate dot product
45
+     * \param u first argument
46
+     * \param v second argument
47
+     * \returns dot product of u and v vectors
48
+     */
90 49
     static vec_t dot(const Vector3d &u, const Vector3d &v);
91
-    /*------------------------------------------------------
92
-     * Pre  :
93
-     * Post : Returns dot product of U and V vectors
94
-     *
95
-     *-- History ------------------------------------------
96
-     *
97
-     * 2002.05.08:
98
-     * Mongoose - Created
99
-     ------------------------------------------------------*/
100 50
 
51
+    /*!
52
+     * \brief Calculate cross product
53
+     * \param u first argument
54
+     * \param v second argument
55
+     * \returns cross product of u and v vectors
56
+     */
101 57
     static Vector3d cross(const Vector3d &u, const Vector3d &v);
102
-    /*------------------------------------------------------
103
-     * Pre  :
104
-     * Post : Returns cross product of U and V vectors
105
-     *
106
-     *-- History ------------------------------------------
107
-     *
108
-     * 2002.05.08:
109
-     * Mongoose - Created
110
-     ------------------------------------------------------*/
111 58
 
59
+    /*!
60
+     * \brief Get Magnitude
61
+     * \returns magnitude of this vector
62
+     */
112 63
     vec_t magnitude();
113
-    /*------------------------------------------------------
114
-     * Pre  :
115
-     * Post : Returns magnitude this vector
116
-     *
117
-     *-- History ------------------------------------------
118
-     *
119
-     * 2002.05.08:
120
-     * Mongoose - Created
121
-     ------------------------------------------------------*/
122 64
 
65
+    /*!
66
+     * \brief Normalize
67
+     * \returns normalized copy of this vector
68
+     */
123 69
     Vector3d unit();
124
-    /*------------------------------------------------------
125
-     * Pre  :
126
-     * Post : Returns normalized copy of this vector
127
-     *
128
-     *-- History ------------------------------------------
129
-     *
130
-     * 2002.05.08:
131
-     * Mongoose - Created
132
-     ------------------------------------------------------*/
133 70
 
71
+    /*!
72
+     * \brief Get the Zero vector
73
+     * \returns (0, 0, 0) vector
74
+     */
134 75
     static Vector3d zeroVector();
135
-    /*------------------------------------------------------
136
-     * Pre  :
137
-     * Post : Returns the Zero vector <0, 0, 0>
138
-     *
139
-     *-- History ------------------------------------------
140
-     *
141
-     * 2003.06.08:
142
-     * Mongoose - Created
143
-     ------------------------------------------------------*/
144 76
 
77
+    /*!
78
+     * \brief Add to this vector
79
+     * \param v addend
80
+     * \returns a vector = this vector + v
81
+     */
145 82
     Vector3d operator +(const Vector3d &v);
146
-    /*------------------------------------------------------
147
-     * Pre  :
148
-     * Post : Returns a vector = this vector + v
149
-     *
150
-     *-- History ------------------------------------------
151
-     *
152
-     * 2002.05.08:
153
-     * Mongoose - Created
154
-     ------------------------------------------------------*/
155 83
 
84
+    /*!
85
+     * \brief Subtract from this vector
86
+     * \param v subtrahend
87
+     * \returns a vector = this vector - v
88
+     */
156 89
     Vector3d operator -(const Vector3d &v);
157
-    /*------------------------------------------------------
158
-     * Pre  :
159
-     * Post : Returns a vector = this vector - v
160
-     *
161
-     *-- History ------------------------------------------
162
-     *
163
-     * 2002.05.08:
164
-     * Mongoose - Created
165
-     ------------------------------------------------------*/
166 90
 
91
+    /*!
92
+     * \brief Negate this vector
93
+     * \returns a copy of this vector, negated
94
+     */
167 95
     Vector3d operator -();
168
-    /*------------------------------------------------------
169
-     * Pre  :
170
-     * Post : Returns a copy of this vector, negated
171
-     *
172
-     *-- History ------------------------------------------
173
-     *
174
-     * 2002.05.08:
175
-     * Mongoose - Created
176
-     ------------------------------------------------------*/
177 96
 
97
+    /*!
98
+     * \brief Scale this vector
99
+     * \param s scaling factor
100
+     * \returns this vector multiplied with s
101
+     */
178 102
     Vector3d operator *(vec_t s);
179
-    /*------------------------------------------------------
180
-     * Pre  : S is scalar to scale by
181
-     * Post : Returns scale by S of this vector ( mult )
182
-     *
183
-     *-- History ------------------------------------------
184
-     *
185
-     * 2002.05.08:
186
-     * Mongoose - Created
187
-     ------------------------------------------------------*/
188 103
 
104
+    /*!
105
+     * \brief Scale this vactor
106
+     * \param s inverse scaling factor
107
+     * \returns this vector divided by s
108
+     */
189 109
     Vector3d operator /(vec_t s);
190
-    /*------------------------------------------------------
191
-     * Pre  : S is scalar to scale by
192
-     * Post : Returns scale by S of this vector ( div )
193
-     *
194
-     *-- History ------------------------------------------
195
-     *
196
-     * 2002.05.08:
197
-     * Mongoose - Created
198
-     ------------------------------------------------------*/
199 110
 
111
+    /*!
112
+     * \brief Dot product this vector
113
+     * \param v second vector for dot product
114
+     * \returns dot product of V by this vector
115
+     */
200 116
     vec_t operator *(const Vector3d &v);
201
-    /*------------------------------------------------------
202
-     * Pre  : V is vector to dot by
203
-     * Post : Returns dot by V with this vector
204
-     *
205
-     *-- History ------------------------------------------
206
-     *
207
-     * 2002.05.08:
208
-     * Mongoose - Created
209
-     ------------------------------------------------------*/
210
-
211
-
212
-    ////////////////////////////////////////////////////////////
213
-    // Public Mutators
214
-    ////////////////////////////////////////////////////////////
215 117
 
118
+    /*!
119
+     * \brief Normalizes this vector
120
+     */
216 121
     void normalize();
217
-    /*------------------------------------------------------
218
-     * Pre  :
219
-     * Post : Normalizes *this vector
220
-     *
221
-     *-- History ------------------------------------------
222
-     *
223
-     * 2002.05.08:
224
-     * Mongoose - Created
225
-     ------------------------------------------------------*/
226 122
 
123
+    /*!
124
+     * \brief Set this vector to Zero (0, 0, 0)
125
+     */
227 126
     void zero();
228
-    /*------------------------------------------------------
229
-     * Pre  :
230
-     * Post :This is set to the Zero vector <0, 0, 0>
231
-     *
232
-     *-- History ------------------------------------------
233
-     *
234
-     * 2003.06.08:
235
-     * Mongoose - Created
236
-     ------------------------------------------------------*/
237 127
 
128
+    /*!
129
+     * \brief Set this vector
130
+     * \param v what this vector will be set to
131
+     * \returns this vector, now equal to v
132
+     */
238 133
     Vector3d &operator =(const Vector3d &v);
239
-    /*------------------------------------------------------
240
-     * Pre  :
241
-     * Post : this = v, values are assigned   =)
242
-     *
243
-     *-- History ------------------------------------------
244
-     *
245
-     * 2002.05.08:
246
-     * Mongoose - Created
247
-     ------------------------------------------------------*/
248 134
 
135
+    /*!
136
+     * \brief Add to this vector, in place
137
+     * \param v what will be added to this vector
138
+     * \returns this vector, with v added
139
+     */
249 140
     Vector3d &operator +=(const Vector3d &v);
250
-    /*------------------------------------------------------
251
-     * Pre  :
252
-     * Post : this += v, values are sumed, assigned   =)
253
-     *
254
-     *-- History ------------------------------------------
255
-     *
256
-     * 2002.05.08:
257
-     * Mongoose - Created
258
-     ------------------------------------------------------*/
259 141
 
142
+    /*!
143
+     * \brief Subtract from this vector, in place
144
+     * \param v what will be subtracted from this vector
145
+     * \returns this vector, with v subtracted
146
+     */
260 147
     Vector3d &operator -=(const Vector3d &v);
261
-    /*------------------------------------------------------
262
-     * Pre  :
263
-     * Post : this -= v, values are diffed, assigned   =)
264
-     *
265
-     *-- History ------------------------------------------
266
-     *
267
-     * 2002.05.08:
268
-     * Mongoose - Created
269
-     ------------------------------------------------------*/
270 148
 
149
+    /*!
150
+     * \brief Scale this vector, in place
151
+     * \param s scaling factor
152
+     * \returns this vactor multiplied by s
153
+     */
271 154
     Vector3d &operator *=(vec_t s);
272
-    /*------------------------------------------------------
273
-     * Pre  :
274
-     * Post : this *= s, values are scaled, assigned   =)
275
-     *
276
-     *-- History ------------------------------------------
277
-     *
278
-     * 2002.05.08:
279
-     * Mongoose - Created
280
-     ------------------------------------------------------*/
281
-
282
-    vec3_t mVec;   /* Vector data */
283
-
284
- private:
285
-
286
-    ////////////////////////////////////////////////////////////
287
-    // Private Accessors
288
-    ////////////////////////////////////////////////////////////
289
-
290
-
291
-    ////////////////////////////////////////////////////////////
292
-    // Private Mutators
293
-    ////////////////////////////////////////////////////////////
294 155
 
156
+    vec3_t mVec; //!< Vector data
295 157
 };
296 158
 
297 159
 #endif

+ 127
- 242
include/ViewVolume.h View File

@@ -1,28 +1,9 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file include/ViewVolume.h
3
+ * \brief Viewing Volume for culling use
3 4
  *
4
- * Project : hel
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : ViewVolume
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: This is the viewing volume for culling use
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- Test Defines -----------------------------------------------
17
- *
18
- * UNIT_TEST_VIEWVOLUME - Builds ViewVolume class as a console unit test
19
- *
20
- *-- History ------------------------------------------------
21
- *
22
- * 2002.12.15:
23
- * Mongoose - Created
24
- ================================================================*/
25
-
5
+ * \author Mongoose
6
+ */
26 7
 
27 8
 #ifndef _VIEWVOLUME_H_
28 9
 #define _VIEWVOLUME_H_
@@ -30,265 +11,169 @@
30 11
 #include <Matrix.h>
31 12
 #include <BoundingVolume.h>
32 13
 
33
-class ViewVolume
34
-{
35
- public:
36
-
37
-    enum ViewVolumeSide
38
-    {
39
-        rightSide  = 0, // Right
40
-        leftSide   = 1, // Left
41
-        bottomSide = 2, // Bottom
42
-        topSide    = 3, // Top
43
-        farSide    = 4, // Back
44
-        nearSide   = 5  // Front
14
+/*!
15
+ * \brief Viewing Volume for culling use
16
+ */
17
+class ViewVolume {
18
+public:
19
+
20
+    /*!
21
+     * \brief Sides of the view volume
22
+     */
23
+    enum ViewVolumeSide {
24
+        rightSide  = 0, //!< Right
25
+        leftSide   = 1, //!< Left
26
+        bottomSide = 2, //!< Bottom
27
+        topSide    = 3, //!< Top
28
+        farSide    = 4, //!< Back
29
+        nearSide   = 5  //!< Front
45 30
     };
46 31
 
47
-    enum ViewVolumePlane
48
-    {
49
-        planeA = 0, // X value of normal
50
-        planeB = 1, // Y value of normal
51
-        planeC = 2, // Z value of normal
52
-        planeD = 3  // Distance to origin
32
+    /*!
33
+     * \brief Planes of the view volume
34
+     */
35
+    enum ViewVolumePlane {
36
+        planeA = 0, //!< X value of normal
37
+        planeB = 1, //!< Y value of normal
38
+        planeC = 2, //!< Z value of normal
39
+        planeD = 3  //!< Distance to origin
53 40
     };
54 41
 
55
-
56
-    ////////////////////////////////////////////////////////////
57
-    // Constructors
58
-    ////////////////////////////////////////////////////////////
59
-
42
+    /*!
43
+     * \brief Constructs an object of ViewVolume
44
+     */
60 45
     ViewVolume();
61
-    /*------------------------------------------------------
62
-     * Pre  :
63
-     * Post : Constructs an object of ViewVolume
64
-     *
65
-     *-- History ------------------------------------------
66
-     *
67
-     * 2002.12.15:
68
-     * Mongoose - Created
69
-     ------------------------------------------------------*/
70 46
 
47
+    /*!
48
+     * \brief Deconstructs an object of ViewVolume
49
+     */
71 50
     ~ViewVolume();
72
-    /*------------------------------------------------------
73
-     * Pre  : ViewVolume object is allocated
74
-     * Post : Deconstructs an object of ViewVolume
75
-     *
76
-     *-- History ------------------------------------------
77
-     *
78
-     * 2002.12.15:
79
-     * Mongoose - Created
80
-     ------------------------------------------------------*/
81
-
82
-
83
-    ////////////////////////////////////////////////////////////
84
-    // Public Accessors
85
-    ////////////////////////////////////////////////////////////
86 51
 
52
+    /*!
53
+     * \brief Check if bounding volume is in view volume
54
+     * \param bvol bounding volume to check
55
+     * \returns true if frustum contains the given bounding volume
56
+     */
87 57
     bool isBoundingVolumeInFrustum(BoundingVolume bvol);
88
-    /*------------------------------------------------------
89
-     * Pre  :
90
-     * Post : Returns true if frustum contains the given
91
-     *        bounding volume
92
-     *
93
-     *-- History ------------------------------------------
94
-     *
95
-     * 2002.12.15:
96
-     * Mongoose - Created
97
-     ------------------------------------------------------*/
98 58
 
59
+    /*!
60
+     * \brief Check if bounding sphere is in view volume
61
+     * \param bvol bounding sphere to check
62
+     * \returns true if frustum contains the given bounding volume
63
+     */
99 64
     bool isBoundingSphereInFrustum(BoundingSphere bvol);
100
-    /*------------------------------------------------------
101
-     * Pre  :
102
-     * Post : Returns true if frustum contains the given
103
-     *        bounding volume
104
-     *
105
-     *-- History ------------------------------------------
106
-     *
107
-     * 2002.12.15:
108
-     * Mongoose - Created
109
-     ------------------------------------------------------*/
110 65
 
66
+    /*!
67
+     * \brief Check if bounding box is in view volume
68
+     * \param bvol bounding box to check
69
+     * \returns true if frustum contains the given bounding volume
70
+     */
111 71
     bool isBoundingBoxInFrustum(BoundingBox bvol);
112
-    /*------------------------------------------------------
113
-     * Pre  :
114
-     * Post : Returns true if frustum contains the given
115
-     *        bounding volume
116
-     *
117
-     *-- History ------------------------------------------
118
-     *
119
-     * 2002.12.15:
120
-     * Mongoose - Created
121
-     ------------------------------------------------------*/
122 72
 
73
+    /*!
74
+     * \brief Check if point is in view volume
75
+     * \param x X coordinate of point
76
+     * \param y Y coordinate of point
77
+     * \param z Z coordinate of point
78
+     * \returns true if point in view volume
79
+     */
123 80
     bool isPointInFrustum(vec_t x, vec_t y, vec_t z);
124
-    /*------------------------------------------------------
125
-     * Pre  :
126
-     * Post :
127
-     *
128
-     *-- History ------------------------------------------
129
-     *
130
-     * 2002.12.15:
131
-     * Mongoose - Created
132
-     ------------------------------------------------------*/
133 81
 
82
+    /*!
83
+     * \brief Check if bounding sphere is in view volume
84
+     * \param x X coordinate of a valid abstract sphere
85
+     * \param y Y coordinate of a valid abstract sphere
86
+     * \param z Z coordinate of a valid abstract sphere
87
+     * \param radius radius of a valid abstract sphere
88
+     * \returns true if abstract sphere in view volume
89
+     */
134 90
     bool isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius);
135
-    /*------------------------------------------------------
136
-     * Pre  : Abstract sphere is valid
137
-     * Post : Returns true if abstract sphere in view volume
138
-     *
139
-     *-- History ------------------------------------------
140
-     *
141
-     * 2002.12.15:
142
-     * Mongoose - Created
143
-     ------------------------------------------------------*/
144 91
 
92
+    /*!
93
+     * \brief Check if bounding box is in view volume
94
+     * \param min minimum point of valid abstract bounding box
95
+     * \param max maximum point of valid abstract bounding box
96
+     * \returns true if abstract bounding box in view volume
97
+     */
145 98
     bool isBboxInFrustum(vec3_t min, vec3_t max);
146
-    /*------------------------------------------------------
147
-     * Pre  : Abstract bounding box is valid
148
-     * Post : Returns true if abstract bounding box in view volume
149
-     *
150
-     *-- History ------------------------------------------
151
-     *
152
-     * 2002.12.15:
153
-     * Mongoose - Created
154
-     ------------------------------------------------------*/
155 99
 
100
+    /*!
101
+     * \brief Distance to Bounding sphere
102
+     * \param x X coordinate of a valid abstract sphere
103
+     * \param y Y coordinate of a valid abstract sphere
104
+     * \param z Z coordinate of a valid abstract sphere
105
+     * \param radius radius of a valid abstract sphere
106
+     * \returns distance to abstract sphere bounding volume
107
+     */
156 108
     vec_t getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, vec_t radius);
157
-    /*------------------------------------------------------
158
-     * Pre  : Abstract sphere is valid
159
-     * Post : Returns distance to abstract sphere
160
-     *        bounding volume
161
-     *
162
-     *-- History ------------------------------------------
163
-     *
164
-     * 2002.12.15:
165
-     * Mongoose - Created
166
-     ------------------------------------------------------*/
167 109
 
110
+    /*!
111
+     * \brief Distance to Bounding box
112
+     * \param min minimum point of a valid abstract bounding box
113
+     * \param max maximum point of a valid abstract bounding box
114
+     * \returns distance to abstract box bounding volume
115
+     */
168 116
     vec_t getDistToBboxFromNear(vec3_t min, vec3_t max);
169
-    /*------------------------------------------------------
170
-     * Pre  : Abstract bounding box is valid
171
-     * Post : Returns distance to abstract box
172
-     *        bounding volume
173
-     *
174
-     *-- History ------------------------------------------
175
-     *
176
-     * 2002.12.15:
177
-     * Mongoose - Created
178
-     ------------------------------------------------------*/
179 117
 
118
+    /*!
119
+     * \brief Get a copy of the view volume
120
+     * \param frustum where frustum will be stored
121
+     */
180 122
     void getFrustum(vec_t frustum[6][4]);
181
-    /*------------------------------------------------------
182
-     * Pre  : Frustum is allocated 6x4 vec_t
183
-     * Post : Get a copy of the view volume
184
-     *
185
-     *-- History ------------------------------------------
186
-     *
187
-     * 2002.12.26:
188
-     * Mongoose - Created
189
-     ------------------------------------------------------*/
190 123
 
124
+    /*!
125
+     * \brief Get a copy of a given plane in view volume
126
+     * \param p side
127
+     * \param plane wher plane will be stored
128
+     */
191 129
     void getPlane(ViewVolumeSide p, vec4_t plane);
192
-    /*------------------------------------------------------
193
-     * Pre  :
194
-     * Post : Get a copy of a given plane in view volume
195
-     *
196
-     *-- History ------------------------------------------
197
-     *
198
-     * 2002.12.26:
199
-     * Mongoose - Created
200
-     ------------------------------------------------------*/
201
-
202
-
203
-    ////////////////////////////////////////////////////////////
204
-    // Public Mutators
205
-    ////////////////////////////////////////////////////////////
206 130
 
131
+    /*!
132
+     * \brief Updates view volume for this frame.
133
+     * \param proj new projection matrix
134
+     * \param mdl new model matrix
135
+     */
207 136
     void updateFrame(matrix_t proj, matrix_t mdl);
208
-    /*------------------------------------------------------
209
-     * Pre  : Given valid projection and model matrices
210
-     * Post : Updates view volume for this frame
211
-     *
212
-     *-- History ------------------------------------------
213
-     *
214
-     * 2002.12.15:
215
-     * Mongoose - Created
216
-     ------------------------------------------------------*/
217 137
 
218
-    void updateFrame();
219
-    /*------------------------------------------------------
220
-     * Pre  : Called setModel() and setProjection()
221
-     * Post : Updates view volume for this frame
222
-     *
223
-     *-- History ------------------------------------------
138
+    /*!
139
+     * \brief Updates view volume for this frame.
224 140
      *
225
-     * 2002.12.15:
226
-     * Mongoose - Created
227
-     ------------------------------------------------------*/
141
+     * Model & Projection Matrices must be set.
142
+     */
143
+    void updateFrame();
228 144
 
145
+    /*!
146
+     * \brief Set this class' model matrix
147
+     * \param mdl new model matrix
148
+     */
229 149
     void setModel(matrix_t mdl);
230
-    /*------------------------------------------------------
231
-     * Pre  : It's valid model matrix
232
-     * Post : Sets this class' model matrix
233
-     *
234
-     *-- History ------------------------------------------
235
-     *
236
-     * 2002.12.15:
237
-     * Mongoose - Created
238
-     ------------------------------------------------------*/
239 150
 
151
+    /*!
152
+     * \brief Set this class' projection matrix
153
+     * \param proj new projection matrix
154
+     */
240 155
     void setProjection(matrix_t proj);
241
-    /*------------------------------------------------------
242
-     * Pre  : It's the valid projection matrix
243
-     * Post : Sets this class' projection matrix
244
-     *
245
-     *-- History ------------------------------------------
246
-     *
247
-     * 2002.12.15:
248
-     * Mongoose - Created
249
-     ------------------------------------------------------*/
250
-
251
- private:
252
-
253
-    ////////////////////////////////////////////////////////////
254
-    // Private Accessors
255
-    ////////////////////////////////////////////////////////////
256 156
 
157
+private:
257 158
 
258
-    ////////////////////////////////////////////////////////////
259
-    // Private Mutators
260
-    ////////////////////////////////////////////////////////////
261
-
262
-    void updateClip();
263
-    /*------------------------------------------------------
264
-     * Pre  : model and projection matrices are set
265
-     * Post : Computes clipping matrix
159
+    /*!
160
+     * \brief Computes clipping matrix.
266 161
      *
267
-     *-- History ------------------------------------------
268
-     *
269
-     * 2002.12.15:
270
-     * Mongoose - Created
271
-     ------------------------------------------------------*/
162
+     * Model & Projection matrices must be set!
163
+     */
164
+    void updateClip();
272 165
 
273
-    void updateFrustum();
274
-    /*------------------------------------------------------
275
-     * Pre  : model, projection, clip matrices are set
276
-     * Post : Computes planes of frustum
277
-     *
278
-     *-- History ------------------------------------------
166
+    /*!
167
+     * \brief Computes planes of frustum.
279 168
      *
280
-     * 2002.12.15:
281
-     * Mongoose - Created
282
-     ------------------------------------------------------*/
283
-
284
-
285
-    Matrix mProjection;         /* Projection matrix */
286
-
287
-    Matrix mModel;             /* Model matrix */
288
-
289
-    Matrix mClip;               /* Clipping matrix */
169
+     * Model, Projection & Clip matrices must be set!
170
+     */
171
+    void updateFrustum();
290 172
 
291
-    vec_t mFrustum[6][4];      /* View volume */
173
+    Matrix mProjection;   //!< Projection matrix
174
+    Matrix mModel;        //!< Model matrix
175
+    Matrix mClip;         //!< Clipping matrix
176
+    vec_t mFrustum[6][4]; //!< View volume
292 177
 };
293 178
 
294 179
 #endif

+ 0
- 4
include/World.h View File

@@ -13,10 +13,6 @@
13 13
  *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15 15
  *
16
- *-- Test Defines -----------------------------------------------
17
- *
18
- * UNIT_TEST_WORLD - Builds World class as a console unit test
19
- *
20 16
  *-- History ------------------------------------------------
21 17
  *
22 18
  * 2002.12.16:

+ 1
- 1
src/Network.cpp View File

@@ -440,7 +440,7 @@ int Network::runServer()
440 440
 
441 441
         fflush(stdout);
442 442
 
443
-#ifdef UNIT_TEST_NETWORK
443
+#ifdef UNIT_TEST
444 444
         if ((rand() % 10 == 0))
445 445
         {
446 446
             printf("Server: Simulating a lost ack %u\n", f.seq);

+ 44
- 150
src/Quaternion.cpp View File

@@ -1,71 +1,39 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file src/Quaternion.cpp
3
+ * \brief Quaternion
3 4
  *
4
- * Project : Hel
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Quaternion
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: Quaternion now in C++ class form fresh from the grove
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History -------------------------------------------------
17
- *
18
- * 2002.12.16:
19
- * Mongoose - Created, based on mtk3d ( freyja )
20
- =================================================================*/
5
+ * \author Mongoose
6
+ */
21 7
 
22 8
 #include <math.h>
23 9
 
24 10
 #include <Quaternion.h>
25 11
 
26
-
27
-////////////////////////////////////////////////////////////
28
-// Constructors
29
-////////////////////////////////////////////////////////////
30
-
31
-Quaternion::Quaternion()
32
-{
12
+Quaternion::Quaternion() {
33 13
     mW = 0;
34 14
     mX = 0;
35 15
     mY = 0;
36 16
     mZ = 0;
37 17
 }
38 18
 
39
-
40
-Quaternion::Quaternion(vec_t w, vec_t x, vec_t y, vec_t z)
41
-{
19
+Quaternion::Quaternion(vec_t w, vec_t x, vec_t y, vec_t z) {
42 20
     mW = w;
43 21
     mX = x;
44 22
     mY = y;
45 23
     mZ = z;
46 24
 }
47 25
 
48
-
49
-Quaternion::Quaternion(vec4_t v)
50
-{
26
+Quaternion::Quaternion(vec4_t v) {
51 27
     mW = v[0];
52 28
     mX = v[1];
53 29
     mY = v[2];
54 30
     mZ = v[3];
55 31
 }
56 32
 
57
-
58
-Quaternion::~Quaternion()
59
-{
33
+Quaternion::~Quaternion() {
60 34
 }
61 35
 
62
-
63
-////////////////////////////////////////////////////////////
64
-// Public Accessors
65
-////////////////////////////////////////////////////////////
66
-
67
-void Quaternion::getMatrix(matrix_t m)
68
-{
36
+void Quaternion::getMatrix(matrix_t m) {
69 37
     m[ 0] = 1.0f - 2.0f * (mY*mY + mZ*mZ);
70 38
     m[ 1] = 2.0f * (mX*mY - mW*mZ);
71 39
     m[ 2] = 2.0f * (mX*mZ + mW*mY);
@@ -87,9 +55,7 @@ void Quaternion::getMatrix(matrix_t m)
87 55
     m[15] = 1.0f;
88 56
 }
89 57
 
90
-
91
-Quaternion &Quaternion::operator =(const Quaternion &q)
92
-{
58
+Quaternion &Quaternion::operator =(const Quaternion &q) {
93 59
     mW  = q.mW;
94 60
     mX = q.mX;
95 61
     mY = q.mY;
@@ -97,91 +63,62 @@ Quaternion &Quaternion::operator =(const Quaternion &q)
97 63
     return *this;
98 64
 }
99 65
 
100
-
101
-Quaternion Quaternion::operator *(const Quaternion &q)
102
-{
66
+Quaternion Quaternion::operator *(const Quaternion &q) {
103 67
     return multiply(*this, q);
104 68
 }
105 69
 
106
-
107
-Quaternion Quaternion::operator /(const Quaternion &q)
108
-{
70
+Quaternion Quaternion::operator /(const Quaternion &q) {
109 71
     return divide(*this, q);
110 72
 }
111 73
 
112
-
113
-Quaternion Quaternion::operator +(const Quaternion &q)
114
-{
74
+Quaternion Quaternion::operator +(const Quaternion &q) {
115 75
     return add(*this, q);
116 76
 }
117 77
 
118
-
119
-Quaternion Quaternion::operator -(const Quaternion &q)
120
-{
78
+Quaternion Quaternion::operator -(const Quaternion &q) {
121 79
     return subtract(*this, q);
122 80
 }
123 81
 
124
-
125
-bool Quaternion::operator ==(const Quaternion &q)
126
-{
82
+bool Quaternion::operator ==(const Quaternion &q) {
127 83
     //return (mX == q.mX && mY == q.mY && mZ == q.mZ && mW == q.mW);
128 84
     return (equalEpsilon(mX, q.mX) && equalEpsilon(mY, q.mY) &&
129 85
             equalEpsilon(mZ, q.mZ) && equalEpsilon(mW, q.mW));
130 86
 }
131 87
 
132
-
133
-Quaternion Quaternion::conjugate()
134
-{
88
+Quaternion Quaternion::conjugate() {
135 89
     return Quaternion(mW, -mX, -mY, -mZ);
136 90
 }
137 91
 
138
-
139
-Quaternion Quaternion::scale(vec_t s)
140
-{
92
+Quaternion Quaternion::scale(vec_t s) {
141 93
     return Quaternion(mW * s, mX * s, mY * s, mZ * s);
142 94
 }
143 95
 
144
-
145
-Quaternion Quaternion::inverse()
146
-{
96
+Quaternion Quaternion::inverse() {
147 97
     return conjugate().scale(1/magnitude());
148 98
 }
149 99
 
150
-
151
-vec_t Quaternion::dot(Quaternion a, Quaternion b)
152
-{
100
+vec_t Quaternion::dot(Quaternion a, Quaternion b) {
153 101
     return ((a.mW * b.mW) + (a.mX * b.mX) + (a.mY * b.mY) + (a.mZ * b.mZ));
154 102
 }
155 103
 
156
-
157
-vec_t Quaternion::magnitude()
158
-{
104
+vec_t Quaternion::magnitude() {
159 105
     return sqrtf(dot(*this, *this));
160 106
 }
161 107
 
162
-
163
-////////////////////////////////////////////////////////////
164
-// Public Mutators
165
-////////////////////////////////////////////////////////////
166
-
167
-void Quaternion::setIdentity()
168
-{
108
+void Quaternion::setIdentity() {
169 109
     mW = 1.0;
170 110
     mX = 0.0;
171 111
     mY = 0.0;
172 112
     mZ = 0.0;
173 113
 }
174 114
 
175
-
176
-void Quaternion::set(vec_t angle, vec_t x, vec_t y, vec_t z)
177
-{
115
+void Quaternion::set(vec_t angle, vec_t x, vec_t y, vec_t z) {
178 116
     vec_t temp, dist;
179 117
 
180
-
181 118
     // Normalize
182 119
     temp = x*x + y*y + z*z;
183 120
 
184
-    dist = (float)(1.0 / sqrt(temp));
121
+    dist = 1.0f / sqrtf(temp);
185 122
 
186 123
     x *= dist;
187 124
     y *= dist;
@@ -191,23 +128,17 @@ void Quaternion::set(vec_t angle, vec_t x, vec_t y, vec_t z)
191 128
     mY = y;
192 129
     mZ = z;
193 130
 
194
-    mW = (float)cos(angle / 2.0f);
131
+    mW = cosf(angle / 2.0f);
195 132
 }
196 133
 
197
-
198
-void Quaternion::normalize()
199
-{
134
+void Quaternion::normalize() {
200 135
     vec_t dist, square;
201 136
 
202
-
203 137
     square = mX * mX + mY * mY + mZ * mZ + mW * mW;
204 138
 
205
-    if (square > 0.0)
206
-    {
207
-        dist = (float)(1.0 / sqrt(square));
208
-    }
209
-    else
210
-    {
139
+    if (square > 0.0) {
140
+        dist = 1.0f / sqrtf(square);
141
+    } else {
211 142
         dist = 1;
212 143
     }
213 144
 
@@ -217,18 +148,14 @@ void Quaternion::normalize()
217 148
     mW *= dist;
218 149
 }
219 150
 
220
-
221
-void Quaternion::copy(Quaternion q)
222
-{
151
+void Quaternion::copy(Quaternion q) {
223 152
     mW = q.mW;
224 153
     mX = q.mX;
225 154
     mY = q.mY;
226 155
     mZ = q.mZ;
227 156
 }
228 157
 
229
-
230
-Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
231
-{
158
+Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time) {
232 159
     /*******************************************************************
233 160
      * Spherical Linear Interpolation algorthim
234 161
      *-----------------------------------------------------------------
@@ -250,16 +177,13 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
250 177
 
251 178
     // Don't bother if it's the same rotation, it's the same as the result
252 179
     if (a == b)
253
-    {
254 180
         return a;
255
-    }
256 181
 
257 182
     // A . B
258 183
     result = dot(a, b);
259 184
 
260 185
     // If the dot product is less than 0, the angle is greater than 90 degrees
261
-    if (result < 0.0f)
262
-    {
186
+    if (result < 0.0f) {
263 187
         // Negate quaternion B and the result of the dot product
264 188
         b = Quaternion(-b.mW, -b.mX, -b.mY, -b.mZ);
265 189
         result = -result;
@@ -280,8 +204,7 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
280 204
 
281 205
     // Check if the angle between the 2 quaternions was big enough
282 206
     // to warrant such calculations
283
-    if (1 - result > 0.1f)
284
-    {
207
+    if (1 - result > 0.1f) {
285 208
         // Get the angle between the 2 quaternions, and then
286 209
         // store the sin() of that angle
287 210
         theta = (float)acos(result);
@@ -298,16 +221,12 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
298 221
     return (a.scale(scaleA) + b.scale(scaleB));
299 222
 }
300 223
 
301
-
302
-void Quaternion::setByMatrix(matrix_t matrix)
303
-{
224
+void Quaternion::setByMatrix(matrix_t matrix) {
304 225
     float diagonal = matrix[0] + matrix[5] + matrix[10] + 1.0f;
305 226
     float scale = 0.0f;
306 227
     float w = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f;
307 228
 
308
-
309
-    if (diagonal > 0.00000001)
310
-    {
229
+    if (diagonal > 0.00000001) {
311 230
         // Calculate the scale of the diagonal
312 231
         scale = (float)(sqrt(diagonal) * 2);
313 232
 
@@ -315,12 +234,9 @@ void Quaternion::setByMatrix(matrix_t matrix)
315 234
         x = (matrix[9] - matrix[6]) / scale;
316 235
         y = (matrix[2] - matrix[8]) / scale;
317 236
         z = (matrix[4] - matrix[1]) / scale;
318
-    }
319
-    else
320
-    {
237
+    } else {
321 238
         // If the first element of the diagonal is the greatest value
322
-        if (matrix[0] > matrix[5] && matrix[0] > matrix[10])
323
-        {
239
+        if (matrix[0] > matrix[5] && matrix[0] > matrix[10]) {
324 240
             // Find the scale according to the first element, and double it
325 241
             scale = (float)sqrt(1.0f + matrix[0] - matrix[5] - matrix[10])*2.0f;
326 242
 
@@ -329,10 +245,8 @@ void Quaternion::setByMatrix(matrix_t matrix)
329 245
             x = 0.25f * scale;
330 246
             y = (matrix[4] + matrix[1]) / scale;
331 247
             z = (matrix[2] + matrix[8]) / scale;
332
-        }
333
-        // The second element of the diagonal is the greatest value
334
-        else if (matrix[5] > matrix[10])
335
-        {
248
+        } else if (matrix[5] > matrix[10]) {
249
+            // The second element of the diagonal is the greatest value
336 250
             // Find the scale according to the second element, and double it
337 251
             scale = (float)sqrt(1.0f + matrix[5] - matrix[0] - matrix[10])*2.0f;
338 252
 
@@ -341,10 +255,7 @@ void Quaternion::setByMatrix(matrix_t matrix)
341 255
             x = (matrix[4] + matrix[1]) / scale;
342 256
             y = 0.25f * scale;
343 257
             z = (matrix[9] + matrix[6]) / scale;
344
-        }
345
-        // The third element of the diagonal is the greatest value
346
-        else
347
-        {
258
+        } else { // The third element of the diagonal is the greatest value
348 259
             // Find the scale according to the third element, and double it
349 260
             scale = (float)sqrt(1.0f + matrix[10] - matrix[0] - matrix[5])*2.0f;
350 261
 
@@ -362,45 +273,28 @@ void Quaternion::setByMatrix(matrix_t matrix)
362 273
     mZ = z;
363 274
 }
364 275
 
365
-
366
-////////////////////////////////////////////////////////////
367
-// Private Accessors
368
-////////////////////////////////////////////////////////////
369
-
370
-Quaternion Quaternion::multiply(Quaternion a, Quaternion b)
371
-{
276
+Quaternion Quaternion::multiply(Quaternion a, Quaternion b) {
372 277
     return Quaternion(a.mW * b.mW - a.mX * b.mX - a.mY * b.mY - a.mZ * b.mZ,
373 278
             a.mW * b.mX + a.mX * b.mW + a.mY * b.mZ - a.mZ * b.mY,
374 279
             a.mW * b.mY + a.mY * b.mW + a.mZ * b.mX - a.mX * b.mZ,
375 280
             a.mW * b.mZ + a.mZ * b.mW + a.mX * b.mY - a.mY * b.mX);
376 281
 }
377 282
 
378
-
379
-Quaternion Quaternion::divide(Quaternion a, Quaternion b)
380
-{
283
+Quaternion Quaternion::divide(Quaternion a, Quaternion b) {
381 284
     return (a * (b.inverse()));
382 285
 }
383 286
 
384
-
385
-Quaternion Quaternion::add(Quaternion a, Quaternion b)
386
-{
287
+Quaternion Quaternion::add(Quaternion a, Quaternion b) {
387 288
     return Quaternion(a.mW + b.mW,
388 289
             a.mX + b.mX,
389 290
             a.mY + b.mY,
390 291
             a.mZ + b.mZ);
391 292
 }
392 293
 
393
-
394
-Quaternion Quaternion::subtract(Quaternion a, Quaternion b)
395
-{
294
+Quaternion Quaternion::subtract(Quaternion a, Quaternion b) {
396 295
     return Quaternion(a.mW - b.mW,
397 296
             a.mX - b.mX,
398 297
             a.mY - b.mY,
399 298
             a.mZ - b.mZ);
400 299
 }
401 300
 
402
-
403
-////////////////////////////////////////////////////////////
404
-// Private Mutators
405
-////////////////////////////////////////////////////////////
406
-

+ 41
- 131
src/SDLSystem.cpp View File

@@ -1,31 +1,9 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file src/SDLSystem.cpp
3
+ * \brief SDL System interface implementation
3 4
  *
4
- * Project : OpenRaider
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : SDL
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments:
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History -------------------------------------------------
17
- *
18
- * 2003.06.30,
19
- * Mongoose - SDL_TTF support moved to Texture class
20
- *
21
- * 2003.06.03:
22
- * Mongoose - SDL_TTF support based on Sam Lantinga's public domain
23
- *            SDL_TTF demo functions and algorithms
24
- *
25
- * 2002.06.06:
26
- * Mongoose - Created
27
- =================================================================*/
28
-
5
+ * \author Mongoose
6
+ */
29 7
 
30 8
 #include <stdlib.h>
31 9
 #include <stdio.h>
@@ -40,17 +18,10 @@
40 18
 
41 19
 #include <SDLSystem.h>
42 20
 
43
-
44 21
 unsigned int *gWidth = 0x0;
45 22
 unsigned int *gHeight = 0x0;
46 23
 
47
-
48
-////////////////////////////////////////////////////////////
49
-// Constructors
50
-////////////////////////////////////////////////////////////
51
-
52
-SDLSystem::SDLSystem() : System()
53
-{
24
+SDLSystem::SDLSystem() : System() {
54 25
     mWindow = 0x0;
55 26
     gWidth = &m_width;
56 27
     gHeight = &m_height;
@@ -58,31 +29,16 @@ SDLSystem::SDLSystem() : System()
58 29
     mFullscreen = false;
59 30
 }
60 31
 
61
-
62
-SDLSystem::~SDLSystem()
63
-{
32
+SDLSystem::~SDLSystem() {
64 33
 }
65 34
 
66
-
67
-////////////////////////////////////////////////////////////
68
-// Public Accessors
69
-////////////////////////////////////////////////////////////
70
-
71
-unsigned int SDLSystem::getTicks()
72
-{
35
+unsigned int SDLSystem::getTicks() {
73 36
     return SDL_GetTicks();
74 37
 }
75 38
 
76
-
77
-////////////////////////////////////////////////////////////
78
-// Public Mutators
79
-////////////////////////////////////////////////////////////
80
-
81 39
 #ifdef FIXME
82
-void SDLSystem::bindKeyCommand(const char *cmd, int key, int event)
83
-{
84
-    if (key > 255)
85
-    {
40
+void SDLSystem::bindKeyCommand(const char *cmd, int key, int event) {
41
+    if (key > 255) {
86 42
         printf("Currently key event mapping only handles ASCII characters\n");
87 43
         return;
88 44
     }
@@ -93,19 +49,13 @@ void SDLSystem::bindKeyCommand(const char *cmd, int key, int event)
93 49
 }
94 50
 #endif
95 51
 
96
-
97
-void SDLSystem::setGrabMouse(bool on)
98
-{
52
+void SDLSystem::setGrabMouse(bool on) {
99 53
     SDL_WM_GrabInput(on ? SDL_GRAB_ON : SDL_GRAB_OFF);
100 54
 }
101 55
 
102
-
103
-void SDLSystem::initVideo(unsigned int width, unsigned int height,
104
-        bool fullscreen)
105
-{
56
+void SDLSystem::initVideo(unsigned int width, unsigned int height, bool fullscreen) {
106 57
     int flags = 0; //, x, y;
107 58
 
108
-
109 59
     // Create GL context
110 60
     SDL_Init(SDL_INIT_VIDEO);
111 61
     printf("Created OpenGL Context\n");
@@ -115,18 +65,15 @@ void SDLSystem::initVideo(unsigned int width, unsigned int height,
115 65
     m_height = height;
116 66
 
117 67
 #ifndef __APPLE__
118
-    if (!m_driver || !m_driver[0] || SDL_GL_LoadLibrary(m_driver) < 0)
119
-    {
68
+    if (!m_driver || !m_driver[0] || SDL_GL_LoadLibrary(m_driver) < 0) {
120 69
         SDL_ClearError();
121 70
 
122 71
         // Fallback 1
123
-        if (SDL_GL_LoadLibrary("libGL.so") < 0)
124
-        {
72
+        if (SDL_GL_LoadLibrary("libGL.so") < 0) {
125 73
             SDL_ClearError();
126 74
 
127 75
             // Fallback 2
128
-            if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
129
-            {
76
+            if (SDL_GL_LoadLibrary("libGL.so.1") < 0) {
130 77
                 fprintf(stderr, "initVideo> SDL_GL_LoadLibrary failed!\n");
131 78
                 fprintf(stderr, "initVideo> Error is [%s].\n", SDL_GetError());
132 79
                 shutdown(1);
@@ -166,14 +113,11 @@ void SDLSystem::initVideo(unsigned int width, unsigned int height,
166 113
     resizeGL(width, height);
167 114
 }
168 115
 
169
-
170
-void SDLSystem::resize(unsigned int width, unsigned int height)
171
-{
116
+void SDLSystem::resize(unsigned int width, unsigned int height) {
172 117
     int flags = 0;
173 118
 
174 119
     GLfloat aspect;
175 120
 
176
-
177 121
     m_width = width;
178 122
     m_height = height;
179 123
 
@@ -206,24 +150,18 @@ void SDLSystem::resize(unsigned int width, unsigned int height)
206 150
     resizeGL(width, height);
207 151
 }
208 152
 
209
-
210
-void SDLSystem::runGame()
211
-{
153
+void SDLSystem::runGame() {
212 154
     SDL_Event event;
213 155
     unsigned int mkeys, mod, key;
214 156
     int btn = 0;
215 157
     bool specialKey;
216 158
 
217
-
218
-    for (;;)
219
-    {
159
+    for (;;) {
220 160
         // Pause for 10-20 ms
221 161
         SDL_Delay(10);
222 162
 
223
-        while (SDL_PollEvent(&event))
224
-        {
225
-            switch (event.type)
226
-            {
163
+        while (SDL_PollEvent(&event)) {
164
+            switch (event.type) {
227 165
                 case SDL_QUIT:
228 166
                     shutdown(0);
229 167
                     break;
@@ -240,8 +178,7 @@ void SDLSystem::runGame()
240 178
                     //handleMouseEvent(event.button.button, event.button.state,
241 179
                     //                    event.button.x, event.button.y);
242 180
 
243
-                    switch (event.button.button)
244
-                    {
181
+                    switch (event.button.button) {
245 182
                         case SDL_BUTTON_LEFT:
246 183
                             btn = SYS_MOUSE_LEFT;
247 184
                             break;
@@ -253,12 +190,9 @@ void SDLSystem::runGame()
253 190
                             break;
254 191
                     }
255 192
 
256
-                    if (event.button.state == SDL_PRESSED)
257
-                    {
193
+                    if (event.button.state == SDL_PRESSED) {
258 194
                         handleKeyPressEvent(btn, 0); //! \fixme mod not used
259
-                    }
260
-                    else
261
-                    {
195
+                    } else {
262 196
                         handleKeyReleaseEvent(btn, 0); //! \fixme mod not used
263 197
                     }
264 198
                     break;
@@ -296,8 +230,7 @@ void SDLSystem::runGame()
296 230
                     key = event.key.keysym.sym;
297 231
                     specialKey = false;
298 232
 
299
-                    switch (key)
300
-                    {
233
+                    switch (key) {
301 234
                         case SDLK_F1:
302 235
                             key = SYS_KEY_F1;
303 236
                             specialKey = true;
@@ -383,14 +316,10 @@ void SDLSystem::runGame()
383 316
 
384 317
 #ifdef UNICODE_SUPPORT
385 318
                     // JML: if a std key was pressed get it ascii code
386
-                    if (!specialKey && key != 0)
387
-                    {
388
-                        if ((event.key.keysym.unicode & 0xFF80) == 0)
389
-                        {
390
-                            key= (unsigned int)(event.key.keysym.unicode & 0x7F);
391
-                        }
392
-                        else
393
-                        {
319
+                    if (!specialKey && key != 0) {
320
+                        if ((event.key.keysym.unicode & 0xFF80) == 0) {
321
+                            key = (unsigned int)(event.key.keysym.unicode & 0x7F);
322
+                        } else {
394 323
                             key = 0;
395 324
                         }
396 325
                     }
@@ -399,50 +328,38 @@ void SDLSystem::runGame()
399 328
                      * consoles using this expect text characters, add unicode
400 329
                      * support later when they're able to handle it
401 330
                      */
402
-                    if (key > 255 && key < 1000)
403
-                    {
331
+                    if (key > 255 && key < 1000) {
404 332
                         key = 0;
405 333
                     }
406 334
 #endif
407 335
 
408
-                    if (key == mConsoleKey)
409
-                    {
410
-                        if (event.type == SDL_KEYDOWN)
411
-                        {
336
+                    if (key == mConsoleKey) {
337
+                        if (event.type == SDL_KEYDOWN) {
412 338
                             mConsoleMode = !mConsoleMode;
413 339
                             // Tmp hack
414 340
                             handleConsoleKeyPressEvent(mConsoleKey, 0);
415 341
                         }
416
-                    }
417
-                    else if (mConsoleMode) // Console keying ( text input )
418
-                    {
419
-                        switch (event.type)
420
-                        {
342
+                    } else if (mConsoleMode) { // Console keying (text input)
343
+                        switch (event.type) {
421 344
                             case SDL_KEYDOWN:
422 345
                                 handleConsoleKeyPressEvent(key, mod);
423 346
                                 break;
424 347
                             default:
425 348
                                 ;
426 349
                         }
427
-                    }
428
-                    else if (mKeyEvents[key] != 0)// Bound key
429
-                    {
350
+                    } else if (mKeyEvents[key] != 0) { // Bound key
430 351
                         //if (key < 255 && mKeyEvents[key] != 0)
431 352
                         key = mKeyEvents[key];
432 353
 
433
-                        switch (event.type)
434
-                        {
354
+                        switch (event.type) {
435 355
                             case SDL_KEYDOWN:
436 356
                                 handleBoundKeyPressEvent(key);
437 357
                                 break;
438 358
                             default:
439 359
                                 handleBoundKeyReleaseEvent(key);
440 360
                         }
441
-                    }
442
-                    else // 'Classic' key event handlers
443
-                    {
444
-                        switch (event.type)
445
-                        {
361
+                    } else { // 'Classic' key event handlers
362
+                        switch (event.type) {
446 363
                             case SDL_KEYDOWN:
447 364
                                 handleKeyPressEvent(key, mod);
448 365
                                 break;
@@ -463,9 +380,7 @@ void SDLSystem::runGame()
463 380
     }
464 381
 }
465 382
 
466
-
467
-void SDLSystem::shutdown(int i)
468
-{
383
+void SDLSystem::shutdown(int i) {
469 384
     //SDL_QuitSubSystem(SDL_OPENGL);
470 385
     //SDL_Quit(); // Moved to atexit() call
471 386
 
@@ -477,11 +392,8 @@ void SDLSystem::shutdown(int i)
477 392
     exit(i);
478 393
 }
479 394
 
480
-
481
-void SDLSystem::toggleFullscreen()
482
-{
483
-    if (mWindow)
484
-    {
395
+void SDLSystem::toggleFullscreen() {
396
+    if (mWindow) {
485 397
         mFullscreen = !mFullscreen;
486 398
         SDL_ShowCursor(SDL_DISABLE);
487 399
 
@@ -521,9 +433,7 @@ void SDLSystem::toggleFullscreen()
521 433
     }
522 434
 }
523 435
 
524
-
525
-void SDLSystem::swapBuffersGL()
526
-{
436
+void SDLSystem::swapBuffersGL() {
527 437
     SDL_GL_SwapBuffers();
528 438
 }
529 439
 

+ 26
- 112
src/Vector3d.cpp View File

@@ -1,86 +1,48 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file src/Vector3d.cpp
3
+ * \brief 3D Math vector
3 4
  *
4
- * Project : Hel
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Vector3d
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: Math vector
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History -------------------------------------------------
17
- *
18
- * 2002.12.24:
19
- * Mongoose - Created
20
- =================================================================*/
5
+ * \author Mongoose
6
+ */
21 7
 
22 8
 #include <math.h>
23 9
 
24 10
 #include <Vector3d.h>
25 11
 
26
-
27
-////////////////////////////////////////////////////////////
28
-// Constructors
29
-////////////////////////////////////////////////////////////
30
-
31
-Vector3d::Vector3d()
32
-{
12
+Vector3d::Vector3d() {
33 13
     mVec[0] = mVec[1] = mVec[2] = 0.0f;
34 14
 }
35 15
 
36
-
37
-Vector3d::Vector3d(vec3_t v)
38
-{
16
+Vector3d::Vector3d(vec3_t v) {
39 17
     mVec[0] = v[0];
40 18
     mVec[1] = v[1];
41 19
     mVec[2] = v[2];
42 20
 }
43 21
 
44
-
45
-Vector3d::Vector3d(vec_t x, vec_t y, vec_t z)
46
-{
22
+Vector3d::Vector3d(vec_t x, vec_t y, vec_t z) {
47 23
     mVec[0] = x;
48 24
     mVec[1] = y;
49 25
     mVec[2] = z;
50 26
 }
51 27
 
52
-
53
-Vector3d::~Vector3d()
54
-{
28
+Vector3d::~Vector3d() {
55 29
 }
56 30
 
57
-
58
-////////////////////////////////////////////////////////////
59
-// Public Accessors
60
-////////////////////////////////////////////////////////////
61
-
62
-vec_t Vector3d::dot(const Vector3d &u, const Vector3d &v)
63
-{
31
+vec_t Vector3d::dot(const Vector3d &u, const Vector3d &v) {
64 32
     return (u.mVec[0]*v.mVec[0] + u.mVec[1]*v.mVec[1] + u.mVec[2]*v.mVec[2]);
65 33
 }
66 34
 
67
-
68
-Vector3d Vector3d::cross(const Vector3d &u, const Vector3d &v)
69
-{
35
+Vector3d Vector3d::cross(const Vector3d &u, const Vector3d &v) {
70 36
     return Vector3d(u.mVec[1] * v.mVec[2] - u.mVec[2] * v.mVec[1],
71 37
             u.mVec[2] * v.mVec[0] - u.mVec[0] * v.mVec[2],
72 38
             u.mVec[0] * v.mVec[1] - u.mVec[1] * v.mVec[0]);
73 39
 }
74 40
 
75
-
76
-vec_t Vector3d::magnitude()
77
-{
41
+vec_t Vector3d::magnitude() {
78 42
     return sqrtf(mVec[0]*mVec[0] + mVec[1]*mVec[1] + mVec[2]*mVec[2]);
79 43
 }
80 44
 
81
-
82
-Vector3d Vector3d::unit()
83
-{
45
+Vector3d Vector3d::unit() {
84 46
     vec_t norm = magnitude();
85 47
 
86 48
     return Vector3d(mVec[0] / norm,
@@ -88,73 +50,45 @@ Vector3d Vector3d::unit()
88 50
             mVec[2] / norm);
89 51
 }
90 52
 
91
-
92
-Vector3d Vector3d::zeroVector()
93
-{
53
+Vector3d Vector3d::zeroVector() {
94 54
     return Vector3d(0, 0, 0);
95 55
 }
96 56
 
97
-
98
-Vector3d Vector3d::operator +(const Vector3d &v)
99
-{
57
+Vector3d Vector3d::operator +(const Vector3d &v) {
100 58
     return Vector3d(mVec[0] + v.mVec[0],
101 59
             mVec[1] + v.mVec[1],
102 60
             mVec[2] + v.mVec[2]);
103 61
 }
104 62
 
105
-
106
-Vector3d Vector3d::operator -(const Vector3d &v)
107
-{
63
+Vector3d Vector3d::operator -(const Vector3d &v) {
108 64
     return Vector3d(mVec[0] - v.mVec[0],
109 65
             mVec[1] - v.mVec[1],
110 66
             mVec[2] - v.mVec[2]);
111 67
 }
112 68
 
113
-
114
-Vector3d Vector3d::operator -()
115
-{
69
+Vector3d Vector3d::operator -() {
116 70
     return Vector3d(-mVec[0],
117 71
             -mVec[1],
118 72
             -mVec[2]);
119 73
 }
120 74
 
121
-
122
-Vector3d Vector3d::operator *(vec_t s)
123
-{
75
+Vector3d Vector3d::operator *(vec_t s) {
124 76
     return Vector3d(s * mVec[0],
125 77
             s * mVec[1],
126 78
             s * mVec[2]);
127 79
 }
128 80
 
129
-
130
-Vector3d Vector3d::operator /(vec_t s)
131
-{
81
+Vector3d Vector3d::operator /(vec_t s) {
132 82
     return Vector3d(mVec[0] / s,
133 83
             mVec[1] / s,
134 84
             mVec[2] / s);
135 85
 }
136 86
 
137
-
138
-vec_t Vector3d::operator *(const Vector3d &v)
139
-{
87
+vec_t Vector3d::operator *(const Vector3d &v) {
140 88
     return dot(*this, v);
141 89
 }
142 90
 
143
-
144
-//Vector3d Vector3d::operator *(const Matrix &m)
145
-//{
146
-//  vec3_t v;
147
-//
148
-//  return
149
-//}
150
-
151
-
152
-////////////////////////////////////////////////////////////
153
-// Public Mutators
154
-////////////////////////////////////////////////////////////
155
-
156
-void Vector3d::normalize()
157
-{
91
+void Vector3d::normalize() {
158 92
     vec_t norm = magnitude();
159 93
 
160 94
     mVec[0] /= norm;
@@ -162,57 +96,37 @@ void Vector3d::normalize()
162 96
     mVec[2] /= norm;
163 97
 }
164 98
 
165
-
166
-void Vector3d::zero()
167
-{
99
+void Vector3d::zero() {
168 100
     mVec[0] = 0;
169 101
     mVec[1] = 0;
170 102
     mVec[2] = 0;
171 103
 }
172 104
 
173
-
174
-Vector3d &Vector3d::operator =(const Vector3d &v)
175
-{
105
+Vector3d &Vector3d::operator =(const Vector3d &v) {
176 106
     mVec[0] = v.mVec[0];
177 107
     mVec[1] = v.mVec[1];
178 108
     mVec[2] = v.mVec[2];
179 109
     return *this;
180 110
 }
181 111
 
182
-
183
-Vector3d &Vector3d::operator +=(const Vector3d &v)
184
-{
112
+Vector3d &Vector3d::operator +=(const Vector3d &v) {
185 113
     mVec[0] += v.mVec[0];
186 114
     mVec[1] += v.mVec[1];
187 115
     mVec[2] += v.mVec[2];
188 116
     return *this;
189 117
 }
190 118
 
191
-
192
-Vector3d &Vector3d::operator -=(const Vector3d &v)
193
-{
119
+Vector3d &Vector3d::operator -=(const Vector3d &v) {
194 120
     mVec[0] -= v.mVec[0];
195 121
     mVec[1] -= v.mVec[1];
196 122
     mVec[2] -= v.mVec[2];
197 123
     return *this;
198 124
 }
199 125
 
200
-
201
-Vector3d &Vector3d::operator *=(vec_t s)
202
-{
126
+Vector3d &Vector3d::operator *=(vec_t s) {
203 127
     mVec[0] *= s;
204 128
     mVec[1] *= s;
205 129
     mVec[2] *= s;
206 130
     return *this;
207 131
 }
208 132
 
209
-
210
-////////////////////////////////////////////////////////////
211
-// Private Accessors
212
-////////////////////////////////////////////////////////////
213
-
214
-
215
-////////////////////////////////////////////////////////////
216
-// Private Mutators
217
-////////////////////////////////////////////////////////////
218
-

+ 36
- 151
src/ViewVolume.cpp View File

@@ -1,37 +1,17 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file include/ViewVolume.h
3
+ * \brief Viewing Volume for culling use
3 4
  *
4
- * Project : hel
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : ViewVolume
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: This is the viewing volume for culling use
5
+ * Thanks Mark Morley for the article I used to get several algorithms.
11 6
  *
12
- *           Thanks Mark Morley for the article I used
13
- *           to get several algorithms.
14
- *
15
- *           This file was generated using Mongoose's C++
16
- *           template generator script.  <stu7440@westga.edu>
17
- *
18
- *-- History -------------------------------------------------
19
- *
20
- * 2002.12.15:
21
- * Mongoose - Created
22
- =================================================================*/
7
+ * \author Mongoose
8
+ */
23 9
 
24 10
 #include <math.h>
25 11
 
26 12
 #include <ViewVolume.h>
27 13
 
28
-
29
-////////////////////////////////////////////////////////////
30
-// Constructors
31
-////////////////////////////////////////////////////////////
32
-
33
-ViewVolume::ViewVolume()
34
-{
14
+ViewVolume::ViewVolume() {
35 15
     mFrustum[0][0] = mFrustum[0][1] = mFrustum[0][2] = mFrustum[0][3] = 0.0f;
36 16
     mFrustum[1][0] = mFrustum[1][1] = mFrustum[1][2] = mFrustum[1][3] = 0.0f;
37 17
     mFrustum[2][0] = mFrustum[2][1] = mFrustum[2][2] = mFrustum[2][3] = 0.0f;
@@ -40,80 +20,47 @@ ViewVolume::ViewVolume()
40 20
     mFrustum[5][0] = mFrustum[5][1] = mFrustum[5][2] = mFrustum[5][3] = 0.0f;
41 21
 }
42 22
 
43
-
44
-ViewVolume::~ViewVolume()
45
-{
23
+ViewVolume::~ViewVolume() {
46 24
 }
47 25
 
48
-
49
-////////////////////////////////////////////////////////////
50
-// Public Accessors
51
-////////////////////////////////////////////////////////////
52
-
53
-bool ViewVolume::isBoundingVolumeInFrustum(BoundingVolume bvol)
54
-{
26
+bool ViewVolume::isBoundingVolumeInFrustum(BoundingVolume bvol) {
55 27
     return (isBoundingSphereInFrustum(bvol.mSphere) &&
56 28
             isBoundingBoxInFrustum(bvol.mBox));
57 29
 }
58 30
 
59
-
60
-bool ViewVolume::isBoundingSphereInFrustum(BoundingSphere bvol)
61
-{
31
+bool ViewVolume::isBoundingSphereInFrustum(BoundingSphere bvol) {
62 32
     return (isSphereInFrustum(bvol.mCenter[0],
63 33
                 bvol.mCenter[1],
64 34
                 bvol.mCenter[2],
65 35
                 bvol.mRadius));
66 36
 }
67 37
 
68
-
69
-bool ViewVolume::isBoundingBoxInFrustum(BoundingBox bvol)
70
-{
38
+bool ViewVolume::isBoundingBoxInFrustum(BoundingBox bvol) {
71 39
     return (isBboxInFrustum(bvol.mMin, bvol.mMax));
72 40
 }
73 41
 
74
-
75
-bool ViewVolume::isPointInFrustum(vec_t x, vec_t y, vec_t z)
76
-{
77
-    unsigned int p;
78
-
79
-
80
-    for (p = 0; p < 6; ++p)
81
-    {
42
+bool ViewVolume::isPointInFrustum(vec_t x, vec_t y, vec_t z) {
43
+    for (unsigned int p = 0; p < 6; ++p) {
82 44
         if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z +
83
-                mFrustum[p][3] <= 0)
84
-        {
45
+                mFrustum[p][3] <= 0) {
85 46
             return false;
86 47
         }
87 48
     }
88
-
89 49
     return true;
90 50
 }
91 51
 
92
-
93
-bool ViewVolume::isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius)
94
-{
95
-    unsigned int p;
52
+bool ViewVolume::isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius) {
96 53
     vec_t d;
97
-
98
-
99
-    for (p = 0; p < 6; ++p)
100
-    {
54
+    for (unsigned int p = 0; p < 6; ++p) {
101 55
         d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
102 56
         if (d <= -radius)
103 57
             return false;
104 58
     }
105
-
106 59
     return true;
107 60
 }
108 61
 
109
-
110
-bool ViewVolume::isBboxInFrustum(vec3_t min, vec3_t max)
111
-{
112
-    unsigned int p;
113
-
114
-
115
-    for (p = 0; p < 6; ++p)
116
-    {
62
+bool ViewVolume::isBboxInFrustum(vec3_t min, vec3_t max) {
63
+    for (unsigned int p = 0; p < 6; ++p) {
117 64
         if (mFrustum[p][0] * min[0] +
118 65
                 mFrustum[p][1] * min[1] +
119 66
                 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
@@ -156,34 +103,23 @@ bool ViewVolume::isBboxInFrustum(vec3_t min, vec3_t max)
156 103
 
157 104
         return false;
158 105
     }
159
-
160 106
     return true;
161 107
 }
162 108
 
163
-
164
-vec_t ViewVolume::getDistToSphereFromNear(vec_t x, vec_t y, vec_t z,
165
-        vec_t radius)
166
-{
167
-    unsigned int p;
109
+vec_t ViewVolume::getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, vec_t radius) {
168 110
     vec_t d = 0.0;
169
-
170
-    for (p = 0; p < 6; ++p)
171
-    {
111
+    for (unsigned int p = 0; p < 6; ++p) {
172 112
         d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
173 113
         if (d <= -radius)
174 114
             return 0;
175 115
     }
176
-
177 116
     return d + radius;
178 117
 }
179 118
 
180
-
181
-vec_t ViewVolume::getDistToBboxFromNear(vec3_t min, vec3_t max)
182
-{
119
+vec_t ViewVolume::getDistToBboxFromNear(vec3_t min, vec3_t max) {
183 120
     vec3_t center;
184 121
     vec_t d, radius;
185 122
 
186
-
187 123
     helMidpoint3v(min, max, center);
188 124
 
189 125
     // 5 should be near plane
@@ -200,99 +136,48 @@ vec_t ViewVolume::getDistToBboxFromNear(vec3_t min, vec3_t max)
200 136
     return d + radius;
201 137
 }
202 138
 
203
-
204
-void ViewVolume::getFrustum(vec_t frustum[6][4])
205
-{
206
-    unsigned int plane;
207
-
208
-
209
-    for (plane = 0; plane < 6; ++plane)
210
-    {
211
-        frustum[plane][0] = mFrustum[plane][0];
212
-        frustum[plane][1] = mFrustum[plane][1];
213
-        frustum[plane][2] = mFrustum[plane][2];
214
-        frustum[plane][3] = mFrustum[plane][3];
139
+void ViewVolume::getFrustum(vec_t frustum[6][4]) {
140
+    for (unsigned int p = 0; p < 6; ++p) {
141
+        for (unsigned int i = 0; i < 4; ++i) {
142
+            frustum[p][i] = mFrustum[p][i];
143
+        }
215 144
     }
216 145
 }
217 146
 
218
-
219
-void ViewVolume::getPlane(ViewVolumeSide p, vec4_t plane)
220
-{
221
-    plane[0] =  mFrustum[p][0];
222
-    plane[1] =  mFrustum[p][1];
223
-    plane[2] =  mFrustum[p][2];
224
-    plane[3] =  mFrustum[p][3];
147
+void ViewVolume::getPlane(ViewVolumeSide p, vec4_t plane) {
148
+    for (unsigned int i = 0; i < 4; ++i) {
149
+        plane[i] =  mFrustum[p][i];
150
+    }
225 151
 }
226 152
 
227
-
228
-////////////////////////////////////////////////////////////
229
-// Public Mutators
230
-////////////////////////////////////////////////////////////
231
-
232
-void ViewVolume::updateFrame(matrix_t proj, matrix_t mdl)
233
-{
153
+void ViewVolume::updateFrame(matrix_t proj, matrix_t mdl) {
234 154
     setModel(mdl);
235 155
     setProjection(proj);
236 156
     updateClip();
237 157
     updateFrustum();
238 158
 }
239 159
 
240
-
241
-void ViewVolume::updateFrame()
242
-{
160
+void ViewVolume::updateFrame() {
243 161
     updateClip();
244 162
     updateFrustum();
245 163
 }
246 164
 
247
-
248
-void ViewVolume::setModel(matrix_t mdl)
249
-{
165
+void ViewVolume::setModel(matrix_t mdl) {
250 166
     mModel.setMatrix(mdl);
251 167
 }
252 168
 
253
-
254
-void ViewVolume::setProjection(matrix_t proj)
255
-{
256
-    /*void setProjection(viewAngle, aspectRatio, near, far)
257
-     ****************************
258
-     *float far = 4000.0f;
259
-     *float near = 4.0f;
260
-     *float viewAngle = 45.0f;
261
-     *float aspectRatio = 800.0f/600.0f;
262
-     ****************************
263
-     *float top = near * tan(PI/180 * viewAngle/2)
264
-     *float bottom = -top
265
-     *float right = top * aspectRatio
266
-     *float left = - right
267
-     */
268
-
169
+void ViewVolume::setProjection(matrix_t proj) {
269 170
     mProjection.setMatrix(proj);
270 171
 }
271 172
 
272
-
273
-
274
-////////////////////////////////////////////////////////////
275
-// Private Accessors
276
-////////////////////////////////////////////////////////////
277
-
278
-
279
-////////////////////////////////////////////////////////////
280
-// Private Mutators
281
-////////////////////////////////////////////////////////////
282
-
283
-void ViewVolume::updateClip()
284
-{
285
-    //mClip = mModel * mProjection;
173
+void ViewVolume::updateClip() {
286 174
     mClip = mProjection * mModel;
287 175
 }
288 176
 
289
-
290
-void ViewVolume::updateFrustum()
291
-{
177
+void ViewVolume::updateFrustum() {
292 178
     matrix_t clip;
293 179
     vec_t t;
294 180
 
295
-
296 181
     mClip.getMatrix(clip);
297 182
 
298 183
     /* Extract the numbers for the RIGHT plane */

Loading…
Cancel
Save