Thomas Buck 11 роки тому
джерело
коміт
cc4de9324d
51 змінених файлів з 25015 додано та 25013 видалено
  1. 15
    13
      ChangeLog
  2. 265
    265
      include/Camera.h
  3. 42
    42
      include/Emitter.h
  4. 46
    46
      include/List.h
  5. 388
    388
      include/Map.h
  6. 1
    1
      include/MatMath.h
  7. 335
    335
      include/Matrix.h
  8. 237
    237
      include/Network.h
  9. 388
    388
      include/OpenRaider.h
  10. 323
    323
      include/Quaternion.h
  11. 295
    295
      include/Render.h
  12. 168
    168
      include/SDLSystem.h
  13. 72
    72
      include/SkeletalModel.h
  14. 406
    406
      include/Texture.h
  15. 1603
    1603
      include/TombRaider.h
  16. 28
    28
      include/TombRaider1.h
  17. 465
    465
      include/TombRaider5.h
  18. 1042
    1042
      include/Tree.h
  19. 260
    260
      include/Vector.h
  20. 252
    252
      include/Vector3d.h
  21. 243
    243
      include/ViewVolume.h
  22. 390
    390
      include/World.h
  23. 6
    6
      include/tga.h
  24. 200
    200
      src/Camera.cpp
  25. 202
    202
      src/Emitter.cpp
  26. 150
    150
      src/GLString.cpp
  27. 171
    171
      src/MatMath.cpp
  28. 319
    319
      src/Matrix.cpp
  29. 480
    480
      src/Network.cpp
  30. 470
    470
      src/OpenGLMesh.cpp
  31. 3120
    3120
      src/OpenRaider.cpp
  32. 71
    71
      src/Particle.cpp
  33. 218
    218
      src/Quaternion.cpp
  34. 1772
    1772
      src/Render.cpp
  35. 326
    326
      src/SDLSystem.cpp
  36. 65
    65
      src/SkeletalModel.cpp
  37. 128
    128
      src/Sound.cpp
  38. 514
    514
      src/System.cpp
  39. 878
    878
      src/Texture.cpp
  40. 5655
    5655
      src/TombRaider.cpp
  41. 54
    54
      src/Vector3d.cpp
  42. 231
    231
      src/ViewVolume.cpp
  43. 532
    532
      src/World.cpp
  44. 895
    895
      src/memory_test.cpp
  45. 392
    392
      src/tga.cpp
  46. 192
    192
      test/GLString.cpp
  47. 29
    29
      test/Matrix.cpp
  48. 60
    60
      test/Network.cpp
  49. 9
    9
      test/Sound.cpp
  50. 486
    486
      test/TombRaider.cpp
  51. 126
    126
      test/memory_test.cpp

+ 15
- 13
ChangeLog Переглянути файл

@@ -7,6 +7,8 @@
7 7
 
8 8
 	[ 20140120 ]
9 9
 	* Removed HAVE_SDL & HAVE_SDL_TTF flags. SDL & TTF always required!
10
+	* Converted all tabs to spaces (4 spaces per tab)
11
+	* Auto indented all cpp files
10 12
 
11 13
 	[ 20140119 ]
12 14
 	* Enabled linear texture filtering for fonts, resulting in nicer
@@ -169,7 +171,7 @@
169 171
 	[ 20030701 ]
170 172
 	* Removing OpenRaider Map use for level/music string storage
171 173
 	  ( This means if you set a map to a certain number in rc, then
172
-	    you can no longer call it by 'load #' )
174
+		you can no longer call it by 'load #' )
173 175
 	* Fixed PSKModel unit test build
174 176
 	* Fixed Hel Simulation, Spring unit test builds
175 177
 	
@@ -428,7 +430,7 @@
428 430
 
429 431
 	* TR4 pak sound reading and dumping 
430 432
 	  ( I couldn't find any paks using compression - however
431
-	    my algorithm can handle those that may )
433
+		my algorithm can handle those that may )
432 434
 	* Sound read from TR1 paks agian ( TombRaider.test can dump them )
433 435
 	* TR4 ponytail type guessing algorithm works with TR4 paks
434 436
 	  ( May not apply to all custom lara models )
@@ -1063,7 +1065,7 @@
1063 1065
 	* Worked on portal code (testing)
1064 1066
 	* Since adding quaternion camera, segfault on exit... hhmmm...
1065 1067
 	* Finished quaternion based camera and rendering
1066
- 	* Planning to break mtk3d into base type classes and expand it as
1068
+	* Planning to break mtk3d into base type classes and expand it as
1067 1069
 	  a library with learping functions for use in animation also  =)
1068 1070
 	* Started on quaternion camera and quaternion support in mtk3d
1069 1071
 	* TR4 sound fx postioning loader starts
@@ -1082,14 +1084,14 @@
1082 1084
  OpenRaider (0.0.3-20010602) Mongoose <mongoose@users.sourceforge.net>
1083 1085
 
1084 1086
 	* SDL is very slow atm ( drag ass )
1085
-   	  You can edit Makefile to set it to use it if you want
1087
+	  You can edit Makefile to set it to use it if you want
1086 1088
 	* Finished basic test SDL interface
1087 1089
 	* Started on item sprite loading (likes a little more, but not priority)
1088 1090
 	* Aren't you all gald I ditched render engine #1 now?  ;)
1089 1091
 	* New sprite rendering code
1090 1092
 	* Fixed bug that drew static room meshes twice
1091 1093
 	* Fixed bug that drew alpha sorted tris 3 times
1092
-   	  (Fixes all known alpha rendering bugs)
1094
+	  (Fixes all known alpha rendering bugs)
1093 1095
 	* Room sprite loading code
1094 1096
 	* Cleaned code, fixed some documentation
1095 1097
 	* Started work on Resource agent, not ready to replace old code yet
@@ -1108,7 +1110,7 @@
1108 1110
 	* SDL support starts back
1109 1111
 	* Added my old linux joystick code
1110 1112
 	* Basic sorted alpha poly render second pass with very small penalty
1111
-   	  ( An all new rendering feature never in engine before )
1113
+	  ( An all new rendering feature never in engine before )
1112 1114
 	* Figured out best way to sort alpha polys exp with rooms only for now
1113 1115
 	* SkyMesh support ( rendering/identifing ) for TR2 and TR3
1114 1116
 	* Static mesh rendering back ( doesn't use room lighting 
@@ -1124,7 +1126,7 @@
1124 1126
 	* Code clean up
1125 1127
 	* Item sprite and room sprite loader code about finished
1126 1128
 	* Finished adding my screenshot code from Freyja, and
1127
-   	  made it produce TGAs instead of PPMs ( cmd 'S' )
1129
+	  made it produce TGAs instead of PPMs ( cmd 'S' )
1128 1130
 
1129 1131
 
1130 1132
  OpenRaider (0.0.3-20010528) Mongoose <mongoose@users.sourceforge.net>
@@ -1132,14 +1134,14 @@
1132 1134
 	* POublic CVS Release 
1133 1135
 	* Vertex lighting now functional and stable in new engine
1134 1136
 	* Fix for TR4 water alpha via textile generator, but
1135
-   	  some light shards are still black - might be other
1136
-   	  alpha flags that are unknown
1137
+	  some light shards are still black - might be other
1138
+	  alpha flags that are unknown
1137 1139
 	* New level loader using _map_list
1138 1140
 	* New Map list RC rule
1139 1141
 	* Start of item sprite code in new engine
1140
- 	* Leaving old Texture calls for compaiblity with obsolete
1142
+	* Leaving old Texture calls for compaiblity with obsolete
1141 1143
 	* New textile loading by moving new code into Freyja's
1142
-   	  TombRaider module to handle *all pixmap generation
1144
+	  TombRaider module to handle *all pixmap generation
1143 1145
 	* User documentation
1144 1146
 
1145 1147
 
@@ -1149,7 +1151,7 @@
1149 1151
 	* Resource system back in
1150 1152
 	* AL init threaded off
1151 1153
 	* Switched order of AL and GL inits 
1152
-   	  ( so you can have in game progess loader for loading )
1154
+	  ( so you can have in game progess loader for loading )
1153 1155
 
1154 1156
 
1155 1157
  OpenRaider (0.0.3-20010526) Mongoose <mongoose@users.sourceforge.net>
@@ -1188,7 +1190,7 @@
1188 1190
 	* TR4 texture fixes ported from gegg
1189 1191
 	* Fixed segfault on texture handling
1190 1192
 	* Removed splash screen code completely
1191
-   	  ( Will later use loader screens just like TR )
1193
+	  ( Will later use loader screens just like TR )
1192 1194
 
1193 1195
 
1194 1196
  OpenRaider (0.0.2-20010522) Mongoose <mongoose@users.sourceforge.net>

+ 265
- 265
include/Camera.h Переглянути файл

@@ -60,7 +60,7 @@ enum camera_command                /* Interactive camera control */
60 60
 
61 61
 enum CameraFlags
62 62
 {
63
-	Camera_FlyMode = 1
63
+    Camera_FlyMode = 1
64 64
 };
65 65
 
66 66
 
@@ -68,206 +68,206 @@ class Camera
68 68
 {
69 69
  public:
70 70
 
71
-	////////////////////////////////////////////////////////////
72
-	// Constructors
73
-	////////////////////////////////////////////////////////////
74
-
75
-	Camera();
76
-	/*------------------------------------------------------
77
-	 * Pre  :
78
-	 * Post : Constructs an object of Camera
79
-	 *
80
-	 *-- History ------------------------------------------
81
-	 *
82
-	 * 2001.05.18:
83
-	 * Mongoose - Created
84
-	 ------------------------------------------------------*/
85
-
86
-	~Camera();
87
-	/*------------------------------------------------------
88
-	 * Pre  : Camera object is allocated
89
-	 * Post : Deconstructs an object of Camera
90
-	 *
91
-	 *-- History ------------------------------------------
92
-	 *
93
-	 * 2001.05.18:
94
-	 * Mongoose - Created
95
-	 ------------------------------------------------------*/
96
-
97
-
98
-	////////////////////////////////////////////////////////////
99
-	// Public Accessors
100
-	////////////////////////////////////////////////////////////
101
-
102
-	unsigned int getId();
103
-	/*------------------------------------------------------
104
-	 * Pre  :
105
-	 * Post : Returns this camera's id
106
-	 *
107
-	 *-- History ------------------------------------------
108
-	 *
109
-	 * 2001.05.18:
110
-	 * Mongoose - Created
111
-	 ------------------------------------------------------*/
112
-
113
-	void getPosition(vec3_t pos);
114
-	/*------------------------------------------------------
115
-	 * Pre  :
116
-	 * Post : Returns current position
117
-	 *
118
-	 *-- History ------------------------------------------
119
-	 *
120
-	 * 2002.06.16:
121
-	 * Mongoose - Created
122
-	 ------------------------------------------------------*/
123
-
124
-	void getUp(vec3_t up);
125
-	/*------------------------------------------------------
126
-	 * Pre  :
127
-	 * Post : Returns up vector
128
-	 *
129
-	 *-- History ------------------------------------------
130
-	 *
131
-	 * 2001.05.18:
132
-	 * Mongoose - Created
133
-	 ------------------------------------------------------*/
134
-
135
-	void getTarget(vec3_t target);
136
-	/*------------------------------------------------------
137
-	 * Pre  :
138
-	 * Post : Returns target ( look at pos )
139
-	 *
140
-	 *-- History ------------------------------------------
141
-	 *
142
-	 * 2001.05.18:
143
-	 * Mongoose - Created
144
-	 ------------------------------------------------------*/
145
-
146
-	float getYaw();
147
-	/*------------------------------------------------------
148
-	 * Pre  : Get current yaw in degrees
149
-	 * Post :
150
-	 *
151
-	 *-- History ------------------------------------------
152
-	 *
153
-	 * 2002.06.22:
154
-	 * Mongoose - Created
155
-	 ------------------------------------------------------*/
156
-
157
-	double getRadianYaw();
158
-	/*------------------------------------------------------
159
-	 * Pre  :
160
-	 * Post : Returns theta angle/yaw of camera
161
-	 *
162
-	 *-- History ------------------------------------------
163
-	 *
164
-	 * 2001.05.26:
165
-	 * Mongoose - Created
166
-	 ------------------------------------------------------*/
167
-
168
-	float getPitch();
169
-	/*------------------------------------------------------
170
-	 * Pre  : Get current pitch in degrees
171
-	 * Post :
172
-	 *
173
-	 *-- History ------------------------------------------
174
-	 *
175
-	 * 2002.06.22:
176
-	 * Mongoose - Created
177
-	 ------------------------------------------------------*/
178
-
179
-	double getRadianPitch();
180
-	/*------------------------------------------------------
181
-	 * Pre  :
182
-	 * Post : Returns phi angle/pitch of camera
183
-	 *
184
-	 *-- History ------------------------------------------
185
-	 *
186
-	 * 2001.05.26:
187
-	 * Mongoose - Created
188
-	 ------------------------------------------------------*/
189
-
190
-	bool isBehind(int x, int z);
191
-	/*------------------------------------------------------
192
-	 * Pre  :
193
-	 * Post : Returns true if (x, z) is behind camera eye
194
-	 *
195
-	 *-- History ------------------------------------------
196
-	 *
197
-	 * 2001.05.26:
198
-	 * Mongoose - Created
199
-	 ------------------------------------------------------*/
200
-
201
-
202
-	////////////////////////////////////////////////////////////
203
-	// Public Mutators
204
-	////////////////////////////////////////////////////////////
205
-
206
-	void rotate(float angle, float x, float y, float z);
207
-	/*------------------------------------------------------
208
-	 * Pre  : x,y,z axis; angle in radians
209
-	 * Post : Rotates camera
210
-	 *
211
-	 *-- History ------------------------------------------
212
-	 *
213
-	 * 2001.06.04:
214
-	 * Mongoose - Created
215
-	 ------------------------------------------------------*/
216
-
217
-	void translate(float x, float y, float z);
218
-	/*------------------------------------------------------
219
-	 * Pre  :
220
-	 * Post : Camera position is set to x,y,z
221
-	 *
222
-	 *-- History ------------------------------------------
223
-	 *
224
-	 * 2001.05.18:
225
-	 * Mongoose - Created
226
-	 ------------------------------------------------------*/
227
-
228
-	void reset();
229
-	/*------------------------------------------------------
230
-	 * Pre  :
231
-	 * Post : Camera is set to inital state
232
-	 *
233
-	 *-- History ------------------------------------------
234
-	 *
235
-	 * 2001.05.18:
236
-	 * Mongoose - Created
237
-	 ------------------------------------------------------*/
238
-
239
-	void setSensitivityX(float angle);
240
-	/*------------------------------------------------------
241
-	 * Pre  : angle is theta's rotation delta in degrees
242
-	 * Post : Sets rotation delta
243
-	 *
244
-	 *-- History ------------------------------------------
245
-	 *
246
-	 * 2001.06.04:
247
-	 * Mongoose - Created
248
-	 ------------------------------------------------------*/
249
-
250
-	void setSensitivityY(float angle);
251
-	/*------------------------------------------------------
252
-	 * Pre  : angle is theta's rotation delta in degrees
253
-	 * Post : Sets rotation delta
254
-	 *
255
-	 *-- History ------------------------------------------
256
-	 *
257
-	 * 2001.06.04:
258
-	 * Mongoose - Created
259
-	 ------------------------------------------------------*/
260
-
261
-	void command(enum camera_command cmd);
262
-	/*------------------------------------------------------
263
-	 * Pre  : Command is valid camera command
264
-	 * Post : Sends interactive command to camera
265
-	 *
266
-	 *-- History ------------------------------------------
267
-	 *
268
-	 * 2001.05.18:
269
-	 * Mongoose - Created
270
-	 ------------------------------------------------------*/
71
+    ////////////////////////////////////////////////////////////
72
+    // Constructors
73
+    ////////////////////////////////////////////////////////////
74
+
75
+    Camera();
76
+    /*------------------------------------------------------
77
+     * Pre  :
78
+     * Post : Constructs an object of Camera
79
+     *
80
+     *-- History ------------------------------------------
81
+     *
82
+     * 2001.05.18:
83
+     * Mongoose - Created
84
+     ------------------------------------------------------*/
85
+
86
+    ~Camera();
87
+    /*------------------------------------------------------
88
+     * Pre  : Camera object is allocated
89
+     * Post : Deconstructs an object of Camera
90
+     *
91
+     *-- History ------------------------------------------
92
+     *
93
+     * 2001.05.18:
94
+     * Mongoose - Created
95
+     ------------------------------------------------------*/
96
+
97
+
98
+    ////////////////////////////////////////////////////////////
99
+    // Public Accessors
100
+    ////////////////////////////////////////////////////////////
101
+
102
+    unsigned int getId();
103
+    /*------------------------------------------------------
104
+     * Pre  :
105
+     * Post : Returns this camera's id
106
+     *
107
+     *-- History ------------------------------------------
108
+     *
109
+     * 2001.05.18:
110
+     * Mongoose - Created
111
+     ------------------------------------------------------*/
112
+
113
+    void getPosition(vec3_t pos);
114
+    /*------------------------------------------------------
115
+     * Pre  :
116
+     * Post : Returns current position
117
+     *
118
+     *-- History ------------------------------------------
119
+     *
120
+     * 2002.06.16:
121
+     * Mongoose - Created
122
+     ------------------------------------------------------*/
123
+
124
+    void getUp(vec3_t up);
125
+    /*------------------------------------------------------
126
+     * Pre  :
127
+     * Post : Returns up vector
128
+     *
129
+     *-- History ------------------------------------------
130
+     *
131
+     * 2001.05.18:
132
+     * Mongoose - Created
133
+     ------------------------------------------------------*/
134
+
135
+    void getTarget(vec3_t target);
136
+    /*------------------------------------------------------
137
+     * Pre  :
138
+     * Post : Returns target ( look at pos )
139
+     *
140
+     *-- History ------------------------------------------
141
+     *
142
+     * 2001.05.18:
143
+     * Mongoose - Created
144
+     ------------------------------------------------------*/
145
+
146
+    float getYaw();
147
+    /*------------------------------------------------------
148
+     * Pre  : Get current yaw in degrees
149
+     * Post :
150
+     *
151
+     *-- History ------------------------------------------
152
+     *
153
+     * 2002.06.22:
154
+     * Mongoose - Created
155
+     ------------------------------------------------------*/
156
+
157
+    double getRadianYaw();
158
+    /*------------------------------------------------------
159
+     * Pre  :
160
+     * Post : Returns theta angle/yaw of camera
161
+     *
162
+     *-- History ------------------------------------------
163
+     *
164
+     * 2001.05.26:
165
+     * Mongoose - Created
166
+     ------------------------------------------------------*/
167
+
168
+    float getPitch();
169
+    /*------------------------------------------------------
170
+     * Pre  : Get current pitch in degrees
171
+     * Post :
172
+     *
173
+     *-- History ------------------------------------------
174
+     *
175
+     * 2002.06.22:
176
+     * Mongoose - Created
177
+     ------------------------------------------------------*/
178
+
179
+    double getRadianPitch();
180
+    /*------------------------------------------------------
181
+     * Pre  :
182
+     * Post : Returns phi angle/pitch of camera
183
+     *
184
+     *-- History ------------------------------------------
185
+     *
186
+     * 2001.05.26:
187
+     * Mongoose - Created
188
+     ------------------------------------------------------*/
189
+
190
+    bool isBehind(int x, int z);
191
+    /*------------------------------------------------------
192
+     * Pre  :
193
+     * Post : Returns true if (x, z) is behind camera eye
194
+     *
195
+     *-- History ------------------------------------------
196
+     *
197
+     * 2001.05.26:
198
+     * Mongoose - Created
199
+     ------------------------------------------------------*/
200
+
201
+
202
+    ////////////////////////////////////////////////////////////
203
+    // Public Mutators
204
+    ////////////////////////////////////////////////////////////
205
+
206
+    void rotate(float angle, float x, float y, float z);
207
+    /*------------------------------------------------------
208
+     * Pre  : x,y,z axis; angle in radians
209
+     * Post : Rotates camera
210
+     *
211
+     *-- History ------------------------------------------
212
+     *
213
+     * 2001.06.04:
214
+     * Mongoose - Created
215
+     ------------------------------------------------------*/
216
+
217
+    void translate(float x, float y, float z);
218
+    /*------------------------------------------------------
219
+     * Pre  :
220
+     * Post : Camera position is set to x,y,z
221
+     *
222
+     *-- History ------------------------------------------
223
+     *
224
+     * 2001.05.18:
225
+     * Mongoose - Created
226
+     ------------------------------------------------------*/
227
+
228
+    void reset();
229
+    /*------------------------------------------------------
230
+     * Pre  :
231
+     * Post : Camera is set to inital state
232
+     *
233
+     *-- History ------------------------------------------
234
+     *
235
+     * 2001.05.18:
236
+     * Mongoose - Created
237
+     ------------------------------------------------------*/
238
+
239
+    void setSensitivityX(float angle);
240
+    /*------------------------------------------------------
241
+     * Pre  : angle is theta's rotation delta in degrees
242
+     * Post : Sets rotation delta
243
+     *
244
+     *-- History ------------------------------------------
245
+     *
246
+     * 2001.06.04:
247
+     * Mongoose - Created
248
+     ------------------------------------------------------*/
249
+
250
+    void setSensitivityY(float angle);
251
+    /*------------------------------------------------------
252
+     * Pre  : angle is theta's rotation delta in degrees
253
+     * Post : Sets rotation delta
254
+     *
255
+     *-- History ------------------------------------------
256
+     *
257
+     * 2001.06.04:
258
+     * Mongoose - Created
259
+     ------------------------------------------------------*/
260
+
261
+    void command(enum camera_command cmd);
262
+    /*------------------------------------------------------
263
+     * Pre  : Command is valid camera command
264
+     * Post : Sends interactive command to camera
265
+     *
266
+     *-- History ------------------------------------------
267
+     *
268
+     * 2001.05.18:
269
+     * Mongoose - Created
270
+     ------------------------------------------------------*/
271 271
 
272 272
    void setSpeed(float s);
273 273
    /*------------------------------------------------------
@@ -280,91 +280,91 @@ class Camera
280 280
     * Mongoose - Created
281 281
     ------------------------------------------------------*/
282 282
 
283
-	void update();
284
-	/*------------------------------------------------------
285
-	 * Pre  :
286
-	 * Post : Updates view target
287
-	 *
288
-	 *-- History ------------------------------------------
289
-	 *
290
-	 * 2001.05.18:
291
-	 * Mongoose - Created
292
-	 ------------------------------------------------------*/
293
-
294
-	void setPosition(vec3_t pos);
295
-	/*------------------------------------------------------
296
-	 * Pre  : Set current position
297
-	 * Post :
298
-	 *
299
-	 *-- History ------------------------------------------
300
-	 *
301
-	 * 2002.06.16:
302
-	 * Mongoose - Created
303
-	 ------------------------------------------------------*/
304
-
305
-	void setUp(vec3_t up);
306
-	/*------------------------------------------------------
307
-	 * Pre  :
308
-	 * Post : Sets up vector
309
-	 *
310
-	 *-- History ------------------------------------------
311
-	 *
312
-	 * 2001.05.18:
313
-	 * Mongoose - Created
314
-	 ------------------------------------------------------*/
315
-
316
-	void setTarget(vec3_t target);
317
-	/*------------------------------------------------------
318
-	 * Pre  :
319
-	 * Post : Sets target ( look at pos )
320
-	 *
321
-	 *-- History ------------------------------------------
322
-	 *
323
-	 * 2001.05.18:
324
-	 * Mongoose - Created
325
-	 ------------------------------------------------------*/
283
+    void update();
284
+    /*------------------------------------------------------
285
+     * Pre  :
286
+     * Post : Updates view target
287
+     *
288
+     *-- History ------------------------------------------
289
+     *
290
+     * 2001.05.18:
291
+     * Mongoose - Created
292
+     ------------------------------------------------------*/
293
+
294
+    void setPosition(vec3_t pos);
295
+    /*------------------------------------------------------
296
+     * Pre  : Set current position
297
+     * Post :
298
+     *
299
+     *-- History ------------------------------------------
300
+     *
301
+     * 2002.06.16:
302
+     * Mongoose - Created
303
+     ------------------------------------------------------*/
304
+
305
+    void setUp(vec3_t up);
306
+    /*------------------------------------------------------
307
+     * Pre  :
308
+     * Post : Sets up vector
309
+     *
310
+     *-- History ------------------------------------------
311
+     *
312
+     * 2001.05.18:
313
+     * Mongoose - Created
314
+     ------------------------------------------------------*/
315
+
316
+    void setTarget(vec3_t target);
317
+    /*------------------------------------------------------
318
+     * Pre  :
319
+     * Post : Sets target ( look at pos )
320
+     *
321
+     *-- History ------------------------------------------
322
+     *
323
+     * 2001.05.18:
324
+     * Mongoose - Created
325
+     ------------------------------------------------------*/
326 326
 
327 327
 
328 328
  private:
329 329
 
330
-	////////////////////////////////////////////////////////////
331
-	// Private Accessors
332
-	////////////////////////////////////////////////////////////
330
+    ////////////////////////////////////////////////////////////
331
+    // Private Accessors
332
+    ////////////////////////////////////////////////////////////
333 333
 
334 334
 
335
-	////////////////////////////////////////////////////////////
336
-	// Private Mutators
337
-	////////////////////////////////////////////////////////////
335
+    ////////////////////////////////////////////////////////////
336
+    // Private Mutators
337
+    ////////////////////////////////////////////////////////////
338 338
 
339
-	unsigned int mId;           /* Unquie id */
339
+    unsigned int mId;           /* Unquie id */
340 340
 
341
-	Quaternion mQ;              /* Quaternion for rotation */
341
+    Quaternion mQ;              /* Quaternion for rotation */
342 342
 
343
-	unsigned int mFlags;        /* For testing with flags  */
343
+    unsigned int mFlags;        /* For testing with flags  */
344 344
 
345
-	double mPos[4];             /* Location in 3 space (aka eye) */
345
+    double mPos[4];             /* Location in 3 space (aka eye) */
346 346
 
347
-	double mTarget[4];          /* Postition we're looking at  */
347
+    double mTarget[4];          /* Postition we're looking at  */
348 348
 
349
-	double mUp[4];              /* Up vector  */
349
+    double mUp[4];              /* Up vector  */
350 350
 
351
-	double mSide[4];            /* Side vector  */
351
+    double mSide[4];            /* Side vector  */
352 352
 
353
-	double mViewDistance;      /* Distance from target */
353
+    double mViewDistance;      /* Distance from target */
354 354
 
355
-	double mTranslateDelta;    /* Step size to move */
355
+    double mTranslateDelta;    /* Step size to move */
356 356
 
357
-	double mRotateDelta;       /* Radians to rotate  Y */
357
+    double mRotateDelta;       /* Radians to rotate  Y */
358 358
 
359
-	double mTheta;              /* View angle  Y */
359
+    double mTheta;              /* View angle  Y */
360 360
 
361
-	double mRotateDelta2;      /* Radians to rotate  Z */
361
+    double mRotateDelta2;      /* Radians to rotate  Z */
362 362
 
363
-	double mTheta2;             /* View angle  Z */
363
+    double mTheta2;             /* View angle  Z */
364 364
 
365
-	bool mUpdate;               /* Check to see if view needs updating */
365
+    bool mUpdate;               /* Check to see if view needs updating */
366 366
 
367
-	static unsigned int mCounter;   /* Id system use */
367
+    static unsigned int mCounter;   /* Id system use */
368 368
 };
369 369
 
370 370
 #endif

+ 42
- 42
include/Emitter.h Переглянути файл

@@ -33,18 +33,18 @@ class Emitter
33 33
 {
34 34
  public:
35 35
 
36
-	typedef enum
37
-	{
38
-		fUseFrustumCulling = 1,
39
-		fUseDepthSorting = 2
40
-	} EmitterFlags;
36
+    typedef enum
37
+    {
38
+        fUseFrustumCulling = 1,
39
+        fUseDepthSorting = 2
40
+    } EmitterFlags;
41 41
 
42 42
 
43 43
   Emitter(const char *name, int n);
44 44
   /*------------------------------------------------------
45 45
    * Pre  : name is a valid C string
46
-	*        n is a number greater than 0
47
-	*
46
+    *        n is a number greater than 0
47
+    *
48 48
    * Post : Constructs an object of Emitter
49 49
    *
50 50
    *-- History ------------------------------------------
@@ -108,7 +108,7 @@ class Emitter
108 108
    * Mongoose - Created
109 109
    ------------------------------------------------------*/
110 110
 
111
-	void Orientation(float x, float y, float z);
111
+    void Orientation(float x, float y, float z);
112 112
   /*------------------------------------------------------
113 113
    * Pre  : x,y,z exist
114 114
    * Post : Sets orientation of emitter in 3 space
@@ -119,7 +119,7 @@ class Emitter
119 119
    * Mongoose - Created
120 120
    ------------------------------------------------------*/
121 121
 
122
-	void Orientation(float *x, float *y, float *z);
122
+    void Orientation(float *x, float *y, float *z);
123 123
   /*------------------------------------------------------
124 124
    * Pre  : x,y,z exist
125 125
    * Post : Returns orientation of emitter in 3 space
@@ -146,9 +146,9 @@ class Emitter
146 146
   /*------------------------------------------------------
147 147
    * Pre  :
148 148
    * Post : Set and Unset flag with op
149
-	*
150
-	*          true - set
151
-	*          flase - unset
149
+    *
150
+    *          true - set
151
+    *          flase - unset
152 152
    *
153 153
    *-- History ------------------------------------------
154 154
    *
@@ -160,9 +160,9 @@ class Emitter
160 160
   /*------------------------------------------------------
161 161
    * Pre  : n is a number greater than 0
162 162
    * Post : Allocates the particle array and sets the count.
163
-	*        If the array has been allocated previously, then
164
-	*        the array is deallocated and a new one made.
165
-	*
163
+    *        If the array has been allocated previously, then
164
+    *        the array is deallocated and a new one made.
165
+    *
166 166
    *
167 167
    *-- History ------------------------------------------
168 168
    *
@@ -204,13 +204,13 @@ class Emitter
204 204
    ------------------------------------------------------*/
205 205
 
206 206
   void TextureId(unsigned int particle_start, unsigned int particle_end,
207
-					  int id);
207
+                      int id);
208 208
   /*------------------------------------------------------
209 209
    * Pre  : particle_start and particle_end are a valid
210
-	*        range of particles in the array
211
-	*
212
-	*        id is a valid texture id
213
-	*
210
+    *        range of particles in the array
211
+    *
212
+    *        id is a valid texture id
213
+    *
214 214
    * Post :
215 215
    *
216 216
    *-- History ------------------------------------------
@@ -220,13 +220,13 @@ class Emitter
220 220
    ------------------------------------------------------*/
221 221
 
222 222
   void Color(unsigned int particle_start, unsigned int particle_end,
223
-				 float r, float g, float b);
223
+                 float r, float g, float b);
224 224
   /*------------------------------------------------------
225 225
    * Pre  : particle_start and particle_end are a valid
226
-	*        range of particles in the array
227
-	*
228
-	*        r,g,b are colors 0.0 to 1.0
229
-	*
226
+    *        range of particles in the array
227
+    *
228
+    *        r,g,b are colors 0.0 to 1.0
229
+    *
230 230
    * Post :
231 231
    *
232 232
    *-- History ------------------------------------------
@@ -236,13 +236,13 @@ class Emitter
236 236
    ------------------------------------------------------*/
237 237
 
238 238
   void Speed(unsigned int particle_start, unsigned int particle_end,
239
-				 float x, float y, float z);
239
+                 float x, float y, float z);
240 240
   /*------------------------------------------------------
241 241
    * Pre  : particle_start and particle_end are a valid
242
-	*        range of particles in the array
243
-	*
244
-	*        take note speed inits at 2000, lower is faster
245
-	*
242
+    *        range of particles in the array
243
+    *
244
+    *        take note speed inits at 2000, lower is faster
245
+    *
246 246
    * Post :
247 247
    *
248 248
    *-- History ------------------------------------------
@@ -252,13 +252,13 @@ class Emitter
252 252
    ------------------------------------------------------*/
253 253
 
254 254
   void Force(unsigned int particle_start, unsigned int particle_end,
255
-				 float x, float y, float z);
255
+                 float x, float y, float z);
256 256
   /*------------------------------------------------------
257 257
    * Pre  : particle_start and particle_end are a valid
258
-	*        range of particles in the array
259
-	*
260
-	*        Force/Gravity acting on particles
261
-	*
258
+    *        range of particles in the array
259
+    *
260
+    *        Force/Gravity acting on particles
261
+    *
262 262
    * Post :
263 263
    *
264 264
    *-- History ------------------------------------------
@@ -268,7 +268,7 @@ class Emitter
268 268
    ------------------------------------------------------*/
269 269
 
270 270
 
271
-	static vec_t mFrustum[6][4]; /* View Volume copy */
271
+    static vec_t mFrustum[6][4]; /* View Volume copy */
272 272
 
273 273
 
274 274
  private:
@@ -276,17 +276,17 @@ class Emitter
276 276
     static int compareParticleDist(const void *voidA, const void *voidB);
277 277
 
278 278
 
279
-	char *_name;              /* Emitter name */
279
+    char *_name;              /* Emitter name */
280 280
 
281
-	unsigned int _flags;      /* Emitter flags */
281
+    unsigned int _flags;      /* Emitter flags */
282 282
 
283
-	vec3_t _pos;              /* Position in 3 space */
283
+    vec3_t _pos;              /* Position in 3 space */
284 284
 
285
-	vec3_t _mangle;           /* Oreintation in 3 space */
285
+    vec3_t _mangle;           /* Oreintation in 3 space */
286 286
 
287
-	Particle *_particle;      /* Array of particles */
287
+    Particle *_particle;      /* Array of particles */
288 288
 
289
-	unsigned int _count;      /* Particle count */
289
+    unsigned int _count;      /* Particle count */
290 290
 };
291 291
 
292 292
 #endif

+ 46
- 46
include/List.h Переглянути файл

@@ -149,8 +149,8 @@ template <class T> class List
149 149
       // Found
150 150
       if (current->Id() == id)
151 151
       {
152
-	_cache = current;
153
-	return current->Data();
152
+    _cache = current;
153
+    return current->Data();
154 154
       }
155 155
 
156 156
       last = current;
@@ -178,8 +178,8 @@ template <class T> class List
178 178
       // Found
179 179
       if (current->Data() == data)
180 180
       {
181
-	_cache = current;
182
-	return current->Id();
181
+    _cache = current;
182
+    return current->Id();
183 183
       }
184 184
 
185 185
       last = current;
@@ -219,20 +219,20 @@ template <class T> class List
219 219
       // Remove
220 220
       if (current->Id() == id)
221 221
       {
222
-	if (current == _head)
223
-	  _head = current->Next();
224
-	else
225
-	{
226
-	  last->Next(current->Next());
227
-	}
222
+    if (current == _head)
223
+      _head = current->Next();
224
+    else
225
+    {
226
+      last->Next(current->Next());
227
+    }
228 228
 
229
-	if (_current == current)
230
-	  _current = NULL;
229
+    if (_current == current)
230
+      _current = NULL;
231 231
 
232
-	delete current;
233
-	_num_items--;
232
+    delete current;
233
+    _num_items--;
234 234
 
235
-	return;
235
+    return;
236 236
       }
237 237
 
238 238
       last = current;
@@ -253,20 +253,20 @@ template <class T> class List
253 253
       // Remove
254 254
       if (current->Data() == data)
255 255
       {
256
-	if (current == _head)
257
-	  _head = current->Next();
258
-	else
259
-	{
260
-	  last->Next(current->Next());
261
-	}
256
+    if (current == _head)
257
+      _head = current->Next();
258
+    else
259
+    {
260
+      last->Next(current->Next());
261
+    }
262 262
 
263
-	if (_current == current)
264
-	  _current = NULL;
263
+    if (_current == current)
264
+      _current = NULL;
265 265
 
266
-	delete current;
267
-	_num_items--;
266
+    delete current;
267
+    _num_items--;
268 268
 
269
-	return;
269
+    return;
270 270
       }
271 271
 
272 272
       last = current;
@@ -323,7 +323,7 @@ template <class T> class List
323 323
       current = current->Next();
324 324
 
325 325
       if (current)
326
-	printf(", ");
326
+    printf(", ");
327 327
 
328 328
       fflush(stdout);
329 329
     }
@@ -401,29 +401,29 @@ template <class T> class List
401 401
       //EXP
402 402
       if (_last)
403 403
       {
404
-	i = _last->Id();
405
-	current = _last;
404
+    i = _last->Id();
405
+    current = _last;
406 406
       }
407 407
 
408 408
       while (current)
409 409
       {
410
-	// Prepend
411
-	if (current->Id() > i)
412
-	{
413
-	  node->Id(i);
414
-	  node->Next(current);
415
-
416
-	  if (current == _head)
417
-	    _head = node;
418
-	  else if (last)
419
-	    last->Next(node);
420
-
421
-	  return node->Id();
422
-	}
423
-
424
-	i++;
425
-	last = current;
426
-	current = current->Next();
410
+    // Prepend
411
+    if (current->Id() > i)
412
+    {
413
+      node->Id(i);
414
+      node->Next(current);
415
+
416
+      if (current == _head)
417
+        _head = node;
418
+      else if (last)
419
+        last->Next(node);
420
+
421
+      return node->Id();
422
+    }
423
+
424
+    i++;
425
+    last = current;
426
+    current = current->Next();
427 427
       }
428 428
 
429 429
       // Append

+ 388
- 388
include/Map.h Переглянути файл

@@ -51,61 +51,61 @@ template <class K, class D> class MapNode
51 51
 {
52 52
 public:
53 53
 
54
-	MapNode(K key, D data)
55
-	{
56
-		_data  = data;
57
-		_key = key;
58
-		_next = NULL;
59
-	}
54
+    MapNode(K key, D data)
55
+    {
56
+        _data  = data;
57
+        _key = key;
58
+        _next = NULL;
59
+    }
60 60
 
61 61
 
62
-	~MapNode()
63
-	{
64
-	}
62
+    ~MapNode()
63
+    {
64
+    }
65 65
 
66 66
 
67
-	void Key(K key)
68
-	{
69
-		_key = key;
70
-	}
67
+    void Key(K key)
68
+    {
69
+        _key = key;
70
+    }
71 71
 
72 72
 
73
-	K Key()
74
-	{
75
-		return _key;
76
-	}
73
+    K Key()
74
+    {
75
+        return _key;
76
+    }
77 77
 
78 78
 
79
-	void Data(D data)
80
-	{
79
+    void Data(D data)
80
+    {
81 81
     _data = data;
82
-	}
82
+    }
83 83
 
84 84
 
85
-	D Data()
86
-	{
87
-		return _data;
88
-	}
85
+    D Data()
86
+    {
87
+        return _data;
88
+    }
89 89
 
90 90
 
91
-	MapNode<K, D> *Next()
92
-	{
93
-		return _next;
94
-	}
91
+    MapNode<K, D> *Next()
92
+    {
93
+        return _next;
94
+    }
95 95
 
96 96
 
97
-	void Next(MapNode<K, D> *next)
98
-	{
99
-		_next = next;
100
-	}
97
+    void Next(MapNode<K, D> *next)
98
+    {
99
+        _next = next;
100
+    }
101 101
 
102 102
 private:
103 103
 
104
-	MapNode<K, D> *_next;
104
+    MapNode<K, D> *_next;
105 105
 
106
-	K _key;
106
+    K _key;
107 107
 
108
-	D _data;
108
+    D _data;
109 109
 };
110 110
 
111 111
 
@@ -113,458 +113,458 @@ template <class K, class D> class Map
113 113
 {
114 114
 public:
115 115
 
116
-	Map()
117
-	{
118
-		UnSetError();
119
-		_num_items = 0;
120
-		_head = NULL;
121
-		_current = NULL;
122
-		_cache = NULL;
123
-	}
116
+    Map()
117
+    {
118
+        UnSetError();
119
+        _num_items = 0;
120
+        _head = NULL;
121
+        _current = NULL;
122
+        _cache = NULL;
123
+    }
124 124
 
125 125
 
126
-	~Map()
127
-	{
128
-		Clear();
129
-	}
126
+    ~Map()
127
+    {
128
+        Clear();
129
+    }
130 130
 
131 131
 
132
-	void Clear()
133
-	{
134
-		UnSetError();
135
-		_num_items = 0;
136
-		_cache = NULL;
132
+    void Clear()
133
+    {
134
+        UnSetError();
135
+        _num_items = 0;
136
+        _cache = NULL;
137 137
 
138
-		while (_head)
139
-		{
140
-			_current = _head;
141
-			_head = _head->Next();
142
-			delete _current;
143
-		}
138
+        while (_head)
139
+        {
140
+            _current = _head;
141
+            _head = _head->Next();
142
+            delete _current;
143
+        }
144 144
 
145
-		_tree.Clear();
146
-	}
145
+        _tree.Clear();
146
+    }
147 147
 
148 148
 
149
-	void SetError()
150
-	{
151
-		_error = true;
152
-	}
149
+    void SetError()
150
+    {
151
+        _error = true;
152
+    }
153 153
 
154 154
 
155
-	void UnSetError()
156
-	{
157
-		_error = false;
158
-	}
155
+    void UnSetError()
156
+    {
157
+        _error = false;
158
+    }
159 159
 
160 160
 
161
-	bool GetError()
162
-	{
163
-		return _error;
164
-	}
161
+    bool GetError()
162
+    {
163
+        return _error;
164
+    }
165 165
 
166 166
 
167
-	D FindDataByKey(K key)
168
-	{
169
-		MapNode<K, D> *current = NULL;
170
-		MapNode<K, D> *next = NULL;
167
+    D FindDataByKey(K key)
168
+    {
169
+        MapNode<K, D> *current = NULL;
170
+        MapNode<K, D> *next = NULL;
171 171
 
172 172
 
173
-		if (_head)
174
-		{
175
-			UnSetError();
173
+        if (_head)
174
+        {
175
+            UnSetError();
176 176
 
177
-			if (_cache)
178
-			{
179
-				next = _cache->Next();
180
-			}
177
+            if (_cache)
178
+            {
179
+                next = _cache->Next();
180
+            }
181 181
 
182
-			// Mongoose 2002.02.19, Optimize for sequential searches
183
-			if (next && key == next->Key())
184
-			{
185
-				current = next;
186
-			}
187
-			else // Mongoose 2002.02.19, Use search algorithm otherwise
188
-			{
189
-				current = _tree.SearchByKey(key, &_error);
190
-
191
-				if (_error)
192
-					return false;
193
-			}
182
+            // Mongoose 2002.02.19, Optimize for sequential searches
183
+            if (next && key == next->Key())
184
+            {
185
+                current = next;
186
+            }
187
+            else // Mongoose 2002.02.19, Use search algorithm otherwise
188
+            {
189
+                current = _tree.SearchByKey(key, &_error);
190
+
191
+                if (_error)
192
+                    return false;
193
+            }
194 194
 
195
-			if (current)
196
-			{
197
-				_cache = _current = current;
198
-				return current->Data();
199
-			}
200
-		}
195
+            if (current)
196
+            {
197
+                _cache = _current = current;
198
+                return current->Data();
199
+            }
200
+        }
201 201
 
202
-		SetError();
203
-		return 0;
204
-	}
202
+        SetError();
203
+        return 0;
204
+    }
205 205
 
206 206
 
207
-	D operator [] (K key)
208
-	{
209
-		return FindDataByKey(key);
210
-	}
207
+    D operator [] (K key)
208
+    {
209
+        return FindDataByKey(key);
210
+    }
211 211
 
212 212
 
213
-	K FindKeyByData(D data)
214
-	{
215
-		MapNode<K, D> *current = _head;
216
-		MapNode<K, D> *last = NULL;
213
+    K FindKeyByData(D data)
214
+    {
215
+        MapNode<K, D> *current = _head;
216
+        MapNode<K, D> *last = NULL;
217 217
 
218 218
 
219
-		UnSetError();
219
+        UnSetError();
220 220
 
221
-		while (current)
222
-		{
223
-			// Found
224
-			if (current->Data() == data)
225
-			{
226
-				_cache = current;
227
-				return current->Key();
228
-			}
221
+        while (current)
222
+        {
223
+            // Found
224
+            if (current->Data() == data)
225
+            {
226
+                _cache = current;
227
+                return current->Key();
228
+            }
229 229
 
230
-			last = current;
231
-			current = current->Next();
232
-		}
230
+            last = current;
231
+            current = current->Next();
232
+        }
233 233
 
234
-		SetError();
234
+        SetError();
235 235
 
236
-		return 0;
237
-	}
236
+        return 0;
237
+    }
238 238
 
239 239
 
240
-	D getCache()
241
-	{
242
-		if (_cache == 0x0)
243
-		{
244
-			printf("Map::getCache> Bad request - should segfault\n");
245
-		}
240
+    D getCache()
241
+    {
242
+        if (_cache == 0x0)
243
+        {
244
+            printf("Map::getCache> Bad request - should segfault\n");
245
+        }
246 246
 
247
-		return _cache->Data();
248
-	}
249
-
250
-
251
-	bool findKey(K key)
252
-	{
253
-		MapNode<K, D> *current = NULL;
254
-		MapNode<K, D> *next = NULL;
255
-
256
-		if (_head)
257
-		{
258
-			UnSetError();
247
+        return _cache->Data();
248
+    }
249
+
250
+
251
+    bool findKey(K key)
252
+    {
253
+        MapNode<K, D> *current = NULL;
254
+        MapNode<K, D> *next = NULL;
255
+
256
+        if (_head)
257
+        {
258
+            UnSetError();
259 259
 
260
-			if (_cache)
261
-			{
262
-				if (_cache->Key() == key)
263
-				{
264
-					return true;
265
-				}
260
+            if (_cache)
261
+            {
262
+                if (_cache->Key() == key)
263
+                {
264
+                    return true;
265
+                }
266 266
 
267
-				next = _cache->Next();
268
-			}
267
+                next = _cache->Next();
268
+            }
269 269
 
270
-			// Mongoose 2002.02.19, Optimize for sequential searches
271
-			if (next && key == next->Key())
272
-			{
273
-				current = next;
274
-			}
275
-			else // Mongoose 2002.02.19, Use search algorithm otherwise
276
-			{
277
-				current = _tree.SearchByKey(key, &_error);
278
-			}
279
-
280
-			if (current)
281
-			{
282
-				_cache = _current = current;
283
-				//curData = current->Data();
284
-				return true;
285
-			}
286
-		}
287
-
288
-		SetError();
289
-		return false;
290
-	}
291
-
292
-
293
-	bool Add(K key, D data)
294
-	{
295
-		MapNode<K, D> *node;
296
-
297
-
298
-		UnSetError();
299
-		node = new MapNode<K, D>(key, data);
300
-		_num_items++;
301
-		return Add(node);
302
-	}
270
+            // Mongoose 2002.02.19, Optimize for sequential searches
271
+            if (next && key == next->Key())
272
+            {
273
+                current = next;
274
+            }
275
+            else // Mongoose 2002.02.19, Use search algorithm otherwise
276
+            {
277
+                current = _tree.SearchByKey(key, &_error);
278
+            }
279
+
280
+            if (current)
281
+            {
282
+                _cache = _current = current;
283
+                //curData = current->Data();
284
+                return true;
285
+            }
286
+        }
287
+
288
+        SetError();
289
+        return false;
290
+    }
291
+
292
+
293
+    bool Add(K key, D data)
294
+    {
295
+        MapNode<K, D> *node;
296
+
297
+
298
+        UnSetError();
299
+        node = new MapNode<K, D>(key, data);
300
+        _num_items++;
301
+        return Add(node);
302
+    }
303 303
 
304 304
 
305
-	bool Add(MapNode<K, D> *node)
306
-	{
307
-		MapNode<K, D> *current = _head;
308
-		MapNode<K, D> *last = NULL;
305
+    bool Add(MapNode<K, D> *node)
306
+    {
307
+        MapNode<K, D> *current = _head;
308
+        MapNode<K, D> *last = NULL;
309 309
 
310 310
 
311
-		if (!node)
312
-			return false;
311
+        if (!node)
312
+            return false;
313 313
 
314
-		UnSetError();
314
+        UnSetError();
315 315
 
316
-		if (_head)
317
-		{
318
-			current = _head;
319
-			last = NULL;
320
-
321
-			while (current)
322
-			{
323
-				// Prepend
324
-				if (current->Key() > node->Key())
325
-				{
326
-					node->Next(current);
327
-
328
-					if (current == _head)
329
-					{
330
-						_head = node;
331
-					}
332
-					else if (last)
333
-					{
334
-						last->Next(node);
335
-					}
336
-
337
-					_tree.Insert(node->Key(), node);
338
-					return true;
339
-				}
340
-
341
-				last = current;
342
-				current = current->Next();
343
-			}
344
-
345
-			// Append
346
-			last->Next(node);
347
-		}
348
-		else
349
-		{
350
-			_head = node;
351
-		}
352
-
353
-		_tree.Insert(node->Key(), node);
354
-		return true;
355
-	}
356
-
357
-
358
-	void RemoveByKey(K key)
359
-	{
360
-		MapNode<K, D> *current = _head;
361
-		MapNode<K, D> *last = NULL;
362
-
363
-
364
-		UnSetError();
365
-
366
-		_cache = NULL;
316
+        if (_head)
317
+        {
318
+            current = _head;
319
+            last = NULL;
320
+
321
+            while (current)
322
+            {
323
+                // Prepend
324
+                if (current->Key() > node->Key())
325
+                {
326
+                    node->Next(current);
327
+
328
+                    if (current == _head)
329
+                    {
330
+                        _head = node;
331
+                    }
332
+                    else if (last)
333
+                    {
334
+                        last->Next(node);
335
+                    }
336
+
337
+                    _tree.Insert(node->Key(), node);
338
+                    return true;
339
+                }
340
+
341
+                last = current;
342
+                current = current->Next();
343
+            }
344
+
345
+            // Append
346
+            last->Next(node);
347
+        }
348
+        else
349
+        {
350
+            _head = node;
351
+        }
352
+
353
+        _tree.Insert(node->Key(), node);
354
+        return true;
355
+    }
356
+
357
+
358
+    void RemoveByKey(K key)
359
+    {
360
+        MapNode<K, D> *current = _head;
361
+        MapNode<K, D> *last = NULL;
362
+
363
+
364
+        UnSetError();
365
+
366
+        _cache = NULL;
367 367
 
368
-		while (current)
369
-		{
370
-			// Remove
371
-			if (current->Key() == key)
372
-			{
373
-				if (current == _head)
374
-				{
375
-					_head = current->Next();
376
-				}
377
-				else
378
-				{
379
-					last->Next(current->Next());
380
-				}
368
+        while (current)
369
+        {
370
+            // Remove
371
+            if (current->Key() == key)
372
+            {
373
+                if (current == _head)
374
+                {
375
+                    _head = current->Next();
376
+                }
377
+                else
378
+                {
379
+                    last->Next(current->Next());
380
+                }
381 381
 
382
-				if (_current == current)
383
-				{
384
-					_current = NULL;
385
-				}
382
+                if (_current == current)
383
+                {
384
+                    _current = NULL;
385
+                }
386 386
 
387
-				_tree.RemoveByKey(current->Key());
388
-				delete current;
389
-				_num_items--;
387
+                _tree.RemoveByKey(current->Key());
388
+                delete current;
389
+                _num_items--;
390 390
 
391
-				return;
392
-			}
391
+                return;
392
+            }
393 393
 
394
-			last = current;
395
-			current = current->Next();
396
-		}
394
+            last = current;
395
+            current = current->Next();
396
+        }
397 397
 
398
-		SetError();
399
-	}
398
+        SetError();
399
+    }
400 400
 
401 401
 
402
-	void RemoveByData(D data)
403
-	{
404
-		MapNode<K, D> *current = _head;
405
-		MapNode<K, D> *last = NULL;
402
+    void RemoveByData(D data)
403
+    {
404
+        MapNode<K, D> *current = _head;
405
+        MapNode<K, D> *last = NULL;
406 406
 
407 407
 
408
-		UnSetError();
408
+        UnSetError();
409 409
 
410
-		_cache = NULL;
410
+        _cache = NULL;
411 411
 
412
-		while (current)
413
-		{
414
-			// Remove
415
-			if (current->Data() == data)
416
-			{
417
-				if (current == _head)
418
-				{
419
-					_head = current->Next();
420
-				}
421
-				else
422
-				{
423
-					last->Next(current->Next());
424
-				}
412
+        while (current)
413
+        {
414
+            // Remove
415
+            if (current->Data() == data)
416
+            {
417
+                if (current == _head)
418
+                {
419
+                    _head = current->Next();
420
+                }
421
+                else
422
+                {
423
+                    last->Next(current->Next());
424
+                }
425 425
 
426
-				if (_current == current)
427
-				{
428
-					_current = NULL;
429
-				}
426
+                if (_current == current)
427
+                {
428
+                    _current = NULL;
429
+                }
430 430
 
431
-				_tree.RemoveByKey(current->Key());
432
-				delete current;
433
-				_num_items--;
431
+                _tree.RemoveByKey(current->Key());
432
+                delete current;
433
+                _num_items--;
434 434
 
435
-				return;
436
-			}
435
+                return;
436
+            }
437 437
 
438
-			last = current;
439
-			current = current->Next();
440
-		}
438
+            last = current;
439
+            current = current->Next();
440
+        }
441 441
 
442
-		SetError();
443
-	}
442
+        SetError();
443
+    }
444 444
 
445 445
 
446
-	bool Empty()
447
-	{
448
-		return (_head == NULL);
449
-	}
446
+    bool Empty()
447
+    {
448
+        return (_head == NULL);
449
+    }
450 450
 
451 451
 
452
-	unsigned int count()
453
-	{
454
-		return _num_items;
455
-	}
452
+    unsigned int count()
453
+    {
454
+        return _num_items;
455
+    }
456 456
 
457
-	unsigned int NumItems()
458
-	{
459
-		return _num_items;
460
-	}
457
+    unsigned int NumItems()
458
+    {
459
+        return _num_items;
460
+    }
461 461
 
462 462
 
463
-	void Print(void (*print_key_func)(K), void (*print_data_func)(D))
464
-	{
465
-		MapNode<K, D> *current = _head;
463
+    void Print(void (*print_key_func)(K), void (*print_data_func)(D))
464
+    {
465
+        MapNode<K, D> *current = _head;
466 466
 
467 467
 
468
-		UnSetError();
468
+        UnSetError();
469 469
 
470
-		if (!print_key_func || !print_data_func)
471
-		{
472
-			SetError();
473
-			return;
474
-		}
470
+        if (!print_key_func || !print_data_func)
471
+        {
472
+            SetError();
473
+            return;
474
+        }
475 475
 
476
-		printf(" [%i] {\n", _num_items);
476
+        printf(" [%i] {\n", _num_items);
477 477
 
478
-		while (current)
479
-		{
480
-			printf("(");
481
-			(*print_key_func)(current->Key());
482
-			printf(", ");
483
-			(*print_data_func)(current->Data());
484
-			printf("), ");
478
+        while (current)
479
+        {
480
+            printf("(");
481
+            (*print_key_func)(current->Key());
482
+            printf(", ");
483
+            (*print_data_func)(current->Data());
484
+            printf("), ");
485 485
 
486
-			current = current->Next();
487
-			fflush(stdout);
488
-		}
486
+            current = current->Next();
487
+            fflush(stdout);
488
+        }
489 489
 
490
-		printf(" }\n");
491
-	}
490
+        printf(" }\n");
491
+    }
492 492
 
493 493
 
494
-	void Reset()
495
-	{
496
-		_current = _head;
497
-		_cache = _head;
498
-	}
494
+    void Reset()
495
+    {
496
+        _current = _head;
497
+        _cache = _head;
498
+    }
499 499
 
500 500
 
501
-	bool operator ++ (int)
502
-	{
503
-		return Next();
504
-	}
501
+    bool operator ++ (int)
502
+    {
503
+        return Next();
504
+    }
505 505
 
506 506
     bool operator ++ ()
507
-	{
508
-		return Next();
509
-	}
507
+    {
508
+        return Next();
509
+    }
510 510
 
511 511
 
512
-	bool Next()
513
-	{
514
-		if (_current)
515
-		{
516
-			_current = _current->Next();
517
-		}
512
+    bool Next()
513
+    {
514
+        if (_current)
515
+        {
516
+            _current = _current->Next();
517
+        }
518 518
 
519
-		return (_current != NULL);
520
-	}
519
+        return (_current != NULL);
520
+    }
521 521
 
522 522
 
523
-	bool CurrentExists()
524
-	{
525
-		return (_current != 0);
526
-	}
523
+    bool CurrentExists()
524
+    {
525
+        return (_current != 0);
526
+    }
527 527
 
528 528
 
529
-	K CurrentKey()
530
-	{
531
-		UnSetError();
529
+    K CurrentKey()
530
+    {
531
+        UnSetError();
532 532
 
533
-		if (!_current)
534
-		{
535
-			SetError();
536
-			return 0;
537
-		}
533
+        if (!_current)
534
+        {
535
+            SetError();
536
+            return 0;
537
+        }
538 538
 
539
-		return _current->Key();
540
-	}
539
+        return _current->Key();
540
+    }
541 541
 
542 542
 
543
-	D Current()
544
-	{
545
-		UnSetError();
543
+    D Current()
544
+    {
545
+        UnSetError();
546 546
 
547
-		if (!_current)
548
-		{
549
-			SetError();
550
-			return 0;
551
-		}
547
+        if (!_current)
548
+        {
549
+            SetError();
550
+            return 0;
551
+        }
552 552
 
553
-		return _current->Data();
554
-	}
553
+        return _current->Data();
554
+    }
555 555
 
556 556
 private:
557 557
 
558
-	unsigned int _num_items;
558
+    unsigned int _num_items;
559 559
 
560
-	bool _error;
560
+    bool _error;
561 561
 
562
-	Tree<K, MapNode<K, D> *> _tree;
562
+    Tree<K, MapNode<K, D> *> _tree;
563 563
 
564
-	MapNode<K, D> *_head;
564
+    MapNode<K, D> *_head;
565 565
 
566
-	MapNode<K, D> *_current;
566
+    MapNode<K, D> *_current;
567 567
 
568
-	MapNode<K, D> *_cache;
568
+    MapNode<K, D> *_cache;
569 569
 };
570 570
 #endif

+ 1
- 1
include/MatMath.h Переглянути файл

@@ -53,7 +53,7 @@ int helIntersectionLineAndPolygon(vec3_t intersect, vec3_t p1, vec3_t p2, vec3_t
53 53
  * \param plane Plane
54 54
  * \returns distance
55 55
  */
56
-vec_t helDistToSphereFromPlane3v(vec3_t center,	vec_t radius, vec4_t plane);
56
+vec_t helDistToSphereFromPlane3v(vec3_t center, vec_t radius, vec4_t plane);
57 57
 
58 58
 /*!
59 59
  * \brief Calculate the distance from a box to a plane

+ 335
- 335
include/Matrix.h Переглянути файл

@@ -32,350 +32,350 @@
32 32
 #include <Quaternion.h>
33 33
 #include <Vector3d.h>
34 34
 
35
-	///////////////////////////////////////////////
36
-	// Multidim map for row order encoding       //
37
-	///////////////////////////////////////////////
38
-	// 0,0 - 0;   0,1 - 1;   0,2 - 2;   0,3 - 3  //
39
-	// 1,0 - 4;   1,1 - 5;   1,2 - 6;   1,3 - 7  //
40
-	// 2,0 - 8;   2,1 - 9;   2,2 - 10;  2,3 - 11 //
41
-	// 3,0 - 12;  3,1 - 13;  3,2 - 14;  3,3 - 15 //
42
-	///////////////////////////////////////////////
43
-
44
-	///////////////////////////////////////////////
45
-	// Multidim map for column order encoding    //
46
-	///////////////////////////////////////////////
47
-	// 0,0 - 0;   0,1 - 4;   0,2 - 8;   0,3 - 12 //
48
-	// 1,0 - 1;   1,1 - 5;   1,2 - 9;   1,3 - 13 //
49
-	// 2,0 - 2;   2,1 - 6;   2,2 - 10;  2,3 - 14 //
50
-	// 3,0 - 3;   3,1 - 7;   3,2 - 11;  3,3 - 15 //
51
-	///////////////////////////////////////////////
35
+    ///////////////////////////////////////////////
36
+    // Multidim map for row order encoding       //
37
+    ///////////////////////////////////////////////
38
+    // 0,0 - 0;   0,1 - 1;   0,2 - 2;   0,3 - 3  //
39
+    // 1,0 - 4;   1,1 - 5;   1,2 - 6;   1,3 - 7  //
40
+    // 2,0 - 8;   2,1 - 9;   2,2 - 10;  2,3 - 11 //
41
+    // 3,0 - 12;  3,1 - 13;  3,2 - 14;  3,3 - 15 //
42
+    ///////////////////////////////////////////////
43
+
44
+    ///////////////////////////////////////////////
45
+    // Multidim map for column order encoding    //
46
+    ///////////////////////////////////////////////
47
+    // 0,0 - 0;   0,1 - 4;   0,2 - 8;   0,3 - 12 //
48
+    // 1,0 - 1;   1,1 - 5;   1,2 - 9;   1,3 - 13 //
49
+    // 2,0 - 2;   2,1 - 6;   2,2 - 10;  2,3 - 14 //
50
+    // 3,0 - 3;   3,1 - 7;   3,2 - 11;  3,3 - 15 //
51
+    ///////////////////////////////////////////////
52 52
 
53 53
 
54 54
 class Matrix
55 55
 {
56 56
  public:
57 57
 
58
-	////////////////////////////////////////////////////////////
59
-	// Constructors
60
-	////////////////////////////////////////////////////////////
61
-
62
-	Matrix();
63
-	/*------------------------------------------------------
64
-	 * Pre  :
65
-	 * Post : Constructs an object of Matrix
66
-	 *
67
-	 *-- History ------------------------------------------
68
-	 *
69
-	 * 2002.05.11:
70
-	 * Mongoose - Created
71
-	 ------------------------------------------------------*/
72
-
73
-	Matrix(matrix_t mat);
74
-	/*------------------------------------------------------
75
-	 * Pre  :
76
-	 * Post : Constructs an object of Matrix
77
-	 *
78
-	 *-- History ------------------------------------------
79
-	 *
80
-	 * 2002.05.11:
81
-	 * Mongoose - Created
82
-	 ------------------------------------------------------*/
83
-
84
-	Matrix(Quaternion &q);
85
-	/*------------------------------------------------------
86
-	 * Pre  :
87
-	 * Post : Converts and asigns Q to a Matrix
88
-	 *        returns quaternion as Matrix
89
-	 *
90
-	 *-- History ------------------------------------------
91
-	 *
92
-	 * 2002.05.08:
93
-	 * Mongoose - Created
94
-	 ------------------------------------------------------*/
95
-
96
-	~Matrix();
97
-	/*------------------------------------------------------
98
-	 * Pre  : Matrix object is allocated
99
-	 * Post : Deconstructs an object of Matrix
100
-	 *
101
-	 *-- History ------------------------------------------
102
-	 *
103
-	 * 2002.05.11:
104
-	 * Mongoose - Created
105
-	 ------------------------------------------------------*/
106
-
107
-	////////////////////////////////////////////////////////////
108
-	// Public Accessors
109
-	////////////////////////////////////////////////////////////
110
-
111
-	void getMatrix(matrix_t mat);
112
-	/*------------------------------------------------------
113
-	 * Pre  :
114
-	 * Post : Returns this matrix copy
115
-	 *
116
-	 *-- History ------------------------------------------
117
-	 *
118
-	 * 2002.05.08:
119
-	 * Mongoose - Created
120
-	 ------------------------------------------------------*/
121
-
122
-	void getTransposeMatrix(matrix_t mat);
123
-	/*------------------------------------------------------
124
-	 * Pre  :
125
-	 * Post : Returns this matrix transposed
126
-	 *
127
-	 *-- History ------------------------------------------
128
-	 *
129
-	 * 2002.05.08:
130
-	 * Mongoose - Created
131
-	 ------------------------------------------------------*/
132
-
133
-	bool getInvert(matrix_t mat);
134
-	/*------------------------------------------------------
135
-	 * Pre  :
136
-	 * Post : Returns this matrix inverted
137
-	 *
138
-	 *-- History ------------------------------------------
139
-	 *
140
-	 * 2002.05.08:
141
-	 * Mongoose - Created
142
-	 ------------------------------------------------------*/
143
-
144
-	Matrix multiply(const Matrix &a, const Matrix &b);
145
-	/*------------------------------------------------------
146
-	 * Pre  : Multiplies 2 matrices
147
-	 * Post : Returns resultant matrix
148
-	 *
149
-	 *-- History ------------------------------------------
150
-	 *
151
-	 * 2002.05.08:
152
-	 * Mongoose - Created
153
-	 ------------------------------------------------------*/
154
-
155
-	void multiply4d(double *v, double *result);
156
-	/*------------------------------------------------------
157
-	 * Pre  : Multiplies <V> vector (double[4]) and <This> matrix
158
-	 *
159
-	 * Post : Returns <Result> vector,
160
-	 *        <V> and <Result> maybe be the same vector
161
-	 *
162
-	 *-- History ------------------------------------------
163
-	 *
164
-	 * 2002.05.08:
165
-	 * Mongoose - Created
166
-	 ------------------------------------------------------*/
167
-
168
-	void multiply4v(vec4_t v, vec4_t result);
169
-	/*------------------------------------------------------
170
-	 * Pre  : Multiplies <V> vector and <This> matrix
171
-	 *
172
-	 * Post : Returns <Result> vector,
173
-	 *        <V> and <Result> maybe be the same vector
174
-	 *
175
-	 *-- History ------------------------------------------
176
-	 *
177
-	 * 2002.05.08:
178
-	 * Mongoose - Created
179
-	 ------------------------------------------------------*/
180
-
181
-	void multiply3v(vec3_t v, vec3_t result);
182
-	/*------------------------------------------------------
183
-	 * Pre  : Multiplies <V> vector and <This> matrix
184
-	 *
185
-	 * Post : Returns <Result> vector,
186
-	 *        <V> and <Result> maybe be the same vector
187
-	 *
188
-	 *-- History ------------------------------------------
189
-	 *
190
-	 * 2002.05.08:
191
-	 * Mongoose - Created
192
-	 ------------------------------------------------------*/
193
-
194
-	void print();
195
-	/*------------------------------------------------------
196
-	 * Pre  :
197
-	 * Post : Prints matrix values to stdout
198
-	 *
199
-	 *-- History ------------------------------------------
200
-	 *
201
-	 * 2002.05.08:
202
-	 * Mongoose - Created
203
-	 ------------------------------------------------------*/
204
-
205
-	bool isIdentity();
206
-	/*------------------------------------------------------
207
-	 * Pre  :
208
-	 * Post : Is this matrix the identity matrix?
209
-	 *
210
-	 *-- History ------------------------------------------
211
-	 *
212
-	 * 2002.05.08:
213
-	 * Mongoose - Created
214
-	 ------------------------------------------------------*/
215
-
216
-	Matrix operator *(const Matrix &a);
217
-	/*------------------------------------------------------
218
-	 * Pre  : Multiplies A and this matrices
219
-	 * Post : Returns resultant matrix
220
-	 *
221
-	 *-- History ------------------------------------------
222
-	 *
223
-	 * 2002.05.08:
224
-	 * Mongoose - Created
225
-	 ------------------------------------------------------*/
226
-
227
-	Vector3d operator *(Vector3d v);
228
-	/*------------------------------------------------------
229
-	 * Pre  : <V> is vector to multiply by this matrix
230
-	 * Post : Returns resultant vector ( mult )
231
-	 *
232
-	 *-- History ------------------------------------------
233
-	 *
234
-	 * 2002.05.08:
235
-	 * Mongoose - Created
236
-	 ------------------------------------------------------*/
237
-
238
-
239
-	////////////////////////////////////////////////////////////
240
-	// Public Mutators
241
-	////////////////////////////////////////////////////////////
242
-
243
-	void setIdentity();
244
-	/*------------------------------------------------------
245
-	 * Pre  :
246
-	 * Post : Sets to identity matrix
247
-	 *
248
-	 *-- History ------------------------------------------
249
-	 *
250
-	 * 2002.05.08:
251
-	 * Mongoose - Created
252
-	 ------------------------------------------------------*/
253
-
254
-	void setMatrix(matrix_t mat);
255
-	/*------------------------------------------------------
256
-	 * Pre  :
257
-	 * Post : Set the matrix ( dangerous, scary boo )
258
-	 *
259
-	 *-- History ------------------------------------------
260
-	 *
261
-	 * 2002.05.08:
262
-	 * Mongoose - Created
263
-	 ------------------------------------------------------*/
264
-
265
-	void rotate(vec_t x, vec_t y, vec_t z);
266
-	/*------------------------------------------------------
267
-	 * Pre  : Radian input
268
-	 * Post : Rotates object in 3 space
269
-	 *
270
-	 *-- History ------------------------------------------
271
-	 *
272
-	 * 2002.05.08:
273
-	 * Mongoose - Created
274
-	 ------------------------------------------------------*/
275
-
276
-	void rotate(const vec_t *xyz);
277
-	/*------------------------------------------------------
278
-	 * Pre  : Rotates object in 3 space, Radian input
279
-	 * Post : Returns true on sucess
280
-	 *
281
-	 *-- History ------------------------------------------
282
-	 *
283
-	 * 2002.05.08:
284
-	 * Mongoose - Created
285
-	 ------------------------------------------------------*/
286
-
287
-	void scale(vec_t x, vec_t y, vec_t z);
288
-	/*------------------------------------------------------
289
-	 * Pre  :
290
-	 * Post : Scales object in 3 space
291
-	 *
292
-	 *-- History ------------------------------------------
293
-	 *
294
-	 * 2002.05.08:
295
-	 * Mongoose - Created
296
-	 ------------------------------------------------------*/
297
-
298
-	void scale(const vec_t *xyz);
299
-	/*------------------------------------------------------
300
-	 * Pre  :
301
-	 * Post : Scales object in 3 space
302
-	 *
303
-	 *-- History ------------------------------------------
304
-	 *
305
-	 * 2002.05.08:
306
-	 * Mongoose - Created
307
-	 ------------------------------------------------------*/
308
-
309
-	void translate(vec_t x, vec_t y, vec_t z);
310
-	/*------------------------------------------------------
311
-	 * Pre  :
312
-	 * Post : Translates ( moves ) object in 3 space
313
-	 *
314
-	 *-- History ------------------------------------------
315
-	 *
316
-	 * 2002.05.08:
317
-	 * Mongoose - Created
318
-	 ------------------------------------------------------*/
319
-
320
-	void translate(const vec_t *xyz);
321
-	/*------------------------------------------------------
322
-	 * Pre  :
323
-	 * Post : Translates ( moves ) object in 3 space
324
-	 *
325
-	 *-- History ------------------------------------------
326
-	 *
327
-	 * 2002.05.08:
328
-	 * Mongoose - Created
329
-	 ------------------------------------------------------*/
330
-
331
-	void transpose();
332
-	/*------------------------------------------------------
333
-	 * Pre  :
334
-	 * Post : Transpose this matrix
335
-	 *
336
-	 *-- History ------------------------------------------
337
-	 *
338
-	 * 2002.05.08:
339
-	 * Mongoose - Created
340
-	 ------------------------------------------------------*/
341
-
342
-	matrix_t mMatrix;      /* Data model, moved public for faster
343
-									  external renderer feedback use */
58
+    ////////////////////////////////////////////////////////////
59
+    // Constructors
60
+    ////////////////////////////////////////////////////////////
61
+
62
+    Matrix();
63
+    /*------------------------------------------------------
64
+     * Pre  :
65
+     * Post : Constructs an object of Matrix
66
+     *
67
+     *-- History ------------------------------------------
68
+     *
69
+     * 2002.05.11:
70
+     * Mongoose - Created
71
+     ------------------------------------------------------*/
72
+
73
+    Matrix(matrix_t mat);
74
+    /*------------------------------------------------------
75
+     * Pre  :
76
+     * Post : Constructs an object of Matrix
77
+     *
78
+     *-- History ------------------------------------------
79
+     *
80
+     * 2002.05.11:
81
+     * Mongoose - Created
82
+     ------------------------------------------------------*/
83
+
84
+    Matrix(Quaternion &q);
85
+    /*------------------------------------------------------
86
+     * Pre  :
87
+     * Post : Converts and asigns Q to a Matrix
88
+     *        returns quaternion as Matrix
89
+     *
90
+     *-- History ------------------------------------------
91
+     *
92
+     * 2002.05.08:
93
+     * Mongoose - Created
94
+     ------------------------------------------------------*/
95
+
96
+    ~Matrix();
97
+    /*------------------------------------------------------
98
+     * Pre  : Matrix object is allocated
99
+     * Post : Deconstructs an object of Matrix
100
+     *
101
+     *-- History ------------------------------------------
102
+     *
103
+     * 2002.05.11:
104
+     * Mongoose - Created
105
+     ------------------------------------------------------*/
106
+
107
+    ////////////////////////////////////////////////////////////
108
+    // Public Accessors
109
+    ////////////////////////////////////////////////////////////
110
+
111
+    void getMatrix(matrix_t mat);
112
+    /*------------------------------------------------------
113
+     * Pre  :
114
+     * Post : Returns this matrix copy
115
+     *
116
+     *-- History ------------------------------------------
117
+     *
118
+     * 2002.05.08:
119
+     * Mongoose - Created
120
+     ------------------------------------------------------*/
121
+
122
+    void getTransposeMatrix(matrix_t mat);
123
+    /*------------------------------------------------------
124
+     * Pre  :
125
+     * Post : Returns this matrix transposed
126
+     *
127
+     *-- History ------------------------------------------
128
+     *
129
+     * 2002.05.08:
130
+     * Mongoose - Created
131
+     ------------------------------------------------------*/
132
+
133
+    bool getInvert(matrix_t mat);
134
+    /*------------------------------------------------------
135
+     * Pre  :
136
+     * Post : Returns this matrix inverted
137
+     *
138
+     *-- History ------------------------------------------
139
+     *
140
+     * 2002.05.08:
141
+     * Mongoose - Created
142
+     ------------------------------------------------------*/
143
+
144
+    Matrix multiply(const Matrix &a, const Matrix &b);
145
+    /*------------------------------------------------------
146
+     * Pre  : Multiplies 2 matrices
147
+     * Post : Returns resultant matrix
148
+     *
149
+     *-- History ------------------------------------------
150
+     *
151
+     * 2002.05.08:
152
+     * Mongoose - Created
153
+     ------------------------------------------------------*/
154
+
155
+    void multiply4d(double *v, double *result);
156
+    /*------------------------------------------------------
157
+     * Pre  : Multiplies <V> vector (double[4]) and <This> matrix
158
+     *
159
+     * Post : Returns <Result> vector,
160
+     *        <V> and <Result> maybe be the same vector
161
+     *
162
+     *-- History ------------------------------------------
163
+     *
164
+     * 2002.05.08:
165
+     * Mongoose - Created
166
+     ------------------------------------------------------*/
167
+
168
+    void multiply4v(vec4_t v, vec4_t result);
169
+    /*------------------------------------------------------
170
+     * Pre  : Multiplies <V> vector and <This> matrix
171
+     *
172
+     * Post : Returns <Result> vector,
173
+     *        <V> and <Result> maybe be the same vector
174
+     *
175
+     *-- History ------------------------------------------
176
+     *
177
+     * 2002.05.08:
178
+     * Mongoose - Created
179
+     ------------------------------------------------------*/
180
+
181
+    void multiply3v(vec3_t v, vec3_t result);
182
+    /*------------------------------------------------------
183
+     * Pre  : Multiplies <V> vector and <This> matrix
184
+     *
185
+     * Post : Returns <Result> vector,
186
+     *        <V> and <Result> maybe be the same vector
187
+     *
188
+     *-- History ------------------------------------------
189
+     *
190
+     * 2002.05.08:
191
+     * Mongoose - Created
192
+     ------------------------------------------------------*/
193
+
194
+    void print();
195
+    /*------------------------------------------------------
196
+     * Pre  :
197
+     * Post : Prints matrix values to stdout
198
+     *
199
+     *-- History ------------------------------------------
200
+     *
201
+     * 2002.05.08:
202
+     * Mongoose - Created
203
+     ------------------------------------------------------*/
204
+
205
+    bool isIdentity();
206
+    /*------------------------------------------------------
207
+     * Pre  :
208
+     * Post : Is this matrix the identity matrix?
209
+     *
210
+     *-- History ------------------------------------------
211
+     *
212
+     * 2002.05.08:
213
+     * Mongoose - Created
214
+     ------------------------------------------------------*/
215
+
216
+    Matrix operator *(const Matrix &a);
217
+    /*------------------------------------------------------
218
+     * Pre  : Multiplies A and this matrices
219
+     * Post : Returns resultant matrix
220
+     *
221
+     *-- History ------------------------------------------
222
+     *
223
+     * 2002.05.08:
224
+     * Mongoose - Created
225
+     ------------------------------------------------------*/
226
+
227
+    Vector3d operator *(Vector3d v);
228
+    /*------------------------------------------------------
229
+     * Pre  : <V> is vector to multiply by this matrix
230
+     * Post : Returns resultant vector ( mult )
231
+     *
232
+     *-- History ------------------------------------------
233
+     *
234
+     * 2002.05.08:
235
+     * Mongoose - Created
236
+     ------------------------------------------------------*/
237
+
238
+
239
+    ////////////////////////////////////////////////////////////
240
+    // Public Mutators
241
+    ////////////////////////////////////////////////////////////
242
+
243
+    void setIdentity();
244
+    /*------------------------------------------------------
245
+     * Pre  :
246
+     * Post : Sets to identity matrix
247
+     *
248
+     *-- History ------------------------------------------
249
+     *
250
+     * 2002.05.08:
251
+     * Mongoose - Created
252
+     ------------------------------------------------------*/
253
+
254
+    void setMatrix(matrix_t mat);
255
+    /*------------------------------------------------------
256
+     * Pre  :
257
+     * Post : Set the matrix ( dangerous, scary boo )
258
+     *
259
+     *-- History ------------------------------------------
260
+     *
261
+     * 2002.05.08:
262
+     * Mongoose - Created
263
+     ------------------------------------------------------*/
264
+
265
+    void rotate(vec_t x, vec_t y, vec_t z);
266
+    /*------------------------------------------------------
267
+     * Pre  : Radian input
268
+     * Post : Rotates object in 3 space
269
+     *
270
+     *-- History ------------------------------------------
271
+     *
272
+     * 2002.05.08:
273
+     * Mongoose - Created
274
+     ------------------------------------------------------*/
275
+
276
+    void rotate(const vec_t *xyz);
277
+    /*------------------------------------------------------
278
+     * Pre  : Rotates object in 3 space, Radian input
279
+     * Post : Returns true on sucess
280
+     *
281
+     *-- History ------------------------------------------
282
+     *
283
+     * 2002.05.08:
284
+     * Mongoose - Created
285
+     ------------------------------------------------------*/
286
+
287
+    void scale(vec_t x, vec_t y, vec_t z);
288
+    /*------------------------------------------------------
289
+     * Pre  :
290
+     * Post : Scales object in 3 space
291
+     *
292
+     *-- History ------------------------------------------
293
+     *
294
+     * 2002.05.08:
295
+     * Mongoose - Created
296
+     ------------------------------------------------------*/
297
+
298
+    void scale(const vec_t *xyz);
299
+    /*------------------------------------------------------
300
+     * Pre  :
301
+     * Post : Scales object in 3 space
302
+     *
303
+     *-- History ------------------------------------------
304
+     *
305
+     * 2002.05.08:
306
+     * Mongoose - Created
307
+     ------------------------------------------------------*/
308
+
309
+    void translate(vec_t x, vec_t y, vec_t z);
310
+    /*------------------------------------------------------
311
+     * Pre  :
312
+     * Post : Translates ( moves ) object in 3 space
313
+     *
314
+     *-- History ------------------------------------------
315
+     *
316
+     * 2002.05.08:
317
+     * Mongoose - Created
318
+     ------------------------------------------------------*/
319
+
320
+    void translate(const vec_t *xyz);
321
+    /*------------------------------------------------------
322
+     * Pre  :
323
+     * Post : Translates ( moves ) object in 3 space
324
+     *
325
+     *-- History ------------------------------------------
326
+     *
327
+     * 2002.05.08:
328
+     * Mongoose - Created
329
+     ------------------------------------------------------*/
330
+
331
+    void transpose();
332
+    /*------------------------------------------------------
333
+     * Pre  :
334
+     * Post : Transpose this matrix
335
+     *
336
+     *-- History ------------------------------------------
337
+     *
338
+     * 2002.05.08:
339
+     * Mongoose - Created
340
+     ------------------------------------------------------*/
341
+
342
+    matrix_t mMatrix;      /* Data model, moved public for faster
343
+                                      external renderer feedback use */
344 344
 
345 345
  private:
346 346
 
347
-	////////////////////////////////////////////////////////////
348
-	// Private Accessors
349
-	////////////////////////////////////////////////////////////
350
-
351
-
352
-	////////////////////////////////////////////////////////////
353
-	// Private Mutators
354
-	////////////////////////////////////////////////////////////
355
-
356
-	void copy(matrix_t source, matrix_t dest);
357
-	/*------------------------------------------------------
358
-	 * Pre  :
359
-	 * Post : Copys value of source to dest
360
-	 *
361
-	 *-- History ------------------------------------------
362
-	 *
363
-	 * 2002.05.08:
364
-	 * Mongoose - Created
365
-	 ------------------------------------------------------*/
366
-
367
-	void multiply(const matrix_t a, const matrix_t b, matrix_t result);
368
-	/*------------------------------------------------------
369
-	 * Pre  : Multiplies matrices a and b
370
-	 *        Neither a or b is also the result
371
-	 *
372
-	 * Post : Sets resultant matrix value ( result )
373
-	 *
374
-	 *-- History ------------------------------------------
375
-	 *
376
-	 * 2002.05.08:
377
-	 * Mongoose - Created
378
-	 ------------------------------------------------------*/
347
+    ////////////////////////////////////////////////////////////
348
+    // Private Accessors
349
+    ////////////////////////////////////////////////////////////
350
+
351
+
352
+    ////////////////////////////////////////////////////////////
353
+    // Private Mutators
354
+    ////////////////////////////////////////////////////////////
355
+
356
+    void copy(matrix_t source, matrix_t dest);
357
+    /*------------------------------------------------------
358
+     * Pre  :
359
+     * Post : Copys value of source to dest
360
+     *
361
+     *-- History ------------------------------------------
362
+     *
363
+     * 2002.05.08:
364
+     * Mongoose - Created
365
+     ------------------------------------------------------*/
366
+
367
+    void multiply(const matrix_t a, const matrix_t b, matrix_t result);
368
+    /*------------------------------------------------------
369
+     * Pre  : Multiplies matrices a and b
370
+     *        Neither a or b is also the result
371
+     *
372
+     * Post : Sets resultant matrix value ( result )
373
+     *
374
+     *-- History ------------------------------------------
375
+     *
376
+     * 2002.05.08:
377
+     * Mongoose - Created
378
+     ------------------------------------------------------*/
379 379
 };
380 380
 
381 381
 #endif

+ 237
- 237
include/Network.h Переглянути файл

@@ -31,18 +31,18 @@
31 31
  ---------------------------------------------*/
32 32
 typedef struct network_packet_s
33 33
 {
34
-	char send;
35
-	unsigned int port;
36
-	unsigned int cid;
37
-	char  data[32];
38
-	float pos[3];
39
-	float pitch;
40
-	float yaw;
41
-	int aframe;
42
-	int bframe;
43
-	int view_model;
44
-
45
-	char gurantee; // TCP like
34
+    char send;
35
+    unsigned int port;
36
+    unsigned int cid;
37
+    char  data[32];
38
+    float pos[3];
39
+    float pitch;
40
+    float yaw;
41
+    int aframe;
42
+    int bframe;
43
+    int view_model;
44
+
45
+    char gurantee; // TCP like
46 46
 
47 47
 } network_packet_t;
48 48
 
@@ -57,11 +57,11 @@ typedef struct network_packet_s
57 57
  ---------------------------------------------*/
58 58
 typedef struct network_frame_s
59 59
 {
60
-	unsigned int header;
61
-	unsigned int seq;
62
-	unsigned int uid;
60
+    unsigned int header;
61
+    unsigned int seq;
62
+    unsigned int uid;
63 63
 
64
-	network_packet_t data;
64
+    network_packet_t data;
65 65
 
66 66
 } network_frame_t;
67 67
 
@@ -80,250 +80,250 @@ class Network
80 80
 {
81 81
  public:
82 82
 
83
-	////////////////////////////////////////////////////////////
84
-	// Constructors ( Singleton )
85
-	////////////////////////////////////////////////////////////
86
-
87
-	static Network *Instance();
88
-	/*------------------------------------------------------
89
-	 * Pre  :
90
-	 * Post : Constructs the object of Network or
91
-	 *        returns pointer to it if previously allocated
92
-	 *
93
-	 *-- History ------------------------------------------
94
-	 *
95
-	 * 2001.08.24:
96
-	 * Mongoose - Created
97
-	 ------------------------------------------------------*/
98
-
99
-	~Network();
100
-	/*------------------------------------------------------
101
-	 * Pre  : Network object is allocated
102
-	 * Post : Deconstructs an object of Network
103
-	 *
104
-	 *-- History ------------------------------------------
105
-	 *
106
-	 * 2002.06.21:
107
-	 * Mongoose - Created
108
-	 ------------------------------------------------------*/
109
-
110
-	////////////////////////////////////////////////////////////
111
-	// Public Accessors
112
-	////////////////////////////////////////////////////////////
113
-
114
-	network_frame_t &getPiggyBack();
115
-	/*------------------------------------------------------
116
-	 * Pre  :
117
-	 * Post :
118
-	 *
119
-	 *-- History ------------------------------------------
120
-	 *
121
-	 * 2002.09.03:
122
-	 * Mongoose - Created
123
-	 ------------------------------------------------------*/
124
-
125
-	unsigned int getUID();
126
-	/*------------------------------------------------------
127
-	 * Pre  :
128
-	 * Post :
129
-	 *
130
-	 *-- History ------------------------------------------
131
-	 *
132
-	 * 2002.09.03:
133
-	 * Mongoose - Created
134
-	 ------------------------------------------------------*/
135
-
136
-	float getRandom(float from, float to);
137
-	/*------------------------------------------------------
138
-	 * Pre  :
139
-	 * Post :
140
-	 *
141
-	 *-- History ------------------------------------------
142
-	 *
143
-	 * 2002.09.03:
144
-	 * Mongoose - Created
145
-	 ------------------------------------------------------*/
146
-
147
-	int getPort();
148
-	/*------------------------------------------------------
149
-	 * Pre  :
150
-	 * Post :
151
-	 *
152
-	 *-- History ------------------------------------------
153
-	 *
154
-	 * 2002.09.03:
155
-	 * Mongoose - Created
156
-	 ------------------------------------------------------*/
157
-
158
-	////////////////////////////////////////////////////////////
159
-	// Public Mutators
160
-	////////////////////////////////////////////////////////////
161
-
162
-	void setDebug(bool toggle);
163
-	/*------------------------------------------------------
164
-	 * Pre  :
165
-	 * Post :
166
-	 *
167
-	 *-- History ------------------------------------------
168
-	 *
169
-	 * 2002.12.15:
170
-	 * Mongoose - Created
171
-	 ------------------------------------------------------*/
172
-
173
-	void setPort(unsigned int port);
174
-	/*------------------------------------------------------
175
-	 * Pre  :
176
-	 * Post :
177
-	 *
178
-	 *-- History ------------------------------------------
179
-	 *
180
-	 * 2002.09.03:
181
-	 * Mongoose - Created
182
-	 ------------------------------------------------------*/
183
-
184
-	void setBindHost(char *s);
185
-	/*------------------------------------------------------
186
-	 * Pre  :
187
-	 * Post :
188
-	 *
189
-	 *-- History ------------------------------------------
190
-	 *
191
-	 * 2002.09.10:
192
-	 * Mongoose - Created
193
-	 ------------------------------------------------------*/
194
-
195
-	void setRemoteHost(char *s);
196
-	/*------------------------------------------------------
197
-	 * Pre  :
198
-	 * Post :
199
-	 *
200
-	 *-- History ------------------------------------------
201
-	 *
202
-	 * 2002.09.03:
203
-	 * Mongoose - Created
204
-	 ------------------------------------------------------*/
205
-
206
-	void killServerThread();
207
-	/*------------------------------------------------------
208
-	 * Pre  :
209
-	 * Post :
210
-	 *
211
-	 *-- History ------------------------------------------
212
-	 *
213
-	 * 2002.09.03:
214
-	 * Mongoose - Created
215
-	 ------------------------------------------------------*/
216
-
217
-	void killClientThread();
218
-	/*------------------------------------------------------
219
-	 * Pre  :
220
-	 * Post :
221
-	 *
222
-	 *-- History ------------------------------------------
223
-	 *
224
-	 * 2002.09.03:
225
-	 * Mongoose - Created
226
-	 ------------------------------------------------------*/
227
-
228
-	void spawnServerThread();
229
-	/*------------------------------------------------------
230
-	 * Pre  :
231
-	 * Post :
232
-	 *
233
-	 *-- History ------------------------------------------
234
-	 *
235
-	 * 2002.09.03:
236
-	 * Mongoose - Created
237
-	 ------------------------------------------------------*/
238
-
239
-	void spawnClientThread();
240
-	/*------------------------------------------------------
241
-	 * Pre  :
242
-	 * Post :
243
-	 *
244
-	 *-- History ------------------------------------------
245
-	 *
246
-	 * 2002.09.03:
247
-	 * Mongoose - Created
248
-	 ------------------------------------------------------*/
249
-
250
-	int runServer();
251
-	/*------------------------------------------------------
252
-	 * Pre  :
253
-	 * Post :
254
-	 *
255
-	 *-- History ------------------------------------------
256
-	 *
257
-	 * 2002.09.03:
258
-	 * Mongoose - Created
259
-	 ------------------------------------------------------*/
260
-
261
-	void runClient();
262
-	/*------------------------------------------------------
263
-	 * Pre  :
264
-	 * Post :
265
-	 *
266
-	 *-- History ------------------------------------------
267
-	 *
268
-	 * 2002.09.03:
269
-	 * Mongoose - Created
270
-	 ------------------------------------------------------*/
83
+    ////////////////////////////////////////////////////////////
84
+    // Constructors ( Singleton )
85
+    ////////////////////////////////////////////////////////////
86
+
87
+    static Network *Instance();
88
+    /*------------------------------------------------------
89
+     * Pre  :
90
+     * Post : Constructs the object of Network or
91
+     *        returns pointer to it if previously allocated
92
+     *
93
+     *-- History ------------------------------------------
94
+     *
95
+     * 2001.08.24:
96
+     * Mongoose - Created
97
+     ------------------------------------------------------*/
98
+
99
+    ~Network();
100
+    /*------------------------------------------------------
101
+     * Pre  : Network object is allocated
102
+     * Post : Deconstructs an object of Network
103
+     *
104
+     *-- History ------------------------------------------
105
+     *
106
+     * 2002.06.21:
107
+     * Mongoose - Created
108
+     ------------------------------------------------------*/
109
+
110
+    ////////////////////////////////////////////////////////////
111
+    // Public Accessors
112
+    ////////////////////////////////////////////////////////////
113
+
114
+    network_frame_t &getPiggyBack();
115
+    /*------------------------------------------------------
116
+     * Pre  :
117
+     * Post :
118
+     *
119
+     *-- History ------------------------------------------
120
+     *
121
+     * 2002.09.03:
122
+     * Mongoose - Created
123
+     ------------------------------------------------------*/
124
+
125
+    unsigned int getUID();
126
+    /*------------------------------------------------------
127
+     * Pre  :
128
+     * Post :
129
+     *
130
+     *-- History ------------------------------------------
131
+     *
132
+     * 2002.09.03:
133
+     * Mongoose - Created
134
+     ------------------------------------------------------*/
135
+
136
+    float getRandom(float from, float to);
137
+    /*------------------------------------------------------
138
+     * Pre  :
139
+     * Post :
140
+     *
141
+     *-- History ------------------------------------------
142
+     *
143
+     * 2002.09.03:
144
+     * Mongoose - Created
145
+     ------------------------------------------------------*/
146
+
147
+    int getPort();
148
+    /*------------------------------------------------------
149
+     * Pre  :
150
+     * Post :
151
+     *
152
+     *-- History ------------------------------------------
153
+     *
154
+     * 2002.09.03:
155
+     * Mongoose - Created
156
+     ------------------------------------------------------*/
157
+
158
+    ////////////////////////////////////////////////////////////
159
+    // Public Mutators
160
+    ////////////////////////////////////////////////////////////
161
+
162
+    void setDebug(bool toggle);
163
+    /*------------------------------------------------------
164
+     * Pre  :
165
+     * Post :
166
+     *
167
+     *-- History ------------------------------------------
168
+     *
169
+     * 2002.12.15:
170
+     * Mongoose - Created
171
+     ------------------------------------------------------*/
172
+
173
+    void setPort(unsigned int port);
174
+    /*------------------------------------------------------
175
+     * Pre  :
176
+     * Post :
177
+     *
178
+     *-- History ------------------------------------------
179
+     *
180
+     * 2002.09.03:
181
+     * Mongoose - Created
182
+     ------------------------------------------------------*/
183
+
184
+    void setBindHost(char *s);
185
+    /*------------------------------------------------------
186
+     * Pre  :
187
+     * Post :
188
+     *
189
+     *-- History ------------------------------------------
190
+     *
191
+     * 2002.09.10:
192
+     * Mongoose - Created
193
+     ------------------------------------------------------*/
194
+
195
+    void setRemoteHost(char *s);
196
+    /*------------------------------------------------------
197
+     * Pre  :
198
+     * Post :
199
+     *
200
+     *-- History ------------------------------------------
201
+     *
202
+     * 2002.09.03:
203
+     * Mongoose - Created
204
+     ------------------------------------------------------*/
205
+
206
+    void killServerThread();
207
+    /*------------------------------------------------------
208
+     * Pre  :
209
+     * Post :
210
+     *
211
+     *-- History ------------------------------------------
212
+     *
213
+     * 2002.09.03:
214
+     * Mongoose - Created
215
+     ------------------------------------------------------*/
216
+
217
+    void killClientThread();
218
+    /*------------------------------------------------------
219
+     * Pre  :
220
+     * Post :
221
+     *
222
+     *-- History ------------------------------------------
223
+     *
224
+     * 2002.09.03:
225
+     * Mongoose - Created
226
+     ------------------------------------------------------*/
227
+
228
+    void spawnServerThread();
229
+    /*------------------------------------------------------
230
+     * Pre  :
231
+     * Post :
232
+     *
233
+     *-- History ------------------------------------------
234
+     *
235
+     * 2002.09.03:
236
+     * Mongoose - Created
237
+     ------------------------------------------------------*/
238
+
239
+    void spawnClientThread();
240
+    /*------------------------------------------------------
241
+     * Pre  :
242
+     * Post :
243
+     *
244
+     *-- History ------------------------------------------
245
+     *
246
+     * 2002.09.03:
247
+     * Mongoose - Created
248
+     ------------------------------------------------------*/
249
+
250
+    int runServer();
251
+    /*------------------------------------------------------
252
+     * Pre  :
253
+     * Post :
254
+     *
255
+     *-- History ------------------------------------------
256
+     *
257
+     * 2002.09.03:
258
+     * Mongoose - Created
259
+     ------------------------------------------------------*/
260
+
261
+    void runClient();
262
+    /*------------------------------------------------------
263
+     * Pre  :
264
+     * Post :
265
+     *
266
+     *-- History ------------------------------------------
267
+     *
268
+     * 2002.09.03:
269
+     * Mongoose - Created
270
+     ------------------------------------------------------*/
271 271
 
272 272
  protected:
273 273
 
274
-	////////////////////////////////////////////////////////////
275
-	// Constructors ( Singleton )
276
-	////////////////////////////////////////////////////////////
274
+    ////////////////////////////////////////////////////////////
275
+    // Constructors ( Singleton )
276
+    ////////////////////////////////////////////////////////////
277 277
 
278
-	Network();
279
-	/*------------------------------------------------------
280
-	 * Pre  :
281
-	 * Post : Constructs an object of Network
282
-	 *
283
-	 *-- History ------------------------------------------
284
-	 *
285
-	 * 2002.06.21:
286
-	 * Mongoose - Created
287
-	 ------------------------------------------------------*/
278
+    Network();
279
+    /*------------------------------------------------------
280
+     * Pre  :
281
+     * Post : Constructs an object of Network
282
+     *
283
+     *-- History ------------------------------------------
284
+     *
285
+     * 2002.06.21:
286
+     * Mongoose - Created
287
+     ------------------------------------------------------*/
288 288
 
289 289
 
290
-	////////////////////////////////////////////////////////////
291
-	// Protected Mutators
292
-	////////////////////////////////////////////////////////////
290
+    ////////////////////////////////////////////////////////////
291
+    // Protected Mutators
292
+    ////////////////////////////////////////////////////////////
293 293
 
294 294
  private:
295 295
 
296
-	////////////////////////////////////////////////////////////
297
-	// Private Accessors
298
-	////////////////////////////////////////////////////////////
296
+    ////////////////////////////////////////////////////////////
297
+    // Private Accessors
298
+    ////////////////////////////////////////////////////////////
299 299
 
300 300
 
301
-	////////////////////////////////////////////////////////////
302
-	// Private Mutators
303
-	////////////////////////////////////////////////////////////
301
+    ////////////////////////////////////////////////////////////
302
+    // Private Mutators
303
+    ////////////////////////////////////////////////////////////
304 304
 
305 305
 
306
-	static Network *mInstance;      /* Singleton use */
306
+    static Network *mInstance;      /* Singleton use */
307 307
 
308
-	bool mSpawnedClient;
308
+    bool mSpawnedClient;
309 309
 
310
-	bool mSpawnedServer;
310
+    bool mSpawnedServer;
311 311
 
312
-	int mPort;
312
+    int mPort;
313 313
 
314
-	char mRemoteHost[REMOTE_HOST_STR_SZ];
314
+    char mRemoteHost[REMOTE_HOST_STR_SZ];
315 315
 
316
-	char mBindHost[BIND_HOST_STR_SZ];
316
+    char mBindHost[BIND_HOST_STR_SZ];
317 317
 
318
-	bool mPiggyBack;
318
+    bool mPiggyBack;
319 319
 
320
-	bool mNetworkReliable;
320
+    bool mNetworkReliable;
321 321
 
322
-	bool mKillClient;
322
+    bool mKillClient;
323 323
 
324
-	bool mKillServer;
324
+    bool mKillServer;
325 325
 
326
-	bool mDebug;
326
+    bool mDebug;
327 327
 };
328 328
 
329 329
 #endif

+ 388
- 388
include/OpenRaider.h Переглянути файл

@@ -41,38 +41,38 @@
41 41
 
42 42
 typedef enum
43 43
 {
44
-	OpenRaiderKey_console = 1, // Reserved 0 event for console in System
45
-	OpenRaiderKey_attack,
46
-	OpenRaiderKey_forward,
47
-	OpenRaiderKey_left,
48
-	OpenRaiderKey_right,
49
-	OpenRaiderKey_backward,
50
-	OpenRaiderKey_jump,
51
-	OpenRaiderKey_tiltUp,
52
-	OpenRaiderKey_tiltDown,
53
-	OpenRaiderKey_panLeft,
54
-	OpenRaiderKey_panRight,
55
-	OpenRaiderKey_crouch
44
+    OpenRaiderKey_console = 1, // Reserved 0 event for console in System
45
+    OpenRaiderKey_attack,
46
+    OpenRaiderKey_forward,
47
+    OpenRaiderKey_left,
48
+    OpenRaiderKey_right,
49
+    OpenRaiderKey_backward,
50
+    OpenRaiderKey_jump,
51
+    OpenRaiderKey_tiltUp,
52
+    OpenRaiderKey_tiltDown,
53
+    OpenRaiderKey_panLeft,
54
+    OpenRaiderKey_panRight,
55
+    OpenRaiderKey_crouch
56 56
 
57 57
 } OpenRaider_KeyEvent;
58 58
 
59 59
 
60 60
 typedef enum
61 61
 {
62
-	OpenRaider_ShowFPS      =   1,
63
-	OpenRaider_DebugMap     =   2,
64
-	OpenRaider_DebugModel   =   4,
65
-	OpenRaider_EnableSound  =   8,
66
-	OpenRaider_DumpTexture  =  16,
67
-	OpenRaider_FullScreen   =  32,
68
-	OpenRaider_Loading      =  64,
69
-	OpenRaider_GameRunning  = 128
62
+    OpenRaider_ShowFPS      =   1,
63
+    OpenRaider_DebugMap     =   2,
64
+    OpenRaider_DebugModel   =   4,
65
+    OpenRaider_EnableSound  =   8,
66
+    OpenRaider_DumpTexture  =  16,
67
+    OpenRaider_FullScreen   =  32,
68
+    OpenRaider_Loading      =  64,
69
+    OpenRaider_GameRunning  = 128
70 70
 
71 71
 } OpenRaiderFlags;
72 72
 
73 73
 typedef enum
74 74
 {
75
-	OpenRaiderSound_Ambient = 1
75
+    OpenRaiderSound_Ambient = 1
76 76
 
77 77
 } OpenRaider_SoundEventType;
78 78
 
@@ -81,393 +81,393 @@ class OpenRaider : public SDLSystem
81 81
 {
82 82
  public:
83 83
 
84
-	////////////////////////////////////////////////////////////
85
-	// Constructors ( Singleton )
86
-	////////////////////////////////////////////////////////////
87
-
88
-	static OpenRaider *Instance();
89
-	/*------------------------------------------------------
90
-	 * Pre  :
91
-	 * Post : Constructs the object of OpenRaider or
92
-	 *        returns pointer to it if previously allocated
93
-	 *
94
-	 *-- History ------------------------------------------
95
-	 *
96
-	 * 2001.08.24:
97
-	 * Mongoose - Created
98
-	 ------------------------------------------------------*/
99
-
100
-	~OpenRaider();
101
-	/*------------------------------------------------------
102
-	 * Pre  : OpenRaider object is allocated
103
-	 * Post : Deconstructs an object of OpenRaider
104
-	 *
105
-	 *-- History ------------------------------------------
106
-	 *
107
-	 * 2001.05.21:
108
-	 * Mongoose - Created
109
-	 ------------------------------------------------------*/
110
-
111
-
112
-	////////////////////////////////////////////////////////////
113
-	// Public Accessors
114
-	////////////////////////////////////////////////////////////
115
-
116
-
117
-	////////////////////////////////////////////////////////////
118
-	// Public Mutators
119
-	////////////////////////////////////////////////////////////
120
-
121
-	void start();
122
-	/*------------------------------------------------------
123
-	 * Pre  :
124
-	 * Post : Init the Game
125
-	 *
126
-	 *-- History ------------------------------------------
127
-	 *
128
-	 * 2001.05.21:
129
-	 * Mongoose - Created
130
-	 ------------------------------------------------------*/
131
-
132
-	void handleMouseMotionEvent(float x, float y);
133
-	/*------------------------------------------------------
134
-	 * Pre  :
135
-	 * Post : Mouse motion input used
136
-	 *
137
-	 *-- History ------------------------------------------
138
-	 *
139
-	 * 2001.06.04:
140
-	 * Mongoose - Created
141
-	 ------------------------------------------------------*/
142
-
143
-	void handleBoundKeyPressEvent(unsigned int key);
144
-	/*------------------------------------------------------
145
-	 * Pre  : <Key> is a valid keyboard code
146
-	 *
147
-	 * Post : Recieves <Event> bound to <Cmd> from <Key> press
148
-	 *
149
-	 *-- History ------------------------------------------
150
-	 *
151
-	 * 2003.06.03:
152
-	 * Mongoose - Created
153
-	 ------------------------------------------------------*/
154
-
155
-	void handleBoundKeyReleaseEvent(unsigned int key);
156
-	/*------------------------------------------------------
157
-	 * Pre  : <Key> is a valid keyboard code
158
-	 *
159
-	 * Post : Recieves <Event> bound to <Cmd> from <Key> release
160
-	 *
161
-	 *-- History ------------------------------------------
162
-	 *
163
-	 * 2003.06.03:
164
-	 * Mongoose - Created
165
-	 ------------------------------------------------------*/
166
-
167
-	 void handleCommand(char *command, unsigned int mode);
168
-	/*------------------------------------------------------
169
-	 * Pre  : <Command> is valid keyword optionally followed
170
-	 *        by ' ' (space) seperated and argument(s)
171
-	 *
172
-	 *        <Mode> is the current type or resource mode
173
-	 *
174
-	 * Post : Executes valid command based on keyword
175
-	 *
176
-	 *-- History ------------------------------------------
177
-	 *
178
-	 * 2002.03.23:
179
-	 * Mongoose - Created
180
-	 ------------------------------------------------------*/
181
-
182
-	 void handleConsoleKeyPressEvent(unsigned int key, unsigned int mod);
183
-	/*------------------------------------------------------
184
-	 * Pre  : <Key> is a valid keyboard code
185
-	 *
186
-	 * Post : Recieves <Key> code from text input in console mode
187
-	 *
188
-	 *-- History ------------------------------------------
189
-	 *
190
-	 * 2003.06.03:
191
-	 * Mongoose - Created
192
-	 ------------------------------------------------------*/
193
-
194
-	void handleKeyPressEvent(unsigned int key, unsigned int mod);
195
-	void handleKeyReleaseEvent(unsigned int key, unsigned int mod);
196
-	/*------------------------------------------------------
197
-	 * Pre  : key and mod are valid key command
198
-	 * Post : executes command acc with key, if any
199
-	 *
200
-	 *-- History ------------------------------------------
201
-	 *
202
-	 * 2001.05.27:
203
-	 * Mongoose - Created
204
-	 ------------------------------------------------------*/
205
-
206
-	void initGL();
207
-	/*------------------------------------------------------
208
-	 * Pre  :
209
-	 * Post :
210
-	 *
211
-	 *-- History ------------------------------------------
212
-	 *
213
-	 * 2002.08.13:
214
-	 * Mongoose - Created
215
-	 ------------------------------------------------------*/
216
-
217
-	void gameFrame();
218
-	/*------------------------------------------------------
219
-	 * Pre  :
220
-	 * Post : One game physics/time frame passes
221
-	 *        Also renders one frame per call
222
-	 *
223
-	 *-- History ------------------------------------------
224
-	 *
225
-	 * 2001.05.21:
226
-	 * Mongoose - Created
227
-	 ------------------------------------------------------*/
228
-
229
-	void print(bool dump_stdout, const char *format, ...);
230
-	/*------------------------------------------------------
231
-	 * Pre  : Use like printf
232
-	 *
233
-	 * Post : Outputs message in game console
234
-	 *
235
-	 *        If dump_stdout is true, print to stdout also
236
-	 *
237
-	 *-- History ------------------------------------------
238
-	 *
239
-	 * 2002.08.13:
240
-	 * Mongoose - Created
241
-	 ------------------------------------------------------*/
84
+    ////////////////////////////////////////////////////////////
85
+    // Constructors ( Singleton )
86
+    ////////////////////////////////////////////////////////////
87
+
88
+    static OpenRaider *Instance();
89
+    /*------------------------------------------------------
90
+     * Pre  :
91
+     * Post : Constructs the object of OpenRaider or
92
+     *        returns pointer to it if previously allocated
93
+     *
94
+     *-- History ------------------------------------------
95
+     *
96
+     * 2001.08.24:
97
+     * Mongoose - Created
98
+     ------------------------------------------------------*/
99
+
100
+    ~OpenRaider();
101
+    /*------------------------------------------------------
102
+     * Pre  : OpenRaider object is allocated
103
+     * Post : Deconstructs an object of OpenRaider
104
+     *
105
+     *-- History ------------------------------------------
106
+     *
107
+     * 2001.05.21:
108
+     * Mongoose - Created
109
+     ------------------------------------------------------*/
110
+
111
+
112
+    ////////////////////////////////////////////////////////////
113
+    // Public Accessors
114
+    ////////////////////////////////////////////////////////////
115
+
116
+
117
+    ////////////////////////////////////////////////////////////
118
+    // Public Mutators
119
+    ////////////////////////////////////////////////////////////
120
+
121
+    void start();
122
+    /*------------------------------------------------------
123
+     * Pre  :
124
+     * Post : Init the Game
125
+     *
126
+     *-- History ------------------------------------------
127
+     *
128
+     * 2001.05.21:
129
+     * Mongoose - Created
130
+     ------------------------------------------------------*/
131
+
132
+    void handleMouseMotionEvent(float x, float y);
133
+    /*------------------------------------------------------
134
+     * Pre  :
135
+     * Post : Mouse motion input used
136
+     *
137
+     *-- History ------------------------------------------
138
+     *
139
+     * 2001.06.04:
140
+     * Mongoose - Created
141
+     ------------------------------------------------------*/
142
+
143
+    void handleBoundKeyPressEvent(unsigned int key);
144
+    /*------------------------------------------------------
145
+     * Pre  : <Key> is a valid keyboard code
146
+     *
147
+     * Post : Recieves <Event> bound to <Cmd> from <Key> press
148
+     *
149
+     *-- History ------------------------------------------
150
+     *
151
+     * 2003.06.03:
152
+     * Mongoose - Created
153
+     ------------------------------------------------------*/
154
+
155
+    void handleBoundKeyReleaseEvent(unsigned int key);
156
+    /*------------------------------------------------------
157
+     * Pre  : <Key> is a valid keyboard code
158
+     *
159
+     * Post : Recieves <Event> bound to <Cmd> from <Key> release
160
+     *
161
+     *-- History ------------------------------------------
162
+     *
163
+     * 2003.06.03:
164
+     * Mongoose - Created
165
+     ------------------------------------------------------*/
166
+
167
+     void handleCommand(char *command, unsigned int mode);
168
+    /*------------------------------------------------------
169
+     * Pre  : <Command> is valid keyword optionally followed
170
+     *        by ' ' (space) seperated and argument(s)
171
+     *
172
+     *        <Mode> is the current type or resource mode
173
+     *
174
+     * Post : Executes valid command based on keyword
175
+     *
176
+     *-- History ------------------------------------------
177
+     *
178
+     * 2002.03.23:
179
+     * Mongoose - Created
180
+     ------------------------------------------------------*/
181
+
182
+     void handleConsoleKeyPressEvent(unsigned int key, unsigned int mod);
183
+    /*------------------------------------------------------
184
+     * Pre  : <Key> is a valid keyboard code
185
+     *
186
+     * Post : Recieves <Key> code from text input in console mode
187
+     *
188
+     *-- History ------------------------------------------
189
+     *
190
+     * 2003.06.03:
191
+     * Mongoose - Created
192
+     ------------------------------------------------------*/
193
+
194
+    void handleKeyPressEvent(unsigned int key, unsigned int mod);
195
+    void handleKeyReleaseEvent(unsigned int key, unsigned int mod);
196
+    /*------------------------------------------------------
197
+     * Pre  : key and mod are valid key command
198
+     * Post : executes command acc with key, if any
199
+     *
200
+     *-- History ------------------------------------------
201
+     *
202
+     * 2001.05.27:
203
+     * Mongoose - Created
204
+     ------------------------------------------------------*/
205
+
206
+    void initGL();
207
+    /*------------------------------------------------------
208
+     * Pre  :
209
+     * Post :
210
+     *
211
+     *-- History ------------------------------------------
212
+     *
213
+     * 2002.08.13:
214
+     * Mongoose - Created
215
+     ------------------------------------------------------*/
216
+
217
+    void gameFrame();
218
+    /*------------------------------------------------------
219
+     * Pre  :
220
+     * Post : One game physics/time frame passes
221
+     *        Also renders one frame per call
222
+     *
223
+     *-- History ------------------------------------------
224
+     *
225
+     * 2001.05.21:
226
+     * Mongoose - Created
227
+     ------------------------------------------------------*/
228
+
229
+    void print(bool dump_stdout, const char *format, ...);
230
+    /*------------------------------------------------------
231
+     * Pre  : Use like printf
232
+     *
233
+     * Post : Outputs message in game console
234
+     *
235
+     *        If dump_stdout is true, print to stdout also
236
+     *
237
+     *-- History ------------------------------------------
238
+     *
239
+     * 2002.08.13:
240
+     * Mongoose - Created
241
+     ------------------------------------------------------*/
242 242
 
243 243
 
244 244
  protected:
245 245
 
246
-	////////////////////////////////////////////////////////////
247
-	// Constructors ( Singleton )
248
-	////////////////////////////////////////////////////////////
246
+    ////////////////////////////////////////////////////////////
247
+    // Constructors ( Singleton )
248
+    ////////////////////////////////////////////////////////////
249 249
 
250
-	OpenRaider();
251
-	/*------------------------------------------------------
252
-	 * Pre  :
253
-	 * Post : Constructs an object of OpenRaider
254
-	 *
255
-	 *-- History ------------------------------------------
256
-	 *
257
-	 * 2001.05.21:
258
-	 * Mongoose - Created
259
-	 ------------------------------------------------------*/
250
+    OpenRaider();
251
+    /*------------------------------------------------------
252
+     * Pre  :
253
+     * Post : Constructs an object of OpenRaider
254
+     *
255
+     *-- History ------------------------------------------
256
+     *
257
+     * 2001.05.21:
258
+     * Mongoose - Created
259
+     ------------------------------------------------------*/
260 260
 
261 261
 
262 262
  private:
263 263
 
264
-	////////////////////////////////////////////////////////////
265
-	// Private Accessors
266
-	////////////////////////////////////////////////////////////
267
-
268
-
269
-	////////////////////////////////////////////////////////////
270
-	// Private Mutators
271
-	////////////////////////////////////////////////////////////
272
-
273
-	void consoleCommand(char *cmd);
274
-	/*------------------------------------------------------
275
-	 * Pre  :
276
-	 * Post :
277
-	 *
278
-	 *-- History ------------------------------------------
279
-	 *
280
-	 * ????.??.??:
281
-	 * Mongoose - Created
282
-	 ------------------------------------------------------*/
283
-
284
-	void soundEvent(int type, int id, vec3_t pos, vec3_t angles);
285
-	/*------------------------------------------------------
286
-	 * Pre  :
287
-	 * Post :
288
-	 *
289
-	 *-- History ------------------------------------------
290
-	 *
291
-	 * 2002.06.16:
292
-	 * Mongoose - Created
293
-	 ------------------------------------------------------*/
294
-
295
-//	void entityEvent(entity_t &e, RaiderEvent event);
296
-	/*------------------------------------------------------
297
-	 * Pre  :
298
-	 * Post :
299
-	 *
300
-	 *-- History ------------------------------------------
301
-	 *
302
-	 * 2002.06.16:
303
-	 * Mongoose - Created
304
-	 ------------------------------------------------------*/
305
-
306
-	void processPakSounds();
307
-	/*------------------------------------------------------
308
-	 * Pre  :
309
-	 * Post :
310
-	 *
311
-	 *-- History ------------------------------------------
312
-	 *
313
-	 * 2001.06.04:
314
-	 * Mongoose - Created
315
-	 ------------------------------------------------------*/
316
-
317
-	void initSound();
318
-	/*------------------------------------------------------
319
-	 * Pre  : Sound system has been init
320
-	 * Post : Loads and positions level sounds and music
321
-	 *
322
-	 *-- History ------------------------------------------
323
-	 *
324
-	 * 2001.06.04:
325
-	 * Mongoose - Created
326
-	 ------------------------------------------------------*/
327
-
328
-	void initTextures();
329
-	/*------------------------------------------------------
330
-	 * Pre  :
331
-	 * Post : Generates all textures or mipmaps
332
-	 *        needed for fonts, splash, ext particles
333
-	 *
334
-	 *-- History ------------------------------------------
335
-	 *
336
-	 * 2001.05.28:
337
-	 * Mongoose - Created
338
-	 ------------------------------------------------------*/
339
-
340
-	void processTextures();
341
-	/*------------------------------------------------------
342
-	 * Pre  :
343
-	 * Post : Generates tombraider textures or mipmaps
344
-	 *        needed for sprites, rooms, and models
345
-	 *
346
-	 *-- History ------------------------------------------
347
-	 *
348
-	 * 2001.05.28:
349
-	 * Mongoose - Created
350
-	 ------------------------------------------------------*/
351
-
352
-	void processSprites();
353
-	/*------------------------------------------------------
354
-	 * Pre  :
355
-	 * Post : Generates render sprite sequences
356
-	 *
357
-	 *-- History ------------------------------------------
358
-	 *
359
-	 * 2001.06.06:
360
-	 * Mongoose - All new functionality
361
-	 *
362
-	 * 2001.05.28:
363
-	 * Mongoose - Created
364
-	 ------------------------------------------------------*/
365
-
366
-	void processMoveables();
367
-	/*------------------------------------------------------
368
-	 * Pre  :
369
-	 * Post :
370
-	 *
371
-	 *-- History ------------------------------------------
372
-	 *
373
-	 * 2001.06.08:
374
-	 * Mongoose - Created
375
-	 ------------------------------------------------------*/
376
-
377
-	void processMoveable(int index, int i, int *ent, List <skeletal_model_t *> &cache2, List <unsigned int> &cache, int object_id);
378
-	/*------------------------------------------------------
379
-	 * Pre  :
380
-	 * Post :
381
-	 *
382
-	 *-- History ------------------------------------------
383
-	 *
384
-	 * 2002.04.06:
385
-	 * Mongoose - Created
386
-	 ------------------------------------------------------*/
387
-
388
-	void processModel(int index);
389
-	/*------------------------------------------------------
390
-	 * Pre  : valid model index
391
-	 * Post : Generates render mesh and any textures
392
-	 *        needed for model[index]
393
-	 *
394
-	 *-- History ------------------------------------------
395
-	 *
396
-	 * 2001.05.26:
397
-	 * Mongoose - Created
398
-	 ------------------------------------------------------*/
399
-
400
-	void processRoom(int index);
401
-	/*------------------------------------------------------
402
-	 * Pre  : valid room index
403
-	 * Post : Generates render mesh and any textures
404
-	 *        needed for room[index]
405
-	 *
406
-	 *-- History ------------------------------------------
407
-	 *
408
-	 * 2001.05.21:
409
-	 * Mongoose - Created
410
-	 ------------------------------------------------------*/
411
-
412
-	void loadLevel(char *filename);
413
-	/*------------------------------------------------------
414
-	 * Pre  :
415
-	 * Post : Loads validated level pak from diskfile
416
-	 *        using maplist
417
-	 *
418
-	 *-- History ------------------------------------------
419
-	 *
420
-	 * 2001.05.21:
421
-	 * Mongoose - Created
422
-	 ------------------------------------------------------*/
423
-
424
-
425
-	static OpenRaider *mInstance; /* Singleton use */
426
-
427
-	TombRaider m_tombraider;      /* Tombraider data support */
428
-
429
-	Sound mSound;                 /* 3d Audio support */
430
-
431
-	Render m_render;              /* Rendering support */
432
-
433
-	Camera m_camera;              /* Client camera support */
434
-
435
-	GLString *mText;              /* Hook to textbox like output */
436
-
437
-	int mNoClipping;              /* 0 - Clipping, 1 - No Clipping,
438
-											   2 - No Clipping w/o gravity */
439
-
440
-	// RC vars //////////////////
441
-
442
-	unsigned int mMode[8];			/* Translate System's mode ids to OR's */
443
-
444
-	unsigned int m_flags;			/* Set options by flags */
445
-
446
-	int m_testSFX;						/* Used for mixed channel sound tests */
447
-
448
-	float m_mouseX, m_mouseY;		/* XY axis rotation deltas */
264
+    ////////////////////////////////////////////////////////////
265
+    // Private Accessors
266
+    ////////////////////////////////////////////////////////////
267
+
268
+
269
+    ////////////////////////////////////////////////////////////
270
+    // Private Mutators
271
+    ////////////////////////////////////////////////////////////
272
+
273
+    void consoleCommand(char *cmd);
274
+    /*------------------------------------------------------
275
+     * Pre  :
276
+     * Post :
277
+     *
278
+     *-- History ------------------------------------------
279
+     *
280
+     * ????.??.??:
281
+     * Mongoose - Created
282
+     ------------------------------------------------------*/
283
+
284
+    void soundEvent(int type, int id, vec3_t pos, vec3_t angles);
285
+    /*------------------------------------------------------
286
+     * Pre  :
287
+     * Post :
288
+     *
289
+     *-- History ------------------------------------------
290
+     *
291
+     * 2002.06.16:
292
+     * Mongoose - Created
293
+     ------------------------------------------------------*/
294
+
295
+//  void entityEvent(entity_t &e, RaiderEvent event);
296
+    /*------------------------------------------------------
297
+     * Pre  :
298
+     * Post :
299
+     *
300
+     *-- History ------------------------------------------
301
+     *
302
+     * 2002.06.16:
303
+     * Mongoose - Created
304
+     ------------------------------------------------------*/
305
+
306
+    void processPakSounds();
307
+    /*------------------------------------------------------
308
+     * Pre  :
309
+     * Post :
310
+     *
311
+     *-- History ------------------------------------------
312
+     *
313
+     * 2001.06.04:
314
+     * Mongoose - Created
315
+     ------------------------------------------------------*/
316
+
317
+    void initSound();
318
+    /*------------------------------------------------------
319
+     * Pre  : Sound system has been init
320
+     * Post : Loads and positions level sounds and music
321
+     *
322
+     *-- History ------------------------------------------
323
+     *
324
+     * 2001.06.04:
325
+     * Mongoose - Created
326
+     ------------------------------------------------------*/
327
+
328
+    void initTextures();
329
+    /*------------------------------------------------------
330
+     * Pre  :
331
+     * Post : Generates all textures or mipmaps
332
+     *        needed for fonts, splash, ext particles
333
+     *
334
+     *-- History ------------------------------------------
335
+     *
336
+     * 2001.05.28:
337
+     * Mongoose - Created
338
+     ------------------------------------------------------*/
339
+
340
+    void processTextures();
341
+    /*------------------------------------------------------
342
+     * Pre  :
343
+     * Post : Generates tombraider textures or mipmaps
344
+     *        needed for sprites, rooms, and models
345
+     *
346
+     *-- History ------------------------------------------
347
+     *
348
+     * 2001.05.28:
349
+     * Mongoose - Created
350
+     ------------------------------------------------------*/
351
+
352
+    void processSprites();
353
+    /*------------------------------------------------------
354
+     * Pre  :
355
+     * Post : Generates render sprite sequences
356
+     *
357
+     *-- History ------------------------------------------
358
+     *
359
+     * 2001.06.06:
360
+     * Mongoose - All new functionality
361
+     *
362
+     * 2001.05.28:
363
+     * Mongoose - Created
364
+     ------------------------------------------------------*/
365
+
366
+    void processMoveables();
367
+    /*------------------------------------------------------
368
+     * Pre  :
369
+     * Post :
370
+     *
371
+     *-- History ------------------------------------------
372
+     *
373
+     * 2001.06.08:
374
+     * Mongoose - Created
375
+     ------------------------------------------------------*/
376
+
377
+    void processMoveable(int index, int i, int *ent, List <skeletal_model_t *> &cache2, List <unsigned int> &cache, int object_id);
378
+    /*------------------------------------------------------
379
+     * Pre  :
380
+     * Post :
381
+     *
382
+     *-- History ------------------------------------------
383
+     *
384
+     * 2002.04.06:
385
+     * Mongoose - Created
386
+     ------------------------------------------------------*/
387
+
388
+    void processModel(int index);
389
+    /*------------------------------------------------------
390
+     * Pre  : valid model index
391
+     * Post : Generates render mesh and any textures
392
+     *        needed for model[index]
393
+     *
394
+     *-- History ------------------------------------------
395
+     *
396
+     * 2001.05.26:
397
+     * Mongoose - Created
398
+     ------------------------------------------------------*/
399
+
400
+    void processRoom(int index);
401
+    /*------------------------------------------------------
402
+     * Pre  : valid room index
403
+     * Post : Generates render mesh and any textures
404
+     *        needed for room[index]
405
+     *
406
+     *-- History ------------------------------------------
407
+     *
408
+     * 2001.05.21:
409
+     * Mongoose - Created
410
+     ------------------------------------------------------*/
411
+
412
+    void loadLevel(char *filename);
413
+    /*------------------------------------------------------
414
+     * Pre  :
415
+     * Post : Loads validated level pak from diskfile
416
+     *        using maplist
417
+     *
418
+     *-- History ------------------------------------------
419
+     *
420
+     * 2001.05.21:
421
+     * Mongoose - Created
422
+     ------------------------------------------------------*/
423
+
424
+
425
+    static OpenRaider *mInstance; /* Singleton use */
426
+
427
+    TombRaider m_tombraider;      /* Tombraider data support */
428
+
429
+    Sound mSound;                 /* 3d Audio support */
430
+
431
+    Render m_render;              /* Rendering support */
432
+
433
+    Camera m_camera;              /* Client camera support */
434
+
435
+    GLString *mText;              /* Hook to textbox like output */
436
+
437
+    int mNoClipping;              /* 0 - Clipping, 1 - No Clipping,
438
+                                               2 - No Clipping w/o gravity */
439
+
440
+    // RC vars //////////////////
441
+
442
+    unsigned int mMode[8];          /* Translate System's mode ids to OR's */
443
+
444
+    unsigned int m_flags;           /* Set options by flags */
445
+
446
+    int m_testSFX;                      /* Used for mixed channel sound tests */
447
+
448
+    float m_mouseX, m_mouseY;       /* XY axis rotation deltas */
449 449
 
450
-	unsigned int m_texOffset;		/* Offset of TombRaider textures in list */
450
+    unsigned int m_texOffset;       /* Offset of TombRaider textures in list */
451 451
 
452
-	unsigned int mLevelTextureOffset;
452
+    unsigned int mLevelTextureOffset;
453 453
 
454
-	// Game vars //////////////
454
+    // Game vars //////////////
455 455
 
456
-	Vector <char *> mMusicList;  /* List of game level music */
456
+    Vector <char *> mMusicList;  /* List of game level music */
457 457
 
458
-	Vector <char *> mMapList;    /* List of game maps */
458
+    Vector <char *> mMapList;    /* List of game maps */
459 459
 
460
-	char m_mapName[32];          /* Current map filename */
460
+    char m_mapName[32];          /* Current map filename */
461 461
 
462
-	char *m_pakDir;              /* Current pak directory */
462
+    char *m_pakDir;              /* Current pak directory */
463 463
 
464
-	char *m_audioDir;            /* Current audio directory */
464
+    char *m_audioDir;            /* Current audio directory */
465 465
 
466
-	char *m_homeDir;             /* Current home directory */
466
+    char *m_homeDir;             /* Current home directory */
467 467
 
468
-	Vector<entity_t *> mClients; /* Player entity/clients */
468
+    Vector<entity_t *> mClients; /* Player entity/clients */
469 469
 
470
-	unsigned int mMaxClients;    /* Max number of clients */
470
+    unsigned int mMaxClients;    /* Max number of clients */
471 471
 };
472 472
 
473 473
 #endif

+ 323
- 323
include/Quaternion.h Переглянути файл

@@ -33,333 +33,333 @@ class Quaternion
33 33
 {
34 34
  public:
35 35
 
36
-	////////////////////////////////////////////////////////////
37
-	// Constructors
38
-	////////////////////////////////////////////////////////////
39
-
40
-	Quaternion();
41
-	/*------------------------------------------------------
42
-	 * Pre  :
43
-	 * Post : Constructs an object of Quaternion
44
-	 *
45
-	 *-- History ------------------------------------------
46
-	 *
47
-	 * 2002.12.16:
48
-	 * Mongoose - Created
49
-	 ------------------------------------------------------*/
50
-
51
-	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
-
62
-	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
-
73
-	~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
-
89
-	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
-
100
-	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
-
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 )
118
-	 *
119
-	 *-- History ------------------------------------------
120
-	 *
121
-	 * 2002.05.08:
122
-	 * Mongoose - Created
123
-	 ------------------------------------------------------*/
124
-
125
-	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
-
137
-	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
-
149
-	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
-
161
-	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
-
173
-	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
-
184
-	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
-
195
-	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
-
206
-	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
-
217
-	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
-
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
236
-	 *
237
-	 *-- History ------------------------------------------
238
-	 *
239
-	 * 2002.05.08:
240
-	 * Mongoose - Created
241
-	 ------------------------------------------------------*/
242
-
243
-
244
-	////////////////////////////////////////////////////////////
245
-	// Public Mutators
246
-	////////////////////////////////////////////////////////////
247
-
248
-	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
-
259
-	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
-
270
-	void normalize();
271
-	/*------------------------------------------------------
272
-	 * Pre  :
273
-	 * Post : Normalize this quaternion
274
-	 *
275
-	 *-- History ------------------------------------------
276
-	 *
277
-	 * 2002.05.08:
278
-	 * Mongoose - Created
279
-	 ------------------------------------------------------*/
280
-
281
-	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
-
292
-	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
-	 ------------------------------------------------------*/
36
+    ////////////////////////////////////////////////////////////
37
+    // Constructors
38
+    ////////////////////////////////////////////////////////////
39
+
40
+    Quaternion();
41
+    /*------------------------------------------------------
42
+     * Pre  :
43
+     * Post : Constructs an object of Quaternion
44
+     *
45
+     *-- History ------------------------------------------
46
+     *
47
+     * 2002.12.16:
48
+     * Mongoose - Created
49
+     ------------------------------------------------------*/
50
+
51
+    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
+
62
+    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
+
73
+    ~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
+
89
+    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
+
100
+    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
+
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 )
118
+     *
119
+     *-- History ------------------------------------------
120
+     *
121
+     * 2002.05.08:
122
+     * Mongoose - Created
123
+     ------------------------------------------------------*/
124
+
125
+    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
+
137
+    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
+
149
+    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
+
161
+    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
+
173
+    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
+
184
+    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
+
195
+    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
+
206
+    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
+
217
+    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
+
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
236
+     *
237
+     *-- History ------------------------------------------
238
+     *
239
+     * 2002.05.08:
240
+     * Mongoose - Created
241
+     ------------------------------------------------------*/
242
+
243
+
244
+    ////////////////////////////////////////////////////////////
245
+    // Public Mutators
246
+    ////////////////////////////////////////////////////////////
247
+
248
+    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
+
259
+    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
+
270
+    void normalize();
271
+    /*------------------------------------------------------
272
+     * Pre  :
273
+     * Post : Normalize this quaternion
274
+     *
275
+     *-- History ------------------------------------------
276
+     *
277
+     * 2002.05.08:
278
+     * Mongoose - Created
279
+     ------------------------------------------------------*/
280
+
281
+    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
+
292
+    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 302
 
303 303
 
304 304
  private:
305 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
-
362
-	vec_t mW, mX, mY, mZ;          /* Quaternion */
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
+
362
+    vec_t mW, mX, mY, mZ;          /* Quaternion */
363 363
 };
364 364
 
365 365
 #endif

+ 295
- 295
include/Render.h Переглянути файл

@@ -43,35 +43,35 @@
43 43
 class RenderRoom
44 44
 {
45 45
 public:
46
-	RenderRoom()
47
-	{
48
-		room = 0x0;
49
-	}
46
+    RenderRoom()
47
+    {
48
+        room = 0x0;
49
+    }
50 50
 
51
-	~RenderRoom()
52
-	{
53
-		//! \fixme Hangs when erasing - might be shared pointers somewhere
54
-		//lights.erase();
55
-	}
51
+    ~RenderRoom()
52
+    {
53
+        //! \fixme Hangs when erasing - might be shared pointers somewhere
54
+        //lights.erase();
55
+    }
56 56
 
57
-	void computeCenter()
58
-	{
59
-		if (room)
60
-		{
61
-			helMidpoint3v(room->bbox_min, room->bbox_max, center);
62
-		}
63
-	}
57
+    void computeCenter()
58
+    {
59
+        if (room)
60
+        {
61
+            helMidpoint3v(room->bbox_min, room->bbox_max, center);
62
+        }
63
+    }
64 64
 
65
-	vec_t dist;              /* Distance to near plane, move to room?  */
65
+    vec_t dist;              /* Distance to near plane, move to room?  */
66 66
 
67
-	vec3_t center;           /* Center of bbox, move to room? */
67
+    vec3_t center;           /* Center of bbox, move to room? */
68 68
 
69
-	room_mesh_t *room;       /* Physical room stored in World,
70
-										 Very dangerous as allocated and used */
69
+    room_mesh_t *room;       /* Physical room stored in World,
70
+                                         Very dangerous as allocated and used */
71 71
 
72
-	Vector<Light *> lights;  /* List of lights in this room */
72
+    Vector<Light *> lights;  /* List of lights in this room */
73 73
 
74
-	OpenGLMesh mesh;         /* OpenGL mesh that represents this room */
74
+    OpenGLMesh mesh;         /* OpenGL mesh that represents this room */
75 75
 };
76 76
 
77 77
 
@@ -79,169 +79,169 @@ class Render
79 79
 {
80 80
  public:
81 81
 
82
-	typedef enum
82
+    typedef enum
83 83
    {
84
-		modeDisabled    = 0,
85
-		modeLoadScreen  = 1,
86
-		modeVertexLight = 2,
87
-		modeSolid       = 3,
88
-		modeWireframe   = 4,
89
-		modeTexture     = 5
90
-	} RenderMode;
91
-
92
-	typedef enum
84
+        modeDisabled    = 0,
85
+        modeLoadScreen  = 1,
86
+        modeVertexLight = 2,
87
+        modeSolid       = 3,
88
+        modeWireframe   = 4,
89
+        modeTexture     = 5
90
+    } RenderMode;
91
+
92
+    typedef enum
93 93
    {
94
-		fParticles		= 1,
95
-		fPortals			= 2,
96
-		fRoomAlpha		= 4,
97
-		fViewModel    = 8,
98
-		fSprites      = 16,
99
-		fRoomModels   = 32,
100
-		fEntityModels = 64,
101
-		fFog          = 128,
102
-		fUsePortals   = 256,
103
-		fFastCard     = 1024,
104
-		fGL_Lights    = 2048,
105
-		fOneRoom      = 4096,
106
-		fRenderPonytail = 8192,
107
-		fMultiTexture = 16384,
108
-		fUpdateRoomListPerFrame = 32768,
109
-		fAnimateAllModels = 65536,
110
-		fAllRooms      =  131072
111
-	} RenderFlags;
112
-
113
-	typedef enum
114
-	{
115
-		roomMesh = 1,
116
-		skeletalMesh = 2
117
-
118
-	} RenderMeshType;
119
-
120
-	////////////////////////////////////////////////////////////
121
-	// Constructors
122
-	////////////////////////////////////////////////////////////
123
-
124
-	Render();
125
-	/*------------------------------------------------------
126
-	 * Pre  :
127
-	 * Post : Constructs an object of Render
128
-	 *
129
-	 *-- History ------------------------------------------
130
-	 *
131
-	 * 2001.05.21:
132
-	 * Mongoose - Created
133
-	 ------------------------------------------------------*/
134
-
135
-	~Render();
136
-	/*------------------------------------------------------
137
-	 * Pre  : Render object is allocated
138
-	 * Post : Deconstructs an object of Render
139
-	 *
140
-	 *-- History ------------------------------------------
141
-	 *
142
-	 * 2001.05.21:
143
-	 * Mongoose - Created
144
-	 ------------------------------------------------------*/
145
-
146
-
147
-	////////////////////////////////////////////////////////////
148
-	// Public Accessors
149
-	////////////////////////////////////////////////////////////
150
-
151
-	void screenShot(char *filenameBase);
152
-	/*------------------------------------------------------
153
-	 * Pre  :
154
-	 * Post : Makes a screenshot, writes to disk as file
155
-	 *
156
-	 *-- History ------------------------------------------
157
-	 *
158
-	 * 2002.12.20:
159
-	 * Mongoose - Created, factored out of OpenRaider class
160
-	 ------------------------------------------------------*/
161
-
162
-	int getMode();
163
-	/*------------------------------------------------------
164
-	 * Pre  :
165
-	 * Post : Gets current rendering mode
166
-	 *
167
-	 *-- History ------------------------------------------
168
-	 *
169
-	 * 2001.05.21:
170
-	 * Mongoose - Created
171
-	 ------------------------------------------------------*/
172
-
173
-
174
-	////////////////////////////////////////////////////////////
175
-	// Public Mutators
176
-	////////////////////////////////////////////////////////////
177
-
178
-	void addRoom(RenderRoom *rRoom);
179
-	/*------------------------------------------------------
180
-	 * Pre  :
181
-	 * Post :
182
-	 *
183
-	 *-- History ------------------------------------------
184
-	 *
185
-	 * 2002.12.21:
186
-	 * Mongoose - Created, factored out of World
187
-	 ------------------------------------------------------*/
188
-
189
-	void Init(int width, int height, bool fastCard);
190
-	/*------------------------------------------------------
191
-	 * Pre  :
192
-	 * Post : Starts and sets up OpenGL target
193
-	 *
194
-	 *-- History ------------------------------------------
195
-	 *
196
-	 * 2001.05.21:
197
-	 * Mongoose - Created
198
-	 ------------------------------------------------------*/
199
-
200
-	void loadTexture(unsigned char *image,
201
-						  unsigned int width, unsigned int height,
202
-						  unsigned int id);
203
-	/*------------------------------------------------------
204
-	 * Pre  :
205
-	 * Post : Loads textures in a certian id slot
206
-	 *
207
-	 *-- History ------------------------------------------
208
-	 *
209
-	 * 2002.12.20:
210
-	 * Mongoose - Created, factored out of OpenRaider class
211
-	 ------------------------------------------------------*/
212
-
213
-	void initTextures(char *textureDir, unsigned int *numLoaded,
214
-							unsigned int *nextId);
215
-	/*------------------------------------------------------
216
-	 * Pre  : textureDir is valid and exists with textures
217
-	 * Post : Sets up textures for OpenRaider
218
-	 *        Returns number of loaded textures and
219
-	 *
220
-	 *        numLoaded will update number of
221
-	 *        external textures loaded
222
-	 *
223
-	 *        nextId will update next level texture id
224
-	 *
225
-	 *-- History ------------------------------------------
226
-	 *
227
-	 * 2002.12.20:
228
-	 * Mongoose - Created, factored out of OpenRaider class
229
-	 ------------------------------------------------------*/
230
-
231
-	void initEmitter(const char *name, unsigned int size,
232
-						  unsigned int snowTex1, unsigned int snowTex2);
233
-	/*------------------------------------------------------
234
-	 * Pre  : Textures are init and these args are valid
235
-	 * Post : Emitter is set up for rendering with 2 textures
236
-	 *        in a overhead rain or snow like pattern
237
-	 *
238
-	 *-- History ------------------------------------------
239
-	 *
240
-	 * 2002.12.20:
241
-	 * Mongoose - Created
242
-	 ------------------------------------------------------*/
243
-
244
-	void ClearWorld();
94
+        fParticles      = 1,
95
+        fPortals            = 2,
96
+        fRoomAlpha      = 4,
97
+        fViewModel    = 8,
98
+        fSprites      = 16,
99
+        fRoomModels   = 32,
100
+        fEntityModels = 64,
101
+        fFog          = 128,
102
+        fUsePortals   = 256,
103
+        fFastCard     = 1024,
104
+        fGL_Lights    = 2048,
105
+        fOneRoom      = 4096,
106
+        fRenderPonytail = 8192,
107
+        fMultiTexture = 16384,
108
+        fUpdateRoomListPerFrame = 32768,
109
+        fAnimateAllModels = 65536,
110
+        fAllRooms      =  131072
111
+    } RenderFlags;
112
+
113
+    typedef enum
114
+    {
115
+        roomMesh = 1,
116
+        skeletalMesh = 2
117
+
118
+    } RenderMeshType;
119
+
120
+    ////////////////////////////////////////////////////////////
121
+    // Constructors
122
+    ////////////////////////////////////////////////////////////
123
+
124
+    Render();
125
+    /*------------------------------------------------------
126
+     * Pre  :
127
+     * Post : Constructs an object of Render
128
+     *
129
+     *-- History ------------------------------------------
130
+     *
131
+     * 2001.05.21:
132
+     * Mongoose - Created
133
+     ------------------------------------------------------*/
134
+
135
+    ~Render();
136
+    /*------------------------------------------------------
137
+     * Pre  : Render object is allocated
138
+     * Post : Deconstructs an object of Render
139
+     *
140
+     *-- History ------------------------------------------
141
+     *
142
+     * 2001.05.21:
143
+     * Mongoose - Created
144
+     ------------------------------------------------------*/
145
+
146
+
147
+    ////////////////////////////////////////////////////////////
148
+    // Public Accessors
149
+    ////////////////////////////////////////////////////////////
150
+
151
+    void screenShot(char *filenameBase);
152
+    /*------------------------------------------------------
153
+     * Pre  :
154
+     * Post : Makes a screenshot, writes to disk as file
155
+     *
156
+     *-- History ------------------------------------------
157
+     *
158
+     * 2002.12.20:
159
+     * Mongoose - Created, factored out of OpenRaider class
160
+     ------------------------------------------------------*/
161
+
162
+    int getMode();
163
+    /*------------------------------------------------------
164
+     * Pre  :
165
+     * Post : Gets current rendering mode
166
+     *
167
+     *-- History ------------------------------------------
168
+     *
169
+     * 2001.05.21:
170
+     * Mongoose - Created
171
+     ------------------------------------------------------*/
172
+
173
+
174
+    ////////////////////////////////////////////////////////////
175
+    // Public Mutators
176
+    ////////////////////////////////////////////////////////////
177
+
178
+    void addRoom(RenderRoom *rRoom);
179
+    /*------------------------------------------------------
180
+     * Pre  :
181
+     * Post :
182
+     *
183
+     *-- History ------------------------------------------
184
+     *
185
+     * 2002.12.21:
186
+     * Mongoose - Created, factored out of World
187
+     ------------------------------------------------------*/
188
+
189
+    void Init(int width, int height, bool fastCard);
190
+    /*------------------------------------------------------
191
+     * Pre  :
192
+     * Post : Starts and sets up OpenGL target
193
+     *
194
+     *-- History ------------------------------------------
195
+     *
196
+     * 2001.05.21:
197
+     * Mongoose - Created
198
+     ------------------------------------------------------*/
199
+
200
+    void loadTexture(unsigned char *image,
201
+                          unsigned int width, unsigned int height,
202
+                          unsigned int id);
203
+    /*------------------------------------------------------
204
+     * Pre  :
205
+     * Post : Loads textures in a certian id slot
206
+     *
207
+     *-- History ------------------------------------------
208
+     *
209
+     * 2002.12.20:
210
+     * Mongoose - Created, factored out of OpenRaider class
211
+     ------------------------------------------------------*/
212
+
213
+    void initTextures(char *textureDir, unsigned int *numLoaded,
214
+                            unsigned int *nextId);
215
+    /*------------------------------------------------------
216
+     * Pre  : textureDir is valid and exists with textures
217
+     * Post : Sets up textures for OpenRaider
218
+     *        Returns number of loaded textures and
219
+     *
220
+     *        numLoaded will update number of
221
+     *        external textures loaded
222
+     *
223
+     *        nextId will update next level texture id
224
+     *
225
+     *-- History ------------------------------------------
226
+     *
227
+     * 2002.12.20:
228
+     * Mongoose - Created, factored out of OpenRaider class
229
+     ------------------------------------------------------*/
230
+
231
+    void initEmitter(const char *name, unsigned int size,
232
+                          unsigned int snowTex1, unsigned int snowTex2);
233
+    /*------------------------------------------------------
234
+     * Pre  : Textures are init and these args are valid
235
+     * Post : Emitter is set up for rendering with 2 textures
236
+     *        in a overhead rain or snow like pattern
237
+     *
238
+     *-- History ------------------------------------------
239
+     *
240
+     * 2002.12.20:
241
+     * Mongoose - Created
242
+     ------------------------------------------------------*/
243
+
244
+    void ClearWorld();
245 245
   /*------------------------------------------------------
246 246
    * Pre  :
247 247
    * Post : Removes current world/entity/etc geometery
@@ -252,9 +252,9 @@ class Render
252 252
    * Mongoose - Created
253 253
    ------------------------------------------------------*/
254 254
 
255
-	void toggleFlag(unsigned int flag);
256
-	void clearFlags(unsigned int flags);
257
-	void setFlags(unsigned int flags);
255
+    void toggleFlag(unsigned int flag);
256
+    void clearFlags(unsigned int flags);
257
+    void setFlags(unsigned int flags);
258 258
   /*------------------------------------------------------
259 259
    * Pre  : (Un)Sets bitflags for various control use
260 260
    * Post : Changes state of renderer in some way
@@ -265,7 +265,7 @@ class Render
265 265
    * Mongoose - Created
266 266
    ------------------------------------------------------*/
267 267
 
268
-	void setMode(int n);
268
+    void setMode(int n);
269 269
   /*------------------------------------------------------
270 270
    * Pre  :
271 271
    * Post :
@@ -276,7 +276,7 @@ class Render
276 276
    * Mongoose - Created
277 277
    ------------------------------------------------------*/
278 278
 
279
-	void Update(int width, int height);
279
+    void Update(int width, int height);
280 280
   /*------------------------------------------------------
281 281
    * Pre  :
282 282
    * Post :
@@ -287,7 +287,7 @@ class Render
287 287
    * Mongoose - Created
288 288
    ------------------------------------------------------*/
289 289
 
290
-	void Display();
290
+    void Display();
291 291
   /*------------------------------------------------------
292 292
    * Pre  :
293 293
    * Post : Renders a single game frame
@@ -298,7 +298,7 @@ class Render
298 298
    * Mongoose - Created
299 299
    ------------------------------------------------------*/
300 300
 
301
-	void setSkyMesh(int index, bool rot);
301
+    void setSkyMesh(int index, bool rot);
302 302
   /*------------------------------------------------------
303 303
    * Pre  :
304 304
    * Post :
@@ -309,7 +309,7 @@ class Render
309 309
    * Mongoose - Created
310 310
    ------------------------------------------------------*/
311 311
 
312
-	void ViewModel(entity_t *ent, int index);
312
+    void ViewModel(entity_t *ent, int index);
313 313
   /*------------------------------------------------------
314 314
    * Pre  :
315 315
    * Post :
@@ -320,7 +320,7 @@ class Render
320 320
    * Mongoose - Created
321 321
    ------------------------------------------------------*/
322 322
 
323
-	void RegisterCamera(Camera *camera);
323
+    void RegisterCamera(Camera *camera);
324 324
   /*------------------------------------------------------
325 325
    * Pre  :
326 326
    * Post :
@@ -342,7 +342,7 @@ class Render
342 342
     * Mongoose - Created
343 343
     ------------------------------------------------------*/
344 344
 
345
-	//! \fixme Should be private
345
+    //! \fixme Should be private
346 346
    void drawLoadScreen();
347 347
    /*------------------------------------------------------
348 348
     * Pre  : Texture is init
@@ -354,7 +354,7 @@ class Render
354 354
     * Mongoose - Created
355 355
     ------------------------------------------------------*/
356 356
 
357
-	void addSkeletalModel(SkeletalModel *mdl);
357
+    void addSkeletalModel(SkeletalModel *mdl);
358 358
    /*------------------------------------------------------
359 359
     * Pre  :
360 360
     * Post :
@@ -368,53 +368,53 @@ class Render
368 368
 
369 369
 private:
370 370
 
371
-	////////////////////////////////////////////////////////////
372
-	// Private Accessors
373
-	////////////////////////////////////////////////////////////
374
-
375
-	bool isVisible(float bboxMin[3], float bboxMax[3]);
376
-	/*------------------------------------------------------
377
-	 * Pre  : Abstract bounding box must be valid
378
-	 * Post : If object's bounding box is in viewing volume
379
-	 *        return true, else false
380
-	 *
381
-	 *-- History ------------------------------------------
382
-	 *
383
-	 * 2002.12.16:
384
-	 * Mongoose - Moved to Render class
385
-	 *
386
-	 * 2001.06.06:
387
-	 * Mongoose - Created
388
-	 ------------------------------------------------------*/
389
-
390
-	bool isVisible(float x, float y, float z);
391
-	/*------------------------------------------------------
392
-	 * Pre  :
393
-	 * Post : Is point in view volume?
394
-	 *
395
-	 *-- History ------------------------------------------
396
-	 *
397
-	 * 2002.12.16:
398
-	 * Mongoose - Created
399
-	 ------------------------------------------------------*/
400
-
401
-	bool isVisible(float x, float y, float z, float radius);
402
-	/*------------------------------------------------------
403
-	 * Pre  :
404
-	 * Post : Is sphere in view volume?
405
-	 *
406
-	 *-- History ------------------------------------------
407
-	 *
408
-	 * 2002.12.16:
409
-	 * Mongoose - Created
410
-	 ------------------------------------------------------*/
411
-
412
-
413
-	////////////////////////////////////////////////////////////
414
-	// Private Mutators
415
-	////////////////////////////////////////////////////////////
416
-
417
-	void newRoomRenderList(int index);
371
+    ////////////////////////////////////////////////////////////
372
+    // Private Accessors
373
+    ////////////////////////////////////////////////////////////
374
+
375
+    bool isVisible(float bboxMin[3], float bboxMax[3]);
376
+    /*------------------------------------------------------
377
+     * Pre  : Abstract bounding box must be valid
378
+     * Post : If object's bounding box is in viewing volume
379
+     *        return true, else false
380
+     *
381
+     *-- History ------------------------------------------
382
+     *
383
+     * 2002.12.16:
384
+     * Mongoose - Moved to Render class
385
+     *
386
+     * 2001.06.06:
387
+     * Mongoose - Created
388
+     ------------------------------------------------------*/
389
+
390
+    bool isVisible(float x, float y, float z);
391
+    /*------------------------------------------------------
392
+     * Pre  :
393
+     * Post : Is point in view volume?
394
+     *
395
+     *-- History ------------------------------------------
396
+     *
397
+     * 2002.12.16:
398
+     * Mongoose - Created
399
+     ------------------------------------------------------*/
400
+
401
+    bool isVisible(float x, float y, float z, float radius);
402
+    /*------------------------------------------------------
403
+     * Pre  :
404
+     * Post : Is sphere in view volume?
405
+     *
406
+     *-- History ------------------------------------------
407
+     *
408
+     * 2002.12.16:
409
+     * Mongoose - Created
410
+     ------------------------------------------------------*/
411
+
412
+
413
+    ////////////////////////////////////////////////////////////
414
+    // Private Mutators
415
+    ////////////////////////////////////////////////////////////
416
+
417
+    void newRoomRenderList(int index);
418 418
    /*------------------------------------------------------
419 419
     * Pre  : room index is valid
420 420
     * Post : Build a visible room list starting at index
@@ -425,12 +425,12 @@ private:
425 425
     * Mongoose - Created
426 426
     ------------------------------------------------------*/
427 427
 
428
-	void buildRoomRenderList(RenderRoom *room);
428
+    void buildRoomRenderList(RenderRoom *room);
429 429
    /*------------------------------------------------------
430 430
     * Pre  : room is valid
431 431
     * Post : Build a visible room list starting from room
432
-	 *        and only consider it's linked rooms and their
433
-	 *        linked rooms
432
+     *        and only consider it's linked rooms and their
433
+     *        linked rooms
434 434
     *
435 435
     *-- History ------------------------------------------
436 436
     *
@@ -438,7 +438,7 @@ private:
438 438
     * Mongoose - Created
439 439
     ------------------------------------------------------*/
440 440
 
441
-	void drawObjects();
441
+    void drawObjects();
442 442
    /*------------------------------------------------------
443 443
     * Pre  : Texture is init
444 444
     * Post : Renders visible world objects
@@ -449,10 +449,10 @@ private:
449 449
     * Mongoose - Created
450 450
     ------------------------------------------------------*/
451 451
 
452
-	void drawSkyMesh(float scale);
452
+    void drawSkyMesh(float scale);
453 453
    /*------------------------------------------------------
454 454
     * Pre  : Texture is init
455
-	 *        scale is correct for map size
455
+     *        scale is correct for map size
456 456
     * Post : Renders Sky domes/boxes/etc by scaling factor
457 457
     *
458 458
     *-- History ------------------------------------------
@@ -461,7 +461,7 @@ private:
461 461
     * Mongoose - Created
462 462
     ------------------------------------------------------*/
463 463
 
464
-	void drawModel(SkeletalModel *model);
464
+    void drawModel(SkeletalModel *model);
465 465
    /*------------------------------------------------------
466 466
     * Pre  : Texture is init
467 467
     * Post : Renders a skeletal model
@@ -472,15 +472,15 @@ private:
472 472
     * Mongoose - Created
473 473
     ------------------------------------------------------*/
474 474
 
475
-	void drawRoom(RenderRoom *rRoom, bool draw_alpha);
475
+    void drawRoom(RenderRoom *rRoom, bool draw_alpha);
476 476
    /*------------------------------------------------------
477 477
     * Pre  : Texture is init
478
-	 *        Draw all rooms with alpha false, then
479
-	 *        draw with alpha true
480
-	 *
478
+     *        Draw all rooms with alpha false, then
479
+     *        draw with alpha true
480
+     *
481 481
     * Post : Renders a room in 2 seperate passes to
482
-	 *        handle alpha, currently doesn't sort alpha
483
-	 *        but looks pretty good
482
+     *        handle alpha, currently doesn't sort alpha
483
+     *        but looks pretty good
484 484
     *
485 485
     *-- History ------------------------------------------
486 486
     *
@@ -488,7 +488,7 @@ private:
488 488
     * Mongoose - Created
489 489
     ------------------------------------------------------*/
490 490
 
491
-	void drawRoomModel(static_model_t *mesh);
491
+    void drawRoomModel(static_model_t *mesh);
492 492
    /*------------------------------------------------------
493 493
     * Pre  : Texture is init
494 494
     * Post : Renders static room model
@@ -499,7 +499,7 @@ private:
499 499
     * Mongoose - Created
500 500
     ------------------------------------------------------*/
501 501
 
502
-	void drawModelMesh(model_mesh_t *r_mesh, RenderMeshType type);
502
+    void drawModelMesh(model_mesh_t *r_mesh, RenderMeshType type);
503 503
    /*------------------------------------------------------
504 504
     * Pre  : Texture is init, type is object containing mesh
505 505
     * Post : Renders a mesh
@@ -510,7 +510,7 @@ private:
510 510
     * Mongoose - Created
511 511
     ------------------------------------------------------*/
512 512
 
513
-	void drawSprite(sprite_t *sprite);
513
+    void drawSprite(sprite_t *sprite);
514 514
    /*------------------------------------------------------
515 515
     * Pre  : Texture is init
516 516
     * Post : Renders a sprite
@@ -521,65 +521,65 @@ private:
521 521
     * Mongoose - Created
522 522
     ------------------------------------------------------*/
523 523
 
524
-	void updateViewVolume();
525
-	/*------------------------------------------------------
526
-	 * Pre  : Call once per render frame
527
-	 * Post : Updated view volume
528
-	 *
529
-	 *-- History ------------------------------------------
530
-	 *
531
-	 * 2002.12.16:
532
-	 * Mongoose - Created
533
-	 ------------------------------------------------------*/
534
-
535
-	void tmpRenderModelMesh(model_mesh_t *r_mesh, texture_tri_t *ttri);
536
-	/*------------------------------------------------------
537
-	 * Pre  :
538
-	 * Post : Let them eat cake...
539
-	 *
540
-	 *-- History ------------------------------------------
541
-	 *
542
-	 * 2003.05.19:
543
-	 * Mongoose - Created
544
-	 ------------------------------------------------------*/
524
+    void updateViewVolume();
525
+    /*------------------------------------------------------
526
+     * Pre  : Call once per render frame
527
+     * Post : Updated view volume
528
+     *
529
+     *-- History ------------------------------------------
530
+     *
531
+     * 2002.12.16:
532
+     * Mongoose - Created
533
+     ------------------------------------------------------*/
534
+
535
+    void tmpRenderModelMesh(model_mesh_t *r_mesh, texture_tri_t *ttri);
536
+    /*------------------------------------------------------
537
+     * Pre  :
538
+     * Post : Let them eat cake...
539
+     *
540
+     *-- History ------------------------------------------
541
+     *
542
+     * 2003.05.19:
543
+     * Mongoose - Created
544
+     ------------------------------------------------------*/
545 545
 
546 546
 
547 547
 
548 548
 #ifdef USING_EMITTER
549
-	Emitter *mEmitter;      /* Particle emitter test */
549
+    Emitter *mEmitter;      /* Particle emitter test */
550 550
 #endif
551 551
 
552
-	Texture mTexture;       /* Texture subsystem */
552
+    Texture mTexture;       /* Texture subsystem */
553 553
 
554
-	Camera *mCamera;        /* Camera subsystem */
554
+    Camera *mCamera;        /* Camera subsystem */
555 555
 
556
-	GLString mString;       /* GL Text subsystem */
556
+    GLString mString;       /* GL Text subsystem */
557 557
 
558
-	Vector<RenderRoom *> mRoomRenderList;
558
+    Vector<RenderRoom *> mRoomRenderList;
559 559
 
560
-	Vector<RenderRoom *> mRooms;
560
+    Vector<RenderRoom *> mRooms;
561 561
 
562
-	Vector<SkeletalModel *> mModels;
562
+    Vector<SkeletalModel *> mModels;
563 563
 
564
-	unsigned int mFlags;    /* Rendering flags */
564
+    unsigned int mFlags;    /* Rendering flags */
565 565
 
566
-	unsigned int mWidth;    /* Viewport width */
566
+    unsigned int mWidth;    /* Viewport width */
567 567
 
568
-	unsigned int mHeight;   /* Viewport height */
568
+    unsigned int mHeight;   /* Viewport height */
569 569
 
570
-	unsigned int mMode;     /* Rendering mode */
570
+    unsigned int mMode;     /* Rendering mode */
571 571
 
572
-	unsigned int *mNumTexturesLoaded;
572
+    unsigned int *mNumTexturesLoaded;
573 573
 
574
-	unsigned int *mNextTextureId;
574
+    unsigned int *mNextTextureId;
575 575
 
576
-	// float mSplash;
576
+    // float mSplash;
577 577
 
578
-	int mLock;
578
+    int mLock;
579 579
 
580
-	int mSkyMesh;           /* Skymesh model id */
580
+    int mSkyMesh;           /* Skymesh model id */
581 581
 
582
-	bool mSkyMeshRotation;  /* Should Skymesh be rotated? */
582
+    bool mSkyMeshRotation;  /* Should Skymesh be rotated? */
583 583
 };
584 584
 
585 585
 #endif

+ 168
- 168
include/SDLSystem.h Переглянути файл

@@ -35,88 +35,88 @@ class SDLSystem : public System
35 35
 {
36 36
  public:
37 37
 
38
-	////////////////////////////////////////////////////////////
39
-	// Constructors
40
-	////////////////////////////////////////////////////////////
41
-
42
-	SDLSystem();
43
-	/*------------------------------------------------------
44
-	 * Pre  :
45
-	 * Post : Constructs an object of SDLSystem
46
-	 *
47
-	 *-- History ------------------------------------------
48
-	 *
49
-	 * 2002.06.06:
50
-	 * Mongoose - Created
51
-	 ------------------------------------------------------*/
52
-
53
-	virtual ~SDLSystem();
54
-	/*------------------------------------------------------
55
-	 * Pre  : SDL object is allocated
56
-	 * Post : Deconstructs an object of SDLSystem
57
-	 *
58
-	 *-- History ------------------------------------------
59
-	 *
60
-	 * 2002.06.06:
61
-	 * Mongoose - Created
62
-	 ------------------------------------------------------*/
63
-
64
-
65
-	////////////////////////////////////////////////////////////
66
-	// Public Accessors
67
-	////////////////////////////////////////////////////////////
68
-
69
-	virtual unsigned int getTicks();
70
-	/*------------------------------------------------------
71
-	 * Pre  :
72
-	 * Post : Returns number of milliseconds since start of
73
-	 *        program
74
-	 *
75
-	 *-- History ------------------------------------------
76
-	 *
77
-	 * 2002.06.06:
78
-	 * Mongoose - Created
79
-	 ------------------------------------------------------*/
80
-
81
-
82
-	////////////////////////////////////////////////////////////
83
-	// Public Mutators
84
-	////////////////////////////////////////////////////////////
85
-
86
-	//FIXME: void bindKeyCommand(const char *cmd, int key, int event);
87
-	/*------------------------------------------------------
88
-	 * Pre  : <Cmd> is a valid command string
89
-	 *        <Key> is a valid keyboard code
90
-	 *        <Event> is a valid game event Id
91
-	 *
92
-	 * Post : Sets <Event> binding <Cmd> to <Key> press
93
-	 *
94
-	 *-- History ------------------------------------------
95
-	 *
96
-	 * 2003.06.03:
97
-	 * Mongoose - Created
98
-	 ------------------------------------------------------*/
38
+    ////////////////////////////////////////////////////////////
39
+    // Constructors
40
+    ////////////////////////////////////////////////////////////
41
+
42
+    SDLSystem();
43
+    /*------------------------------------------------------
44
+     * Pre  :
45
+     * Post : Constructs an object of SDLSystem
46
+     *
47
+     *-- History ------------------------------------------
48
+     *
49
+     * 2002.06.06:
50
+     * Mongoose - Created
51
+     ------------------------------------------------------*/
52
+
53
+    virtual ~SDLSystem();
54
+    /*------------------------------------------------------
55
+     * Pre  : SDL object is allocated
56
+     * Post : Deconstructs an object of SDLSystem
57
+     *
58
+     *-- History ------------------------------------------
59
+     *
60
+     * 2002.06.06:
61
+     * Mongoose - Created
62
+     ------------------------------------------------------*/
63
+
64
+
65
+    ////////////////////////////////////////////////////////////
66
+    // Public Accessors
67
+    ////////////////////////////////////////////////////////////
68
+
69
+    virtual unsigned int getTicks();
70
+    /*------------------------------------------------------
71
+     * Pre  :
72
+     * Post : Returns number of milliseconds since start of
73
+     *        program
74
+     *
75
+     *-- History ------------------------------------------
76
+     *
77
+     * 2002.06.06:
78
+     * Mongoose - Created
79
+     ------------------------------------------------------*/
80
+
81
+
82
+    ////////////////////////////////////////////////////////////
83
+    // Public Mutators
84
+    ////////////////////////////////////////////////////////////
85
+
86
+    //FIXME: void bindKeyCommand(const char *cmd, int key, int event);
87
+    /*------------------------------------------------------
88
+     * Pre  : <Cmd> is a valid command string
89
+     *        <Key> is a valid keyboard code
90
+     *        <Event> is a valid game event Id
91
+     *
92
+     * Post : Sets <Event> binding <Cmd> to <Key> press
93
+     *
94
+     *-- History ------------------------------------------
95
+     *
96
+     * 2003.06.03:
97
+     * Mongoose - Created
98
+     ------------------------------------------------------*/
99 99
 
100 100
    void glPrintf2d(float x, float y, char *string);
101 101
    /*------------------------------------------------------
102 102
     * Pre  : <X>, and <Y> are valid world coordinates
103
-	 *        <String> is a valid string
104
-	 *
105
-	 *        Requires glEnterMode2d() call before entry
106
-	 *
107
-	 *        System::bufferString(..) can cache printf()
108
-	 *        style calls for use with this method
109
-	 *
103
+     *        <String> is a valid string
104
+     *
105
+     *        Requires glEnterMode2d() call before entry
106
+     *
107
+     *        System::bufferString(..) can cache printf()
108
+     *        style calls for use with this method
109
+     *
110 110
     * Post : Renders string in OpenGL ( 2d projection )
111
-	 *
112
-	 *        Call glExitMode2d() after finishing calls
113
-	 *        to this method and other 2d rendering
111
+     *
112
+     *        Call glExitMode2d() after finishing calls
113
+     *        to this method and other 2d rendering
114 114
     *
115 115
     *-- History ------------------------------------------
116 116
     *
117
-	 * 2003.06.03:
118
-	 * Mongoose - Ported to SDL_TTF
119
-	 *
117
+     * 2003.06.03:
118
+     * Mongoose - Ported to SDL_TTF
119
+     *
120 120
     * 2001.12.31:
121 121
     * Mongoose - Created
122 122
     ------------------------------------------------------*/
@@ -124,101 +124,101 @@ class SDLSystem : public System
124 124
    void glPrintf3d(float x, float y, float z, char *string);
125 125
    /*------------------------------------------------------
126 126
     * Pre  : <X>, <Y>, and <Z> are valid world coordinates
127
-	 *        <String> is a valid string
128
-	 *
129
-	 *        System::bufferString(..) can cache printf()
130
-	 *        style calls for use with this method
131
-	 *
127
+     *        <String> is a valid string
128
+     *
129
+     *        System::bufferString(..) can cache printf()
130
+     *        style calls for use with this method
131
+     *
132 132
     * Post : Renders string in OpenGL ( 3d projection )
133 133
     *
134 134
     *-- History ------------------------------------------
135 135
     *
136
-	 * 2003.06.03:
137
-	 * Mongoose - Ported to SDL_TTF
138
-	 *
136
+     * 2003.06.03:
137
+     * Mongoose - Ported to SDL_TTF
138
+     *
139 139
     * 2001.12.31:
140 140
     * Mongoose - Created
141 141
     ------------------------------------------------------*/
142 142
 
143
-	void initVideo(unsigned int width, unsigned int height,
144
-						bool fullscreen);
145
-	/*------------------------------------------------------
146
-	 * Pre  : Video mode request <Width> x <Height>
147
-	 *        <Fullscreen> enables fullscreen rendering
148
-	 *
149
-	 * Post : Start up video subsystem
150
-	 *
151
-	 *-- History ------------------------------------------
152
-	 *
153
-	 * 2002.06.06:
154
-	 * Mongoose - Created
155
-	 ------------------------------------------------------*/
156
-
157
-	void resize(unsigned int width, unsigned int height);
158
-	/*------------------------------------------------------
159
-	 * Pre  :
160
-	 * Post : Resizes game window
161
-	 *
162
-	 *-- History ------------------------------------------
163
-	 *
164
-	 * 2002.06.06:
165
-	 * Mongoose - Created, from old SDLUnitTest code
166
-	 ------------------------------------------------------*/
167
-
168
-	void runGame();
169
-	/*------------------------------------------------------
170
-	 * Pre  :
171
-	 * Post : Start game loop
172
-	 *
173
-	 *-- History ------------------------------------------
174
-	 *
175
-	 * 2002.06.06:
176
-	 * Mongoose - Created
177
-	 ------------------------------------------------------*/
178
-
179
-	void setGrabMouse(bool on);
180
-	/*------------------------------------------------------
181
-	 * Pre  :
182
-	 * Post :
183
-	 *
184
-	 *-- History ------------------------------------------
185
-	 *
186
-	 * 2003.01.05:
187
-	 * Mongoose - Created
188
-	 ------------------------------------------------------*/
189
-
190
-	void shutdown(int i);
191
-	/*------------------------------------------------------
192
-	 * Pre  :
193
-	 * Post : Shutsdown the game subsystems, exits game loop
194
-	 *
195
-	 *-- History ------------------------------------------
196
-	 *
197
-	 * 2002.06.06:
198
-	 * Mongoose - Created
199
-	 ------------------------------------------------------*/
200
-
201
-	void swapBuffersGL();
202
-	/*------------------------------------------------------
203
-	 * Pre  :
204
-	 * Post : Swaps OpenGL buufers ( call at end of frame )
205
-	 *
206
-	 *-- History ------------------------------------------
207
-	 *
208
-	 * 2002.06.06:
209
-	 * Mongoose - Created
210
-	 ------------------------------------------------------*/
211
-
212
-	void toggleFullscreen();
213
-	/*------------------------------------------------------
214
-	 * Pre  :
215
-	 * Post : Toggle fullscreen windowing mode
216
-	 *
217
-	 *-- History ------------------------------------------
218
-	 *
219
-	 * 2002.06.06:
220
-	 * Mongoose - Created
221
-	 ------------------------------------------------------*/
143
+    void initVideo(unsigned int width, unsigned int height,
144
+                        bool fullscreen);
145
+    /*------------------------------------------------------
146
+     * Pre  : Video mode request <Width> x <Height>
147
+     *        <Fullscreen> enables fullscreen rendering
148
+     *
149
+     * Post : Start up video subsystem
150
+     *
151
+     *-- History ------------------------------------------
152
+     *
153
+     * 2002.06.06:
154
+     * Mongoose - Created
155
+     ------------------------------------------------------*/
156
+
157
+    void resize(unsigned int width, unsigned int height);
158
+    /*------------------------------------------------------
159
+     * Pre  :
160
+     * Post : Resizes game window
161
+     *
162
+     *-- History ------------------------------------------
163
+     *
164
+     * 2002.06.06:
165
+     * Mongoose - Created, from old SDLUnitTest code
166
+     ------------------------------------------------------*/
167
+
168
+    void runGame();
169
+    /*------------------------------------------------------
170
+     * Pre  :
171
+     * Post : Start game loop
172
+     *
173
+     *-- History ------------------------------------------
174
+     *
175
+     * 2002.06.06:
176
+     * Mongoose - Created
177
+     ------------------------------------------------------*/
178
+
179
+    void setGrabMouse(bool on);
180
+    /*------------------------------------------------------
181
+     * Pre  :
182
+     * Post :
183
+     *
184
+     *-- History ------------------------------------------
185
+     *
186
+     * 2003.01.05:
187
+     * Mongoose - Created
188
+     ------------------------------------------------------*/
189
+
190
+    void shutdown(int i);
191
+    /*------------------------------------------------------
192
+     * Pre  :
193
+     * Post : Shutsdown the game subsystems, exits game loop
194
+     *
195
+     *-- History ------------------------------------------
196
+     *
197
+     * 2002.06.06:
198
+     * Mongoose - Created
199
+     ------------------------------------------------------*/
200
+
201
+    void swapBuffersGL();
202
+    /*------------------------------------------------------
203
+     * Pre  :
204
+     * Post : Swaps OpenGL buufers ( call at end of frame )
205
+     *
206
+     *-- History ------------------------------------------
207
+     *
208
+     * 2002.06.06:
209
+     * Mongoose - Created
210
+     ------------------------------------------------------*/
211
+
212
+    void toggleFullscreen();
213
+    /*------------------------------------------------------
214
+     * Pre  :
215
+     * Post : Toggle fullscreen windowing mode
216
+     *
217
+     *-- History ------------------------------------------
218
+     *
219
+     * 2002.06.06:
220
+     * Mongoose - Created
221
+     ------------------------------------------------------*/
222 222
 
223 223
  protected:
224 224
     int m_old_width;
@@ -228,15 +228,15 @@ class SDLSystem : public System
228 228
 
229 229
  private:
230 230
 
231
-	////////////////////////////////////////////////////////////
232
-	// Private Accessors
233
-	////////////////////////////////////////////////////////////
231
+    ////////////////////////////////////////////////////////////
232
+    // Private Accessors
233
+    ////////////////////////////////////////////////////////////
234 234
 
235 235
 
236
-	////////////////////////////////////////////////////////////
237
-	// Private Mutators
238
-	////////////////////////////////////////////////////////////
236
+    ////////////////////////////////////////////////////////////
237
+    // Private Mutators
238
+    ////////////////////////////////////////////////////////////
239 239
 
240
-	SDL_Surface *mWindow;	/* This is the pointer to the SDL surface */
240
+    SDL_Surface *mWindow;   /* This is the pointer to the SDL surface */
241 241
 };
242 242
 #endif

+ 72
- 72
include/SkeletalModel.h Переглянути файл

@@ -20,45 +20,45 @@
20 20
 
21 21
 typedef struct bone_tag_s
22 22
 {
23
-	int mesh;
24
-	vec3_t off;
25
-	vec3_t rot;
26
-	char flag;
23
+    int mesh;
24
+    vec3_t off;
25
+    vec3_t rot;
26
+    char flag;
27 27
 
28 28
 } bone_tag_t;
29 29
 
30 30
 
31 31
 typedef struct bone_frame_s
32 32
 {
33
-	Vector<bone_tag_t *> tag;
34
-	vec3_t pos;
35
-	float yaw;
33
+    Vector<bone_tag_t *> tag;
34
+    vec3_t pos;
35
+    float yaw;
36 36
 
37 37
 } bone_frame_t;
38 38
 
39 39
 
40 40
 typedef struct animation_frame_s
41 41
 {
42
-	int id;
43
-	char rate;
44
-	Vector<bone_frame_t *> frame;
42
+    int id;
43
+    char rate;
44
+    Vector<bone_frame_t *> frame;
45 45
 
46 46
 } animation_frame_t;
47 47
 
48 48
 
49 49
 typedef struct skeletal_model_s
50 50
 {
51
-	int id;
52
-	bool tr4Overlay;
53
-	bool pigtails;
54
-	int ponytailId;
55
-	vec3_t ponytail;
56
-	int ponytailMeshId;
57
-	unsigned int ponytailNumMeshes;
58
-	float ponytailAngle;
59
-	float ponyOff;
60
-	float ponyOff2;
61
-	Vector<animation_frame_t *> animation;
51
+    int id;
52
+    bool tr4Overlay;
53
+    bool pigtails;
54
+    int ponytailId;
55
+    vec3_t ponytail;
56
+    int ponytailMeshId;
57
+    unsigned int ponytailNumMeshes;
58
+    float ponytailAngle;
59
+    float ponyOff;
60
+    float ponyOff2;
61
+    Vector<animation_frame_t *> animation;
62 62
 
63 63
 } skeletal_model_t;
64 64
 
@@ -67,83 +67,83 @@ class SkeletalModel
67 67
 {
68 68
  public:
69 69
 
70
-	////////////////////////////////////////////////////////////
71
-	// Constructors
72
-	////////////////////////////////////////////////////////////
70
+    ////////////////////////////////////////////////////////////
71
+    // Constructors
72
+    ////////////////////////////////////////////////////////////
73 73
 
74
-	SkeletalModel();
75
-	/*------------------------------------------------------
76
-	 * Pre  :
77
-	 * Post : Constructs an object of SkeletalModel
78
-	 *
79
-	 *-- History ------------------------------------------
80
-	 *
81
-	 * 2003.05.19:
82
-	 * Mongoose - Created
83
-	 ------------------------------------------------------*/
74
+    SkeletalModel();
75
+    /*------------------------------------------------------
76
+     * Pre  :
77
+     * Post : Constructs an object of SkeletalModel
78
+     *
79
+     *-- History ------------------------------------------
80
+     *
81
+     * 2003.05.19:
82
+     * Mongoose - Created
83
+     ------------------------------------------------------*/
84 84
 
85
-	~SkeletalModel();
86
-	/*------------------------------------------------------
87
-	 * Pre  : SkeletalModel object is allocated
88
-	 * Post : Deconstructs an object of SkeletalModel
89
-	 *
90
-	 *-- History ------------------------------------------
91
-	 *
92
-	 * 2003.05.19:
93
-	 * Mongoose - Created
94
-	 ------------------------------------------------------*/
85
+    ~SkeletalModel();
86
+    /*------------------------------------------------------
87
+     * Pre  : SkeletalModel object is allocated
88
+     * Post : Deconstructs an object of SkeletalModel
89
+     *
90
+     *-- History ------------------------------------------
91
+     *
92
+     * 2003.05.19:
93
+     * Mongoose - Created
94
+     ------------------------------------------------------*/
95 95
 
96 96
 
97
-	////////////////////////////////////////////////////////////
98
-	// Public Accessors
99
-	////////////////////////////////////////////////////////////
97
+    ////////////////////////////////////////////////////////////
98
+    // Public Accessors
99
+    ////////////////////////////////////////////////////////////
100 100
 
101
-	int getAnimation();
101
+    int getAnimation();
102 102
 
103
-	int getFrame() ;
103
+    int getFrame() ;
104 104
 
105
-	int getIdleAnimation();
105
+    int getIdleAnimation();
106 106
 
107 107
 
108
-	////////////////////////////////////////////////////////////
109
-	// Public Mutators
110
-	////////////////////////////////////////////////////////////
108
+    ////////////////////////////////////////////////////////////
109
+    // Public Mutators
110
+    ////////////////////////////////////////////////////////////
111 111
 
112
-	void setModel(skeletal_model_t *mdl);
112
+    void setModel(skeletal_model_t *mdl);
113 113
 
114
-	void setAnimation(int index);
114
+    void setAnimation(int index);
115 115
 
116
-	void setFrame(int index);
116
+    void setFrame(int index);
117 117
 
118
-	void setIdleAnimation(int index);
118
+    void setIdleAnimation(int index);
119 119
 
120 120
 
121
-	enum SkeletalModelFlag { fReserved = 1 };
121
+    enum SkeletalModelFlag { fReserved = 1 };
122 122
 
123
-	unsigned int flags;
123
+    unsigned int flags;
124 124
 
125
-	skeletal_model_t *model;   /* World render model */
125
+    skeletal_model_t *model;   /* World render model */
126 126
 
127
-	float time;                /* Interpolation use */
128
-	float lastTime;
127
+    float time;                /* Interpolation use */
128
+    float lastTime;
129 129
 
130
-	float rate; // temp cache this here for old animation system use
130
+    float rate; // temp cache this here for old animation system use
131 131
 
132 132
 private:
133 133
 
134
-	////////////////////////////////////////////////////////////
135
-	// Private Accessors
136
-	////////////////////////////////////////////////////////////
134
+    ////////////////////////////////////////////////////////////
135
+    // Private Accessors
136
+    ////////////////////////////////////////////////////////////
137 137
 
138 138
 
139
-	////////////////////////////////////////////////////////////
140
-	// Private Mutators
141
-	////////////////////////////////////////////////////////////
139
+    ////////////////////////////////////////////////////////////
140
+    // Private Mutators
141
+    ////////////////////////////////////////////////////////////
142 142
 
143 143
 
144
-	int mBoneFrame;             /* Bone frame */
145
-	int mAnimationFrame;        /* Animation frame */
146
-	int mIdleAnimation;         /* Idle animation */
144
+    int mBoneFrame;             /* Bone frame */
145
+    int mAnimationFrame;        /* Animation frame */
146
+    int mIdleAnimation;         /* Idle animation */
147 147
 };
148 148
 
149 149
 #endif

+ 406
- 406
include/Texture.h Переглянути файл

@@ -36,41 +36,41 @@
36 36
 
37 37
 typedef struct
38 38
 {
39
-	int x, y, w, h;
40
-	int minx; int maxx; int miny; int maxy; int advance;
39
+    int x, y, w, h;
40
+    int minx; int maxx; int miny; int maxy; int advance;
41 41
 
42 42
 } ttf_glyph_t;
43 43
 
44 44
 typedef struct
45 45
 {
46
-	unsigned int utf8Offset;
47
-	unsigned int count;
46
+    unsigned int utf8Offset;
47
+    unsigned int count;
48 48
 
49 49
 /* [utf8Offset -> utf8Offset+count],
50
-	 matches indexing into glyphs[0 -> count] for texcoords, etc
51
-	----------------------------------------
52
-	41     -> 126     ASCII English w/ special chars,
53
-	0x303f -> 0x3093  Japanese hiragana kana,
54
-	0x301a -> 0x30f6  Japanese katakana kana */
50
+     matches indexing into glyphs[0 -> count] for texcoords, etc
51
+    ----------------------------------------
52
+    41     -> 126     ASCII English w/ special chars,
53
+    0x303f -> 0x3093  Japanese hiragana kana,
54
+    0x301a -> 0x30f6  Japanese katakana kana */
55 55
 
56
-	unsigned int width;     /* Width and height of RGBA texture */
57
-	unsigned char *texture; /* RGBA texture data */
56
+    unsigned int width;     /* Width and height of RGBA texture */
57
+    unsigned char *texture; /* RGBA texture data */
58 58
 
59
-	ttf_glyph_t *glyphs;    /* For typesetting and rendering use */
60
-	int fontHeight;
61
-	int fontAscent;
62
-	int fontDescent;
63
-	int fontSpacing;
59
+    ttf_glyph_t *glyphs;    /* For typesetting and rendering use */
60
+    int fontHeight;
61
+    int fontAscent;
62
+    int fontDescent;
63
+    int fontSpacing;
64 64
 
65 65
 } ttf_texture_t;
66 66
 
67 67
 
68 68
 typedef struct
69 69
 {
70
-	unsigned int utf8Offset;
71
-	unsigned int count;
72
-	int textureId;
73
-	int drawListBase;
70
+    unsigned int utf8Offset;
71
+    unsigned int count;
72
+    int textureId;
73
+    int drawListBase;
74 74
 
75 75
 } gl_font_t;
76 76
 
@@ -80,399 +80,399 @@ class Texture
80 80
 {
81 81
  public:
82 82
 
83
-	enum ColorMode
84
-	{
85
-		GREYSCALE = 1,
86
-		RGB,
87
-		RGBA,
88
-		ARGB
89
-	};
90
-
91
-	enum TextureFlag
92
-	{
93
-		fUseMipmaps			= (1 << 0),
94
-		fUseMultiTexture	= (1 << 1),
83
+    enum ColorMode
84
+    {
85
+        GREYSCALE = 1,
86
+        RGB,
87
+        RGBA,
88
+        ARGB
89
+    };
90
+
91
+    enum TextureFlag
92
+    {
93
+        fUseMipmaps         = (1 << 0),
94
+        fUseMultiTexture    = (1 << 1),
95 95
         fUseSDL_TTF         = (1 << 2)
96
-	};
96
+    };
97 97
 
98 98
 
99
-	////////////////////////////////////////////////////////////
100
-	// Constructors
101
-	////////////////////////////////////////////////////////////
99
+    ////////////////////////////////////////////////////////////
100
+    // Constructors
101
+    ////////////////////////////////////////////////////////////
102 102
 
103 103
    Texture();
104
-	/*------------------------------------------------------
105
-	 * Pre  :
106
-	 * Post : Constructs an object of Texture
107
-	 *
108
-	 *-- History ------------------------------------------
109
-	 *
110
-	 * 2001.05.29:
111
-	 * Mongoose - Big code clean up, documentation
112
-	 *
113
-	 * 2000.10.05:
114
-	 * Mongoose - Created
115
-	 ------------------------------------------------------*/
104
+    /*------------------------------------------------------
105
+     * Pre  :
106
+     * Post : Constructs an object of Texture
107
+     *
108
+     *-- History ------------------------------------------
109
+     *
110
+     * 2001.05.29:
111
+     * Mongoose - Big code clean up, documentation
112
+     *
113
+     * 2000.10.05:
114
+     * Mongoose - Created
115
+     ------------------------------------------------------*/
116 116
 
117 117
    ~Texture();
118
-	/*------------------------------------------------------
119
-	 * Pre  : This object exists
120
-	 * Post : Deconstructs an object of Texture
121
-	 *
122
-	 *-- History ------------------------------------------
123
-	 *
124
-	 * 2001.05.29:
125
-	 * Mongoose - Big code clean up, documentation
126
-	 *
127
-	 * 2000.10.05:
128
-	 * Mongoose - Created
129
-	 ------------------------------------------------------*/
130
-
131
-
132
-	////////////////////////////////////////////////////////////
133
-	// Public Accessors
134
-	////////////////////////////////////////////////////////////
135
-
136
-	static unsigned char *generateColorTexture(unsigned char rgba[4],
137
-															 unsigned int width,
138
-															 unsigned int height);
139
-	/*------------------------------------------------------
140
-	 * Pre  : <Rgba> is 32bpp RGBA color
141
-	 *        <Width> and <Height> are powers of two, pref
142
-	 *        the same number
143
-	 * Post :
144
-	 *
145
-	 *-- History ------------------------------------------
146
-	 *
147
-	 * 2003.06.30:
148
-	 * Mongoose - Created
149
-	 ------------------------------------------------------*/
150
-
151
-	gl_font_t *generateFont(ttf_texture_t *texture);
152
-	/*------------------------------------------------------
153
-	 * Pre  :
154
-	 * Post :
155
-	 *
156
-	 *-- History ------------------------------------------
157
-	 *
158
-	 * 2003.06.30:
159
-	 * Mongoose - Created
160
-	 ------------------------------------------------------*/
161
-
162
-	ttf_texture_t *generateFontTexture(const char *filename, int pointSize,
163
-												  unsigned int textureWidth,
164
-												  unsigned char color[3],
165
-												  unsigned int utf8Offset,
166
-												  unsigned int count,
167
-												  char verbose);
168
-	/*------------------------------------------------------
169
-	 * Pre  : <Filename> of TTF font
170
-	 *        <PointSize> to generate
171
-	 *        <TextureWidth> is width of texture, height will match it
172
-	 *        <Color> is RGB 24bit color
173
-	 *        <Utf8Offset> is offset into font's encoding chart
174
-	 *        <Count> is number of glyphs to read from offset start
175
-	 *        <Verbose> dumps debug info to stdout
176
-	 *
177
-	 * Post : Generates a font texture with typeset info from TTF
178
-	 *
179
-	 *        DOES NOT load the texture itself, call loadFont()
180
-	 *        on returned ttf_texture_t
181
-	 *
182
-	 *
183
-	 *-- History ------------------------------------------
184
-	 *
185
-	 * 2003.06.03:
186
-	 * Mongoose - Created
187
-	 ------------------------------------------------------*/
118
+    /*------------------------------------------------------
119
+     * Pre  : This object exists
120
+     * Post : Deconstructs an object of Texture
121
+     *
122
+     *-- History ------------------------------------------
123
+     *
124
+     * 2001.05.29:
125
+     * Mongoose - Big code clean up, documentation
126
+     *
127
+     * 2000.10.05:
128
+     * Mongoose - Created
129
+     ------------------------------------------------------*/
130
+
131
+
132
+    ////////////////////////////////////////////////////////////
133
+    // Public Accessors
134
+    ////////////////////////////////////////////////////////////
135
+
136
+    static unsigned char *generateColorTexture(unsigned char rgba[4],
137
+                                                             unsigned int width,
138
+                                                             unsigned int height);
139
+    /*------------------------------------------------------
140
+     * Pre  : <Rgba> is 32bpp RGBA color
141
+     *        <Width> and <Height> are powers of two, pref
142
+     *        the same number
143
+     * Post :
144
+     *
145
+     *-- History ------------------------------------------
146
+     *
147
+     * 2003.06.30:
148
+     * Mongoose - Created
149
+     ------------------------------------------------------*/
150
+
151
+    gl_font_t *generateFont(ttf_texture_t *texture);
152
+    /*------------------------------------------------------
153
+     * Pre  :
154
+     * Post :
155
+     *
156
+     *-- History ------------------------------------------
157
+     *
158
+     * 2003.06.30:
159
+     * Mongoose - Created
160
+     ------------------------------------------------------*/
161
+
162
+    ttf_texture_t *generateFontTexture(const char *filename, int pointSize,
163
+                                                  unsigned int textureWidth,
164
+                                                  unsigned char color[3],
165
+                                                  unsigned int utf8Offset,
166
+                                                  unsigned int count,
167
+                                                  char verbose);
168
+    /*------------------------------------------------------
169
+     * Pre  : <Filename> of TTF font
170
+     *        <PointSize> to generate
171
+     *        <TextureWidth> is width of texture, height will match it
172
+     *        <Color> is RGB 24bit color
173
+     *        <Utf8Offset> is offset into font's encoding chart
174
+     *        <Count> is number of glyphs to read from offset start
175
+     *        <Verbose> dumps debug info to stdout
176
+     *
177
+     * Post : Generates a font texture with typeset info from TTF
178
+     *
179
+     *        DOES NOT load the texture itself, call loadFont()
180
+     *        on returned ttf_texture_t
181
+     *
182
+     *
183
+     *-- History ------------------------------------------
184
+     *
185
+     * 2003.06.03:
186
+     * Mongoose - Created
187
+     ------------------------------------------------------*/
188 188
 
189 189
    int getTextureCount();
190
-	/*------------------------------------------------------
191
-	 * Pre  :
192
-	 * Post : Returns number of textures in use, or -1 for
193
-	 *        error ( Not initalized )
194
-	 *
195
-	 *-- History ------------------------------------------
196
-	 *
197
-	 * 2001.05.29:
198
-	 * Mongoose - Big code clean up, documentation
199
-	 *
200
-	 * 2000.10.05:
201
-	 * Mongoose - Created
202
-	 ------------------------------------------------------*/
203
-
204
-	void glScreenShot(char *base, unsigned int width, unsigned int height);
205
-	/*------------------------------------------------------
206
-	 * Pre  : <Base> is base filename,
207
-	 *        <Width> and <Height> are viewport dim
208
-	 *
209
-	 * Post : Dumps a screenshot to disk,
210
-	 *        avoids overwriting files with same base name
211
-	 *
212
-	 *-- History ------------------------------------------
213
-	 *
214
-	 * 2002.06.16:
215
-	 * Mongoose - Created
216
-	 ------------------------------------------------------*/
217
-
218
-
219
-	////////////////////////////////////////////////////////////
220
-	// Public Mutators
221
-	////////////////////////////////////////////////////////////
222
-
223
-	void bindMultiTexture(int texture0, int texture1);
224
-	/*------------------------------------------------------
225
-	 * Pre  :
226
-	 * Post : Sets up multitexture rendering with passed texture ids
227
-	 *
228
-	 *-- History ------------------------------------------
229
-	 *
230
-	 * 2002.12.24:
231
-	 * Mongoose - Created
232
-	 ------------------------------------------------------*/
190
+    /*------------------------------------------------------
191
+     * Pre  :
192
+     * Post : Returns number of textures in use, or -1 for
193
+     *        error ( Not initalized )
194
+     *
195
+     *-- History ------------------------------------------
196
+     *
197
+     * 2001.05.29:
198
+     * Mongoose - Big code clean up, documentation
199
+     *
200
+     * 2000.10.05:
201
+     * Mongoose - Created
202
+     ------------------------------------------------------*/
203
+
204
+    void glScreenShot(char *base, unsigned int width, unsigned int height);
205
+    /*------------------------------------------------------
206
+     * Pre  : <Base> is base filename,
207
+     *        <Width> and <Height> are viewport dim
208
+     *
209
+     * Post : Dumps a screenshot to disk,
210
+     *        avoids overwriting files with same base name
211
+     *
212
+     *-- History ------------------------------------------
213
+     *
214
+     * 2002.06.16:
215
+     * Mongoose - Created
216
+     ------------------------------------------------------*/
217
+
218
+
219
+    ////////////////////////////////////////////////////////////
220
+    // Public Mutators
221
+    ////////////////////////////////////////////////////////////
222
+
223
+    void bindMultiTexture(int texture0, int texture1);
224
+    /*------------------------------------------------------
225
+     * Pre  :
226
+     * Post : Sets up multitexture rendering with passed texture ids
227
+     *
228
+     *-- History ------------------------------------------
229
+     *
230
+     * 2002.12.24:
231
+     * Mongoose - Created
232
+     ------------------------------------------------------*/
233 233
 
234 234
    void bindTextureId(unsigned int n);
235
-	/*------------------------------------------------------
236
-	 * Pre  : n is valid texture index
237
-	 * Post : Binds the texture for use in GL
238
-	 *
239
-	 *-- History ------------------------------------------
240
-	 *
241
-	 * 2001.05.29:
242
-	 * Mongoose - Big code clean up, documentation
243
-	 *
244
-	 * 2000.10.05:
245
-	 * Mongoose - Created
246
-	 ------------------------------------------------------*/
247
-
248
-	void clearFlag(TextureFlag flag);
249
-	/*------------------------------------------------------
250
-	 * Pre  :
251
-	 * Post : CLears a option flag
252
-	 *
253
-	 *-- History ------------------------------------------
254
-	 *
255
-	 * 2003.01.05:
256
-	 * Mongoose - Created
257
-	 ------------------------------------------------------*/
258
-
259
-	void disableMultiTexture();
260
-	/*------------------------------------------------------
261
-	 * Pre  :
262
-	 * Post :
263
-	 *
264
-	 *-- History ------------------------------------------
265
-	 *
266
-	 * 2002.12.24:
267
-	 * Mongoose - Created
268
-	 ------------------------------------------------------*/
269
-
270
-	void initSDL_TTF();
271
-	/*------------------------------------------------------
272
-	 * Pre  :
273
-	 * Post : Loads SDL_TTF if avalible
274
-	 *
275
-	 *-- History ------------------------------------------
276
-	 *
277
-	 * 2003.06.03:
278
-	 * Mongoose - Created
279
-	 ------------------------------------------------------*/
235
+    /*------------------------------------------------------
236
+     * Pre  : n is valid texture index
237
+     * Post : Binds the texture for use in GL
238
+     *
239
+     *-- History ------------------------------------------
240
+     *
241
+     * 2001.05.29:
242
+     * Mongoose - Big code clean up, documentation
243
+     *
244
+     * 2000.10.05:
245
+     * Mongoose - Created
246
+     ------------------------------------------------------*/
247
+
248
+    void clearFlag(TextureFlag flag);
249
+    /*------------------------------------------------------
250
+     * Pre  :
251
+     * Post : CLears a option flag
252
+     *
253
+     *-- History ------------------------------------------
254
+     *
255
+     * 2003.01.05:
256
+     * Mongoose - Created
257
+     ------------------------------------------------------*/
258
+
259
+    void disableMultiTexture();
260
+    /*------------------------------------------------------
261
+     * Pre  :
262
+     * Post :
263
+     *
264
+     *-- History ------------------------------------------
265
+     *
266
+     * 2002.12.24:
267
+     * Mongoose - Created
268
+     ------------------------------------------------------*/
269
+
270
+    void initSDL_TTF();
271
+    /*------------------------------------------------------
272
+     * Pre  :
273
+     * Post : Loads SDL_TTF if avalible
274
+     *
275
+     *-- History ------------------------------------------
276
+     *
277
+     * 2003.06.03:
278
+     * Mongoose - Created
279
+     ------------------------------------------------------*/
280 280
 
281 281
    int loadBuffer(unsigned char *image,
282
-						unsigned int width, unsigned int height,
283
-						ColorMode mode, unsigned int bpp);
284
-	/*------------------------------------------------------
285
-	 * Pre  : image must be a valid pixmap that agrees
286
-	 *        with mode, width, and height
287
-	 *
288
-	 * Post : Returns texture id or < 0 error flag
289
-	 *
290
-	 *-- History ------------------------------------------
291
-	 *
292
-	 * 2001.05.29:
293
-	 * Mongoose - Big code clean up, documentation
294
-	 *
295
-	 * 2000.10.05:
296
-	 * Mongoose - Created
297
-	 ------------------------------------------------------*/
282
+                        unsigned int width, unsigned int height,
283
+                        ColorMode mode, unsigned int bpp);
284
+    /*------------------------------------------------------
285
+     * Pre  : image must be a valid pixmap that agrees
286
+     *        with mode, width, and height
287
+     *
288
+     * Post : Returns texture id or < 0 error flag
289
+     *
290
+     *-- History ------------------------------------------
291
+     *
292
+     * 2001.05.29:
293
+     * Mongoose - Big code clean up, documentation
294
+     *
295
+     * 2000.10.05:
296
+     * Mongoose - Created
297
+     ------------------------------------------------------*/
298 298
 
299 299
    int loadBufferSlot(unsigned char *image,
300
-							 unsigned int width, unsigned int height,
301
-							 ColorMode mode, unsigned int bpp,
302
-							 unsigned int slot);
303
-	/*------------------------------------------------------
304
-	 * Pre  : image must be a valid pixmap that agrees
305
-	 *        with mode, width, and height, slot ( ID )
306
-	 *
307
-	 * Post : Returns texture id or < 0 error flag
308
-	 *
309
-	 *-- History ------------------------------------------
310
-	 *
311
-	 * 2002.09.05:
312
-	 * Mongoose - Created
313
-	 ------------------------------------------------------*/
314
-
315
-	int loadColorTexture(unsigned char rgba[4],
316
-								unsigned int width, unsigned int height);
317
-	/*------------------------------------------------------
318
-	 * Pre  :
319
-	 * Post : Generates and loads a solid color texture,
320
-	 *        returns texture Id or -1 if failed
321
-	 *
322
-	 *-- History ------------------------------------------
323
-	 *
324
-	 * 2003.06.30:
325
-	 * Mongoose - Created
326
-	 ------------------------------------------------------*/
327
-
328
-	int loadFontTTF(const char *filename,
329
-						 unsigned int utf8Offset, unsigned int count);
330
-	/*------------------------------------------------------
331
-	 * Pre  : <Filename> of TTF font
332
-	 *        <Utf8Offset> is offset into UNICODE table
333
-	 *        <Count> is number of glyphs to load
334
-	 *
335
-	 * Post : Loads a TTF,
336
-	 *        Generates: texture image, glyph list, and drawlist
337
-	 *
338
-	 *        Returns font id if sucessful, or < 0 if error
339
-	 *
340
-	 *-- History ------------------------------------------
341
-	 *
342
-	 * 2003.07.05:
343
-	 * Mongoose - Created
344
-	 ------------------------------------------------------*/
345
-
346
-	int loadPNG(const char *filename);
347
-	/*------------------------------------------------------
348
-	 * Pre  : Texture is init and filename/file is valid
349
-	 * Post : Loads PNG as texture and returns ID or -1 error
350
-	 *
351
-	 *-- History ------------------------------------------
352
-	 *
353
-	 * 2002.06.16:
354
-	 * Mongoose - Created, from Freyja
355
-	 ------------------------------------------------------*/
356
-
357
-	int loadTGA(const char *filename);
358
-	/*------------------------------------------------------
359
-	 * Pre  : Texture is init and filename/file is valid
360
-	 * Post : Loads TGA as texture and returns ID or -1 error
361
-	 *
362
-	 *-- History ------------------------------------------
363
-	 *
364
-	 * 2002.06.16:
365
-	 * Mongoose - Created
366
-	 ------------------------------------------------------*/
300
+                             unsigned int width, unsigned int height,
301
+                             ColorMode mode, unsigned int bpp,
302
+                             unsigned int slot);
303
+    /*------------------------------------------------------
304
+     * Pre  : image must be a valid pixmap that agrees
305
+     *        with mode, width, and height, slot ( ID )
306
+     *
307
+     * Post : Returns texture id or < 0 error flag
308
+     *
309
+     *-- History ------------------------------------------
310
+     *
311
+     * 2002.09.05:
312
+     * Mongoose - Created
313
+     ------------------------------------------------------*/
314
+
315
+    int loadColorTexture(unsigned char rgba[4],
316
+                                unsigned int width, unsigned int height);
317
+    /*------------------------------------------------------
318
+     * Pre  :
319
+     * Post : Generates and loads a solid color texture,
320
+     *        returns texture Id or -1 if failed
321
+     *
322
+     *-- History ------------------------------------------
323
+     *
324
+     * 2003.06.30:
325
+     * Mongoose - Created
326
+     ------------------------------------------------------*/
327
+
328
+    int loadFontTTF(const char *filename,
329
+                         unsigned int utf8Offset, unsigned int count);
330
+    /*------------------------------------------------------
331
+     * Pre  : <Filename> of TTF font
332
+     *        <Utf8Offset> is offset into UNICODE table
333
+     *        <Count> is number of glyphs to load
334
+     *
335
+     * Post : Loads a TTF,
336
+     *        Generates: texture image, glyph list, and drawlist
337
+     *
338
+     *        Returns font id if sucessful, or < 0 if error
339
+     *
340
+     *-- History ------------------------------------------
341
+     *
342
+     * 2003.07.05:
343
+     * Mongoose - Created
344
+     ------------------------------------------------------*/
345
+
346
+    int loadPNG(const char *filename);
347
+    /*------------------------------------------------------
348
+     * Pre  : Texture is init and filename/file is valid
349
+     * Post : Loads PNG as texture and returns ID or -1 error
350
+     *
351
+     *-- History ------------------------------------------
352
+     *
353
+     * 2002.06.16:
354
+     * Mongoose - Created, from Freyja
355
+     ------------------------------------------------------*/
356
+
357
+    int loadTGA(const char *filename);
358
+    /*------------------------------------------------------
359
+     * Pre  : Texture is init and filename/file is valid
360
+     * Post : Loads TGA as texture and returns ID or -1 error
361
+     *
362
+     *-- History ------------------------------------------
363
+     *
364
+     * 2002.06.16:
365
+     * Mongoose - Created
366
+     ------------------------------------------------------*/
367 367
 
368 368
    void reset();
369
-	/*------------------------------------------------------
370
-	 * Pre  :
371
-	 * Post : Resets all texture data
372
-	 *
373
-	 *-- History ------------------------------------------
374
-	 *
375
-	 * 2001.05.29:
376
-	 * Mongoose - Big code clean up, documentation
377
-	 *
378
-	 * 2000.10.05:
379
-	 * Mongoose - Created
380
-	 ------------------------------------------------------*/
381
-
382
-	void setFlag(TextureFlag flag);
383
-	/*------------------------------------------------------
384
-	 * Pre  :
385
-	 * Post : Sets a option flag
386
-	 *
387
-	 *-- History ------------------------------------------
388
-	 *
389
-	 * 2003.01.05:
390
-	 * Mongoose - Created
391
-	 ------------------------------------------------------*/
392
-
393
-	void setMaxTextureCount(unsigned int n);
394
-	/*------------------------------------------------------
395
-	 * Pre  : n is max number of textures you wish to allow
396
-	 * Post : Sets up GL texturing, and must be called
397
-	 *        as the first setup step
398
-	 *
399
-	 *-- History ------------------------------------------
400
-	 *
401
-	 * 2001.05.29:
402
-	 * Mongoose - Big code clean up, documentation
403
-	 *
404
-	 * 2000.10.05:
405
-	 * Mongoose - Created
406
-	 ------------------------------------------------------*/
407
-
408
-	void useMultiTexture(float u, float v);
409
-	/*------------------------------------------------------
410
-	 * Pre  :
411
-	 * Post :
412
-	 *
413
-	 *-- History ------------------------------------------
414
-	 *
415
-	 * 2002.12.24:
416
-	 * Mongoose - Created
417
-	 ------------------------------------------------------*/
418
-
419
-	void useMultiTexture(float aU, float aV, float bU, float bV);
420
-	/*------------------------------------------------------
421
-	 * Pre  :
422
-	 * Post :
423
-	 *
424
-	 *-- History ------------------------------------------
425
-	 *
426
-	 * 2002.12.24:
427
-	 * Mongoose - Created
428
-	 ------------------------------------------------------*/
369
+    /*------------------------------------------------------
370
+     * Pre  :
371
+     * Post : Resets all texture data
372
+     *
373
+     *-- History ------------------------------------------
374
+     *
375
+     * 2001.05.29:
376
+     * Mongoose - Big code clean up, documentation
377
+     *
378
+     * 2000.10.05:
379
+     * Mongoose - Created
380
+     ------------------------------------------------------*/
381
+
382
+    void setFlag(TextureFlag flag);
383
+    /*------------------------------------------------------
384
+     * Pre  :
385
+     * Post : Sets a option flag
386
+     *
387
+     *-- History ------------------------------------------
388
+     *
389
+     * 2003.01.05:
390
+     * Mongoose - Created
391
+     ------------------------------------------------------*/
392
+
393
+    void setMaxTextureCount(unsigned int n);
394
+    /*------------------------------------------------------
395
+     * Pre  : n is max number of textures you wish to allow
396
+     * Post : Sets up GL texturing, and must be called
397
+     *        as the first setup step
398
+     *
399
+     *-- History ------------------------------------------
400
+     *
401
+     * 2001.05.29:
402
+     * Mongoose - Big code clean up, documentation
403
+     *
404
+     * 2000.10.05:
405
+     * Mongoose - Created
406
+     ------------------------------------------------------*/
407
+
408
+    void useMultiTexture(float u, float v);
409
+    /*------------------------------------------------------
410
+     * Pre  :
411
+     * Post :
412
+     *
413
+     *-- History ------------------------------------------
414
+     *
415
+     * 2002.12.24:
416
+     * Mongoose - Created
417
+     ------------------------------------------------------*/
418
+
419
+    void useMultiTexture(float aU, float aV, float bU, float bV);
420
+    /*------------------------------------------------------
421
+     * Pre  :
422
+     * Post :
423
+     *
424
+     *-- History ------------------------------------------
425
+     *
426
+     * 2002.12.24:
427
+     * Mongoose - Created
428
+     ------------------------------------------------------*/
429 429
 
430 430
 
431 431
  private:
432 432
 
433
-	////////////////////////////////////////////////////////////
434
-	// Private Accessors
435
-	////////////////////////////////////////////////////////////
433
+    ////////////////////////////////////////////////////////////
434
+    // Private Accessors
435
+    ////////////////////////////////////////////////////////////
436 436
 
437
-	int nextPower(int seed);
438
-	/*------------------------------------------------------
439
-	 * Pre  :
440
-	 * Post :
441
-	 *
442
-	 *-- History ------------------------------------------
443
-	 *
444
-	 * 2002.06.16:
445
-	 * Mongoose - Created
446
-	 ------------------------------------------------------*/
437
+    int nextPower(int seed);
438
+    /*------------------------------------------------------
439
+     * Pre  :
440
+     * Post :
441
+     *
442
+     *-- History ------------------------------------------
443
+     *
444
+     * 2002.06.16:
445
+     * Mongoose - Created
446
+     ------------------------------------------------------*/
447 447
 
448
-	unsigned char *scaleBuffer(unsigned char *image, int width, int height,
449
-										int components);
450
-	/*------------------------------------------------------
451
-	 * Pre  :
452
-	 * Post :
453
-	 *
454
-	 *-- History ------------------------------------------
455
-	 *
456
-	 * 2002.06.16:
457
-	 * Mongoose - Created
458
-	 ------------------------------------------------------*/
448
+    unsigned char *scaleBuffer(unsigned char *image, int width, int height,
449
+                                        int components);
450
+    /*------------------------------------------------------
451
+     * Pre  :
452
+     * Post :
453
+     *
454
+     *-- History ------------------------------------------
455
+     *
456
+     * 2002.06.16:
457
+     * Mongoose - Created
458
+     ------------------------------------------------------*/
459 459
 
460 460
 
461
-	////////////////////////////////////////////////////////////
462
-	// Private Mutators
463
-	////////////////////////////////////////////////////////////
461
+    ////////////////////////////////////////////////////////////
462
+    // Private Mutators
463
+    ////////////////////////////////////////////////////////////
464 464
 
465
-   unsigned int *mTextureIds;		/* GL texture list */
465
+   unsigned int *mTextureIds;       /* GL texture list */
466 466
 
467
-   unsigned int mTextureCount;	/* Texture counter */
467
+   unsigned int mTextureCount;  /* Texture counter */
468 468
 
469
-   unsigned int mTextureLimit;	/* The texture limit */
469
+   unsigned int mTextureLimit;  /* The texture limit */
470 470
 
471
-	unsigned int mFlags;				/* Class options */
471
+    unsigned int mFlags;                /* Class options */
472 472
 
473
-   int mTextureId;					/* Currently bound texture id */
473
+   int mTextureId;                  /* Currently bound texture id */
474 474
 
475
-	int mTextureId2;					/* Multitexture Texture Id */
475
+    int mTextureId2;                    /* Multitexture Texture Id */
476 476
 };
477 477
 
478 478
 
@@ -480,31 +480,31 @@ class Texture
480 480
 void bufferedPrintf(char *string, unsigned int len, char *s, ...);
481 481
 
482 482
 void glPrint3d(float x, float y, float z,
483
-					float pitch, float yaw, float roll,
484
-					float scale,
485
-					char *string);
483
+                    float pitch, float yaw, float roll,
484
+                    float scale,
485
+                    char *string);
486 486
 
487 487
 void glPrint2d(float x, float y, float scale, char *string);
488 488
 
489
-	void glEnterMode2d(unsigned int width, unsigned int height);
490
-	/*------------------------------------------------------
491
-	 * Pre  :
492
-	 * Post : OpenGL ortho projection
493
-	 *
494
-	 *-- History ------------------------------------------
495
-	 *
496
-	 * 2003.06.03:
497
-	 * Mongoose - Created
498
-	 ------------------------------------------------------*/
499
-
500
-	void glExitMode2d();
501
-	/*------------------------------------------------------
502
-	 * Pre  :
503
-	 * Post : OpenGL model matrix projection
504
-	 *
505
-	 *-- History ------------------------------------------
506
-	 *
507
-	 * 2003.06.03:
508
-	 * Mongoose - Created
509
-	 ------------------------------------------------------*/
489
+    void glEnterMode2d(unsigned int width, unsigned int height);
490
+    /*------------------------------------------------------
491
+     * Pre  :
492
+     * Post : OpenGL ortho projection
493
+     *
494
+     *-- History ------------------------------------------
495
+     *
496
+     * 2003.06.03:
497
+     * Mongoose - Created
498
+     ------------------------------------------------------*/
499
+
500
+    void glExitMode2d();
501
+    /*------------------------------------------------------
502
+     * Pre  :
503
+     * Post : OpenGL model matrix projection
504
+     *
505
+     *-- History ------------------------------------------
506
+     *
507
+     * 2003.06.03:
508
+     * Mongoose - Created
509
+     ------------------------------------------------------*/
510 510
 #endif

+ 1603
- 1603
include/TombRaider.h
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 28
- 28
include/TombRaider1.h Переглянути файл

@@ -26,38 +26,38 @@ class TombRaider1
26 26
 {
27 27
 public:
28 28
 
29
-	TombRaider1();
29
+    TombRaider1();
30 30
 
31
-	~TombRaider1();
31
+    ~TombRaider1();
32 32
 
33
-	enum Items
33
+    enum Items
34 34
    {
35
-		Lara = 0,
36
-		PistolAnimation  = 1,
37
-		ShotgunAnimation = 2,
38
-		MagnumAnimation = 3,
39
-		LaraAlternate = 4, // Lara's home appearance, wounded, or turned to gold
40
-		UziAnimation = 5,
41
-		LaraMutant = 6,
42
-		Wolf = 7,
43
-		Bear = 8,
44
-		Bat = 9
45
-	};
35
+        Lara = 0,
36
+        PistolAnimation  = 1,
37
+        ShotgunAnimation = 2,
38
+        MagnumAnimation = 3,
39
+        LaraAlternate = 4, // Lara's home appearance, wounded, or turned to gold
40
+        UziAnimation = 5,
41
+        LaraMutant = 6,
42
+        Wolf = 7,
43
+        Bear = 8,
44
+        Bat = 9
45
+    };
46 46
 
47
-	enum WolfStates
48
-	{
49
-		WolfState_Walking   = 1,
50
-		WolfState_Running   = 2,
51
-		WolfState_Jumping   = 3,
52
-		WolfState_Stalking  = 5,
53
-		WolfState_JumpingAttack   = 6,
54
-		WolfState_Attacking = 7,
55
-		WolfState_Lying     = 8,  // down
56
-		WolfState_Getting   = 9,  // ready to strike
57
-		WolfState_RunningJump   = 10,
58
-		WolfState_Dying     = 11,
59
-		WolfState_Biting    = 12
60
-	};
47
+    enum WolfStates
48
+    {
49
+        WolfState_Walking   = 1,
50
+        WolfState_Running   = 2,
51
+        WolfState_Jumping   = 3,
52
+        WolfState_Stalking  = 5,
53
+        WolfState_JumpingAttack   = 6,
54
+        WolfState_Attacking = 7,
55
+        WolfState_Lying     = 8,  // down
56
+        WolfState_Getting   = 9,  // ready to strike
57
+        WolfState_RunningJump   = 10,
58
+        WolfState_Dying     = 11,
59
+        WolfState_Biting    = 12
60
+    };
61 61
 };
62 62
 
63 63
 #ifdef FIXME_DONT_COMPILE

+ 465
- 465
include/TombRaider5.h Переглянути файл

@@ -20,471 +20,471 @@
20 20
 
21 21
 typedef enum
22 22
 {
23
-		TR4_OBJ_LARA = 0,
24
-		TR4_OBJ_PISTOLS_ANIM = 1,
25
-		TR4_OBJ_UZI_ANIM = 2,
26
-		TR4_OBJ_SHOTGUN_ANIM = 3,
27
-		TR4_OBJ_CROSSBOW_ANIM = 4,
28
-		TR4_OBJ_GRENADE_GUN_ANIM = 5,
29
-		TR4_OBJ_SIXSHOOTER_ANIM = 6,
30
-		TR4_OBJ_FLARE_ANIM = 7,
31
-		TR4_OBJ_LARA_SKIN = 8,
32
-		TR4_OBJ_LARA_SKIN_JOINTS = 9,
33
-		TR4_OBJ_LARA_SCREAM = 10,
34
-		TR4_OBJ_LARA_CROSSBOW_LASER = 11,
35
-		TR4_OBJ_LARA_REVOLVER_LASER = 12,
36
-		TR4_OBJ_LARA_HOLSTERS = 13,
37
-		TR4_OBJ_LARA_HOLSTERS_PISTOLS = 14,
38
-		TR4_OBJ_LARA_HOLSTERS_UZIS = 15,
39
-		TR4_OBJ_LARA_HOLSTERS_SIXSHOOTER = 16,
40
-		TR4_OBJ_LARA_SPEECH_HEAD1 = 17,
41
-		TR4_OBJ_LARA_SPEECH_HEAD2 = 18,
42
-		TR4_OBJ_LARA_SPEECH_HEAD3 = 19,
43
-		TR4_OBJ_LARA_SPEECH_HEAD4 = 20,
44
-		TR4_OBJ_ACTOR1_SPEECH_HEAD1 = 21,
45
-		TR4_OBJ_ACTOR1_SPEECH_HEAD2 = 22,
46
-		TR4_OBJ_ACTOR2_SPEECH_HEAD1 = 23,
47
-		TR4_OBJ_ACTOR2_SPEECH_HEAD2 = 24,
48
-		TR4_OBJ_LARA_WATER_MESH = 25,
49
-		TR4_OBJ_LARA_PETROL_MESH = 26,
50
-		TR4_OBJ_LARA_DIRT_MESH = 27,
51
-		TR4_OBJ_CROWBAR_ANIM = 28,
52
-		TR4_OBJ_TORCH_ANIM = 29,
53
-		TR4_OBJ_HAIR = 30,
54
-		TR4_OBJ_MOTORBIKE = 31,
55
-		TR4_OBJ_JEEP = 32,
56
-		TR4_OBJ_VEHICLE_EXTRA = 33,
57
-		TR4_OBJ_ENEMY_JEEP = 34,
58
-		TR4_OBJ_SKELETON = 35,
59
-		TR4_OBJ_SKELETON_MIP = 36,
60
-		TR4_OBJ_GUIDE = 37,
61
-		TR4_OBJ_GUIDE_MIP = 38,
62
-		TR4_OBJ_VON_CROY = 39,
63
-		TR4_OBJ_VON_CROY_MIP = 40,
64
-		TR4_OBJ_BADDY_1 = 41,
65
-		TR4_OBJ_BADDY_1_MIP = 42,
66
-		TR4_OBJ_BADDY_2 = 43,
67
-		TR4_OBJ_BADDY_2_MIP = 44,
68
-		TR4_OBJ_SETHA = 45,
69
-		TR4_OBJ_SETHA_MIP = 46,
70
-		TR4_OBJ_MUMMY = 47,
71
-		TR4_OBJ_MUMMY_MIP = 48,
72
-		TR4_OBJ_SPHINX = 49,
73
-		TR4_OBJ_SPHINX_MIP = 50,
74
-		TR4_OBJ_CROCODILE = 51,
75
-		TR4_OBJ_CROCODILE_MIP = 52,
76
-		TR4_OBJ_HORSEMAN = 53,
77
-		TR4_OBJ_HORSEMAN_MIP = 54,
78
-		TR4_OBJ_SCORPION = 55,
79
-		TR4_OBJ_SCORPION_MIP = 56,
80
-		TR4_OBJ_JEAN_YVES = 57,
81
-		TR4_OBJ_JEAN_YVES_MIP = 58,
82
-		TR4_OBJ_TROOPS = 59,
83
-		TR4_OBJ_TROOPS_MIP = 60,
84
-		TR4_OBJ_KNIGHTS_TEMPLAR = 61,
85
-		TR4_OBJ_KNIGHTS_TEMPLAR_MIP = 62,
86
-		TR4_OBJ_MUTANT = 63,
87
-		TR4_OBJ_MUTANT_MIP = 64,
88
-		TR4_OBJ_HORSE = 65,
89
-		TR4_OBJ_HORSE_MIP = 66,
90
-		TR4_OBJ_BABOON_NORMAL = 67,
91
-		TR4_OBJ_BABOON_NORMAL_MIP = 68,
92
-		TR4_OBJ_BABOON_INV = 69,
93
-		TR4_OBJ_BABOON_INV_MIP = 70,
94
-		TR4_OBJ_BABOON_SILENT = 71,
95
-		TR4_OBJ_BABOON_SILENT_MIP = 72,
96
-		TR4_OBJ_WILD_BOAR = 73,
97
-		TR4_OBJ_WILD_BOAR_MIP = 74,
98
-		TR4_OBJ_HARPY = 75,
99
-		TR4_OBJ_HARPY_MIP = 76,
100
-		TR4_OBJ_DEMIGOD1 = 77,
101
-		TR4_OBJ_DEMIGOD1_MIP = 78,
102
-		TR4_OBJ_DEMIGOD2 = 79,
103
-		TR4_OBJ_DEMIGOD2_MIP = 80,
104
-		TR4_OBJ_DEMIGOD3 = 81,
105
-		TR4_OBJ_DEMIGOD3_MIP = 82,
106
-		TR4_OBJ_LITTLE_BEETLE = 83,
107
-		TR4_OBJ_BIG_BEETLE = 84,
108
-		TR4_OBJ_BIG_BEETLE_MIP = 85,
109
-		TR4_OBJ_WRAITH1 = 86,
110
-		TR4_OBJ_WRAITH2 = 87,
111
-		TR4_OBJ_WRAITH3 = 88,
112
-		TR4_OBJ_WRAITH4 = 89,
113
-		TR4_OBJ_BAT = 90,
114
-		TR4_OBJ_DOG = 91,
115
-		TR4_OBJ_DOG_MIP = 92,
116
-		TR4_OBJ_HAMMERHEAD = 93,
117
-		TR4_OBJ_HAMMERHEAD_MIP = 94,
118
-		TR4_OBJ_SAS = 95,
119
-		TR4_OBJ_SAS_MIP = 96,
120
-		TR4_OBJ_SAS_DYING = 97,
121
-		TR4_OBJ_SAS_DYING_MIP = 98,
122
-		TR4_OBJ_SAS_CAPTAIN = 99,
123
-		TR4_OBJ_SAS_CAPTAIN_MIP = 100,
124
-		TR4_OBJ_SAS_DRAG_BLOKE = 101,
125
-		TR4_OBJ_AHMET = 102,
126
-		TR4_OBJ_AHMET_MIP = 103,
127
-		TR4_OBJ_LARA_DOUBLE = 104,
128
-		TR4_OBJ_LARA_DOUBLE_MIP = 105,
129
-		TR4_OBJ_SMALL_SCORPION = 106,
130
-		TR4_OBJ_FISH = 107,
131
-		TR4_OBJ_GAME_PIECE1 = 108,
132
-		TR4_OBJ_GAME_PIECE2 = 109,
133
-		TR4_OBJ_GAME_PIECE3 = 110,
134
-		TR4_OBJ_ENEMY_PIECE = 111,
135
-		TR4_OBJ_WHEEL_OF_FORTUNE = 112,
136
-		TR4_OBJ_SCALES = 113,
137
-		TR4_OBJ_DARTS = 114,
138
-		TR4_OBJ_DART_EMITTER = 115,
139
-		TR4_OBJ_HOMING_DART_EMITTER = 116,
140
-		TR4_OBJ_FALLING_CEILING = 117,
141
-		TR4_OBJ_FALLING_BLOCK = 118,
142
-		TR4_OBJ_FALLING_BLOCK2 = 119,
143
-		TR4_OBJ_SMASHABLE_BIKE_WALL = 120,
144
-		TR4_OBJ_SMASHABLE_BIKE_FLOOR = 121,
145
-		TR4_OBJ_TRAPDOOR1 = 122,
146
-		TR4_OBJ_TRAPDOOR2 = 123,
147
-		TR4_OBJ_TRAPDOOR3 = 124,
148
-		TR4_OBJ_FLOOR_TRAPDOOR1 = 125,
149
-		TR4_OBJ_FLOOR_TRAPDOOR2 = 126,
150
-		TR4_OBJ_CEILING_TRAPDOOR1 = 127,
151
-		TR4_OBJ_CEILING_TRAPDOOR2 = 128,
152
-		TR4_OBJ_SCALING_TRAPDOOR = 129,
153
-		TR4_OBJ_ROLLINGBALL = 130,
154
-		TR4_OBJ_SPIKEY_FLOOR = 131,
155
-		TR4_OBJ_TEETH_SPIKES = 132,
156
-		TR4_OBJ_JOBY_SPIKES = 133,
157
-		TR4_OBJ_SLICER_DICER = 134,
158
-		TR4_OBJ_CHAIN = 135,
159
-		TR4_OBJ_PLOUGH = 136,
160
-		TR4_OBJ_STARGATE = 137,
161
-		TR4_OBJ_HAMMER = 138,
162
-		TR4_OBJ_BURNING_FLOOR = 139,
163
-		TR4_OBJ_COG = 140,
164
-		TR4_OBJ_SPIKEBALL = 141,
165
-		TR4_OBJ_FLAME = 142,
166
-		TR4_OBJ_FLAME_EMITTER = 143,
167
-		TR4_OBJ_FLAME_EMITTER2 = 144,
168
-		TR4_OBJ_FLAME_EMITTER3 = 145,
169
-		TR4_OBJ_ROPE = 146,
170
-		TR4_OBJ_FIREROPE = 147,
171
-		TR4_OBJ_POLEROPE = 148,
172
-		TR4_OBJ_ONEBLOCK_PLATFORM = 149,
173
-		TR4_OBJ_TWOBLOCK_PLATFORM = 150,
174
-		TR4_OBJ_RAISING_BLOCK1 = 151,
175
-		TR4_OBJ_RAISING_BLOCK2 = 152,
176
-		TR4_OBJ_EXPANDING_PLATFORM = 153,
177
-		TR4_OBJ_SQUISHY_BLOCK1 = 154,
178
-		TR4_OBJ_SQUISHY_BLOCK2 = 155,
179
-		TR4_OBJ_PUSHABLE_OBJECT1 = 156,
180
-		TR4_OBJ_PUSHABLE_OBJECT2 = 157,
181
-		TR4_OBJ_PUSHABLE_OBJECT3 = 158,
182
-		TR4_OBJ_PUSHABLE_OBJECT4 = 159,
183
-		TR4_OBJ_PUSHABLE_OBJECT5 = 160,
184
-		TR4_OBJ_TRIPWIRE = 161,
185
-		TR4_OBJ_SENTRY_GUN = 162,
186
-		TR4_OBJ_MINE = 163,
187
-		TR4_OBJ_MAPPER = 164,
188
-		TR4_OBJ_OBELISK = 165,
189
-		TR4_OBJ_FLOOR_4BLADE = 166,
190
-		TR4_OBJ_ROOF_4BLADE = 167,
191
-		TR4_OBJ_BIRD_BLADE = 168,
192
-		TR4_OBJ_CATWALK_BLADE = 169,
193
-		TR4_OBJ_MOVING_BLADE = 170,
194
-		TR4_OBJ_PLINTH_BLADE = 171,
195
-		TR4_OBJ_SETH_BLADE = 172,
196
-		TR4_OBJ_LIGHTNING_CONDUCTOR = 173,
197
-		TR4_OBJ_ELEMENT_PUZZLE = 174,
198
-		TR4_OBJ_PUZZLE_ITEM1 = 175,
199
-		TR4_OBJ_PUZZLE_ITEM2 = 176,
200
-		TR4_OBJ_PUZZLE_ITEM3 = 177,
201
-		TR4_OBJ_PUZZLE_ITEM4 = 178,
202
-		TR4_OBJ_PUZZLE_ITEM5 = 179,
203
-		TR4_OBJ_PUZZLE_ITEM6 = 180,
204
-		TR4_OBJ_PUZZLE_ITEM7 = 181,
205
-		TR4_OBJ_PUZZLE_ITEM8 = 182,
206
-		TR4_OBJ_PUZZLE_ITEM9 = 183,
207
-		TR4_OBJ_PUZZLE_ITEM10 = 184,
208
-		TR4_OBJ_PUZZLE_ITEM11 = 185,
209
-		TR4_OBJ_PUZZLE_ITEM12 = 186,
210
-		TR4_OBJ_PUZZLE_ITEM1_COMBO1 = 187,
211
-		TR4_OBJ_PUZZLE_ITEM1_COMBO2 = 188,
212
-		TR4_OBJ_PUZZLE_ITEM2_COMBO1 = 189,
213
-		TR4_OBJ_PUZZLE_ITEM2_COMBO2 = 190,
214
-		TR4_OBJ_PUZZLE_ITEM3_COMBO1 = 191,
215
-		TR4_OBJ_PUZZLE_ITEM3_COMBO2 = 192,
216
-		TR4_OBJ_PUZZLE_ITEM4_COMBO1 = 193,
217
-		TR4_OBJ_PUZZLE_ITEM4_COMBO2 = 194,
218
-		TR4_OBJ_PUZZLE_ITEM5_COMBO1 = 195,
219
-		TR4_OBJ_PUZZLE_ITEM5_COMBO2 = 196,
220
-		TR4_OBJ_PUZZLE_ITEM6_COMBO1 = 197,
221
-		TR4_OBJ_PUZZLE_ITEM6_COMBO2 = 198,
222
-		TR4_OBJ_PUZZLE_ITEM7_COMBO1 = 199,
223
-		TR4_OBJ_PUZZLE_ITEM7_COMBO2 = 200,
224
-		TR4_OBJ_PUZZLE_ITEM8_COMBO1 = 201,
225
-		TR4_OBJ_PUZZLE_ITEM8_COMBO2 = 202,
226
-		TR4_OBJ_KEY_ITEM1 = 203,
227
-		TR4_OBJ_KEY_ITEM2 = 204,
228
-		TR4_OBJ_KEY_ITEM3 = 205,
229
-		TR4_OBJ_KEY_ITEM4 = 206,
230
-		TR4_OBJ_KEY_ITEM5 = 207,
231
-		TR4_OBJ_KEY_ITEM6 = 208,
232
-		TR4_OBJ_KEY_ITEM7 = 209,
233
-		TR4_OBJ_KEY_ITEM8 = 210,
234
-		TR4_OBJ_KEY_ITEM9 = 211,
235
-		TR4_OBJ_KEY_ITEM10 = 212,
236
-		TR4_OBJ_KEY_ITEM11 = 213,
237
-		TR4_OBJ_KEY_ITEM12 = 214,
238
-		TR4_OBJ_KEY_ITEM1_COMBO1 = 215,
239
-		TR4_OBJ_KEY_ITEM1_COMBO2 = 216,
240
-		TR4_OBJ_KEY_ITEM2_COMBO1 = 217,
241
-		TR4_OBJ_KEY_ITEM2_COMBO2 = 218,
242
-		TR4_OBJ_KEY_ITEM3_COMBO1 = 219,
243
-		TR4_OBJ_KEY_ITEM3_COMBO2 = 220,
244
-		TR4_OBJ_KEY_ITEM4_COMBO1 = 221,
245
-		TR4_OBJ_KEY_ITEM4_COMBO2 = 222,
246
-		TR4_OBJ_KEY_ITEM5_COMBO1 = 223,
247
-		TR4_OBJ_KEY_ITEM5_COMBO2 = 224,
248
-		TR4_OBJ_KEY_ITEM6_COMBO1 = 225,
249
-		TR4_OBJ_KEY_ITEM6_COMBO2 = 226,
250
-		TR4_OBJ_KEY_ITEM7_COMBO1 = 227,
251
-		TR4_OBJ_KEY_ITEM7_COMBO2 = 228,
252
-		TR4_OBJ_KEY_ITEM8_COMBO1 = 229,
253
-		TR4_OBJ_KEY_ITEM8_COMBO2 = 230,
254
-		TR4_OBJ_PICKUP_ITEM1 = 231,
255
-		TR4_OBJ_PICKUP_ITEM2 = 232,
256
-		TR4_OBJ_PICKUP_ITEM3 = 233,
257
-		TR4_OBJ_PICKUP_ITEM4 = 234,
258
-		TR4_OBJ_PICKUP_ITEM1_COMBO1 = 235,
259
-		TR4_OBJ_PICKUP_ITEM1_COMBO2 = 236,
260
-		TR4_OBJ_PICKUP_ITEM2_COMBO1 = 237,
261
-		TR4_OBJ_PICKUP_ITEM2_COMBO2 = 238,
262
-		TR4_OBJ_PICKUP_ITEM3_COMBO1 = 239,
263
-		TR4_OBJ_PICKUP_ITEM3_COMBO2 = 240,
264
-		TR4_OBJ_PICKUP_ITEM4_COMBO1 = 241,
265
-		TR4_OBJ_PICKUP_ITEM4_COMBO2 = 242,
266
-		TR4_OBJ_EXAMINE1 = 243,
267
-		TR4_OBJ_EXAMINE2 = 244,
268
-		TR4_OBJ_EXAMINE3 = 245,
269
-		TR4_OBJ_CROWBAR_ITEM = 246,
270
-		TR4_OBJ_BURNING_TORCH_ITEM = 247,
271
-		TR4_OBJ_CLOCKWORK_BEETLE = 248,
272
-		TR4_OBJ_CLOCKWORK_BEETLE_COMBO1 = 249,
273
-		TR4_OBJ_CLOCKWORK_BEETLE_COMBO2 = 250,
274
-		TR4_OBJ_MINE_DETECTOR = 251,
275
-		TR4_OBJ_QUEST_ITEM1 = 252,
276
-		TR4_OBJ_QUEST_ITEM2 = 253,
277
-		TR4_OBJ_QUEST_ITEM3 = 254,
278
-		TR4_OBJ_QUEST_ITEM4 = 255,
279
-		TR4_OBJ_QUEST_ITEM5 = 256,
280
-		TR4_OBJ_QUEST_ITEM6 = 257,
281
-		TR4_OBJ_MAP = 258,
282
-		TR4_OBJ_SECRET_MAP = 259,
283
-		TR4_OBJ_PUZZLE_HOLE1 = 260,
284
-		TR4_OBJ_PUZZLE_HOLE2 = 261,
285
-		TR4_OBJ_PUZZLE_HOLE3 = 262,
286
-		TR4_OBJ_PUZZLE_HOLE4 = 263,
287
-		TR4_OBJ_PUZZLE_HOLE5 = 264,
288
-		TR4_OBJ_PUZZLE_HOLE6 = 265,
289
-		TR4_OBJ_PUZZLE_HOLE7 = 266,
290
-		TR4_OBJ_PUZZLE_HOLE8 = 267,
291
-		TR4_OBJ_PUZZLE_HOLE9 = 268,
292
-		TR4_OBJ_PUZZLE_HOLE10 = 269,
293
-		TR4_OBJ_PUZZLE_HOLE11 = 270,
294
-		TR4_OBJ_PUZZLE_HOLE12 = 271,
295
-		TR4_OBJ_PUZZLE_DONE1 = 272,
296
-		TR4_OBJ_PUZZLE_DONE2 = 273,
297
-		TR4_OBJ_PUZZLE_DONE3 = 274,
298
-		TR4_OBJ_PUZZLE_DONE4 = 275,
299
-		TR4_OBJ_PUZZLE_DONE5 = 276,
300
-		TR4_OBJ_PUZZLE_DONE6 = 277,
301
-		TR4_OBJ_PUZZLE_DONE7 = 278,
302
-		TR4_OBJ_PUZZLE_DONE8 = 279,
303
-		TR4_OBJ_PUZZLE_DONE9 = 280,
304
-		TR4_OBJ_PUZZLE_DONE10 = 281,
305
-		TR4_OBJ_PUZZLE_DONE11 = 282,
306
-		TR4_OBJ_PUZZLE_DONE12 = 283,
307
-		TR4_OBJ_KEY_HOLE1 = 284,
308
-		TR4_OBJ_KEY_HOLE2 = 285,
309
-		TR4_OBJ_KEY_HOLE3 = 286,
310
-		TR4_OBJ_KEY_HOLE4 = 287,
311
-		TR4_OBJ_KEY_HOLE5 = 288,
312
-		TR4_OBJ_KEY_HOLE6 = 289,
313
-		TR4_OBJ_KEY_HOLE7 = 290,
314
-		TR4_OBJ_KEY_HOLE8 = 291,
315
-		TR4_OBJ_KEY_HOLE9 = 292,
316
-		TR4_OBJ_KEY_HOLE10 = 293,
317
-		TR4_OBJ_KEY_HOLE11 = 294,
318
-		TR4_OBJ_KEY_HOLE12 = 295,
319
-		TR4_OBJ_WATERSKIN1_EMPTY = 296,
320
-		TR4_OBJ_WATERSKIN1_1 = 297,
321
-		TR4_OBJ_WATERSKIN1_2 = 298,
322
-		TR4_OBJ_WATERSKIN1_3 = 299,
323
-		TR4_OBJ_WATERSKIN2_EMPTY = 300,
324
-		TR4_OBJ_WATERSKIN2_1 = 301,
325
-		TR4_OBJ_WATERSKIN2_2 = 302,
326
-		TR4_OBJ_WATERSKIN2_3 = 303,
327
-		TR4_OBJ_WATERSKIN2_4 = 304,
328
-		TR4_OBJ_WATERSKIN2_5 = 305,
329
-		TR4_OBJ_SWITCH_TYPE1 = 306,
330
-		TR4_OBJ_SWITCH_TYPE2 = 307,
331
-		TR4_OBJ_SWITCH_TYPE3 = 308,
332
-		TR4_OBJ_SWITCH_TYPE4 = 309,
333
-		TR4_OBJ_SWITCH_TYPE5 = 310,
334
-		TR4_OBJ_SWITCH_TYPE6 = 311,
335
-		TR4_OBJ_SWITCH_TYPE7 = 312,
336
-		TR4_OBJ_SWITCH_TYPE8 = 313,
337
-		TR4_OBJ_UNDERWATER_SWITCH1 = 314,
338
-		TR4_OBJ_UNDERWATER_SWITCH2 = 315,
339
-		TR4_OBJ_TURN_SWITCH = 316,
340
-		TR4_OBJ_COG_SWITCH = 317,
341
-		TR4_OBJ_LEVER_SWITCH = 318,
342
-		TR4_OBJ_JUMP_SWITCH = 319,
343
-		TR4_OBJ_CROWBAR_SWITCH = 320,
344
-		TR4_OBJ_PULLEY = 321,
345
-		TR4_OBJ_DOOR_TYPE1 = 322,
346
-		TR4_OBJ_DOOR_TYPE2 = 323,
347
-		TR4_OBJ_DOOR_TYPE3 = 324,
348
-		TR4_OBJ_DOOR_TYPE4 = 325,
349
-		TR4_OBJ_DOOR_TYPE5 = 326,
350
-		TR4_OBJ_DOOR_TYPE6 = 327,
351
-		TR4_OBJ_DOOR_TYPE7 = 328,
352
-		TR4_OBJ_DOOR_TYPE8 = 329,
353
-		TR4_OBJ_PUSHPULL_DOOR1 = 330,
354
-		TR4_OBJ_PUSHPULL_DOOR2 = 331,
355
-		TR4_OBJ_KICK_DOOR1 = 332,
356
-		TR4_OBJ_KICK_DOOR2 = 333,
357
-		TR4_OBJ_UNDERWATER_DOOR = 334,
358
-		TR4_OBJ_DOUBLE_DOORS = 335,
359
-		TR4_OBJ_BRIDGE_FLAT = 336,
360
-		TR4_OBJ_BRIDGE_TILT1 = 337,
361
-		TR4_OBJ_BRIDGE_TILT2 = 338,
362
-		TR4_OBJ_SARCOPHAGUS = 339,
363
-		TR4_OBJ_SEQUENCE_DOOR1 = 340,
364
-		TR4_OBJ_SEQUENCE_SWITCH1 = 341,
365
-		TR4_OBJ_SEQUENCE_SWITCH2 = 342,
366
-		TR4_OBJ_SEQUENCE_SWITCH3 = 343,
367
-		TR4_OBJ_SARCOPHAGUS_CUT = 344,
368
-		TR4_OBJ_HORUS_STATUE = 345,
369
-		TR4_OBJ_GOD_HEAD = 346,
370
-		TR4_OBJ_SETH_DOOR = 347,
371
-		TR4_OBJ_STATUE_PLINTH = 348,
372
-		TR4_OBJ_PISTOLS_ITEM = 349,
373
-		TR4_OBJ_PISTOLS_AMMO_ITEM = 350,
374
-		TR4_OBJ_UZI_ITEM = 351,
375
-		TR4_OBJ_UZI_AMMO_ITEM = 352,
376
-		TR4_OBJ_SHOTGUN_ITEM = 353,
377
-		TR4_OBJ_SHOTGUN_AMMO1_ITEM = 354,
378
-		TR4_OBJ_SHOTGUN_AMMO2_ITEM = 355,
379
-		TR4_OBJ_CROSSBOW_ITEM = 356,
380
-		TR4_OBJ_CROSSBOW_AMMO1_ITEM = 357,
381
-		TR4_OBJ_CROSSBOW_AMMO2_ITEM = 358,
382
-		TR4_OBJ_CROSSBOW_AMMO3_ITEM = 359,
383
-		TR4_OBJ_CROSSBOW_BOLT = 360,
384
-		TR4_OBJ_GRENADE_GUN_ITEM = 361,
385
-		TR4_OBJ_GRENADE_GUN_AMMO1_ITEM = 362,
386
-		TR4_OBJ_GRENADE_GUN_AMMO2_ITEM = 363,
387
-		TR4_OBJ_GRENADE_GUN_AMMO3_ITEM = 364,
388
-		TR4_OBJ_GRENADE = 365,
389
-		TR4_OBJ_SIXSHOOTER_ITEM = 366,
390
-		TR4_OBJ_SIXSHOOTER_AMMO_ITEM = 367,
391
-		TR4_OBJ_BIGMEDI_ITEM = 368,
392
-		TR4_OBJ_SMALLMEDI_ITEM = 369,
393
-		TR4_OBJ_LASERSIGHT_ITEM = 370,
394
-		TR4_OBJ_BINOCULARS_ITEM = 371,
395
-		TR4_OBJ_FLARE_ITEM = 372,
396
-		TR4_OBJ_FLARE_INV_ITEM = 373,
397
-		TR4_OBJ_DIARY_ITEM = 374,
398
-		TR4_OBJ_COMPASS_ITEM = 375,
399
-		TR4_OBJ_MEMCARD_LOAD_INV_ITEM = 376,
400
-		TR4_OBJ_MEMCARD_SAVE_INV_ITEM = 377,
401
-		TR4_OBJ_PC_LOAD_INV_ITEM = 378,
402
-		TR4_OBJ_PC_SAVE_INV_ITEM = 379,
403
-		TR4_OBJ_SMOKE_EMITTER_WHITE = 380,
404
-		TR4_OBJ_SMOKE_EMITTER_BLACK = 381,
405
-		TR4_OBJ_STEAM_EMITTER = 382,
406
-		TR4_OBJ_EARTHQUAKE = 383,
407
-		TR4_OBJ_BUBBLES = 384,
408
-		TR4_OBJ_WATERFALLMIST = 385,
409
-		TR4_OBJ_GUNSHELL = 386,
410
-		TR4_OBJ_SHOTGUNSHELL = 387,
411
-		TR4_OBJ_GUN_FLASH = 388,
412
-		TR4_OBJ_BUTTERFLY = 389,
413
-		TR4_OBJ_SPRINKLER = 390,
414
-		TR4_OBJ_RED_LIGHT = 391,
415
-		TR4_OBJ_GREEN_LIGHT = 392,
416
-		TR4_OBJ_BLUE_LIGHT = 393,
417
-		TR4_OBJ_AMBER_LIGHT = 394,
418
-		TR4_OBJ_WHITE_LIGHT = 395,
419
-		TR4_OBJ_BLINKING_LIGHT = 396,
420
-		TR4_OBJ_LENS_FLARE = 397,
421
-		TR4_OBJ_AI_GUARD = 398,
422
-		TR4_OBJ_AI_AMBUSH = 399,
423
-		TR4_OBJ_AI_PATROL1 = 400,
424
-		TR4_OBJ_AI_MODIFY = 401,
425
-		TR4_OBJ_AI_FOLLOW = 402,
426
-		TR4_OBJ_AI_PATROL2 = 403,
427
-		TR4_OBJ_AI_X1 = 404,
428
-		TR4_OBJ_AI_X2 = 405,
429
-		TR4_OBJ_LARA_START_POS = 406,
430
-		TR4_OBJ_KILL_ALL_TRIGGERS = 407,
431
-		TR4_OBJ_TRIGGER_TRIGGERER = 408,
432
-		TR4_OBJ_SMASH_OBJECT1 = 409,
433
-		TR4_OBJ_SMASH_OBJECT2 = 410,
434
-		TR4_OBJ_SMASH_OBJECT3 = 411,
435
-		TR4_OBJ_SMASH_OBJECT4 = 412,
436
-		TR4_OBJ_SMASH_OBJECT5 = 413,
437
-		TR4_OBJ_SMASH_OBJECT6 = 414,
438
-		TR4_OBJ_SMASH_OBJECT7 = 415,
439
-		TR4_OBJ_SMASH_OBJECT8 = 416,
440
-		TR4_OBJ_MESHSWAP1 = 417,
441
-		TR4_OBJ_MESHSWAP2 = 418,
442
-		TR4_OBJ_MESHSWAP3 = 419,
443
-		TR4_OBJ_DEATH_SLIDE = 420,
444
-		TR4_OBJ_BODY_PART = 421,
445
-		TR4_OBJ_CAMERA_TARGET = 422,
446
-		TR4_OBJ_WATERFALL1 = 423,
447
-		TR4_OBJ_WATERFALL2 = 424,
448
-		TR4_OBJ_WATERFALL3 = 425,
449
-		TR4_OBJ_PLANET_EFFECT = 426,
450
-		TR4_OBJ_ANIMATING1 = 427,
451
-		TR4_OBJ_ANIMATING1_MIP = 428,
452
-		TR4_OBJ_ANIMATING2 = 429,
453
-		TR4_OBJ_ANIMATING2_MIP = 430,
454
-		TR4_OBJ_ANIMATING3 = 431,
455
-		TR4_OBJ_ANIMATING3_MIP = 432,
456
-		TR4_OBJ_ANIMATING4 = 433,
457
-		TR4_OBJ_ANIMATING4_MIP = 434,
458
-		TR4_OBJ_ANIMATING5 = 435,
459
-		TR4_OBJ_ANIMATING5_MIP = 436,
460
-		TR4_OBJ_ANIMATING6 = 437,
461
-		TR4_OBJ_ANIMATING6_MIP = 438,
462
-		TR4_OBJ_ANIMATING7 = 439,
463
-		TR4_OBJ_ANIMATING7_MIP = 440,
464
-		TR4_OBJ_ANIMATING8 = 441,
465
-		TR4_OBJ_ANIMATING8_MIP = 442,
466
-		TR4_OBJ_ANIMATING9 = 443,
467
-		TR4_OBJ_ANIMATING9_MIP = 444,
468
-		TR4_OBJ_ANIMATING10 = 445,
469
-		TR4_OBJ_ANIMATING10_MIP = 446,
470
-		TR4_OBJ_ANIMATING11 = 447,
471
-		TR4_OBJ_ANIMATING11_MIP = 448,
472
-		TR4_OBJ_ANIMATING12 = 449,
473
-		TR4_OBJ_ANIMATING12_MIP = 450,
474
-		TR4_OBJ_ANIMATING13 = 451,
475
-		TR4_OBJ_ANIMATING13_MIP = 452,
476
-		TR4_OBJ_ANIMATING14 = 453,
477
-		TR4_OBJ_ANIMATING14_MIP = 454,
478
-		TR4_OBJ_ANIMATING15 = 455,
479
-		TR4_OBJ_ANIMATING15_MIP = 456,
480
-		TR4_OBJ_ANIMATING16 = 457,
481
-		TR4_OBJ_ANIMATING16_MIP = 458,
482
-		TR4_OBJ_HORIZON = 459,
483
-		TR4_OBJ_SKY_GRAPHICS = 460,				   // Sprite (in SWD file)
484
-		TR4_OBJ_BINOCULAR_GRAPHICS = 461,
485
-		TR4_OBJ_TARGET_GRAPHICS = 462,
486
-		TR4_OBJ_DEFAULT_SPRITES = 463,				// Sprite (in SWD file)
487
-		TR4_OBJ_MISC_SPRITES = 464
23
+        TR4_OBJ_LARA = 0,
24
+        TR4_OBJ_PISTOLS_ANIM = 1,
25
+        TR4_OBJ_UZI_ANIM = 2,
26
+        TR4_OBJ_SHOTGUN_ANIM = 3,
27
+        TR4_OBJ_CROSSBOW_ANIM = 4,
28
+        TR4_OBJ_GRENADE_GUN_ANIM = 5,
29
+        TR4_OBJ_SIXSHOOTER_ANIM = 6,
30
+        TR4_OBJ_FLARE_ANIM = 7,
31
+        TR4_OBJ_LARA_SKIN = 8,
32
+        TR4_OBJ_LARA_SKIN_JOINTS = 9,
33
+        TR4_OBJ_LARA_SCREAM = 10,
34
+        TR4_OBJ_LARA_CROSSBOW_LASER = 11,
35
+        TR4_OBJ_LARA_REVOLVER_LASER = 12,
36
+        TR4_OBJ_LARA_HOLSTERS = 13,
37
+        TR4_OBJ_LARA_HOLSTERS_PISTOLS = 14,
38
+        TR4_OBJ_LARA_HOLSTERS_UZIS = 15,
39
+        TR4_OBJ_LARA_HOLSTERS_SIXSHOOTER = 16,
40
+        TR4_OBJ_LARA_SPEECH_HEAD1 = 17,
41
+        TR4_OBJ_LARA_SPEECH_HEAD2 = 18,
42
+        TR4_OBJ_LARA_SPEECH_HEAD3 = 19,
43
+        TR4_OBJ_LARA_SPEECH_HEAD4 = 20,
44
+        TR4_OBJ_ACTOR1_SPEECH_HEAD1 = 21,
45
+        TR4_OBJ_ACTOR1_SPEECH_HEAD2 = 22,
46
+        TR4_OBJ_ACTOR2_SPEECH_HEAD1 = 23,
47
+        TR4_OBJ_ACTOR2_SPEECH_HEAD2 = 24,
48
+        TR4_OBJ_LARA_WATER_MESH = 25,
49
+        TR4_OBJ_LARA_PETROL_MESH = 26,
50
+        TR4_OBJ_LARA_DIRT_MESH = 27,
51
+        TR4_OBJ_CROWBAR_ANIM = 28,
52
+        TR4_OBJ_TORCH_ANIM = 29,
53
+        TR4_OBJ_HAIR = 30,
54
+        TR4_OBJ_MOTORBIKE = 31,
55
+        TR4_OBJ_JEEP = 32,
56
+        TR4_OBJ_VEHICLE_EXTRA = 33,
57
+        TR4_OBJ_ENEMY_JEEP = 34,
58
+        TR4_OBJ_SKELETON = 35,
59
+        TR4_OBJ_SKELETON_MIP = 36,
60
+        TR4_OBJ_GUIDE = 37,
61
+        TR4_OBJ_GUIDE_MIP = 38,
62
+        TR4_OBJ_VON_CROY = 39,
63
+        TR4_OBJ_VON_CROY_MIP = 40,
64
+        TR4_OBJ_BADDY_1 = 41,
65
+        TR4_OBJ_BADDY_1_MIP = 42,
66
+        TR4_OBJ_BADDY_2 = 43,
67
+        TR4_OBJ_BADDY_2_MIP = 44,
68
+        TR4_OBJ_SETHA = 45,
69
+        TR4_OBJ_SETHA_MIP = 46,
70
+        TR4_OBJ_MUMMY = 47,
71
+        TR4_OBJ_MUMMY_MIP = 48,
72
+        TR4_OBJ_SPHINX = 49,
73
+        TR4_OBJ_SPHINX_MIP = 50,
74
+        TR4_OBJ_CROCODILE = 51,
75
+        TR4_OBJ_CROCODILE_MIP = 52,
76
+        TR4_OBJ_HORSEMAN = 53,
77
+        TR4_OBJ_HORSEMAN_MIP = 54,
78
+        TR4_OBJ_SCORPION = 55,
79
+        TR4_OBJ_SCORPION_MIP = 56,
80
+        TR4_OBJ_JEAN_YVES = 57,
81
+        TR4_OBJ_JEAN_YVES_MIP = 58,
82
+        TR4_OBJ_TROOPS = 59,
83
+        TR4_OBJ_TROOPS_MIP = 60,
84
+        TR4_OBJ_KNIGHTS_TEMPLAR = 61,
85
+        TR4_OBJ_KNIGHTS_TEMPLAR_MIP = 62,
86
+        TR4_OBJ_MUTANT = 63,
87
+        TR4_OBJ_MUTANT_MIP = 64,
88
+        TR4_OBJ_HORSE = 65,
89
+        TR4_OBJ_HORSE_MIP = 66,
90
+        TR4_OBJ_BABOON_NORMAL = 67,
91
+        TR4_OBJ_BABOON_NORMAL_MIP = 68,
92
+        TR4_OBJ_BABOON_INV = 69,
93
+        TR4_OBJ_BABOON_INV_MIP = 70,
94
+        TR4_OBJ_BABOON_SILENT = 71,
95
+        TR4_OBJ_BABOON_SILENT_MIP = 72,
96
+        TR4_OBJ_WILD_BOAR = 73,
97
+        TR4_OBJ_WILD_BOAR_MIP = 74,
98
+        TR4_OBJ_HARPY = 75,
99
+        TR4_OBJ_HARPY_MIP = 76,
100
+        TR4_OBJ_DEMIGOD1 = 77,
101
+        TR4_OBJ_DEMIGOD1_MIP = 78,
102
+        TR4_OBJ_DEMIGOD2 = 79,
103
+        TR4_OBJ_DEMIGOD2_MIP = 80,
104
+        TR4_OBJ_DEMIGOD3 = 81,
105
+        TR4_OBJ_DEMIGOD3_MIP = 82,
106
+        TR4_OBJ_LITTLE_BEETLE = 83,
107
+        TR4_OBJ_BIG_BEETLE = 84,
108
+        TR4_OBJ_BIG_BEETLE_MIP = 85,
109
+        TR4_OBJ_WRAITH1 = 86,
110
+        TR4_OBJ_WRAITH2 = 87,
111
+        TR4_OBJ_WRAITH3 = 88,
112
+        TR4_OBJ_WRAITH4 = 89,
113
+        TR4_OBJ_BAT = 90,
114
+        TR4_OBJ_DOG = 91,
115
+        TR4_OBJ_DOG_MIP = 92,
116
+        TR4_OBJ_HAMMERHEAD = 93,
117
+        TR4_OBJ_HAMMERHEAD_MIP = 94,
118
+        TR4_OBJ_SAS = 95,
119
+        TR4_OBJ_SAS_MIP = 96,
120
+        TR4_OBJ_SAS_DYING = 97,
121
+        TR4_OBJ_SAS_DYING_MIP = 98,
122
+        TR4_OBJ_SAS_CAPTAIN = 99,
123
+        TR4_OBJ_SAS_CAPTAIN_MIP = 100,
124
+        TR4_OBJ_SAS_DRAG_BLOKE = 101,
125
+        TR4_OBJ_AHMET = 102,
126
+        TR4_OBJ_AHMET_MIP = 103,
127
+        TR4_OBJ_LARA_DOUBLE = 104,
128
+        TR4_OBJ_LARA_DOUBLE_MIP = 105,
129
+        TR4_OBJ_SMALL_SCORPION = 106,
130
+        TR4_OBJ_FISH = 107,
131
+        TR4_OBJ_GAME_PIECE1 = 108,
132
+        TR4_OBJ_GAME_PIECE2 = 109,
133
+        TR4_OBJ_GAME_PIECE3 = 110,
134
+        TR4_OBJ_ENEMY_PIECE = 111,
135
+        TR4_OBJ_WHEEL_OF_FORTUNE = 112,
136
+        TR4_OBJ_SCALES = 113,
137
+        TR4_OBJ_DARTS = 114,
138
+        TR4_OBJ_DART_EMITTER = 115,
139
+        TR4_OBJ_HOMING_DART_EMITTER = 116,
140
+        TR4_OBJ_FALLING_CEILING = 117,
141
+        TR4_OBJ_FALLING_BLOCK = 118,
142
+        TR4_OBJ_FALLING_BLOCK2 = 119,
143
+        TR4_OBJ_SMASHABLE_BIKE_WALL = 120,
144
+        TR4_OBJ_SMASHABLE_BIKE_FLOOR = 121,
145
+        TR4_OBJ_TRAPDOOR1 = 122,
146
+        TR4_OBJ_TRAPDOOR2 = 123,
147
+        TR4_OBJ_TRAPDOOR3 = 124,
148
+        TR4_OBJ_FLOOR_TRAPDOOR1 = 125,
149
+        TR4_OBJ_FLOOR_TRAPDOOR2 = 126,
150
+        TR4_OBJ_CEILING_TRAPDOOR1 = 127,
151
+        TR4_OBJ_CEILING_TRAPDOOR2 = 128,
152
+        TR4_OBJ_SCALING_TRAPDOOR = 129,
153
+        TR4_OBJ_ROLLINGBALL = 130,
154
+        TR4_OBJ_SPIKEY_FLOOR = 131,
155
+        TR4_OBJ_TEETH_SPIKES = 132,
156
+        TR4_OBJ_JOBY_SPIKES = 133,
157
+        TR4_OBJ_SLICER_DICER = 134,
158
+        TR4_OBJ_CHAIN = 135,
159
+        TR4_OBJ_PLOUGH = 136,
160
+        TR4_OBJ_STARGATE = 137,
161
+        TR4_OBJ_HAMMER = 138,
162
+        TR4_OBJ_BURNING_FLOOR = 139,
163
+        TR4_OBJ_COG = 140,
164
+        TR4_OBJ_SPIKEBALL = 141,
165
+        TR4_OBJ_FLAME = 142,
166
+        TR4_OBJ_FLAME_EMITTER = 143,
167
+        TR4_OBJ_FLAME_EMITTER2 = 144,
168
+        TR4_OBJ_FLAME_EMITTER3 = 145,
169
+        TR4_OBJ_ROPE = 146,
170
+        TR4_OBJ_FIREROPE = 147,
171
+        TR4_OBJ_POLEROPE = 148,
172
+        TR4_OBJ_ONEBLOCK_PLATFORM = 149,
173
+        TR4_OBJ_TWOBLOCK_PLATFORM = 150,
174
+        TR4_OBJ_RAISING_BLOCK1 = 151,
175
+        TR4_OBJ_RAISING_BLOCK2 = 152,
176
+        TR4_OBJ_EXPANDING_PLATFORM = 153,
177
+        TR4_OBJ_SQUISHY_BLOCK1 = 154,
178
+        TR4_OBJ_SQUISHY_BLOCK2 = 155,
179
+        TR4_OBJ_PUSHABLE_OBJECT1 = 156,
180
+        TR4_OBJ_PUSHABLE_OBJECT2 = 157,
181
+        TR4_OBJ_PUSHABLE_OBJECT3 = 158,
182
+        TR4_OBJ_PUSHABLE_OBJECT4 = 159,
183
+        TR4_OBJ_PUSHABLE_OBJECT5 = 160,
184
+        TR4_OBJ_TRIPWIRE = 161,
185
+        TR4_OBJ_SENTRY_GUN = 162,
186
+        TR4_OBJ_MINE = 163,
187
+        TR4_OBJ_MAPPER = 164,
188
+        TR4_OBJ_OBELISK = 165,
189
+        TR4_OBJ_FLOOR_4BLADE = 166,
190
+        TR4_OBJ_ROOF_4BLADE = 167,
191
+        TR4_OBJ_BIRD_BLADE = 168,
192
+        TR4_OBJ_CATWALK_BLADE = 169,
193
+        TR4_OBJ_MOVING_BLADE = 170,
194
+        TR4_OBJ_PLINTH_BLADE = 171,
195
+        TR4_OBJ_SETH_BLADE = 172,
196
+        TR4_OBJ_LIGHTNING_CONDUCTOR = 173,
197
+        TR4_OBJ_ELEMENT_PUZZLE = 174,
198
+        TR4_OBJ_PUZZLE_ITEM1 = 175,
199
+        TR4_OBJ_PUZZLE_ITEM2 = 176,
200
+        TR4_OBJ_PUZZLE_ITEM3 = 177,
201
+        TR4_OBJ_PUZZLE_ITEM4 = 178,
202
+        TR4_OBJ_PUZZLE_ITEM5 = 179,
203
+        TR4_OBJ_PUZZLE_ITEM6 = 180,
204
+        TR4_OBJ_PUZZLE_ITEM7 = 181,
205
+        TR4_OBJ_PUZZLE_ITEM8 = 182,
206
+        TR4_OBJ_PUZZLE_ITEM9 = 183,
207
+        TR4_OBJ_PUZZLE_ITEM10 = 184,
208
+        TR4_OBJ_PUZZLE_ITEM11 = 185,
209
+        TR4_OBJ_PUZZLE_ITEM12 = 186,
210
+        TR4_OBJ_PUZZLE_ITEM1_COMBO1 = 187,
211
+        TR4_OBJ_PUZZLE_ITEM1_COMBO2 = 188,
212
+        TR4_OBJ_PUZZLE_ITEM2_COMBO1 = 189,
213
+        TR4_OBJ_PUZZLE_ITEM2_COMBO2 = 190,
214
+        TR4_OBJ_PUZZLE_ITEM3_COMBO1 = 191,
215
+        TR4_OBJ_PUZZLE_ITEM3_COMBO2 = 192,
216
+        TR4_OBJ_PUZZLE_ITEM4_COMBO1 = 193,
217
+        TR4_OBJ_PUZZLE_ITEM4_COMBO2 = 194,
218
+        TR4_OBJ_PUZZLE_ITEM5_COMBO1 = 195,
219
+        TR4_OBJ_PUZZLE_ITEM5_COMBO2 = 196,
220
+        TR4_OBJ_PUZZLE_ITEM6_COMBO1 = 197,
221
+        TR4_OBJ_PUZZLE_ITEM6_COMBO2 = 198,
222
+        TR4_OBJ_PUZZLE_ITEM7_COMBO1 = 199,
223
+        TR4_OBJ_PUZZLE_ITEM7_COMBO2 = 200,
224
+        TR4_OBJ_PUZZLE_ITEM8_COMBO1 = 201,
225
+        TR4_OBJ_PUZZLE_ITEM8_COMBO2 = 202,
226
+        TR4_OBJ_KEY_ITEM1 = 203,
227
+        TR4_OBJ_KEY_ITEM2 = 204,
228
+        TR4_OBJ_KEY_ITEM3 = 205,
229
+        TR4_OBJ_KEY_ITEM4 = 206,
230
+        TR4_OBJ_KEY_ITEM5 = 207,
231
+        TR4_OBJ_KEY_ITEM6 = 208,
232
+        TR4_OBJ_KEY_ITEM7 = 209,
233
+        TR4_OBJ_KEY_ITEM8 = 210,
234
+        TR4_OBJ_KEY_ITEM9 = 211,
235
+        TR4_OBJ_KEY_ITEM10 = 212,
236
+        TR4_OBJ_KEY_ITEM11 = 213,
237
+        TR4_OBJ_KEY_ITEM12 = 214,
238
+        TR4_OBJ_KEY_ITEM1_COMBO1 = 215,
239
+        TR4_OBJ_KEY_ITEM1_COMBO2 = 216,
240
+        TR4_OBJ_KEY_ITEM2_COMBO1 = 217,
241
+        TR4_OBJ_KEY_ITEM2_COMBO2 = 218,
242
+        TR4_OBJ_KEY_ITEM3_COMBO1 = 219,
243
+        TR4_OBJ_KEY_ITEM3_COMBO2 = 220,
244
+        TR4_OBJ_KEY_ITEM4_COMBO1 = 221,
245
+        TR4_OBJ_KEY_ITEM4_COMBO2 = 222,
246
+        TR4_OBJ_KEY_ITEM5_COMBO1 = 223,
247
+        TR4_OBJ_KEY_ITEM5_COMBO2 = 224,
248
+        TR4_OBJ_KEY_ITEM6_COMBO1 = 225,
249
+        TR4_OBJ_KEY_ITEM6_COMBO2 = 226,
250
+        TR4_OBJ_KEY_ITEM7_COMBO1 = 227,
251
+        TR4_OBJ_KEY_ITEM7_COMBO2 = 228,
252
+        TR4_OBJ_KEY_ITEM8_COMBO1 = 229,
253
+        TR4_OBJ_KEY_ITEM8_COMBO2 = 230,
254
+        TR4_OBJ_PICKUP_ITEM1 = 231,
255
+        TR4_OBJ_PICKUP_ITEM2 = 232,
256
+        TR4_OBJ_PICKUP_ITEM3 = 233,
257
+        TR4_OBJ_PICKUP_ITEM4 = 234,
258
+        TR4_OBJ_PICKUP_ITEM1_COMBO1 = 235,
259
+        TR4_OBJ_PICKUP_ITEM1_COMBO2 = 236,
260
+        TR4_OBJ_PICKUP_ITEM2_COMBO1 = 237,
261
+        TR4_OBJ_PICKUP_ITEM2_COMBO2 = 238,
262
+        TR4_OBJ_PICKUP_ITEM3_COMBO1 = 239,
263
+        TR4_OBJ_PICKUP_ITEM3_COMBO2 = 240,
264
+        TR4_OBJ_PICKUP_ITEM4_COMBO1 = 241,
265
+        TR4_OBJ_PICKUP_ITEM4_COMBO2 = 242,
266
+        TR4_OBJ_EXAMINE1 = 243,
267
+        TR4_OBJ_EXAMINE2 = 244,
268
+        TR4_OBJ_EXAMINE3 = 245,
269
+        TR4_OBJ_CROWBAR_ITEM = 246,
270
+        TR4_OBJ_BURNING_TORCH_ITEM = 247,
271
+        TR4_OBJ_CLOCKWORK_BEETLE = 248,
272
+        TR4_OBJ_CLOCKWORK_BEETLE_COMBO1 = 249,
273
+        TR4_OBJ_CLOCKWORK_BEETLE_COMBO2 = 250,
274
+        TR4_OBJ_MINE_DETECTOR = 251,
275
+        TR4_OBJ_QUEST_ITEM1 = 252,
276
+        TR4_OBJ_QUEST_ITEM2 = 253,
277
+        TR4_OBJ_QUEST_ITEM3 = 254,
278
+        TR4_OBJ_QUEST_ITEM4 = 255,
279
+        TR4_OBJ_QUEST_ITEM5 = 256,
280
+        TR4_OBJ_QUEST_ITEM6 = 257,
281
+        TR4_OBJ_MAP = 258,
282
+        TR4_OBJ_SECRET_MAP = 259,
283
+        TR4_OBJ_PUZZLE_HOLE1 = 260,
284
+        TR4_OBJ_PUZZLE_HOLE2 = 261,
285
+        TR4_OBJ_PUZZLE_HOLE3 = 262,
286
+        TR4_OBJ_PUZZLE_HOLE4 = 263,
287
+        TR4_OBJ_PUZZLE_HOLE5 = 264,
288
+        TR4_OBJ_PUZZLE_HOLE6 = 265,
289
+        TR4_OBJ_PUZZLE_HOLE7 = 266,
290
+        TR4_OBJ_PUZZLE_HOLE8 = 267,
291
+        TR4_OBJ_PUZZLE_HOLE9 = 268,
292
+        TR4_OBJ_PUZZLE_HOLE10 = 269,
293
+        TR4_OBJ_PUZZLE_HOLE11 = 270,
294
+        TR4_OBJ_PUZZLE_HOLE12 = 271,
295
+        TR4_OBJ_PUZZLE_DONE1 = 272,
296
+        TR4_OBJ_PUZZLE_DONE2 = 273,
297
+        TR4_OBJ_PUZZLE_DONE3 = 274,
298
+        TR4_OBJ_PUZZLE_DONE4 = 275,
299
+        TR4_OBJ_PUZZLE_DONE5 = 276,
300
+        TR4_OBJ_PUZZLE_DONE6 = 277,
301
+        TR4_OBJ_PUZZLE_DONE7 = 278,
302
+        TR4_OBJ_PUZZLE_DONE8 = 279,
303
+        TR4_OBJ_PUZZLE_DONE9 = 280,
304
+        TR4_OBJ_PUZZLE_DONE10 = 281,
305
+        TR4_OBJ_PUZZLE_DONE11 = 282,
306
+        TR4_OBJ_PUZZLE_DONE12 = 283,
307
+        TR4_OBJ_KEY_HOLE1 = 284,
308
+        TR4_OBJ_KEY_HOLE2 = 285,
309
+        TR4_OBJ_KEY_HOLE3 = 286,
310
+        TR4_OBJ_KEY_HOLE4 = 287,
311
+        TR4_OBJ_KEY_HOLE5 = 288,
312
+        TR4_OBJ_KEY_HOLE6 = 289,
313
+        TR4_OBJ_KEY_HOLE7 = 290,
314
+        TR4_OBJ_KEY_HOLE8 = 291,
315
+        TR4_OBJ_KEY_HOLE9 = 292,
316
+        TR4_OBJ_KEY_HOLE10 = 293,
317
+        TR4_OBJ_KEY_HOLE11 = 294,
318
+        TR4_OBJ_KEY_HOLE12 = 295,
319
+        TR4_OBJ_WATERSKIN1_EMPTY = 296,
320
+        TR4_OBJ_WATERSKIN1_1 = 297,
321
+        TR4_OBJ_WATERSKIN1_2 = 298,
322
+        TR4_OBJ_WATERSKIN1_3 = 299,
323
+        TR4_OBJ_WATERSKIN2_EMPTY = 300,
324
+        TR4_OBJ_WATERSKIN2_1 = 301,
325
+        TR4_OBJ_WATERSKIN2_2 = 302,
326
+        TR4_OBJ_WATERSKIN2_3 = 303,
327
+        TR4_OBJ_WATERSKIN2_4 = 304,
328
+        TR4_OBJ_WATERSKIN2_5 = 305,
329
+        TR4_OBJ_SWITCH_TYPE1 = 306,
330
+        TR4_OBJ_SWITCH_TYPE2 = 307,
331
+        TR4_OBJ_SWITCH_TYPE3 = 308,
332
+        TR4_OBJ_SWITCH_TYPE4 = 309,
333
+        TR4_OBJ_SWITCH_TYPE5 = 310,
334
+        TR4_OBJ_SWITCH_TYPE6 = 311,
335
+        TR4_OBJ_SWITCH_TYPE7 = 312,
336
+        TR4_OBJ_SWITCH_TYPE8 = 313,
337
+        TR4_OBJ_UNDERWATER_SWITCH1 = 314,
338
+        TR4_OBJ_UNDERWATER_SWITCH2 = 315,
339
+        TR4_OBJ_TURN_SWITCH = 316,
340
+        TR4_OBJ_COG_SWITCH = 317,
341
+        TR4_OBJ_LEVER_SWITCH = 318,
342
+        TR4_OBJ_JUMP_SWITCH = 319,
343
+        TR4_OBJ_CROWBAR_SWITCH = 320,
344
+        TR4_OBJ_PULLEY = 321,
345
+        TR4_OBJ_DOOR_TYPE1 = 322,
346
+        TR4_OBJ_DOOR_TYPE2 = 323,
347
+        TR4_OBJ_DOOR_TYPE3 = 324,
348
+        TR4_OBJ_DOOR_TYPE4 = 325,
349
+        TR4_OBJ_DOOR_TYPE5 = 326,
350
+        TR4_OBJ_DOOR_TYPE6 = 327,
351
+        TR4_OBJ_DOOR_TYPE7 = 328,
352
+        TR4_OBJ_DOOR_TYPE8 = 329,
353
+        TR4_OBJ_PUSHPULL_DOOR1 = 330,
354
+        TR4_OBJ_PUSHPULL_DOOR2 = 331,
355
+        TR4_OBJ_KICK_DOOR1 = 332,
356
+        TR4_OBJ_KICK_DOOR2 = 333,
357
+        TR4_OBJ_UNDERWATER_DOOR = 334,
358
+        TR4_OBJ_DOUBLE_DOORS = 335,
359
+        TR4_OBJ_BRIDGE_FLAT = 336,
360
+        TR4_OBJ_BRIDGE_TILT1 = 337,
361
+        TR4_OBJ_BRIDGE_TILT2 = 338,
362
+        TR4_OBJ_SARCOPHAGUS = 339,
363
+        TR4_OBJ_SEQUENCE_DOOR1 = 340,
364
+        TR4_OBJ_SEQUENCE_SWITCH1 = 341,
365
+        TR4_OBJ_SEQUENCE_SWITCH2 = 342,
366
+        TR4_OBJ_SEQUENCE_SWITCH3 = 343,
367
+        TR4_OBJ_SARCOPHAGUS_CUT = 344,
368
+        TR4_OBJ_HORUS_STATUE = 345,
369
+        TR4_OBJ_GOD_HEAD = 346,
370
+        TR4_OBJ_SETH_DOOR = 347,
371
+        TR4_OBJ_STATUE_PLINTH = 348,
372
+        TR4_OBJ_PISTOLS_ITEM = 349,
373
+        TR4_OBJ_PISTOLS_AMMO_ITEM = 350,
374
+        TR4_OBJ_UZI_ITEM = 351,
375
+        TR4_OBJ_UZI_AMMO_ITEM = 352,
376
+        TR4_OBJ_SHOTGUN_ITEM = 353,
377
+        TR4_OBJ_SHOTGUN_AMMO1_ITEM = 354,
378
+        TR4_OBJ_SHOTGUN_AMMO2_ITEM = 355,
379
+        TR4_OBJ_CROSSBOW_ITEM = 356,
380
+        TR4_OBJ_CROSSBOW_AMMO1_ITEM = 357,
381
+        TR4_OBJ_CROSSBOW_AMMO2_ITEM = 358,
382
+        TR4_OBJ_CROSSBOW_AMMO3_ITEM = 359,
383
+        TR4_OBJ_CROSSBOW_BOLT = 360,
384
+        TR4_OBJ_GRENADE_GUN_ITEM = 361,
385
+        TR4_OBJ_GRENADE_GUN_AMMO1_ITEM = 362,
386
+        TR4_OBJ_GRENADE_GUN_AMMO2_ITEM = 363,
387
+        TR4_OBJ_GRENADE_GUN_AMMO3_ITEM = 364,
388
+        TR4_OBJ_GRENADE = 365,
389
+        TR4_OBJ_SIXSHOOTER_ITEM = 366,
390
+        TR4_OBJ_SIXSHOOTER_AMMO_ITEM = 367,
391
+        TR4_OBJ_BIGMEDI_ITEM = 368,
392
+        TR4_OBJ_SMALLMEDI_ITEM = 369,
393
+        TR4_OBJ_LASERSIGHT_ITEM = 370,
394
+        TR4_OBJ_BINOCULARS_ITEM = 371,
395
+        TR4_OBJ_FLARE_ITEM = 372,
396
+        TR4_OBJ_FLARE_INV_ITEM = 373,
397
+        TR4_OBJ_DIARY_ITEM = 374,
398
+        TR4_OBJ_COMPASS_ITEM = 375,
399
+        TR4_OBJ_MEMCARD_LOAD_INV_ITEM = 376,
400
+        TR4_OBJ_MEMCARD_SAVE_INV_ITEM = 377,
401
+        TR4_OBJ_PC_LOAD_INV_ITEM = 378,
402
+        TR4_OBJ_PC_SAVE_INV_ITEM = 379,
403
+        TR4_OBJ_SMOKE_EMITTER_WHITE = 380,
404
+        TR4_OBJ_SMOKE_EMITTER_BLACK = 381,
405
+        TR4_OBJ_STEAM_EMITTER = 382,
406
+        TR4_OBJ_EARTHQUAKE = 383,
407
+        TR4_OBJ_BUBBLES = 384,
408
+        TR4_OBJ_WATERFALLMIST = 385,
409
+        TR4_OBJ_GUNSHELL = 386,
410
+        TR4_OBJ_SHOTGUNSHELL = 387,
411
+        TR4_OBJ_GUN_FLASH = 388,
412
+        TR4_OBJ_BUTTERFLY = 389,
413
+        TR4_OBJ_SPRINKLER = 390,
414
+        TR4_OBJ_RED_LIGHT = 391,
415
+        TR4_OBJ_GREEN_LIGHT = 392,
416
+        TR4_OBJ_BLUE_LIGHT = 393,
417
+        TR4_OBJ_AMBER_LIGHT = 394,
418
+        TR4_OBJ_WHITE_LIGHT = 395,
419
+        TR4_OBJ_BLINKING_LIGHT = 396,
420
+        TR4_OBJ_LENS_FLARE = 397,
421
+        TR4_OBJ_AI_GUARD = 398,
422
+        TR4_OBJ_AI_AMBUSH = 399,
423
+        TR4_OBJ_AI_PATROL1 = 400,
424
+        TR4_OBJ_AI_MODIFY = 401,
425
+        TR4_OBJ_AI_FOLLOW = 402,
426
+        TR4_OBJ_AI_PATROL2 = 403,
427
+        TR4_OBJ_AI_X1 = 404,
428
+        TR4_OBJ_AI_X2 = 405,
429
+        TR4_OBJ_LARA_START_POS = 406,
430
+        TR4_OBJ_KILL_ALL_TRIGGERS = 407,
431
+        TR4_OBJ_TRIGGER_TRIGGERER = 408,
432
+        TR4_OBJ_SMASH_OBJECT1 = 409,
433
+        TR4_OBJ_SMASH_OBJECT2 = 410,
434
+        TR4_OBJ_SMASH_OBJECT3 = 411,
435
+        TR4_OBJ_SMASH_OBJECT4 = 412,
436
+        TR4_OBJ_SMASH_OBJECT5 = 413,
437
+        TR4_OBJ_SMASH_OBJECT6 = 414,
438
+        TR4_OBJ_SMASH_OBJECT7 = 415,
439
+        TR4_OBJ_SMASH_OBJECT8 = 416,
440
+        TR4_OBJ_MESHSWAP1 = 417,
441
+        TR4_OBJ_MESHSWAP2 = 418,
442
+        TR4_OBJ_MESHSWAP3 = 419,
443
+        TR4_OBJ_DEATH_SLIDE = 420,
444
+        TR4_OBJ_BODY_PART = 421,
445
+        TR4_OBJ_CAMERA_TARGET = 422,
446
+        TR4_OBJ_WATERFALL1 = 423,
447
+        TR4_OBJ_WATERFALL2 = 424,
448
+        TR4_OBJ_WATERFALL3 = 425,
449
+        TR4_OBJ_PLANET_EFFECT = 426,
450
+        TR4_OBJ_ANIMATING1 = 427,
451
+        TR4_OBJ_ANIMATING1_MIP = 428,
452
+        TR4_OBJ_ANIMATING2 = 429,
453
+        TR4_OBJ_ANIMATING2_MIP = 430,
454
+        TR4_OBJ_ANIMATING3 = 431,
455
+        TR4_OBJ_ANIMATING3_MIP = 432,
456
+        TR4_OBJ_ANIMATING4 = 433,
457
+        TR4_OBJ_ANIMATING4_MIP = 434,
458
+        TR4_OBJ_ANIMATING5 = 435,
459
+        TR4_OBJ_ANIMATING5_MIP = 436,
460
+        TR4_OBJ_ANIMATING6 = 437,
461
+        TR4_OBJ_ANIMATING6_MIP = 438,
462
+        TR4_OBJ_ANIMATING7 = 439,
463
+        TR4_OBJ_ANIMATING7_MIP = 440,
464
+        TR4_OBJ_ANIMATING8 = 441,
465
+        TR4_OBJ_ANIMATING8_MIP = 442,
466
+        TR4_OBJ_ANIMATING9 = 443,
467
+        TR4_OBJ_ANIMATING9_MIP = 444,
468
+        TR4_OBJ_ANIMATING10 = 445,
469
+        TR4_OBJ_ANIMATING10_MIP = 446,
470
+        TR4_OBJ_ANIMATING11 = 447,
471
+        TR4_OBJ_ANIMATING11_MIP = 448,
472
+        TR4_OBJ_ANIMATING12 = 449,
473
+        TR4_OBJ_ANIMATING12_MIP = 450,
474
+        TR4_OBJ_ANIMATING13 = 451,
475
+        TR4_OBJ_ANIMATING13_MIP = 452,
476
+        TR4_OBJ_ANIMATING14 = 453,
477
+        TR4_OBJ_ANIMATING14_MIP = 454,
478
+        TR4_OBJ_ANIMATING15 = 455,
479
+        TR4_OBJ_ANIMATING15_MIP = 456,
480
+        TR4_OBJ_ANIMATING16 = 457,
481
+        TR4_OBJ_ANIMATING16_MIP = 458,
482
+        TR4_OBJ_HORIZON = 459,
483
+        TR4_OBJ_SKY_GRAPHICS = 460,                // Sprite (in SWD file)
484
+        TR4_OBJ_BINOCULAR_GRAPHICS = 461,
485
+        TR4_OBJ_TARGET_GRAPHICS = 462,
486
+        TR4_OBJ_DEFAULT_SPRITES = 463,              // Sprite (in SWD file)
487
+        TR4_OBJ_MISC_SPRITES = 464
488 488
 
489 489
 } tr4_objects_t;
490 490
 

+ 1042
- 1042
include/Tree.h
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 260
- 260
include/Vector.h Переглянути файл

@@ -36,373 +36,373 @@ template <class Object> class Vector
36 36
 {
37 37
 public:
38 38
 
39
-	Vector()
40
-	{
41
-		mData = 0x0;
42
-		mError = 0x0;
39
+    Vector()
40
+    {
41
+        mData = 0x0;
42
+        mError = 0x0;
43 43
 
44
-		mReserve = 0;
45
-		mStart = 0;
46
-		mEnd = 0;
44
+        mReserve = 0;
45
+        mStart = 0;
46
+        mEnd = 0;
47 47
 
48
-		mIndex = 0;
49
-	}
48
+        mIndex = 0;
49
+    }
50 50
 
51 51
 
52
-	Vector(Vector &vector)
53
-	{
54
-		mData = 0x0;
55
-		mError = 0x0;
52
+    Vector(Vector &vector)
53
+    {
54
+        mData = 0x0;
55
+        mError = 0x0;
56 56
 
57
-		mReserve = 0;
58
-		mStart = 0;
59
-		mEnd = 0;
57
+        mReserve = 0;
58
+        mStart = 0;
59
+        mEnd = 0;
60 60
 
61
-		copy(vector);
62
-	}
61
+        copy(vector);
62
+    }
63 63
 
64 64
 
65
-	Vector(unsigned int size)
66
-	{
67
-		mData = 0x0;
68
-		mError = 0x0;
65
+    Vector(unsigned int size)
66
+    {
67
+        mData = 0x0;
68
+        mError = 0x0;
69 69
 
70
-		mReserve = 0;
71
-		mStart = 0;
72
-		mEnd = 0;
70
+        mReserve = 0;
71
+        mStart = 0;
72
+        mEnd = 0;
73 73
 
74
-		mIndex = 0;
74
+        mIndex = 0;
75 75
 
76
-		resize(size);
77
-	}
76
+        resize(size);
77
+    }
78 78
 
79 79
 
80
-	~Vector()
81
-	{
82
-		if (!empty() && mData)
83
-		{
84
-			delete [] mData;
85
-		}
80
+    ~Vector()
81
+    {
82
+        if (!empty() && mData)
83
+        {
84
+            delete [] mData;
85
+        }
86 86
 
87
-		clear();
88
-		mReserve = 0;
89
-	}
87
+        clear();
88
+        mReserve = 0;
89
+    }
90 90
 
91 91
 
92
-	void clear()
93
-	{
94
-		mStart = 0;
95
-		mEnd = 0;
92
+    void clear()
93
+    {
94
+        mStart = 0;
95
+        mEnd = 0;
96 96
 
97
-		mIndex = 0;
98
-	}
97
+        mIndex = 0;
98
+    }
99 99
 
100 100
 
101
-	void erase()
102
-	{
103
-		for (start(); forward(); next())
104
-		{
105
-			if (current())
106
-			{
107
-				delete current();
108
-			}
109
-		}
101
+    void erase()
102
+    {
103
+        for (start(); forward(); next())
104
+        {
105
+            if (current())
106
+            {
107
+                delete current();
108
+            }
109
+        }
110 110
 
111
-		clear();
112
-	}
111
+        clear();
112
+    }
113 113
 
114 114
 
115
-	void reserve(unsigned int count)
116
-	{
117
-		unsigned int i;
118
-		Object *swap = 0x0;
115
+    void reserve(unsigned int count)
116
+    {
117
+        unsigned int i;
118
+        Object *swap = 0x0;
119 119
 
120 120
 
121
-		if (count > mReserve)
122
-		{
123
-			swap = mData;
124
-			mReserve = count;
125
-			mData = new Object[count];
126
-		}
121
+        if (count > mReserve)
122
+        {
123
+            swap = mData;
124
+            mReserve = count;
125
+            mData = new Object[count];
126
+        }
127 127
 
128
-		if (swap)
129
-		{
130
-			for (i = begin(); i < end(); ++i)
131
-			{
132
-				mData[i] = swap[i];
133
-			}
128
+        if (swap)
129
+        {
130
+            for (i = begin(); i < end(); ++i)
131
+            {
132
+                mData[i] = swap[i];
133
+            }
134 134
 
135
-			delete [] swap;
136
-		}
137
-	}
135
+            delete [] swap;
136
+        }
137
+    }
138 138
 
139 139
 
140
-	void resize(unsigned int count)
141
-	{
142
-		resize(count, 0x0);
143
-	}
140
+    void resize(unsigned int count)
141
+    {
142
+        resize(count, 0x0);
143
+    }
144 144
 
145 145
 
146
-	void resize(unsigned int count, Object object)
147
-	{
148
-		unsigned int i;
146
+    void resize(unsigned int count, Object object)
147
+    {
148
+        unsigned int i;
149 149
 
150 150
 
151
-		reserve(count);
151
+        reserve(count);
152 152
 
153
-		for (i = 0; i < count; ++i)
154
-		{
155
-			if (i < begin() || i >= end())
156
-			{
157
-				mData[i] = object;
158
-			}
159
-		}
153
+        for (i = 0; i < count; ++i)
154
+        {
155
+            if (i < begin() || i >= end())
156
+            {
157
+                mData[i] = object;
158
+            }
159
+        }
160 160
 
161
-		mEnd = count;
162
-	}
161
+        mEnd = count;
162
+    }
163 163
 
164 164
 
165
-	void pushBack()
166
-	{
167
-		pushBack(0x0);
168
-	}
165
+    void pushBack()
166
+    {
167
+        pushBack(0x0);
168
+    }
169 169
 
170 170
 
171
-	void pushBack(Object object)
172
-	{
173
-		resize(size() + 1);
174
-		mData[size()-1] = object;
175
-	}
171
+    void pushBack(Object object)
172
+    {
173
+        resize(size() + 1);
174
+        mData[size()-1] = object;
175
+    }
176 176
 
177 177
 
178
-	bool empty()
179
-	{
180
-		return (begin() == end());
181
-	}
178
+    bool empty()
179
+    {
180
+        return (begin() == end());
181
+    }
182 182
 
183 183
 
184
-	unsigned int capacity()
185
-	{
186
-		return mReserve;
187
-	}
184
+    unsigned int capacity()
185
+    {
186
+        return mReserve;
187
+    }
188 188
 
189 189
 
190
-	unsigned int begin()
191
-	{
192
-		return mStart;
193
-	}
190
+    unsigned int begin()
191
+    {
192
+        return mStart;
193
+    }
194 194
 
195 195
 
196
-	unsigned int end()
197
-	{
198
-		return mEnd;
199
-	}
196
+    unsigned int end()
197
+    {
198
+        return mEnd;
199
+    }
200 200
 
201 201
 
202
-	unsigned int size()
203
-	{
204
-		return mEnd;
205
-	}
202
+    unsigned int size()
203
+    {
204
+        return mEnd;
205
+    }
206 206
 
207 207
 
208
-	void copy(Vector<Object> &vector)
209
-	{
210
-		unsigned int i;
208
+    void copy(Vector<Object> &vector)
209
+    {
210
+        unsigned int i;
211 211
 
212 212
 
213
-		if (vector.capacity() > capacity())
214
-		{
215
-			resize(vector.capacity());
216
-		}
213
+        if (vector.capacity() > capacity())
214
+        {
215
+            resize(vector.capacity());
216
+        }
217 217
 
218
-		mStart = vector.begin();
219
-		mEnd = vector.end();
218
+        mStart = vector.begin();
219
+        mEnd = vector.end();
220 220
 
221
-		for (i = vector.begin(); i < vector.end(); ++i)
222
-		{
223
-			mData[i] = vector[i];
224
-			//Add(list->Current()); // WTFBBQ?
225
-		}
226
-	}
221
+        for (i = vector.begin(); i < vector.end(); ++i)
222
+        {
223
+            mData[i] = vector[i];
224
+            //Add(list->Current()); // WTFBBQ?
225
+        }
226
+    }
227 227
 
228 228
 
229
-	void qSort(int (*compareFunc)(const void *, const void *))
230
-	{
231
-		qsort(mData, end(), sizeof(Object), compareFunc);
232
-	}
229
+    void qSort(int (*compareFunc)(const void *, const void *))
230
+    {
231
+        qsort(mData, end(), sizeof(Object), compareFunc);
232
+    }
233 233
 
234 234
 
235
-	void swap(unsigned int index, unsigned int index2)
236
-	{
237
-		if (index < begin() || index > end())
238
-			return;
235
+    void swap(unsigned int index, unsigned int index2)
236
+    {
237
+        if (index < begin() || index > end())
238
+            return;
239 239
 
240
-		if (index2 < begin() || index2 > end())
241
-			return;
240
+        if (index2 < begin() || index2 > end())
241
+            return;
242 242
 
243
-		Object swap = mData[index];
244
-		mData[index] = mData[index2];
245
-		mData[index2] = swap;
246
-	}
243
+        Object swap = mData[index];
244
+        mData[index] = mData[index2];
245
+        mData[index2] = swap;
246
+    }
247 247
 
248 248
 
249
-	void assign(unsigned int index, Object object)
250
-	{
251
-		mData[index] = object;
252
-	}
249
+    void assign(unsigned int index, Object object)
250
+    {
251
+        mData[index] = object;
252
+    }
253 253
 
254 254
 
255
-	Object operator [] (unsigned int index)
256
-	{
257
-		if (mData == 0x0 || index < begin() || index > end() ||
258
-			 index >= size() || empty())
259
-			return mError;
255
+    Object operator [] (unsigned int index)
256
+    {
257
+        if (mData == 0x0 || index < begin() || index > end() ||
258
+             index >= size() || empty())
259
+            return mError;
260 260
 
261
-		return mData[index];
262
-	}
261
+        return mData[index];
262
+    }
263 263
 
264 264
 
265
-	void print(void (*print_func)(Object))
266
-	{
267
-		unsigned int i;
265
+    void print(void (*print_func)(Object))
266
+    {
267
+        unsigned int i;
268 268
 
269 269
 
270
-		for (i = begin(); i < end(); ++i)
271
-		{
272
-			if (print_func)
273
-			{
274
-				(*print_func)(mData[i]);
275
-			}
270
+        for (i = begin(); i < end(); ++i)
271
+        {
272
+            if (print_func)
273
+            {
274
+                (*print_func)(mData[i]);
275
+            }
276 276
 
277
-			fflush(stdout);
278
-		}
277
+            fflush(stdout);
278
+        }
279 279
 
280
-		printf("\n");
281
-	}
280
+        printf("\n");
281
+    }
282 282
 
283 283
 
284
-	// Built-in iterator methods ////////////////////////////////
284
+    // Built-in iterator methods ////////////////////////////////
285 285
 
286
-	void start(unsigned int index)
287
-	{
288
-		if (mData == 0x0 || index < begin() || index > end() ||
289
-			 index >= size() || empty())
290
-			return;
286
+    void start(unsigned int index)
287
+    {
288
+        if (mData == 0x0 || index < begin() || index > end() ||
289
+             index >= size() || empty())
290
+            return;
291 291
 
292
-		mIndex = index;
293
-	}
292
+        mIndex = index;
293
+    }
294 294
 
295
-	void start()
296
-	{
297
-		mIndex = begin();
298
-	}
295
+    void start()
296
+    {
297
+        mIndex = begin();
298
+    }
299 299
 
300 300
 
301
-	void finish()
302
-	{
303
-		mIndex = end() - 1;
304
-	}
301
+    void finish()
302
+    {
303
+        mIndex = end() - 1;
304
+    }
305 305
 
306 306
 
307
-	bool forward()
308
-	{
309
-		return (mIndex < end());
310
-	}
307
+    bool forward()
308
+    {
309
+        return (mIndex < end());
310
+    }
311 311
 
312 312
 
313
-	bool backward()
314
-	{
315
-		return (mIndex + 1 > begin());
316
-	}
313
+    bool backward()
314
+    {
315
+        return (mIndex + 1 > begin());
316
+    }
317 317
 
318 318
 
319
-	void next()
320
-	{
321
-		if (mIndex < end())
322
-			++mIndex;
323
-	}
319
+    void next()
320
+    {
321
+        if (mIndex < end())
322
+            ++mIndex;
323
+    }
324 324
 
325
-	void prev()
326
-	{
327
-		--mIndex;
328
-	}
325
+    void prev()
326
+    {
327
+        --mIndex;
328
+    }
329 329
 
330 330
 
331
-	void setError(Object object)
332
-	{
333
-		mError = object;
334
-	}
331
+    void setError(Object object)
332
+    {
333
+        mError = object;
334
+    }
335 335
 
336 336
 
337
-	unsigned int getCurrentIndex()
338
-	{
339
-		return mIndex;
340
-	}
337
+    unsigned int getCurrentIndex()
338
+    {
339
+        return mIndex;
340
+    }
341 341
 
342 342
 
343
-	unsigned int setCurrentIndex(unsigned int index)
344
-	{
345
-		if (index < end())
346
-		{
347
-			mIndex = index;
348
-		}
349
-	}
343
+    unsigned int setCurrentIndex(unsigned int index)
344
+    {
345
+        if (index < end())
346
+        {
347
+            mIndex = index;
348
+        }
349
+    }
350 350
 
351 351
 
352
-	Object current()
353
-	{
354
-		return mData[mIndex];
355
-	}
352
+    Object current()
353
+    {
354
+        return mData[mIndex];
355
+    }
356 356
 
357 357
 
358
-	/* Requires objects to support '=='  */
359
-	bool find(Object object)
360
-	{
361
-		for (start(); forward(); next())
362
-		{
363
-			if (object == current())
364
-			{
365
-				return true;
366
-			}
367
-		}
358
+    /* Requires objects to support '=='  */
359
+    bool find(Object object)
360
+    {
361
+        for (start(); forward(); next())
362
+        {
363
+            if (object == current())
364
+            {
365
+                return true;
366
+            }
367
+        }
368 368
 
369
-		return false;
370
-	}
369
+        return false;
370
+    }
371 371
 
372
-	// Instead of appending objects this apptempts replacing 'removed' objects
373
-	unsigned int add(Object object)
374
-	{
375
-		if (begin() > 0)
376
-		{
377
-			mData[begin() - 1] = object;
378
-			--mStart;
372
+    // Instead of appending objects this apptempts replacing 'removed' objects
373
+    unsigned int add(Object object)
374
+    {
375
+        if (begin() > 0)
376
+        {
377
+            mData[begin() - 1] = object;
378
+            --mStart;
379 379
 
380
-			return begin();
381
-		}
380
+            return begin();
381
+        }
382 382
 
383
-		pushBack(object);
384
-		return size();
385
-	}
383
+        pushBack(object);
384
+        return size();
385
+    }
386 386
 
387 387
 
388
-	// Hhhmm... dangerous and fun - this gets your data out of order
389
-	void remove(unsigned int index)
390
-	{
391
-		mData[index] = mData[begin()];
392
-		++mStart;
393
-	}
388
+    // Hhhmm... dangerous and fun - this gets your data out of order
389
+    void remove(unsigned int index)
390
+    {
391
+        mData[index] = mData[begin()];
392
+        ++mStart;
393
+    }
394 394
 
395 395
 private:
396 396
 
397
-	Object *mData;
397
+    Object *mData;
398 398
 
399
-	Object mError;
399
+    Object mError;
400 400
 
401
-	unsigned int mReserve;
402
-	unsigned int mStart;
403
-	unsigned int mEnd;
401
+    unsigned int mReserve;
402
+    unsigned int mStart;
403
+    unsigned int mEnd;
404 404
 
405
-	unsigned int mIndex;
405
+    unsigned int mIndex;
406 406
 };
407 407
 
408 408
 #endif

+ 252
- 252
include/Vector3d.h Переглянути файл

@@ -34,263 +34,263 @@ class Vector3d
34 34
 {
35 35
  public:
36 36
 
37
-	////////////////////////////////////////////////////////////
38
-	// Constructors
39
-	////////////////////////////////////////////////////////////
40
-
41
-	Vector3d();
42
-	/*------------------------------------------------------
43
-	 * Pre  :
44
-	 * Post : Constructs an object of Vector3d
45
-	 *
46
-	 *-- History ------------------------------------------
47
-	 *
48
-	 * 2002.12.24:
49
-	 * Mongoose - Created
50
-	 ------------------------------------------------------*/
51
-
52
-	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
-
63
-	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
-
74
-	~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
-
90
-	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
-
101
-	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
-
112
-	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
-
123
-	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
-
134
-	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
-
145
-	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
-
156
-	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
-
167
-	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
-
178
-	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
-
189
-	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
-
200
-	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
-
216
-	void normalize();
217
-	/*------------------------------------------------------
218
-	 * Pre  :
219
-	 * Post : Normalizes *this vector
220
-	 *
221
-	 *-- History ------------------------------------------
222
-	 *
223
-	 * 2002.05.08:
224
-	 * Mongoose - Created
225
-	 ------------------------------------------------------*/
226
-
227
-	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
-
238
-	void 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
-
249
-	void 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
-
260
-	void 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
-
271
-	void 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 */
37
+    ////////////////////////////////////////////////////////////
38
+    // Constructors
39
+    ////////////////////////////////////////////////////////////
40
+
41
+    Vector3d();
42
+    /*------------------------------------------------------
43
+     * Pre  :
44
+     * Post : Constructs an object of Vector3d
45
+     *
46
+     *-- History ------------------------------------------
47
+     *
48
+     * 2002.12.24:
49
+     * Mongoose - Created
50
+     ------------------------------------------------------*/
51
+
52
+    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
+
63
+    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
+
74
+    ~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
+
90
+    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
+
101
+    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
+
112
+    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
+
123
+    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
+
134
+    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
+
145
+    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
+
156
+    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
+
167
+    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
+
178
+    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
+
189
+    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
+
200
+    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
+
216
+    void normalize();
217
+    /*------------------------------------------------------
218
+     * Pre  :
219
+     * Post : Normalizes *this vector
220
+     *
221
+     *-- History ------------------------------------------
222
+     *
223
+     * 2002.05.08:
224
+     * Mongoose - Created
225
+     ------------------------------------------------------*/
226
+
227
+    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
+
238
+    void 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
+
249
+    void 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
+
260
+    void 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
+
271
+    void 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 283
 
284 284
  private:
285 285
 
286
-	////////////////////////////////////////////////////////////
287
-	// Private Accessors
288
-	////////////////////////////////////////////////////////////
286
+    ////////////////////////////////////////////////////////////
287
+    // Private Accessors
288
+    ////////////////////////////////////////////////////////////
289 289
 
290 290
 
291
-	////////////////////////////////////////////////////////////
292
-	// Private Mutators
293
-	////////////////////////////////////////////////////////////
291
+    ////////////////////////////////////////////////////////////
292
+    // Private Mutators
293
+    ////////////////////////////////////////////////////////////
294 294
 
295 295
 };
296 296
 

+ 243
- 243
include/ViewVolume.h Переглянути файл

@@ -34,261 +34,261 @@ class ViewVolume
34 34
 {
35 35
  public:
36 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
45
-	};
46
-
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
53
-	};
54
-
55
-
56
-	////////////////////////////////////////////////////////////
57
-	// Constructors
58
-	////////////////////////////////////////////////////////////
59
-
60
-	ViewVolume();
61
-	/*------------------------------------------------------
62
-	 * Pre  :
63
-	 * Post : Constructs an object of ViewVolume
64
-	 *
65
-	 *-- History ------------------------------------------
66
-	 *
67
-	 * 2002.12.15:
68
-	 * Mongoose - Created
69
-	 ------------------------------------------------------*/
70
-
71
-	~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
-
87
-	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
-
99
-	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
-
111
-	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
-
123
-	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
-
134
-	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
-
145
-	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
-
156
-	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
-
168
-	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
-
180
-	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
-
191
-	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
-
207
-	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
-
218
-	void updateFrame();
219
-	/*------------------------------------------------------
220
-	 * Pre  : Called setModel() and setProjection()
221
-	 * Post : Updates view volume for this frame
222
-	 *
223
-	 *-- History ------------------------------------------
224
-	 *
225
-	 * 2002.12.15:
226
-	 * Mongoose - Created
227
-	 ------------------------------------------------------*/
228
-
229
-	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
-
240
-	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
-	 ------------------------------------------------------*/
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
45
+    };
46
+
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
53
+    };
54
+
55
+
56
+    ////////////////////////////////////////////////////////////
57
+    // Constructors
58
+    ////////////////////////////////////////////////////////////
59
+
60
+    ViewVolume();
61
+    /*------------------------------------------------------
62
+     * Pre  :
63
+     * Post : Constructs an object of ViewVolume
64
+     *
65
+     *-- History ------------------------------------------
66
+     *
67
+     * 2002.12.15:
68
+     * Mongoose - Created
69
+     ------------------------------------------------------*/
70
+
71
+    ~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
+
87
+    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
+
99
+    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
+
111
+    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
+
123
+    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
+
134
+    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
+
145
+    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
+
156
+    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
+
168
+    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
+
180
+    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
+
191
+    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
+
207
+    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
+
218
+    void updateFrame();
219
+    /*------------------------------------------------------
220
+     * Pre  : Called setModel() and setProjection()
221
+     * Post : Updates view volume for this frame
222
+     *
223
+     *-- History ------------------------------------------
224
+     *
225
+     * 2002.12.15:
226
+     * Mongoose - Created
227
+     ------------------------------------------------------*/
228
+
229
+    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
+
240
+    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 250
 
251 251
  private:
252 252
 
253
-	////////////////////////////////////////////////////////////
254
-	// Private Accessors
255
-	////////////////////////////////////////////////////////////
253
+    ////////////////////////////////////////////////////////////
254
+    // Private Accessors
255
+    ////////////////////////////////////////////////////////////
256 256
 
257 257
 
258
-	////////////////////////////////////////////////////////////
259
-	// Private Mutators
260
-	////////////////////////////////////////////////////////////
258
+    ////////////////////////////////////////////////////////////
259
+    // Private Mutators
260
+    ////////////////////////////////////////////////////////////
261 261
 
262
-	void updateClip();
263
-	/*------------------------------------------------------
264
-	 * Pre  : model and projection matrices are set
265
-	 * Post : Computes clipping matrix
266
-	 *
267
-	 *-- History ------------------------------------------
268
-	 *
269
-	 * 2002.12.15:
270
-	 * Mongoose - Created
271
-	 ------------------------------------------------------*/
262
+    void updateClip();
263
+    /*------------------------------------------------------
264
+     * Pre  : model and projection matrices are set
265
+     * Post : Computes clipping matrix
266
+     *
267
+     *-- History ------------------------------------------
268
+     *
269
+     * 2002.12.15:
270
+     * Mongoose - Created
271
+     ------------------------------------------------------*/
272 272
 
273
-	void updateFrustum();
274
-	/*------------------------------------------------------
275
-	 * Pre  : model, projection, clip matrices are set
276
-	 * Post : Computes planes of frustum
277
-	 *
278
-	 *-- History ------------------------------------------
279
-	 *
280
-	 * 2002.12.15:
281
-	 * Mongoose - Created
282
-	 ------------------------------------------------------*/
273
+    void updateFrustum();
274
+    /*------------------------------------------------------
275
+     * Pre  : model, projection, clip matrices are set
276
+     * Post : Computes planes of frustum
277
+     *
278
+     *-- History ------------------------------------------
279
+     *
280
+     * 2002.12.15:
281
+     * Mongoose - Created
282
+     ------------------------------------------------------*/
283 283
 
284 284
 
285
-	Matrix mProjection;       	/* Projection matrix */
285
+    Matrix mProjection;         /* Projection matrix */
286 286
 
287
-	Matrix mModel;         	   /* Model matrix */
287
+    Matrix mModel;             /* Model matrix */
288 288
 
289
-	Matrix mClip;	            /* Clipping matrix */
289
+    Matrix mClip;               /* Clipping matrix */
290 290
 
291
-	vec_t mFrustum[6][4];      /* View volume */
291
+    vec_t mFrustum[6][4];      /* View volume */
292 292
 };
293 293
 
294 294
 #endif

+ 390
- 390
include/World.h Переглянути файл

@@ -41,64 +41,64 @@
41 41
 // Mirrors TombRaider class' room flags really
42 42
 typedef enum
43 43
 {
44
-	roomFlag_underWater    = 0x0001
44
+    roomFlag_underWater    = 0x0001
45 45
 
46 46
 } room_flags_t;
47 47
 
48 48
 typedef enum
49 49
 {
50
-	worldMoveType_walkNoSwim   = -1,
51
-	worldMoveType_walk         = 0,
52
-	worldMoveType_noClipping   = 1,
53
-	worldMoveType_fly          = 2,
54
-	worldMoveType_swim         = 3
50
+    worldMoveType_walkNoSwim   = -1,
51
+    worldMoveType_walk         = 0,
52
+    worldMoveType_noClipping   = 1,
53
+    worldMoveType_fly          = 2,
54
+    worldMoveType_swim         = 3
55 55
 
56 56
 } worldMoveType;
57 57
 
58 58
 
59 59
 typedef struct vertex_s
60 60
 {
61
-	vec3_t pos;
61
+    vec3_t pos;
62 62
 
63 63
 } vertex_t;
64 64
 
65 65
 
66 66
 typedef struct uv_s
67 67
 {
68
-	vec2_t uv;
68
+    vec2_t uv;
69 69
 
70 70
 } uv_t;
71 71
 
72 72
 typedef struct texel_s
73 73
 {
74
-	vec2_t st;
74
+    vec2_t st;
75 75
 
76 76
 } texel_t;
77 77
 
78 78
 
79 79
 typedef struct color_s
80 80
 {
81
-	vec4_t rgba;
81
+    vec4_t rgba;
82 82
 
83 83
 } color_t;
84 84
 
85 85
 
86 86
 typedef struct sprite_s
87 87
 {
88
-	int num_verts; // 4 == Quad, 3 == Triangle, renderered as triangles
89
-	vertex_t vertex[4];
90
-	texel_t texel[4];
91
-	float pos[3];
92
-	float radius; // yeah, I know
93
-	int texture;
88
+    int num_verts; // 4 == Quad, 3 == Triangle, renderered as triangles
89
+    vertex_t vertex[4];
90
+    texel_t texel[4];
91
+    float pos[3];
92
+    float radius; // yeah, I know
93
+    int texture;
94 94
 
95 95
 } sprite_t;
96 96
 
97 97
 
98 98
 typedef struct sprite_seq_s
99 99
 {
100
-	int num_sprites;
101
-	sprite_t *sprite;
100
+    int num_sprites;
101
+    sprite_t *sprite;
102 102
 
103 103
 } sprite_seq_t;
104 104
 
@@ -110,32 +110,32 @@ typedef struct sprite_seq_s
110 110
 
111 111
 typedef struct texture_tri_s
112 112
 {
113
-	int index[3];
114
-	vec_t st[6];
115
-	int texture;
116
-	unsigned short transparency;
113
+    int index[3];
114
+    vec_t st[6];
115
+    int texture;
116
+    unsigned short transparency;
117 117
 
118 118
 } texture_tri_t;
119 119
 
120 120
 
121 121
 typedef struct model_mesh_s
122 122
 {
123
-	Vector<texture_tri_t *> texturedTriangles;
124
-	Vector<texture_tri_t *> coloredTriangles;
125
-	Vector<texture_tri_t *> texturedRectangles;
126
-	Vector<texture_tri_t *> coloredRectangles;
123
+    Vector<texture_tri_t *> texturedTriangles;
124
+    Vector<texture_tri_t *> coloredTriangles;
125
+    Vector<texture_tri_t *> texturedRectangles;
126
+    Vector<texture_tri_t *> coloredRectangles;
127 127
 
128
-	vec3_t center;
129
-	float radius;
128
+    vec3_t center;
129
+    float radius;
130 130
 
131
-	unsigned int vertexCount;
132
-	vec_t *vertices;
131
+    unsigned int vertexCount;
132
+    vec_t *vertices;
133 133
 
134
-	unsigned int colorCount;
135
-	vec_t *colors;
134
+    unsigned int colorCount;
135
+    vec_t *colors;
136 136
 
137
-	unsigned int normalCount;
138
-	vec_t *normals;
137
+    unsigned int normalCount;
138
+    vec_t *normals;
139 139
 
140 140
 } model_mesh_t;
141 141
 
@@ -145,40 +145,40 @@ typedef struct model_mesh_s
145 145
 
146 146
 typedef struct entity_s
147 147
 {
148
-	int id;                    // Unique identifier
149
-	float pos[3];              // World position
150
-	float angles[3];           // Eular angles (pitch, yaw, roll)
151
-	int type;                  // {(0x00, item), (0x01, ai), (0x02, player)}
152
-	int room;                  // Current room entity is in
153
-	worldMoveType moveType;    // Type of motion/clipping
154
-	bool moving;               // In motion?
155
-	struct entity_s *master;   // Part of entity chain?
156
-
157
-	int state;      // State of the Player, AI, or object
158
-	int objectId;              // What kind of entity?
159
-
160
-	int modelId;               // Animation model
161
-	void *tmpHook;
162
-	bool animate;
163
-
164
-	/*
165
-	  float time, lastTime;
166
-	  int state, lastState;
167
-	  int event, lastEvent;
168
-	  int goal;
169
-	 */
148
+    int id;                    // Unique identifier
149
+    float pos[3];              // World position
150
+    float angles[3];           // Eular angles (pitch, yaw, roll)
151
+    int type;                  // {(0x00, item), (0x01, ai), (0x02, player)}
152
+    int room;                  // Current room entity is in
153
+    worldMoveType moveType;    // Type of motion/clipping
154
+    bool moving;               // In motion?
155
+    struct entity_s *master;   // Part of entity chain?
156
+
157
+    int state;      // State of the Player, AI, or object
158
+    int objectId;              // What kind of entity?
159
+
160
+    int modelId;               // Animation model
161
+    void *tmpHook;
162
+    bool animate;
163
+
164
+    /*
165
+      float time, lastTime;
166
+      int state, lastState;
167
+      int event, lastEvent;
168
+      int goal;
169
+     */
170 170
 
171 171
 } entity_t;
172 172
 
173 173
 
174 174
 typedef struct static_model_s
175 175
 {
176
-	int index;     // model_mesh index
177
-	float yaw;     // angle of rotation on Y
178
-	float pos[3];  // position
176
+    int index;     // model_mesh index
177
+    float yaw;     // angle of rotation on Y
178
+    float pos[3];  // position
179 179
 
180
-	//vec3_t bboxMax;
181
-	//vec3_t bboxMin;
180
+    //vec3_t bboxMax;
181
+    //vec3_t bboxMin;
182 182
 
183 183
 } static_model_t;
184 184
 
@@ -186,48 +186,48 @@ typedef struct static_model_s
186 186
 
187 187
 typedef struct portal_s
188 188
 {
189
-	float vertices[4][3];
190
-	float normal[3];
191
-	int adjoining_room;
189
+    float vertices[4][3];
190
+    float normal[3];
191
+    int adjoining_room;
192 192
 
193 193
 } portal_t;
194 194
 
195 195
 
196 196
 typedef struct box_s
197 197
 {
198
-	vertex_t a;
199
-	vertex_t b;
200
-	vertex_t c;
201
-	vertex_t d;
198
+    vertex_t a;
199
+    vertex_t b;
200
+    vertex_t c;
201
+    vertex_t d;
202 202
 
203 203
 } box_t;
204 204
 
205 205
 typedef struct sector_s
206 206
 {
207
-	vec_t floor;
208
-	vec_t ceiling;
207
+    vec_t floor;
208
+    vec_t ceiling;
209 209
 
210
-	bool wall;
210
+    bool wall;
211 211
 
212 212
 } sector_t;
213 213
 
214 214
 //! \fixme No room mesh list or sprites and etc
215 215
 typedef struct room_mesh_s
216 216
 {
217
-	Vector<int> adjacentRooms;
218
-	Vector<portal_t *> portals;
219
-	Vector<static_model_t *> models;
220
-	Vector<sprite_t *> sprites;
221
-	Vector<box_t *> boxes;
222
-	Vector<sector_t *> sectors;
223
-
224
-	int id;
225
-	unsigned int flags;
226
-	unsigned int numXSectors;
227
-	unsigned int numZSectors;
228
-	float pos[3];
229
-	vec3_t bbox_min;
230
-	vec3_t bbox_max;
217
+    Vector<int> adjacentRooms;
218
+    Vector<portal_t *> portals;
219
+    Vector<static_model_t *> models;
220
+    Vector<sprite_t *> sprites;
221
+    Vector<box_t *> boxes;
222
+    Vector<sector_t *> sectors;
223
+
224
+    int id;
225
+    unsigned int flags;
226
+    unsigned int numXSectors;
227
+    unsigned int numZSectors;
228
+    float pos[3];
229
+    vec3_t bbox_min;
230
+    vec3_t bbox_max;
231 231
 
232 232
 } room_mesh_t;
233 233
 
@@ -235,57 +235,57 @@ typedef struct room_mesh_s
235 235
 // Workout generic entity and a client class from these entities
236 236
 typedef struct world_entity_s
237 237
 {
238
-	vec3_t pos;
239
-	vec3_t lastPos;
240
-	vec3_t angle;
241
-	vec_t ttl;
238
+    vec3_t pos;
239
+    vec3_t lastPos;
240
+    vec3_t angle;
241
+    vec_t ttl;
242 242
 
243
-	int type;
244
-	int state;
243
+    int type;
244
+    int state;
245 245
 
246
-	//struct world_entity_s *master;
246
+    //struct world_entity_s *master;
247 247
 
248 248
 } world_entity_t;
249 249
 
250 250
 
251 251
 typedef struct actor_entity_s
252 252
 {
253
-	vec3_t pos;
254
-	vec3_t lastPos;
255
-	vec3_t angle;
256
-	char clipping;
257
-	float time, eventTime, eventTimer;
258
-	int state, nextState;
259
-	float health;
260
-
261
-	// Client
262
-	unsigned int uid;
263
-	char name[32];
264
-	int actor, enemy;
265
-
266
-	// Render
267
-	unsigned int model;
268
-	unsigned int skin;
269
-	unsigned int animFrame;
253
+    vec3_t pos;
254
+    vec3_t lastPos;
255
+    vec3_t angle;
256
+    char clipping;
257
+    float time, eventTime, eventTimer;
258
+    int state, nextState;
259
+    float health;
260
+
261
+    // Client
262
+    unsigned int uid;
263
+    char name[32];
264
+    int actor, enemy;
265
+
266
+    // Render
267
+    unsigned int model;
268
+    unsigned int skin;
269
+    unsigned int animFrame;
270 270
 
271 271
 } actor_entity_t;
272 272
 
273 273
 enum OpenRaiderEvent
274 274
 {
275
-	eNone            = 0,
276
-	eWeaponDischarge,
277
-	eDying,
278
-	eDead,
279
-	eWounded,
280
-	eRunForward,
281
-	eRunBackward,
282
-	eJump,
283
-	eCrouchWalk,
284
-	eIdle,
285
-	eTaunt,
286
-	eTurn,
287
-	eRespawn,
288
-	eLand
275
+    eNone            = 0,
276
+    eWeaponDischarge,
277
+    eDying,
278
+    eDead,
279
+    eWounded,
280
+    eRunForward,
281
+    eRunBackward,
282
+    eJump,
283
+    eCrouchWalk,
284
+    eIdle,
285
+    eTaunt,
286
+    eTurn,
287
+    eRespawn,
288
+    eLand
289 289
 };
290 290
 
291 291
 
@@ -293,290 +293,290 @@ class World
293 293
 {
294 294
  public:
295 295
 
296
-	enum WorldFlag
297
-	{
298
-		fEnableHopping = 1
299
-	};
300
-
301
-	////////////////////////////////////////////////////////////
302
-	// Constructors
303
-	////////////////////////////////////////////////////////////
304
-
305
-	World();
306
-	/*------------------------------------------------------
307
-	 * Pre  :
308
-	 * Post : Constructs an object of World
309
-	 *
310
-	 *-- History ------------------------------------------
311
-	 *
312
-	 * 2002.12.16:
313
-	 * Mongoose - Created
314
-	 ------------------------------------------------------*/
315
-
316
-	~World();
317
-	/*------------------------------------------------------
318
-	 * Pre  : World object is allocated
319
-	 * Post : Deconstructs an object of World
320
-	 *
321
-	 *-- History ------------------------------------------
322
-	 *
323
-	 * 2002.12.16:
324
-	 * Mongoose - Created
325
-	 ------------------------------------------------------*/
326
-
327
-
328
-	////////////////////////////////////////////////////////////
329
-	// Public Accessors
330
-	////////////////////////////////////////////////////////////
331
-
332
-	int getRoomByLocation(int index, float x, float y, float z);
333
-	/*------------------------------------------------------
334
-	 * Pre  : index - Guessed room index
335
-	 * Post : Returns correct room index or -1 for unknown
336
-	 *
337
-	 *        NOTE: If it fails to be in a room it gives
338
-	 *        closest overlapping room
339
-	 *
340
-	 *-- History ------------------------------------------
341
-	 *
342
-	 * 2002.12.20:
343
-	 * Mongoose - Created, factored out of Render class
344
-	 ------------------------------------------------------*/
345
-
346
-	int getRoomByLocation(float x, float y, float z);
347
-	/*------------------------------------------------------
348
-	 * Pre  :
349
-	 * Post : Returns correct room index or -1 for unknown
350
-	 *
351
-	 *        NOTE: If it fails to be in a room it gives
352
-	 *        closest overlapping room
353
-	 *
354
-	 *-- History ------------------------------------------
355
-	 *
356
-	 * 2002.12.20:
357
-	 * Mongoose - Created, factored out of Render class
358
-	 ------------------------------------------------------*/
359
-
360
-	int getAdjoiningRoom(int index,
361
-								float x, float y, float z,
362
-								float x2, float y2, float z2);
363
-	/*------------------------------------------------------
364
-	 * Pre  :
365
-	 * Post : Looks for portal crossings from xyz to xyz2 segment
366
-	 *        from room[index] returns index of adjoined room or -1
367
-	 *
368
-	 *-- History ------------------------------------------
369
-	 *
370
-	 * 2003.05.29:
371
-	 * Mongoose - Created
372
-	 ------------------------------------------------------*/
373
-
374
-	int getSector(int room, float x, float z);
375
-	int getSector(int room, float x, float z, float *floor, float *ceiling);
376
-	/*------------------------------------------------------
377
-	 * Pre  : room - valid room index
378
-	 * Post : Gets the sector index of the position in room
379
-	 *
380
-	 *-- History ------------------------------------------
381
-	 *
382
-	 * 2002.12.20:
383
-	 * Mongoose - Created, factored out of Render class
384
-	 ------------------------------------------------------*/
385
-
386
-	unsigned int getRoomInfo(int room);
387
-	/*------------------------------------------------------
388
-	 * Pre  :
389
-	 * Post :
390
-	 *
391
-	 *-- History ------------------------------------------
392
-	 *
393
-	 * 2003.05.28:
394
-	 * Mongoose - Created
395
-	 ------------------------------------------------------*/
396
-
397
-	bool isWall(int room, int sector);
398
-	/*------------------------------------------------------
399
-	 * Pre  : room - valid room index
400
-	 *        sector - valid sector index
401
-	 * Post : Returns true if this sector is a wall
402
-	 *
403
-	 *-- History ------------------------------------------
404
-	 *
405
-	 * 2002.12.20:
406
-	 * Mongoose - Created, factored out of Render class
407
-	 ------------------------------------------------------*/
408
-
409
-	bool getHeightAtPosition(int index, float x, float *y, float z);
410
-	/*------------------------------------------------------
411
-	 * Pre  : index - valid room index
412
-	 * Post : Returns true if position is in a room
413
-	 *        and sets y to the world height in that room
414
-	 *
415
-	 *-- History ------------------------------------------
416
-	 *
417
-	 * 2002.12.20:
418
-	 * Mongoose - Created, factored out of Render class
419
-	 ------------------------------------------------------*/
420
-
421
-	// Temp methods for rendering use until more refactoring is done
296
+    enum WorldFlag
297
+    {
298
+        fEnableHopping = 1
299
+    };
300
+
301
+    ////////////////////////////////////////////////////////////
302
+    // Constructors
303
+    ////////////////////////////////////////////////////////////
304
+
305
+    World();
306
+    /*------------------------------------------------------
307
+     * Pre  :
308
+     * Post : Constructs an object of World
309
+     *
310
+     *-- History ------------------------------------------
311
+     *
312
+     * 2002.12.16:
313
+     * Mongoose - Created
314
+     ------------------------------------------------------*/
315
+
316
+    ~World();
317
+    /*------------------------------------------------------
318
+     * Pre  : World object is allocated
319
+     * Post : Deconstructs an object of World
320
+     *
321
+     *-- History ------------------------------------------
322
+     *
323
+     * 2002.12.16:
324
+     * Mongoose - Created
325
+     ------------------------------------------------------*/
326
+
327
+
328
+    ////////////////////////////////////////////////////////////
329
+    // Public Accessors
330
+    ////////////////////////////////////////////////////////////
331
+
332
+    int getRoomByLocation(int index, float x, float y, float z);
333
+    /*------------------------------------------------------
334
+     * Pre  : index - Guessed room index
335
+     * Post : Returns correct room index or -1 for unknown
336
+     *
337
+     *        NOTE: If it fails to be in a room it gives
338
+     *        closest overlapping room
339
+     *
340
+     *-- History ------------------------------------------
341
+     *
342
+     * 2002.12.20:
343
+     * Mongoose - Created, factored out of Render class
344
+     ------------------------------------------------------*/
345
+
346
+    int getRoomByLocation(float x, float y, float z);
347
+    /*------------------------------------------------------
348
+     * Pre  :
349
+     * Post : Returns correct room index or -1 for unknown
350
+     *
351
+     *        NOTE: If it fails to be in a room it gives
352
+     *        closest overlapping room
353
+     *
354
+     *-- History ------------------------------------------
355
+     *
356
+     * 2002.12.20:
357
+     * Mongoose - Created, factored out of Render class
358
+     ------------------------------------------------------*/
359
+
360
+    int getAdjoiningRoom(int index,
361
+                                float x, float y, float z,
362
+                                float x2, float y2, float z2);
363
+    /*------------------------------------------------------
364
+     * Pre  :
365
+     * Post : Looks for portal crossings from xyz to xyz2 segment
366
+     *        from room[index] returns index of adjoined room or -1
367
+     *
368
+     *-- History ------------------------------------------
369
+     *
370
+     * 2003.05.29:
371
+     * Mongoose - Created
372
+     ------------------------------------------------------*/
373
+
374
+    int getSector(int room, float x, float z);
375
+    int getSector(int room, float x, float z, float *floor, float *ceiling);
376
+    /*------------------------------------------------------
377
+     * Pre  : room - valid room index
378
+     * Post : Gets the sector index of the position in room
379
+     *
380
+     *-- History ------------------------------------------
381
+     *
382
+     * 2002.12.20:
383
+     * Mongoose - Created, factored out of Render class
384
+     ------------------------------------------------------*/
385
+
386
+    unsigned int getRoomInfo(int room);
387
+    /*------------------------------------------------------
388
+     * Pre  :
389
+     * Post :
390
+     *
391
+     *-- History ------------------------------------------
392
+     *
393
+     * 2003.05.28:
394
+     * Mongoose - Created
395
+     ------------------------------------------------------*/
396
+
397
+    bool isWall(int room, int sector);
398
+    /*------------------------------------------------------
399
+     * Pre  : room - valid room index
400
+     *        sector - valid sector index
401
+     * Post : Returns true if this sector is a wall
402
+     *
403
+     *-- History ------------------------------------------
404
+     *
405
+     * 2002.12.20:
406
+     * Mongoose - Created, factored out of Render class
407
+     ------------------------------------------------------*/
408
+
409
+    bool getHeightAtPosition(int index, float x, float *y, float z);
410
+    /*------------------------------------------------------
411
+     * Pre  : index - valid room index
412
+     * Post : Returns true if position is in a room
413
+     *        and sets y to the world height in that room
414
+     *
415
+     *-- History ------------------------------------------
416
+     *
417
+     * 2002.12.20:
418
+     * Mongoose - Created, factored out of Render class
419
+     ------------------------------------------------------*/
420
+
421
+    // Temp methods for rendering use until more refactoring is done
422 422
 #ifdef BAD_BLOOD
423
-	model_mesh_t *getMesh(int index);
424
-	skeletal_model_t *getModel(int index);
425
-	room_mesh_t *getRoom(int index);
426
-	Vector<entity_t *> *getEntities();
427
-	Vector<sprite_seq_t *> *getSprites();
428
-	Vector<room_mesh_t *> *getRooms();
423
+    model_mesh_t *getMesh(int index);
424
+    skeletal_model_t *getModel(int index);
425
+    room_mesh_t *getRoom(int index);
426
+    Vector<entity_t *> *getEntities();
427
+    Vector<sprite_seq_t *> *getSprites();
428
+    Vector<room_mesh_t *> *getRooms();
429 429
 #endif
430 430
 
431
-	////////////////////////////////////////////////////////////
432
-	// Public Mutators
433
-	////////////////////////////////////////////////////////////
434
-
435
-	void setFlag(WorldFlag flag);
436
-	/*------------------------------------------------------
437
-	 * Pre  :
438
-	 * Post : Sets option flag
439
-	 *
440
-	 *-- History ------------------------------------------
441
-	 *
442
-	 * 2002.12.20:
443
-	 * Mongoose - Created, factored out of Render class
444
-	 ------------------------------------------------------*/
445
-
446
-	void clearFlag(WorldFlag flag);
447
-	/*------------------------------------------------------
448
-	 * Pre  :
449
-	 * Post : Clears option flag
450
-	 *
451
-	 *-- History ------------------------------------------
452
-	 *
453
-	 * 2002.12.20:
454
-	 * Mongoose - Created, factored out of Render class
455
-	 ------------------------------------------------------*/
456
-
457
-	void destroy();
458
-	/*------------------------------------------------------
459
-	 * Pre  :
460
-	 * Post : Clears all data in world, in future will check
461
-	 *        if data is in use before clearing
462
-	 *
463
-	 *-- History ------------------------------------------
464
-	 *
465
-	 * 2002.12.20:
466
-	 * Mongoose - Created
467
-	 ------------------------------------------------------*/
468
-
469
-	void addRoom(room_mesh_t *room);
470
-	/*------------------------------------------------------
471
-	 * Pre  :
472
-	 * Post : Adds object to world
473
-	 *
474
-	 *-- History ------------------------------------------
475
-	 *
476
-	 * 2002.12.20:
477
-	 * Mongoose - Created, factored out of Render class
478
-	 ------------------------------------------------------*/
479
-
480
-	void addMesh(model_mesh_t *model);
481
-	/*------------------------------------------------------
482
-	 * Pre  :
483
-	 * Post : Adds object to world
484
-	 *
485
-	 *-- History ------------------------------------------
486
-	 *
487
-	 * 2002.12.20:
488
-	 * Mongoose - Created, factored out of Render class
489
-	 ------------------------------------------------------*/
490
-
491
-	void addEntity(entity_t *e);
492
-	/*------------------------------------------------------
493
-	 * Pre  :
494
-	 * Post : Adds object to world
495
-	 *
496
-	 *-- History ------------------------------------------
497
-	 *
498
-	 * 2002.12.20:
499
-	 * Mongoose - Created, factored out of Render class
500
-	 ------------------------------------------------------*/
501
-
502
-	int addModel(skeletal_model_t *model);
503
-	/*------------------------------------------------------
504
-	 * Pre  :
505
-	 * Post : Adds object to world, returns next model Id
506
-	 *        or -1 if failed to add model to world
507
-	 *
508
-	 *-- History ------------------------------------------
509
-	 *
510
-	 * 2002.12.20:
511
-	 * Mongoose - Created, factored out of Render class
512
-	 ------------------------------------------------------*/
513
-
514
-	void addSprite(sprite_seq_t *sprite);
515
-	/*------------------------------------------------------
516
-	 * Pre  :
517
-	 * Post : Adds object to world
518
-	 *
519
-	 *-- History ------------------------------------------
520
-	 *
521
-	 * 2002.12.20:
522
-	 * Mongoose - Created, factored out of Render class
523
-	 ------------------------------------------------------*/
524
-
525
-	void moveEntity(entity_t *e, char movement);
526
-	/*------------------------------------------------------
527
-	 * Pre  : movement - 'f' orward
528
-	 *                   'b' ackward
529
-	 *                   'l' eft
530
-	 *                   'r' ight
531
-	 *
532
-	 * Post : Move entity e in a given direction, unless
533
-	 *        a collision ocurrs
534
-	 *
535
-	 *-- History ------------------------------------------
536
-	 *
537
-	 * 2002.12.20:
538
-	 * Mongoose - Moved to WOrld class
539
-	 *
540
-	 * 2002.09.02:
541
-	 * Mongoose - Created
542
-	 ------------------------------------------------------*/
431
+    ////////////////////////////////////////////////////////////
432
+    // Public Mutators
433
+    ////////////////////////////////////////////////////////////
434
+
435
+    void setFlag(WorldFlag flag);
436
+    /*------------------------------------------------------
437
+     * Pre  :
438
+     * Post : Sets option flag
439
+     *
440
+     *-- History ------------------------------------------
441
+     *
442
+     * 2002.12.20:
443
+     * Mongoose - Created, factored out of Render class
444
+     ------------------------------------------------------*/
445
+
446
+    void clearFlag(WorldFlag flag);
447
+    /*------------------------------------------------------
448
+     * Pre  :
449
+     * Post : Clears option flag
450
+     *
451
+     *-- History ------------------------------------------
452
+     *
453
+     * 2002.12.20:
454
+     * Mongoose - Created, factored out of Render class
455
+     ------------------------------------------------------*/
456
+
457
+    void destroy();
458
+    /*------------------------------------------------------
459
+     * Pre  :
460
+     * Post : Clears all data in world, in future will check
461
+     *        if data is in use before clearing
462
+     *
463
+     *-- History ------------------------------------------
464
+     *
465
+     * 2002.12.20:
466
+     * Mongoose - Created
467
+     ------------------------------------------------------*/
468
+
469
+    void addRoom(room_mesh_t *room);
470
+    /*------------------------------------------------------
471
+     * Pre  :
472
+     * Post : Adds object to world
473
+     *
474
+     *-- History ------------------------------------------
475
+     *
476
+     * 2002.12.20:
477
+     * Mongoose - Created, factored out of Render class
478
+     ------------------------------------------------------*/
479
+
480
+    void addMesh(model_mesh_t *model);
481
+    /*------------------------------------------------------
482
+     * Pre  :
483
+     * Post : Adds object to world
484
+     *
485
+     *-- History ------------------------------------------
486
+     *
487
+     * 2002.12.20:
488
+     * Mongoose - Created, factored out of Render class
489
+     ------------------------------------------------------*/
490
+
491
+    void addEntity(entity_t *e);
492
+    /*------------------------------------------------------
493
+     * Pre  :
494
+     * Post : Adds object to world
495
+     *
496
+     *-- History ------------------------------------------
497
+     *
498
+     * 2002.12.20:
499
+     * Mongoose - Created, factored out of Render class
500
+     ------------------------------------------------------*/
501
+
502
+    int addModel(skeletal_model_t *model);
503
+    /*------------------------------------------------------
504
+     * Pre  :
505
+     * Post : Adds object to world, returns next model Id
506
+     *        or -1 if failed to add model to world
507
+     *
508
+     *-- History ------------------------------------------
509
+     *
510
+     * 2002.12.20:
511
+     * Mongoose - Created, factored out of Render class
512
+     ------------------------------------------------------*/
513
+
514
+    void addSprite(sprite_seq_t *sprite);
515
+    /*------------------------------------------------------
516
+     * Pre  :
517
+     * Post : Adds object to world
518
+     *
519
+     *-- History ------------------------------------------
520
+     *
521
+     * 2002.12.20:
522
+     * Mongoose - Created, factored out of Render class
523
+     ------------------------------------------------------*/
524
+
525
+    void moveEntity(entity_t *e, char movement);
526
+    /*------------------------------------------------------
527
+     * Pre  : movement - 'f' orward
528
+     *                   'b' ackward
529
+     *                   'l' eft
530
+     *                   'r' ight
531
+     *
532
+     * Post : Move entity e in a given direction, unless
533
+     *        a collision ocurrs
534
+     *
535
+     *-- History ------------------------------------------
536
+     *
537
+     * 2002.12.20:
538
+     * Mongoose - Moved to WOrld class
539
+     *
540
+     * 2002.09.02:
541
+     * Mongoose - Created
542
+     ------------------------------------------------------*/
543 543
 
544 544
 
545 545
  private:
546 546
 
547
-	////////////////////////////////////////////////////////////
548
-	// Private Accessors
549
-	////////////////////////////////////////////////////////////
547
+    ////////////////////////////////////////////////////////////
548
+    // Private Accessors
549
+    ////////////////////////////////////////////////////////////
550 550
 
551 551
 
552
-	////////////////////////////////////////////////////////////
553
-	// Private Mutators
554
-	////////////////////////////////////////////////////////////
552
+    ////////////////////////////////////////////////////////////
553
+    // Private Mutators
554
+    ////////////////////////////////////////////////////////////
555 555
 
556
-	void clear();
557
-	/*------------------------------------------------------
558
-	 * Pre  :
559
-	 * Post : Clears all data in world
560
-	 *
561
-	 *-- History ------------------------------------------
562
-	 *
563
-	 * 2002.12.20:
564
-	 * Mongoose - Created
565
-	 ------------------------------------------------------*/
556
+    void clear();
557
+    /*------------------------------------------------------
558
+     * Pre  :
559
+     * Post : Clears all data in world
560
+     *
561
+     *-- History ------------------------------------------
562
+     *
563
+     * 2002.12.20:
564
+     * Mongoose - Created
565
+     ------------------------------------------------------*/
566 566
 
567
-	bool mClearLock;
567
+    bool mClearLock;
568 568
 
569
-	unsigned int mFlags;                   /* World flags */
569
+    unsigned int mFlags;                   /* World flags */
570 570
 
571
-	Vector<entity_t *> mEntities;	         /* World entities */
571
+    Vector<entity_t *> mEntities;            /* World entities */
572 572
 
573
-	Vector<room_mesh_t *> mRooms;	         /* Map data and meshes */
573
+    Vector<room_mesh_t *> mRooms;            /* Map data and meshes */
574 574
 
575
-	Vector<model_mesh_t *> mMeshes;	      /* Unanimated meshes */
575
+    Vector<model_mesh_t *> mMeshes;       /* Unanimated meshes */
576 576
 
577
-	Vector<sprite_seq_t *> mSprites;	      /* Sprites */
577
+    Vector<sprite_seq_t *> mSprites;          /* Sprites */
578 578
 
579
-	Vector<skeletal_model_t *> mModels; 	/* Skeletal animation models */
579
+    Vector<skeletal_model_t *> mModels;     /* Skeletal animation models */
580 580
 };
581 581
 
582 582
 #endif

+ 6
- 6
include/tga.h Переглянути файл

@@ -45,7 +45,7 @@ typedef struct mtk_image_tga_s
45 45
   unsigned char comment_lenght;       /* Number of bytes in comment */
46 46
   unsigned char colormap_type;        /* 0 No colormap; 1 Has colormap  */
47 47
   unsigned char image_type;           /* 1 Colormapped, 2 Unmapped;
48
-					 9 Colormapped RLE; 10 Unmapped RLE */
48
+                     9 Colormapped RLE; 10 Unmapped RLE */
49 49
 
50 50
   unsigned short colormap_index;      /* Index of first color map entry */
51 51
   unsigned short colormap_lenght;     /* Number of color map entries */
@@ -73,7 +73,7 @@ typedef struct mtk_image_tga_s
73 73
    ------------------------------------------------------*/
74 74
 
75 75
   int mtk_image__tga_load(FILE *f, unsigned char **image,
76
-			 unsigned int *width, unsigned int *height, char *type);
76
+             unsigned int *width, unsigned int *height, char *type);
77 77
   /*------------------------------------------------------
78 78
    * Pre  : Filename is a valid image file
79 79
    * Post : Image is either a valid pixmap or NULL
@@ -85,7 +85,7 @@ typedef struct mtk_image_tga_s
85 85
    ------------------------------------------------------*/
86 86
 
87 87
   int mtk_image__tga_save(FILE *f, unsigned char *image,
88
-			  unsigned int width, unsigned int height, char type);
88
+              unsigned int width, unsigned int height, char type);
89 89
   /*------------------------------------------------------
90 90
    * Pre  :
91 91
    * Post : Image is saved to diskfile if valid and can
@@ -98,9 +98,9 @@ typedef struct mtk_image_tga_s
98 98
 
99 99
 
100 100
   int mtk_image__tga_save_filename(unsigned char *image,
101
-				   unsigned int width, unsigned int height,
102
-				   char type,
103
-				   char *s, ...);
101
+                   unsigned int width, unsigned int height,
102
+                   char type,
103
+                   char *s, ...);
104 104
   /*------------------------------------------------------
105 105
    * Pre  :
106 106
    * Post : Image is saved to diskfile if valid and can

+ 200
- 200
src/Camera.cpp Переглянути файл

@@ -51,14 +51,14 @@ unsigned int Camera::mCounter = 0;
51 51
 
52 52
 Camera::Camera()
53 53
 {
54
-	mId = ++mCounter;
55
-	mFlags = 0;
56
-	mViewDistance = 14.0;
57
-	mTranslateDelta = 256.0;
58
-	mRotateDelta = HEL_DEG_TO_RAD(15.0);
59
- 	mRotateDelta2 = HEL_DEG_TO_RAD(5.0);
60
-	mFlags &= Camera_FlyMode;
61
-	reset();
54
+    mId = ++mCounter;
55
+    mFlags = 0;
56
+    mViewDistance = 14.0;
57
+    mTranslateDelta = 256.0;
58
+    mRotateDelta = HEL_DEG_TO_RAD(15.0);
59
+    mRotateDelta2 = HEL_DEG_TO_RAD(5.0);
60
+    mFlags &= Camera_FlyMode;
61
+    reset();
62 62
 }
63 63
 
64 64
 
@@ -73,49 +73,49 @@ Camera::~Camera()
73 73
 
74 74
 unsigned int Camera::getId()
75 75
 {
76
-	return mId;
76
+    return mId;
77 77
 }
78 78
 
79 79
 
80 80
 void Camera::getPosition(vec3_t pos)
81 81
 {
82
-	pos[0] = mPos[0];
83
-	pos[1] = mPos[1];
84
-	pos[2] = mPos[2];
82
+    pos[0] = mPos[0];
83
+    pos[1] = mPos[1];
84
+    pos[2] = mPos[2];
85 85
 }
86 86
 
87 87
 
88 88
 void Camera::getUp(vec3_t up)
89 89
 {
90
-	up[0] = mUp[0];
91
-	up[1] = mUp[1];
92
-	up[2] = mUp[2];
90
+    up[0] = mUp[0];
91
+    up[1] = mUp[1];
92
+    up[2] = mUp[2];
93 93
 }
94 94
 
95 95
 
96 96
 void Camera::getTarget(vec3_t target)
97 97
 {
98
-	target[0] = mTarget[0];
99
-	target[1] = mTarget[1];
100
-	target[2] = mTarget[2];
98
+    target[0] = mTarget[0];
99
+    target[1] = mTarget[1];
100
+    target[2] = mTarget[2];
101 101
 }
102 102
 
103 103
 
104 104
 float Camera::getYaw()
105 105
 {
106
-	return HEL_RAD_TO_DEG(mTheta);
106
+    return HEL_RAD_TO_DEG(mTheta);
107 107
 }
108 108
 
109 109
 
110 110
 double Camera::getRadianYaw()
111 111
 {
112
-	return mTheta;
112
+    return mTheta;
113 113
 }
114 114
 
115 115
 
116 116
 double Camera::getRadianPitch()
117 117
 {
118
-	return mTheta2;
118
+    return mTheta2;
119 119
 }
120 120
 
121 121
 
@@ -125,253 +125,253 @@ double Camera::getRadianPitch()
125 125
 
126 126
 void Camera::rotate(float angle, float x, float y, float z)
127 127
 {
128
-	Quaternion t, n;
129
-	Matrix matrix;
130
-	double side[4] = { 1, 0,  0, 1 };
131
-	double up[4] =   { 0, 1,  0, 1 };
132
-	double look[4] = { 0, 0, -1, 1 };
133
- 	unsigned int i;
134
-	matrix_t m;
135
-
136
-
137
-	t.set(angle, x, y, z);
138
-	n = mQ * t;
139
-	n.normalize();
140
-
141
-	n.getMatrix(m);
142
-	matrix.setMatrix(m);
143
-	matrix.multiply4d(side, mSide);
144
-	matrix.multiply4d(look, mTarget);
145
-	matrix.multiply4d(up, mUp);
146
-
147
-	for (i = 0; i < 3; ++i)
148
-	{
149
-		mSide[i] += mPos[i];
150
-		mTarget[i] += mPos[i];
151
-		mUp[i] += mPos[i];
152
-	}
153
-
154
-	mQ = n;
128
+    Quaternion t, n;
129
+    Matrix matrix;
130
+    double side[4] = { 1, 0,  0, 1 };
131
+    double up[4] =   { 0, 1,  0, 1 };
132
+    double look[4] = { 0, 0, -1, 1 };
133
+    unsigned int i;
134
+    matrix_t m;
135
+
136
+
137
+    t.set(angle, x, y, z);
138
+    n = mQ * t;
139
+    n.normalize();
140
+
141
+    n.getMatrix(m);
142
+    matrix.setMatrix(m);
143
+    matrix.multiply4d(side, mSide);
144
+    matrix.multiply4d(look, mTarget);
145
+    matrix.multiply4d(up, mUp);
146
+
147
+    for (i = 0; i < 3; ++i)
148
+    {
149
+        mSide[i] += mPos[i];
150
+        mTarget[i] += mPos[i];
151
+        mUp[i] += mPos[i];
152
+    }
153
+
154
+    mQ = n;
155 155
 }
156 156
 
157 157
 
158 158
 void Camera::translate(float x, float y, float z)
159 159
 {
160
-	int i;
161
-	double result[4];
162
-	double v[4];
163
-	matrix_t m;
164
-	Matrix matrix;
165
-
166
-
167
-	v[0] = x;
168
-	v[1] = y;
169
-	v[2] = -z;
170
-	v[3] = 1;
171
-
172
-	m[0] = mSide[0] - mPos[0];
173
-	m[1] = mUp[0] - mPos[0];
174
-	m[2] = mTarget[0] - mPos[0];
175
-	m[3] = 0;
176
-	m[4] = mSide[1] - mPos[1];
177
-	m[5] = mUp[1] - mPos[1];
178
-	m[6] = mTarget[1] - mPos[1];
179
-	m[7] = 0;
180
-	m[8] = mSide[2] - mPos[2];
181
-	m[9] = mUp[2] - mPos[2];
182
-	m[10] = mTarget[2] - mPos[2];
183
-	m[11] = 0;
184
-	m[12] = 0;
185
-	m[13] = 0;
186
-	m[14] = 0;
187
-	m[15] = 1;
188
-
189
-	matrix.setMatrix(m);
190
-	matrix.multiply4d(v, result);
191
-
192
-	for (i = 0; i < 3; ++i)
193
-	{
194
-		mSide[i] += result[i];
195
-		mUp[i] += result[i];
196
-		mTarget[i] += result[i];
197
-		mPos[i] += result[i];
198
-	}
199
-
200
-	mPos[0] = x;
201
-	mPos[1] = y;
202
-	mPos[2] = z;
160
+    int i;
161
+    double result[4];
162
+    double v[4];
163
+    matrix_t m;
164
+    Matrix matrix;
165
+
166
+
167
+    v[0] = x;
168
+    v[1] = y;
169
+    v[2] = -z;
170
+    v[3] = 1;
171
+
172
+    m[0] = mSide[0] - mPos[0];
173
+    m[1] = mUp[0] - mPos[0];
174
+    m[2] = mTarget[0] - mPos[0];
175
+    m[3] = 0;
176
+    m[4] = mSide[1] - mPos[1];
177
+    m[5] = mUp[1] - mPos[1];
178
+    m[6] = mTarget[1] - mPos[1];
179
+    m[7] = 0;
180
+    m[8] = mSide[2] - mPos[2];
181
+    m[9] = mUp[2] - mPos[2];
182
+    m[10] = mTarget[2] - mPos[2];
183
+    m[11] = 0;
184
+    m[12] = 0;
185
+    m[13] = 0;
186
+    m[14] = 0;
187
+    m[15] = 1;
188
+
189
+    matrix.setMatrix(m);
190
+    matrix.multiply4d(v, result);
191
+
192
+    for (i = 0; i < 3; ++i)
193
+    {
194
+        mSide[i] += result[i];
195
+        mUp[i] += result[i];
196
+        mTarget[i] += result[i];
197
+        mPos[i] += result[i];
198
+    }
199
+
200
+    mPos[0] = x;
201
+    mPos[1] = y;
202
+    mPos[2] = z;
203 203
 }
204 204
 
205 205
 
206 206
 void Camera::reset()
207 207
 {
208
-	mTheta = 0.0;
209
-	mTheta2 = 0.0;
208
+    mTheta = 0.0;
209
+    mTheta2 = 0.0;
210 210
 
211
-	mPos[0] = 0.0;
212
-	mPos[1] = 0.0;
213
-	mPos[2] = 0.0;
211
+    mPos[0] = 0.0;
212
+    mPos[1] = 0.0;
213
+    mPos[2] = 0.0;
214 214
 
215
-	mTarget[0] = 0.0;
216
-	mTarget[1] = 0.0;
217
-	mTarget[2] = mViewDistance;
215
+    mTarget[0] = 0.0;
216
+    mTarget[1] = 0.0;
217
+    mTarget[2] = mViewDistance;
218 218
 
219
-	mSide[0] = 1.0;
220
-	mSide[1] = 0.0;
221
-	mSide[2] = 0.0;
219
+    mSide[0] = 1.0;
220
+    mSide[1] = 0.0;
221
+    mSide[2] = 0.0;
222 222
 
223
-	mUp[0] = 0.0;
224
-	mUp[1] = 1.0;
225
-	mUp[2] = 0.0;
223
+    mUp[0] = 0.0;
224
+    mUp[1] = 1.0;
225
+    mUp[2] = 0.0;
226 226
 
227
-	mQ.setIdentity();
228
-	translate(0.0, 0.0, 0.0);
227
+    mQ.setIdentity();
228
+    translate(0.0, 0.0, 0.0);
229 229
 }
230 230
 
231 231
 
232 232
 void Camera::setSensitivityY(float angle)
233 233
 {
234
-	mRotateDelta2 = HEL_DEG_TO_RAD(angle);
234
+    mRotateDelta2 = HEL_DEG_TO_RAD(angle);
235 235
 }
236 236
 
237 237
 
238 238
 void Camera::setSensitivityX(float angle)
239 239
 {
240
-	mRotateDelta = HEL_DEG_TO_RAD(angle);
240
+    mRotateDelta = HEL_DEG_TO_RAD(angle);
241 241
 }
242 242
 
243 243
 
244 244
 ////////
245 245
 void Camera::command(enum camera_command cmd)
246 246
 {
247
-	switch (cmd)
248
-	{
249
-	case CAMERA_MOVE_FORWARD:
250
-		if (mFlags & Camera_FlyMode)
251
-		{
252
-			mPos[2] += (mTranslateDelta * cos(mTheta));
253
-		}
254
-
255
-	  mPos[0] += (mTranslateDelta * sin(mTheta));
256
-	  mPos[1] += (mTranslateDelta * sin(mTheta2));
257
-	  break;
258
-  case CAMERA_MOVE_BACKWARD:
259
-	  if (mFlags & Camera_FlyMode)
260
-	  {
261
-		  mPos[2] -= (mTranslateDelta * cos(mTheta));
262
-	  }
263
-
264
-	  mPos[0] -= (mTranslateDelta * sin(mTheta));
265
-	  mPos[1] -= (mTranslateDelta * sin(mTheta2));
266
-	  break;
267
-  case CAMERA_MOVE_LEFT:
268
-	  mPos[0] -= (mTranslateDelta * sin(mTheta - 90.0f));
269
-	  mPos[2] -= (mTranslateDelta * cos(mTheta - 90.0f));
270
-	  break;
271
-  case CAMERA_MOVE_RIGHT:
272
-	  mPos[0] -= (mTranslateDelta * sin(mTheta + 90.0f));
273
-	  mPos[2] -= (mTranslateDelta * cos(mTheta + 90.0f));
274
-	  break;
275
- case CAMERA_ROTATE_UP:
276
-     if (mTheta2 < (M_PI / 2)) {
277
-	    mTheta2 += mRotateDelta2;
278
-	    rotate(mTheta2, 1.0, 0.0, 0.0);
279
-     }
280
-	 break;
281
- case CAMERA_ROTATE_DOWN:
282
-     if (mTheta2 > -(M_PI / 2)) {
283
-         mTheta2 -= mRotateDelta2;
284
-         rotate(mTheta2, 1.0, 0.0, 0.0);
285
-     }
286
-     break;
287
- case CAMERA_ROTATE_RIGHT:
288
-	 mTheta += mRotateDelta;
289
-	 rotate(mTheta, 0.0, 1.0, 0.0);
290
-	 break;
291
-  case CAMERA_ROTATE_LEFT:
292
-	  mTheta -= mRotateDelta;
293
-	  rotate(mTheta, 0.0, 1.0, 0.0);
294
-	  break;
295
-  case CAMERA_MOVE_UP:
296
-	  mPos[1] -= mTranslateDelta / 2.0;
297
-	  mTarget[1] -= mTranslateDelta / 2.0;
298
-	  break;
299
-  case CAMERA_MOVE_DOWN:
300
-	  mPos[1] += mTranslateDelta / 2.0;
301
-	  mTarget[1] += mTranslateDelta / 2.0;
302
-	  break;
303
-  case CAMERA_SPEED_UP:
304
-    ++mTranslateDelta;
305
-    break;
306
-  case CAMERA_SPEED_DOWN:
307
-    if (--mTranslateDelta < 0.0)
308
-      mTranslateDelta = 1.0;
309
-    break;
310
-  default:
311
-    ;
312
-  }
247
+    switch (cmd)
248
+    {
249
+        case CAMERA_MOVE_FORWARD:
250
+            if (mFlags & Camera_FlyMode)
251
+            {
252
+                mPos[2] += (mTranslateDelta * cos(mTheta));
253
+            }
254
+
255
+            mPos[0] += (mTranslateDelta * sin(mTheta));
256
+            mPos[1] += (mTranslateDelta * sin(mTheta2));
257
+            break;
258
+        case CAMERA_MOVE_BACKWARD:
259
+            if (mFlags & Camera_FlyMode)
260
+            {
261
+                mPos[2] -= (mTranslateDelta * cos(mTheta));
262
+            }
263
+
264
+            mPos[0] -= (mTranslateDelta * sin(mTheta));
265
+            mPos[1] -= (mTranslateDelta * sin(mTheta2));
266
+            break;
267
+        case CAMERA_MOVE_LEFT:
268
+            mPos[0] -= (mTranslateDelta * sin(mTheta - 90.0f));
269
+            mPos[2] -= (mTranslateDelta * cos(mTheta - 90.0f));
270
+            break;
271
+        case CAMERA_MOVE_RIGHT:
272
+            mPos[0] -= (mTranslateDelta * sin(mTheta + 90.0f));
273
+            mPos[2] -= (mTranslateDelta * cos(mTheta + 90.0f));
274
+            break;
275
+        case CAMERA_ROTATE_UP:
276
+            if (mTheta2 < (M_PI / 2)) {
277
+                mTheta2 += mRotateDelta2;
278
+                rotate(mTheta2, 1.0, 0.0, 0.0);
279
+            }
280
+            break;
281
+        case CAMERA_ROTATE_DOWN:
282
+            if (mTheta2 > -(M_PI / 2)) {
283
+                mTheta2 -= mRotateDelta2;
284
+                rotate(mTheta2, 1.0, 0.0, 0.0);
285
+            }
286
+            break;
287
+        case CAMERA_ROTATE_RIGHT:
288
+            mTheta += mRotateDelta;
289
+            rotate(mTheta, 0.0, 1.0, 0.0);
290
+            break;
291
+        case CAMERA_ROTATE_LEFT:
292
+            mTheta -= mRotateDelta;
293
+            rotate(mTheta, 0.0, 1.0, 0.0);
294
+            break;
295
+        case CAMERA_MOVE_UP:
296
+            mPos[1] -= mTranslateDelta / 2.0;
297
+            mTarget[1] -= mTranslateDelta / 2.0;
298
+            break;
299
+        case CAMERA_MOVE_DOWN:
300
+            mPos[1] += mTranslateDelta / 2.0;
301
+            mTarget[1] += mTranslateDelta / 2.0;
302
+            break;
303
+        case CAMERA_SPEED_UP:
304
+            ++mTranslateDelta;
305
+            break;
306
+        case CAMERA_SPEED_DOWN:
307
+            if (--mTranslateDelta < 0.0)
308
+                mTranslateDelta = 1.0;
309
+            break;
310
+        default:
311
+            ;
312
+    }
313 313
 }
314 314
 
315 315
 
316 316
 //! \fixme Mostly invalid for QUAT_CAM (can rotate on XYZ)
317 317
 bool Camera::isBehind(int x, int z)
318 318
 {
319
-  double bTheta, bCameraX, bCameraZ, Distance;
319
+    double bTheta, bCameraX, bCameraZ, Distance;
320 320
 
321 321
 
322
-  // Set up a "virtual camera" a huge distance behind us
323
-  bTheta = mTheta + HEL_PI;
322
+    // Set up a "virtual camera" a huge distance behind us
323
+    bTheta = mTheta + HEL_PI;
324 324
 
325
-  if (bTheta > HEL_PI)
326
-    bTheta -= HEL_2_PI;
325
+    if (bTheta > HEL_PI)
326
+        bTheta -= HEL_2_PI;
327 327
 
328
-   // 64k is a fair distance away...
329
-  bCameraX = (65536.0 * sin(bTheta)) + mPos[0];
330
-  bCameraZ = (65536.0 * cos(bTheta)) + mPos[2];
328
+    // 64k is a fair distance away...
329
+    bCameraX = (65536.0 * sin(bTheta)) + mPos[0];
330
+    bCameraZ = (65536.0 * cos(bTheta)) + mPos[2];
331 331
 
332
-  bCameraX -= x;
333
-  bCameraZ -= z;
334
-  Distance = sqrt((bCameraX * bCameraX) + (bCameraZ * bCameraZ));
332
+    bCameraX -= x;
333
+    bCameraZ -= z;
334
+    Distance = sqrt((bCameraX * bCameraX) + (bCameraZ * bCameraZ));
335 335
 
336
-  return (Distance < 65536.0);
336
+    return (Distance < 65536.0);
337 337
 }
338 338
 
339 339
 
340 340
 void Camera::setSpeed(float s)
341 341
 {
342
-	mTranslateDelta = s;
342
+    mTranslateDelta = s;
343 343
 }
344 344
 
345 345
 
346 346
 void Camera::update()
347 347
 {
348
-   mTarget[2] = (mViewDistance * cos(mTheta)) + mPos[2];
349
-   mTarget[0] = (mViewDistance * sin(mTheta)) + mPos[0];
350
-	mTarget[1] = (mViewDistance * sin(mTheta2)) + mPos[1]; // + height_offset;
348
+    mTarget[2] = (mViewDistance * cos(mTheta)) + mPos[2];
349
+    mTarget[0] = (mViewDistance * sin(mTheta)) + mPos[0];
350
+    mTarget[1] = (mViewDistance * sin(mTheta2)) + mPos[1]; // + height_offset;
351 351
 }
352 352
 
353 353
 
354 354
 void Camera::setPosition(vec3_t pos)
355 355
 {
356
-	mPos[0] = pos[0];
357
-	mPos[1] = pos[1];
358
-	mPos[2] = pos[2];
356
+    mPos[0] = pos[0];
357
+    mPos[1] = pos[1];
358
+    mPos[2] = pos[2];
359 359
 }
360 360
 
361 361
 
362 362
 void Camera::setUp(vec3_t up)
363 363
 {
364
-	mUp[0] = up[0];
365
-	mUp[1] = up[1];
366
-	mUp[2] = up[2];
364
+    mUp[0] = up[0];
365
+    mUp[1] = up[1];
366
+    mUp[2] = up[2];
367 367
 }
368 368
 
369 369
 
370 370
 void Camera::setTarget(vec3_t target)
371 371
 {
372
-	mTarget[0] = target[0];
373
-	mTarget[1] = target[1];
374
-	mTarget[2] = target[2];
372
+    mTarget[0] = target[0];
373
+    mTarget[1] = target[1];
374
+    mTarget[2] = target[2];
375 375
 }
376 376
 
377 377
 

+ 202
- 202
src/Emitter.cpp Переглянути файл

@@ -41,312 +41,312 @@ vec_t Emitter::mFrustum[6][4];
41 41
 
42 42
 int Emitter::compareParticleDist(const void *voidA, const void *voidB)
43 43
 {
44
-	Particle *a = (Particle *)voidA, *b = (Particle *)voidB;
45
-	float x, y, z, distA, distB;
46
-
47
-	if (!a || !b)
48
-		return -1; // error really
49
-
50
-	a->Pos(&x, &y, &z);
51
-	distA = (Emitter::mFrustum[5][0] * x +
52
-				Emitter::mFrustum[5][1] * y +
53
-				Emitter::mFrustum[5][2] * z +
54
-				Emitter::mFrustum[5][3]);
55
-
56
-	b->Pos(&x, &y, &z);
57
-	distB = (Emitter::mFrustum[5][0] * x +
58
-				Emitter::mFrustum[5][1] * y +
59
-				Emitter::mFrustum[5][2] * z +
60
-				Emitter::mFrustum[5][3]);
61
-
62
-	// reverse less/greater than
63
-	// less than
64
-	if (distA > distB)
65
-		return -1;
66
-
67
-	// greater than ( no need for equal )
68
-	return 1;
44
+    Particle *a = (Particle *)voidA, *b = (Particle *)voidB;
45
+    float x, y, z, distA, distB;
46
+
47
+    if (!a || !b)
48
+        return -1; // error really
49
+
50
+    a->Pos(&x, &y, &z);
51
+    distA = (Emitter::mFrustum[5][0] * x +
52
+            Emitter::mFrustum[5][1] * y +
53
+            Emitter::mFrustum[5][2] * z +
54
+            Emitter::mFrustum[5][3]);
55
+
56
+    b->Pos(&x, &y, &z);
57
+    distB = (Emitter::mFrustum[5][0] * x +
58
+            Emitter::mFrustum[5][1] * y +
59
+            Emitter::mFrustum[5][2] * z +
60
+            Emitter::mFrustum[5][3]);
61
+
62
+    // reverse less/greater than
63
+    // less than
64
+    if (distA > distB)
65
+        return -1;
66
+
67
+    // greater than ( no need for equal )
68
+    return 1;
69 69
 }
70 70
 
71 71
 
72 72
 Emitter::Emitter(const char *name, int n)
73 73
 {
74
-	_name = NULL;
75
-	_flags = 0;
76
-	_particle = NULL;
77
-	_count = 0;
78
-	_pos[0] = _pos[1] = _pos[2] = 0.0;
79
-	_mangle[0] = _mangle[1] = _mangle[2] = 0.0;
80
-
81
-	Name(name);
82
-	ParticleArray(n);
74
+    _name = NULL;
75
+    _flags = 0;
76
+    _particle = NULL;
77
+    _count = 0;
78
+    _pos[0] = _pos[1] = _pos[2] = 0.0;
79
+    _mangle[0] = _mangle[1] = _mangle[2] = 0.0;
80
+
81
+    Name(name);
82
+    ParticleArray(n);
83 83
 }
84 84
 
85 85
 
86 86
 Emitter::~Emitter()
87 87
 {
88
-	if (_name)
89
-	{
90
-		delete [] _name;
91
-	}
88
+    if (_name)
89
+    {
90
+        delete [] _name;
91
+    }
92 92
 
93
-	if (_particle)
94
-	{
95
-		delete [] _particle;
96
-	}
93
+    if (_particle)
94
+    {
95
+        delete [] _particle;
96
+    }
97 97
 
98
-	_count = 0;
98
+    _count = 0;
99 99
 }
100 100
 
101 101
 Particle *Emitter::Particles()
102 102
 {
103
-	return _particle;
103
+    return _particle;
104 104
 }
105 105
 
106 106
 
107 107
 int Emitter::Count()
108 108
 {
109
-	return _count;
109
+    return _count;
110 110
 }
111 111
 
112 112
 
113 113
 void Emitter::Pos(float *x, float *y, float *z)
114 114
 {
115
-	*x = _pos[0];
116
-	*y = _pos[1];
117
-	*z = _pos[2];
115
+    *x = _pos[0];
116
+    *y = _pos[1];
117
+    *z = _pos[2];
118 118
 }
119 119
 
120 120
 
121 121
 void Emitter::Pos(float x, float y, float z)
122 122
 {
123
-	_pos[0] = x;
124
-	_pos[1] = y;
125
-	_pos[2] = z;
123
+    _pos[0] = x;
124
+    _pos[1] = y;
125
+    _pos[2] = z;
126 126
 }
127 127
 
128 128
 
129 129
 void Emitter::Orientation(float *x, float *y, float *z)
130 130
 {
131
-	*x = _mangle[0];
132
-	*y = _mangle[1];
133
-	*z = _mangle[2];
131
+    *x = _mangle[0];
132
+    *y = _mangle[1];
133
+    *z = _mangle[2];
134 134
 }
135 135
 
136 136
 
137 137
 void Emitter::Orientation(float x, float y, float z)
138 138
 {
139
-	_mangle[0] = x;
140
-	_mangle[1] = y;
141
-	_mangle[2] = z;
139
+    _mangle[0] = x;
140
+    _mangle[1] = y;
141
+    _mangle[2] = z;
142 142
 }
143 143
 
144 144
 
145 145
 unsigned int Emitter::Flags()
146 146
 {
147
-  return _flags;
147
+    return _flags;
148 148
 }
149 149
 
150 150
 
151 151
 void Emitter::Flags(unsigned int flag, bool op)
152 152
 {
153
-  _flags |= flag;
153
+    _flags |= flag;
154 154
 
155
-  if (!op)
156
-    _flags ^= flag;
155
+    if (!op)
156
+        _flags ^= flag;
157 157
 }
158 158
 
159 159
 
160 160
 void Emitter::ParticleArray(int n)
161 161
 {
162
-	if (n)
163
-	{
164
-		if (_particle)
165
-		{
166
-			_count = 0;
167
-			delete [] _particle;
168
-		}
169
-
170
-		_count = n;
171
-		_particle = new Particle[_count];
172
-	}
162
+    if (n)
163
+    {
164
+        if (_particle)
165
+        {
166
+            _count = 0;
167
+            delete [] _particle;
168
+        }
169
+
170
+        _count = n;
171
+        _particle = new Particle[_count];
172
+    }
173 173
 }
174 174
 
175 175
 
176 176
 void Emitter::Name(const char *name)
177 177
 {
178
-	int l;
178
+    int l;
179 179
 
180 180
 
181
-	if (name && name[0])
182
-	{
183
-		if (_name)
184
-		{
185
-			delete [] _name;
186
-		}
181
+    if (name && name[0])
182
+    {
183
+        if (_name)
184
+        {
185
+            delete [] _name;
186
+        }
187 187
 
188
-		l = strlen(name);
189
-		_name = new char[l+1];
188
+        l = strlen(name);
189
+        _name = new char[l+1];
190 190
 
191
-		// Mongoose 2002.01.09, Mongoose says 'Only you can prevent overflows'
192
-		strncpy(_name, name, l);
193
-		_name[l] = 0;
194
-	}
191
+        // Mongoose 2002.01.09, Mongoose says 'Only you can prevent overflows'
192
+        strncpy(_name, name, l);
193
+        _name[l] = 0;
194
+    }
195 195
 }
196 196
 
197 197
 
198 198
 void Emitter::SetTextureId(int id)
199 199
 {
200
-	unsigned int i;
200
+    unsigned int i;
201 201
 
202 202
 
203
-	for (i = 0; i < _count; i++)
204
-		_particle[i].TextureId(id);
203
+    for (i = 0; i < _count; i++)
204
+        _particle[i].TextureId(id);
205 205
 }
206 206
 
207 207
 
208 208
 void Emitter::TextureId(unsigned int particle_start,
209
-								unsigned int particle_end, int id)
209
+        unsigned int particle_end, int id)
210 210
 {
211
-	unsigned int i;
211
+    unsigned int i;
212 212
 
213 213
 
214
-	if ((particle_start < _count) &&
215
-		 (particle_end > 0 && particle_end <= _count) &&
216
-		 (particle_start < particle_end))
217
-	{
218
-		for (i = particle_start; i < particle_end; i++)
219
-			_particle[i].TextureId(id);
220
-	}
214
+    if ((particle_start < _count) &&
215
+            (particle_end > 0 && particle_end <= _count) &&
216
+            (particle_start < particle_end))
217
+    {
218
+        for (i = particle_start; i < particle_end; i++)
219
+            _particle[i].TextureId(id);
220
+    }
221 221
 }
222 222
 
223 223
 
224 224
 void Emitter::Color(unsigned int particle_start, unsigned int particle_end,
225
-						  float r, float g, float b)
225
+        float r, float g, float b)
226 226
 {
227
-	unsigned int i;
227
+    unsigned int i;
228 228
 
229 229
 
230
-	if ((particle_start < _count) &&
231
-		 (particle_end > 0 && particle_end <= _count) &&
232
-		 (particle_start < particle_end))
233
-	{
234
-		for (i = particle_start; i < particle_end; i++)
235
-			_particle[i].Color(r, g, b);
236
-	}
230
+    if ((particle_start < _count) &&
231
+            (particle_end > 0 && particle_end <= _count) &&
232
+            (particle_start < particle_end))
233
+    {
234
+        for (i = particle_start; i < particle_end; i++)
235
+            _particle[i].Color(r, g, b);
236
+    }
237 237
 }
238 238
 
239 239
 
240 240
 void Emitter::Speed(unsigned int particle_start, unsigned int particle_end,
241
-						  float x, float y, float z)
241
+        float x, float y, float z)
242 242
 {
243
-	unsigned int i;
243
+    unsigned int i;
244 244
 
245 245
 
246
-	if ((particle_start < _count) &&
247
-		 (particle_end > 0 && particle_end <= _count) &&
248
-		 (particle_start < particle_end))
249
-	{
250
-		for (i = particle_start; i < particle_end; i++)
251
-			_particle[i].Speed(x, y, z);
252
-	}
246
+    if ((particle_start < _count) &&
247
+            (particle_end > 0 && particle_end <= _count) &&
248
+            (particle_start < particle_end))
249
+    {
250
+        for (i = particle_start; i < particle_end; i++)
251
+            _particle[i].Speed(x, y, z);
252
+    }
253 253
 }
254 254
 
255 255
 
256 256
 void Emitter::Force(unsigned int particle_start, unsigned int particle_end,
257
-						  float x, float y, float z)
257
+        float x, float y, float z)
258 258
 {
259
-	unsigned int i;
259
+    unsigned int i;
260 260
 
261 261
 
262
-	if ((particle_start < _count) &&
263
-		 (particle_end > 0 && particle_end <= _count) &&
264
-		 (particle_start < particle_end))
265
-	{
266
-		for (i = particle_start; i < particle_end; i++)
267
-			_particle[i].Force(x, y, z);
268
-	}
262
+    if ((particle_start < _count) &&
263
+            (particle_end > 0 && particle_end <= _count) &&
264
+            (particle_start < particle_end))
265
+    {
266
+        for (i = particle_start; i < particle_end; i++)
267
+            _particle[i].Force(x, y, z);
268
+    }
269 269
 }
270 270
 
271 271
 
272 272
 void Emitter::Draw()
273 273
 {
274
-	unsigned int i, p;
275
-	float x, y, z;
276
-	float r, g, b;
277
-	float life;
278
-
279
-
280
-	if (!_count || !_particle)
281
-	{
282
-		printf("Emitter::Draw> No particles!\n");
283
-		return;
284
-	}
285
-
286
-	glPushMatrix();
287
-
288
-	//glRotatef(_mangle[0], 1.0, 0.0, 0.0);
289
-	//glRotatef(_mangle[1], 0.0, 1.0, 0.0);
290
-	//glRotatef(_mangle[2], 0.0, 0.0, 1.0);
291
-	//glTranslatef(_pos[0], _pos[1], _pos[2]);
292
-
293
-	if (_flags & fUseDepthSorting)
294
-	{
295
-		qsort(_particle, _count, sizeof(Particle), compareParticleDist);
296
-	}
297
-
298
-	for (i = 0; i < _count; i++)
299
-	{
300
-		if (_particle[i].isActive())
301
-		{
302
-			_particle[i].Pos(&x, &y, &z);
303
-
304
-			if (_flags & fUseFrustumCulling)
305
-			{
306
-				for (p = 0; p < 6; ++p)
307
-				{
308
-					if (mFrustum[p][0] * x +
309
-						 mFrustum[p][1] * y +
310
-						 mFrustum[p][2] * z +
311
-						 mFrustum[p][3] < 0)
312
-					{
313
-						_particle[i].setActive(false);
314
-						break;
315
-					}
316
-				}
317
-
318
-				if (!_particle[i].isActive())
319
-					continue;
320
-			}
321
-
322
-			_particle[i].Color(&r, &g, &b);
323
-			life = _particle[i].Life();
324
-
325
-			// Mongoose 2002.01.01, Removed Texture agent dep
326
-			glBindTexture(GL_TEXTURE_2D, _particle[i].Texture());
327
-
328
-			// Alpha is determined by life, which is affected by blend amount
329
-			glColor4f(r, g, b, life);
330
-
331
-			// Render tristrip quad
332
-			glBegin(GL_TRIANGLE_STRIP);
333
-		      glTexCoord2d(1.0, 1.0);
334
-		      glVertex3f(x + 0.5, y + 0.5, z);
335
-
336
-		      glTexCoord2d(0.0, 1.0);
337
-		      glVertex3f(x - 0.5, y + 0.5, z);
338
-
339
-		      glTexCoord2d(1.0, 0.0);
340
-		      glVertex3f(x + 0.5, y - 0.5, z);
341
-
342
-		      glTexCoord2d(0.0, 0.0);
343
-		      glVertex3f(x - 0.5, y - 0.5, z);
344
-		    glEnd();
345
-
346
-			 // Update particle's attributes for it's life cycle
347
-			 _particle[i].Update();
348
-		}
349
-	}
350
-
351
-	glPopMatrix();
274
+    unsigned int i, p;
275
+    float x, y, z;
276
+    float r, g, b;
277
+    float life;
278
+
279
+
280
+    if (!_count || !_particle)
281
+    {
282
+        printf("Emitter::Draw> No particles!\n");
283
+        return;
284
+    }
285
+
286
+    glPushMatrix();
287
+
288
+    //glRotatef(_mangle[0], 1.0, 0.0, 0.0);
289
+    //glRotatef(_mangle[1], 0.0, 1.0, 0.0);
290
+    //glRotatef(_mangle[2], 0.0, 0.0, 1.0);
291
+    //glTranslatef(_pos[0], _pos[1], _pos[2]);
292
+
293
+    if (_flags & fUseDepthSorting)
294
+    {
295
+        qsort(_particle, _count, sizeof(Particle), compareParticleDist);
296
+    }
297
+
298
+    for (i = 0; i < _count; i++)
299
+    {
300
+        if (_particle[i].isActive())
301
+        {
302
+            _particle[i].Pos(&x, &y, &z);
303
+
304
+            if (_flags & fUseFrustumCulling)
305
+            {
306
+                for (p = 0; p < 6; ++p)
307
+                {
308
+                    if (mFrustum[p][0] * x +
309
+                            mFrustum[p][1] * y +
310
+                            mFrustum[p][2] * z +
311
+                            mFrustum[p][3] < 0)
312
+                    {
313
+                        _particle[i].setActive(false);
314
+                        break;
315
+                    }
316
+                }
317
+
318
+                if (!_particle[i].isActive())
319
+                    continue;
320
+            }
321
+
322
+            _particle[i].Color(&r, &g, &b);
323
+            life = _particle[i].Life();
324
+
325
+            // Mongoose 2002.01.01, Removed Texture agent dep
326
+            glBindTexture(GL_TEXTURE_2D, _particle[i].Texture());
327
+
328
+            // Alpha is determined by life, which is affected by blend amount
329
+            glColor4f(r, g, b, life);
330
+
331
+            // Render tristrip quad
332
+            glBegin(GL_TRIANGLE_STRIP);
333
+            glTexCoord2d(1.0, 1.0);
334
+            glVertex3f(x + 0.5, y + 0.5, z);
335
+
336
+            glTexCoord2d(0.0, 1.0);
337
+            glVertex3f(x - 0.5, y + 0.5, z);
338
+
339
+            glTexCoord2d(1.0, 0.0);
340
+            glVertex3f(x + 0.5, y - 0.5, z);
341
+
342
+            glTexCoord2d(0.0, 0.0);
343
+            glVertex3f(x - 0.5, y - 0.5, z);
344
+            glEnd();
345
+
346
+            // Update particle's attributes for it's life cycle
347
+            _particle[i].Update();
348
+        }
349
+    }
350
+
351
+    glPopMatrix();
352 352
 }

+ 150
- 150
src/GLString.cpp Переглянути файл

@@ -25,232 +25,232 @@
25 25
 
26 26
 GLString::GLString()
27 27
 {
28
-	_num_string_max = 0;
29
-	_num_string = 0;
30
-	_scale = 1.0;
31
-	_string = NULL;
28
+    _num_string_max = 0;
29
+    _num_string = 0;
30
+    _scale = 1.0;
31
+    _string = NULL;
32 32
 }
33 33
 
34 34
 
35 35
 GLString::~GLString()
36 36
 {
37
-	unsigned int i;
37
+    unsigned int i;
38 38
 
39
-	if (_string)
40
-	{
39
+    if (_string)
40
+    {
41 41
 
42
-		for (i = 0; i < _num_string; ++i)
43
-		{
44
-			if (_string[i].text)
45
-			{
46
-				delete [] _string[i].text;
47
-			}
48
-		}
42
+        for (i = 0; i < _num_string; ++i)
43
+        {
44
+            if (_string[i].text)
45
+            {
46
+                delete [] _string[i].text;
47
+            }
48
+        }
49 49
 
50
-		delete [] _string;
51
-	}
50
+        delete [] _string;
51
+    }
52 52
 }
53 53
 
54 54
 
55 55
 void GLString::Init(unsigned int max_strings)
56 56
 {
57
-	if (!max_strings)
58
-	{
59
-		return;
60
-	}
57
+    if (!max_strings)
58
+    {
59
+        return;
60
+    }
61 61
 
62
-	_num_string_max = max_strings;
63
-	_string = new gl_string_t[max_strings];
62
+    _num_string_max = max_strings;
63
+    _string = new gl_string_t[max_strings];
64 64
 }
65 65
 
66 66
 
67 67
 void GLString::SetChar(unsigned int string, unsigned int pos, char c)
68 68
 {
69
-	gl_string_t *str = GetString(string);
69
+    gl_string_t *str = GetString(string);
70 70
 
71 71
 
72
-	if (str && pos < str->len)
73
-	{
74
-		str->text[pos] = c;
75
-	}
72
+    if (str && pos < str->len)
73
+    {
74
+        str->text[pos] = c;
75
+    }
76 76
 }
77 77
 
78 78
 
79 79
 unsigned int GLString::GetStringLen(unsigned int string)
80 80
 {
81
-	gl_string_t *str = GetString(string);
81
+    gl_string_t *str = GetString(string);
82 82
 
83 83
 
84
-	if (str)
85
-	{
86
-		return str->len;
87
-	}
84
+    if (str)
85
+    {
86
+        return str->len;
87
+    }
88 88
 
89
-	return 0;
89
+    return 0;
90 90
 }
91 91
 
92 92
 
93 93
 char *GLString::GetBuffer(unsigned int string)
94 94
 {
95
-	gl_string_t *str = GetString(string);
95
+    gl_string_t *str = GetString(string);
96 96
 
97 97
 
98
-	if (str)
99
-	{
100
-		return str->text;
101
-	}
98
+    if (str)
99
+    {
100
+        return str->text;
101
+    }
102 102
 
103
-	return 0;
103
+    return 0;
104 104
 }
105 105
 
106 106
 
107 107
 void GLString::setActive(unsigned int string, bool active)
108 108
 {
109
-	gl_string_t *str;
109
+    gl_string_t *str;
110 110
 
111 111
 
112
-	str = GetString(string);
112
+    str = GetString(string);
113 113
 
114
-	if (str)
115
-	{
116
-		str->active = active;
117
-	}
114
+    if (str)
115
+    {
116
+        str->active = active;
117
+    }
118 118
 }
119 119
 
120 120
 
121 121
 void GLString::SetString(unsigned int string, const char *s, ...)
122 122
 {
123
-	va_list args;
124
-	gl_string_t *str;
125
-	unsigned int len;
123
+    va_list args;
124
+    gl_string_t *str;
125
+    unsigned int len;
126 126
 
127 127
 
128
-	str = GetString(string);
128
+    str = GetString(string);
129 129
 
130
-	if (s && s[0] && str)
131
-	{
132
-		str->active = true;
130
+    if (s && s[0] && str)
131
+    {
132
+        str->active = true;
133 133
 
134
-		len = strlen(s);
134
+        len = strlen(s);
135 135
 
136
-		if (len > str->len)
137
-		{
138
-			len = str->len - 1;
139
-		}
136
+        if (len > str->len)
137
+        {
138
+            len = str->len - 1;
139
+        }
140 140
 
141
-		va_start(args, s);
142
-		vsnprintf(str->text, str->len-2, s, args);
143
-		str->text[str->len-1] = 0;
144
-		va_end(args);
145
-	}
141
+        va_start(args, s);
142
+        vsnprintf(str->text, str->len-2, s, args);
143
+        str->text[str->len-1] = 0;
144
+        va_end(args);
145
+    }
146 146
 }
147 147
 
148 148
 
149 149
 void GLString::Scale(float scale)
150 150
 {
151
-	_scale = scale;
151
+    _scale = scale;
152 152
 }
153 153
 
154 154
 
155 155
 int GLString::glPrintf(int x, int y, const char *string, ...)
156 156
 {
157
-	int sz = 60;
158
-	int n;
159
-	va_list args;
160
-
161
-
162
-	// Mongoose 2002.01.01, Only allow valid strings
163
-	//   we must assume it's NULL terminated also if it passes...
164
-	if (!string || !string[0])
165
-	{
166
-		return -1;
167
-	}
168
-
169
-	if (_num_string > _num_string_max)
170
-	{
171
-		return -2;
172
-	}
173
-
174
-	// Mongoose 2002.01.01, Assume no longer than 'sz' wide lines
175
-	//   on first try
176
-	_string[_num_string].text = new char[sz];
177
-
178
-	// Mongoose 2002.01.03, Setup scale factor
179
-	_string[_num_string].scale = _scale;
180
-
181
-	//  Mongoose 2002.01.01, Setup position
182
-	_string[_num_string].x = x;
183
-	_string[_num_string].y = y;
184
-
185
-	va_start(args, string);
186
-
187
-	// Mongoose 2002.01.01, Get exact size needed if the first try fails
188
-	n = vsnprintf(_string[_num_string].text, sz, string, args);
189
-
190
-	// Mongoose 2002.01.01, Realloc correct amount if truncated
191
-	while (1)
192
-	{
193
-		if (n > -1 && n < sz)
194
-		{
195
-			break;
196
-		}
197
-
198
-		// Mongoose 2002.01.01, For glibc 2.1
199
-		if (n > -1)
200
-		{
201
-			sz = n + 1;
202
-			delete [] _string[_num_string].text;
203
-			_string[_num_string].text = new char[sz];
204
-			n = vsnprintf(_string[_num_string].text, sz, string, args);
205
-
206
-			break;
207
-		}
208
-		else // glibc 2.0
209
-		{
210
-			sz *= 2;
211
-			delete [] _string[_num_string].text;
212
-			_string[_num_string].text = new char[sz];
213
-			n = vsnprintf(_string[_num_string].text, sz, string, args);
214
-		}
215
-	}
216
-
217
-	va_end(args);
218
-
219
-
220
-	// Mongoose 2002.01.04, Remeber string size, for future rebuffering use
221
-	_string[_num_string].len = sz;
222
-
223
-	// Mongoose 2002.01.01, Incement string counter, since we just
224
-	//   allocated a string
225
-	++_num_string;
226
-
227
-	return 0;
157
+    int sz = 60;
158
+    int n;
159
+    va_list args;
160
+
161
+
162
+    // Mongoose 2002.01.01, Only allow valid strings
163
+    //   we must assume it's NULL terminated also if it passes...
164
+    if (!string || !string[0])
165
+    {
166
+        return -1;
167
+    }
168
+
169
+    if (_num_string > _num_string_max)
170
+    {
171
+        return -2;
172
+    }
173
+
174
+    // Mongoose 2002.01.01, Assume no longer than 'sz' wide lines
175
+    //   on first try
176
+    _string[_num_string].text = new char[sz];
177
+
178
+    // Mongoose 2002.01.03, Setup scale factor
179
+    _string[_num_string].scale = _scale;
180
+
181
+    //  Mongoose 2002.01.01, Setup position
182
+    _string[_num_string].x = x;
183
+    _string[_num_string].y = y;
184
+
185
+    va_start(args, string);
186
+
187
+    // Mongoose 2002.01.01, Get exact size needed if the first try fails
188
+    n = vsnprintf(_string[_num_string].text, sz, string, args);
189
+
190
+    // Mongoose 2002.01.01, Realloc correct amount if truncated
191
+    while (1)
192
+    {
193
+        if (n > -1 && n < sz)
194
+        {
195
+            break;
196
+        }
197
+
198
+        // Mongoose 2002.01.01, For glibc 2.1
199
+        if (n > -1)
200
+        {
201
+            sz = n + 1;
202
+            delete [] _string[_num_string].text;
203
+            _string[_num_string].text = new char[sz];
204
+            n = vsnprintf(_string[_num_string].text, sz, string, args);
205
+
206
+            break;
207
+        }
208
+        else // glibc 2.0
209
+        {
210
+            sz *= 2;
211
+            delete [] _string[_num_string].text;
212
+            _string[_num_string].text = new char[sz];
213
+            n = vsnprintf(_string[_num_string].text, sz, string, args);
214
+        }
215
+    }
216
+
217
+    va_end(args);
218
+
219
+
220
+    // Mongoose 2002.01.04, Remeber string size, for future rebuffering use
221
+    _string[_num_string].len = sz;
222
+
223
+    // Mongoose 2002.01.01, Incement string counter, since we just
224
+    //   allocated a string
225
+    ++_num_string;
226
+
227
+    return 0;
228 228
 }
229 229
 
230 230
 
231 231
 void GLString::Render(int width, int height)
232 232
 {
233
-	unsigned int i;
234
-
235
-	for (i = 0; i < _num_string; ++i)
236
-	{
237
-		if (_string[i].active)
238
-		{
239
-			glPrint2d(_string[i].x, _string[i].y,
240
-						 _string[i].scale,
241
-						 _string[i].text);
242
-		}
243
-	}
233
+    unsigned int i;
234
+
235
+    for (i = 0; i < _num_string; ++i)
236
+    {
237
+        if (_string[i].active)
238
+        {
239
+            glPrint2d(_string[i].x, _string[i].y,
240
+                    _string[i].scale,
241
+                    _string[i].text);
242
+        }
243
+    }
244 244
 }
245 245
 
246 246
 
247 247
 gl_string_t *GLString::GetString(unsigned int id)
248 248
 {
249
-	if (id < _num_string)
250
-	{
251
-		return _string + id;
252
-	}
249
+    if (id < _num_string)
250
+    {
251
+        return _string + id;
252
+    }
253 253
 
254
-	return NULL;
254
+    return NULL;
255 255
 }
256 256
 

+ 171
- 171
src/MatMath.cpp Переглянути файл

@@ -15,253 +15,253 @@
15 15
 
16 16
 
17 17
 vec_t helIntersectionOfAbstractSpheres(vec3_t centerA, vec_t radiusA,
18
-													vec3_t centerB, vec_t radiusB)
18
+        vec3_t centerB, vec_t radiusB)
19 19
 {
20
-	Vector3d a = Vector3d(centerA);
21
-	Vector3d b = Vector3d(centerB);
22
-	Vector3d d = a - b;
23
-	vec_t dist, minDist;
20
+    Vector3d a = Vector3d(centerA);
21
+    Vector3d b = Vector3d(centerB);
22
+    Vector3d d = a - b;
23
+    vec_t dist, minDist;
24 24
 
25
-	dist = Vector3d::dot(d, d);
26
-	minDist = radiusA + radiusB;
25
+    dist = Vector3d::dot(d, d);
26
+    minDist = radiusA + radiusB;
27 27
 
28
-	return (dist <= minDist * minDist);
28
+    return (dist <= minDist * minDist);
29 29
 }
30 30
 
31 31
 
32 32
 inline vec_t square(vec_t a)
33 33
 {
34
-	return a * a;
34
+    return a * a;
35 35
 }
36 36
 
37 37
 
38 38
 // Returns number of intersections and intersection position(s)
39 39
 // Got algorithm from http://astronomy.swin.edu.au/~pbourke/geometry/
40 40
 int helIntersectionOfAbstractSphereAndLine(vec3_t center, vec_t radius,
41
-														 vec3_t posA, vec3_t posB,
42
-														 vec3_t intersectionA,
43
-														 vec3_t intersectionB)
41
+        vec3_t posA, vec3_t posB,
42
+        vec3_t intersectionA,
43
+        vec3_t intersectionB)
44 44
 {
45
-	// float x , y , z;
46
-	vec_t a, b, c, mu, i ;
47
-
48
-
49
-	a = (square(posB[0] - posA[0]) +
50
-		  square(posB[1] - posA[1]) +
51
-		  square(posB[2] - posA[2]));
52
-	b = (2 * ((posB[0] - posA[0]) * (posA[0] - center[0]) +
53
-				 (posB[1] - posA[1]) * (posA[1] - center[1]) +
54
-				 (posB[2] - posA[2]) * (posA[2] - center[2])));
55
-	c = (square(center[0]) + square(center[1]) +
56
-		  square(center[2]) + square(posA[0]) +
57
-		  square(posA[1]) + square(posA[2]) -
58
-		  2 * (center[0]*posA[0] + center[1]*posA[1] + center[2]*posA[2]) -
59
-		  square(radius));
60
-
61
-	i = b * b - 4 * a * c;
62
-
63
-
64
-	if (i < 0.0)
65
-	{
66
-		// No intersection
67
-		return 0;
68
-	}
69
-	else if (i == 0.0)
70
-	{
71
-		// One intersection
72
-		mu = -b/(2*a) ;
73
-		intersectionA[1] = posA[0] + mu*(posB[0]-posA[0]);
74
-		intersectionA[2] = posA[1] + mu*(posB[1]-posA[1]);
75
-		intersectionA[3] = posA[2] + mu*(posB[2]-posA[2]);
76
-
77
-		return 1;
78
-	}
79
-	else
80
-	{
81
-		// Two intersections
82
-
83
-		// First intersection
84
-		mu = (-b + sqrt( square(b) - 4*a*c)) / (2*a);
85
-		intersectionA[1] = posA[0] + mu*(posB[0]-posA[0]);
86
-		intersectionA[2] = posA[1] + mu*(posB[1]-posA[1]);
87
-		intersectionA[3] = posA[2] + mu*(posB[2]-posA[2]);
88
-
89
-		// Second intersection
90
-		mu = (-b - sqrt(square(b) - 4*a*c)) / (2*a);
91
-		intersectionB[0] = posA[0] + mu*(posB[0]-posA[0]);
92
-		intersectionB[1] = posA[1] + mu*(posB[1]-posA[1]);
93
-		intersectionB[2] = posA[2] + mu*(posB[2]-posA[2]);
94
-
95
-		return 2;
96
-	}
45
+    // float x , y , z;
46
+    vec_t a, b, c, mu, i ;
47
+
48
+
49
+    a = (square(posB[0] - posA[0]) +
50
+            square(posB[1] - posA[1]) +
51
+            square(posB[2] - posA[2]));
52
+    b = (2 * ((posB[0] - posA[0]) * (posA[0] - center[0]) +
53
+                (posB[1] - posA[1]) * (posA[1] - center[1]) +
54
+                (posB[2] - posA[2]) * (posA[2] - center[2])));
55
+    c = (square(center[0]) + square(center[1]) +
56
+            square(center[2]) + square(posA[0]) +
57
+            square(posA[1]) + square(posA[2]) -
58
+            2 * (center[0]*posA[0] + center[1]*posA[1] + center[2]*posA[2]) -
59
+            square(radius));
60
+
61
+    i = b * b - 4 * a * c;
62
+
63
+
64
+    if (i < 0.0)
65
+    {
66
+        // No intersection
67
+        return 0;
68
+    }
69
+    else if (i == 0.0)
70
+    {
71
+        // One intersection
72
+        mu = -b/(2*a) ;
73
+        intersectionA[1] = posA[0] + mu*(posB[0]-posA[0]);
74
+        intersectionA[2] = posA[1] + mu*(posB[1]-posA[1]);
75
+        intersectionA[3] = posA[2] + mu*(posB[2]-posA[2]);
76
+
77
+        return 1;
78
+    }
79
+    else
80
+    {
81
+        // Two intersections
82
+
83
+        // First intersection
84
+        mu = (-b + sqrt( square(b) - 4*a*c)) / (2*a);
85
+        intersectionA[1] = posA[0] + mu*(posB[0]-posA[0]);
86
+        intersectionA[2] = posA[1] + mu*(posB[1]-posA[1]);
87
+        intersectionA[3] = posA[2] + mu*(posB[2]-posA[2]);
88
+
89
+        // Second intersection
90
+        mu = (-b - sqrt(square(b) - 4*a*c)) / (2*a);
91
+        intersectionB[0] = posA[0] + mu*(posB[0]-posA[0]);
92
+        intersectionB[1] = posA[1] + mu*(posB[1]-posA[1]);
93
+        intersectionB[2] = posA[2] + mu*(posB[2]-posA[2]);
94
+
95
+        return 2;
96
+    }
97 97
 }
98 98
 
99 99
 
100 100
 int helIntersectionLineAndPolygon(vec3_t intersect,
101
-											 vec3_t p1, vec3_t p2,
102
-											 vec3_t *polygon)
101
+        vec3_t p1, vec3_t p2,
102
+        vec3_t *polygon)
103 103
 {
104
-	//	vec3_t normal, a, b;
105
-	Vector3d a, b, normal, pA, pB;
106
-	vec_t d, denominator, mu;
107
-	double theta;
108
-
109
-
110
-	pA = Vector3d(p1);
111
-	pB = Vector3d(p2);
112
-
113
-	// Find normal
114
-	//mtkVectorSubtract(polygon[1], polygon[0], a);
115
-	a = Vector3d(polygon[1]) - Vector3d(polygon[0]);
116
-	//mtkVectorSubtract(polygon[2], polygon[0], b);
117
-	b = Vector3d(polygon[2]) - Vector3d(polygon[0]);
118
-	normal = Vector3d::cross(a, b);
119
-	//mtkVectorCrossProduct(a, b, normal);
120
-	normal.normalize();
121
-	//mtkVectorNormalize(normal, normal);
122
-
123
-	// find D
124
-	//d = (normal[0] * polygon[0][0] -
125
-	//	  normal[1] * polygon[0][1] -
126
-	//	  normal[2] * polygon[0][2]);
127
-	d = (normal.mVec[0] * polygon[0][0] -
128
-		  normal.mVec[1] * polygon[0][1] -
129
-		  normal.mVec[2] * polygon[0][2]);
130
-
131
-	// line segment parallel to plane?
132
-	//mtkVectorSubtract(p2, p1, a); // cache p2 - p1 => a
133
-	a = pB - pA;
134
-
135
-	//denominator = (normal[0] * a[0] +
136
-	//					normal[1] * a[1] +
137
-	//					normal[2] * a[2]);
138
-	denominator = Vector3d::dot(normal, a);
139
-
140
-	if (denominator > 0.0)
141
-		return 0;
142
-
143
-	// Line segment contains intercept point?
144
-	//mu = - ((d + normal[0] * p1[0] + normal[1] * p1[1] + normal[2] * p1[2]) /
145
-	//		  denominator);
146
-	mu = -((d + Vector3d::dot(normal, pA)) / denominator);
147
-
148
-	if (mu < 0.0 || mu > 1.0)
149
-		return 0;
150
-
151
-	//intersect[0] = p1[0] + mu * a[0];
152
-	//intersect[1] = p1[1] + mu * a[1];
153
-	//intersect[2] = p1[2] + mu * a[2];
154
-	b = pA + (a * mu);
155
-	intersect[0] = b.mVec[0];
156
-	intersect[1] = b.mVec[1];
157
-	intersect[2] = b.mVec[2];
158
-
159
-
160
-	// See if the intercept is bound by polygon by winding number
104
+    //  vec3_t normal, a, b;
105
+    Vector3d a, b, normal, pA, pB;
106
+    vec_t d, denominator, mu;
107
+    double theta;
108
+
109
+
110
+    pA = Vector3d(p1);
111
+    pB = Vector3d(p2);
112
+
113
+    // Find normal
114
+    //mtkVectorSubtract(polygon[1], polygon[0], a);
115
+    a = Vector3d(polygon[1]) - Vector3d(polygon[0]);
116
+    //mtkVectorSubtract(polygon[2], polygon[0], b);
117
+    b = Vector3d(polygon[2]) - Vector3d(polygon[0]);
118
+    normal = Vector3d::cross(a, b);
119
+    //mtkVectorCrossProduct(a, b, normal);
120
+    normal.normalize();
121
+    //mtkVectorNormalize(normal, normal);
122
+
123
+    // find D
124
+    //d = (normal[0] * polygon[0][0] -
125
+    //    normal[1] * polygon[0][1] -
126
+    //    normal[2] * polygon[0][2]);
127
+    d = (normal.mVec[0] * polygon[0][0] -
128
+            normal.mVec[1] * polygon[0][1] -
129
+            normal.mVec[2] * polygon[0][2]);
130
+
131
+    // line segment parallel to plane?
132
+    //mtkVectorSubtract(p2, p1, a); // cache p2 - p1 => a
133
+    a = pB - pA;
134
+
135
+    //denominator = (normal[0] * a[0] +
136
+    //                  normal[1] * a[1] +
137
+    //                  normal[2] * a[2]);
138
+    denominator = Vector3d::dot(normal, a);
139
+
140
+    if (denominator > 0.0)
141
+        return 0;
142
+
143
+    // Line segment contains intercept point?
144
+    //mu = - ((d + normal[0] * p1[0] + normal[1] * p1[1] + normal[2] * p1[2]) /
145
+    //        denominator);
146
+    mu = -((d + Vector3d::dot(normal, pA)) / denominator);
147
+
148
+    if (mu < 0.0 || mu > 1.0)
149
+        return 0;
150
+
151
+    //intersect[0] = p1[0] + mu * a[0];
152
+    //intersect[1] = p1[1] + mu * a[1];
153
+    //intersect[2] = p1[2] + mu * a[2];
154
+    b = pA + (a * mu);
155
+    intersect[0] = b.mVec[0];
156
+    intersect[1] = b.mVec[1];
157
+    intersect[2] = b.mVec[2];
158
+
159
+
160
+    // See if the intercept is bound by polygon by winding number
161 161
 #ifdef WINDING_NUMBERS_TRIANGLE
162
-	mtkVectorSubtract(polygon[0], intersect, a);
163
-	mtkVectorNormalize(a, a);
164
-	mtkVectorSubtract(polygon[1], intersect, b);
165
-	mtkVectorNormalize(b, b);
166
-	mtkVectorSubtract(polygon[2], intersect, c);
167
-	mtkVectorNormalize(c, c);
162
+    mtkVectorSubtract(polygon[0], intersect, a);
163
+    mtkVectorNormalize(a, a);
164
+    mtkVectorSubtract(polygon[1], intersect, b);
165
+    mtkVectorNormalize(b, b);
166
+    mtkVectorSubtract(polygon[2], intersect, c);
167
+    mtkVectorNormalize(c, c);
168 168
 
169
-	t0 = mtkVectorDotProduct(a, b);
170
-	t1 = mtkVectorDotProduct(b, c);
171
-	t2 = mtkVectorDotProduct(c, a);
169
+    t0 = mtkVectorDotProduct(a, b);
170
+    t1 = mtkVectorDotProduct(b, c);
171
+    t2 = mtkVectorDotProduct(c, a);
172 172
 
173
-	total = HEL_RAD_TO_DEG(acos(t0) + acos(t1) + acos(t2));
173
+    total = HEL_RAD_TO_DEG(acos(t0) + acos(t1) + acos(t2));
174 174
 
175
-	if (total - 360 < 0.0)
176
-		return 0;
175
+    if (total - 360 < 0.0)
176
+        return 0;
177 177
 #else // assume convex polygons here for sure
178
-	//mtkVectorSubtract(intersect, polygon[0], a);
179
-	//theta = mtkVectorDotProduct(a, normal);
180
-	theta = Vector3d::dot(b - Vector3d(polygon[0]), normal); // b = intersect
178
+    //mtkVectorSubtract(intersect, polygon[0], a);
179
+    //theta = mtkVectorDotProduct(a, normal);
180
+    theta = Vector3d::dot(b - Vector3d(polygon[0]), normal); // b = intersect
181 181
 
182
-	if (theta >= 90.0) // Yeah I know
183
-		return 0;
182
+    if (theta >= 90.0) // Yeah I know
183
+        return 0;
184 184
 #endif
185 185
 
186
-	return 1;
186
+    return 1;
187 187
 }
188 188
 
189 189
 
190
-vec_t helDistToSphereFromPlane3v(vec3_t center,	vec_t radius, vec4_t plane)
190
+vec_t helDistToSphereFromPlane3v(vec3_t center, vec_t radius, vec4_t plane)
191 191
 {
192
-	vec_t d;
192
+    vec_t d;
193 193
 
194 194
 
195
-	d = (plane[0] * center[0] +
196
-		  plane[1] * center[1] +
197
-		  plane[2] * center[2] +
198
-		  plane[3]);
195
+    d = (plane[0] * center[0] +
196
+            plane[1] * center[1] +
197
+            plane[2] * center[2] +
198
+            plane[3]);
199 199
 
200
-	if (d <= -radius)
201
-		return 0;
200
+    if (d <= -radius)
201
+        return 0;
202 202
 
203
-	return d + radius;
203
+    return d + radius;
204 204
 }
205 205
 
206 206
 
207 207
 vec_t helDistToBboxFromPlane3v(vec3_t min, vec3_t max, vec4_t plane)
208 208
 {
209
-	vec3_t center;
210
-	vec_t d, radius;
209
+    vec3_t center;
210
+    vec_t d, radius;
211 211
 
212 212
 
213
-	helMidpoint3v(min, max, center);
213
+    helMidpoint3v(min, max, center);
214 214
 
215
-	d = (plane[0] * center[0] +
216
-		  plane[1] * center[1] +
217
-		  plane[2] * center[2] +
218
-		  plane[3]);
215
+    d = (plane[0] * center[0] +
216
+            plane[1] * center[1] +
217
+            plane[2] * center[2] +
218
+            plane[3]);
219 219
 
220
-	radius = helDist3v(max, center);
220
+    radius = helDist3v(max, center);
221 221
 
222
-	if (d <= -radius)
223
-		return 0;
222
+    if (d <= -radius)
223
+        return 0;
224 224
 
225
-	return d + radius;
225
+    return d + radius;
226 226
 }
227 227
 
228 228
 
229 229
 vec_t helDist3v(vec3_t a, vec3_t b)
230 230
 {
231
-	return (sqrt( ((b[0] - a[0]) * (b[0] - a[0])) +
232
-					  ((b[1] - a[1]) * (b[1] - a[1])) +
233
-					  ((b[2] - a[2]) * (b[2] - a[2]))));
231
+    return (sqrt( ((b[0] - a[0]) * (b[0] - a[0])) +
232
+                ((b[1] - a[1]) * (b[1] - a[1])) +
233
+                ((b[2] - a[2]) * (b[2] - a[2]))));
234 234
 }
235 235
 
236 236
 
237 237
 void helMidpoint3v(vec3_t a, vec3_t b, vec3_t mid)
238 238
 {
239
-	mid[0] = (a[0] + b[0]) / 2;
240
-	mid[1] = (a[1] + b[1]) / 2;
241
-	mid[2] = (a[2] + b[2]) / 2;
239
+    mid[0] = (a[0] + b[0]) / 2;
240
+    mid[1] = (a[1] + b[1]) / 2;
241
+    mid[2] = (a[2] + b[2]) / 2;
242 242
 }
243 243
 
244 244
 
245 245
 vec_t helNorm4v(vec4_t v)
246 246
 {
247
-	return (sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]));
247
+    return (sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]));
248 248
 }
249 249
 
250 250
 
251 251
 vec_t helNorm3v(vec3_t v)
252 252
 {
253
-	return (sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]));
253
+    return (sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]));
254 254
 }
255 255
 
256 256
 
257 257
 vec_t helNorm2v(vec2_t v)
258 258
 {
259
-	return (sqrt(v[0]*v[0] + v[1]*v[1]));
259
+    return (sqrt(v[0]*v[0] + v[1]*v[1]));
260 260
 }
261 261
 
262 262
 
263 263
 vec_t helRandomNum(vec_t from, vec_t to)
264 264
 {
265
-	return from + ((to - from) * rand() / (RAND_MAX + 1.0));
265
+    return from + ((to - from) * rand() / (RAND_MAX + 1.0));
266 266
 }
267 267
 

+ 319
- 319
src/Matrix.cpp Переглянути файл

@@ -31,23 +31,23 @@
31 31
 
32 32
 Matrix::Matrix()
33 33
 {
34
-	setIdentity();
34
+    setIdentity();
35 35
 }
36 36
 
37 37
 
38 38
 Matrix::Matrix(matrix_t m)
39 39
 {
40
-	setMatrix(m);
40
+    setMatrix(m);
41 41
 }
42 42
 
43 43
 
44 44
 Matrix::Matrix(Quaternion &q)
45 45
 {
46
-	matrix_t m;
46
+    matrix_t m;
47 47
 
48 48
 
49
-	q.getMatrix(m);
50
-	setMatrix(m);
49
+    q.getMatrix(m);
50
+    setMatrix(m);
51 51
 }
52 52
 
53 53
 
@@ -63,128 +63,128 @@ Matrix::~Matrix()
63 63
 
64 64
 bool Matrix::getInvert(matrix_t out)
65 65
 {
66
-	matrix_t m;
66
+    matrix_t m;
67 67
 
68 68
 #ifdef COLUMN_ORDER
69
-	getMatrix(m);
69
+    getMatrix(m);
70 70
 #else
71
-	getTransposeMatrix(m);
71
+    getTransposeMatrix(m);
72 72
 #endif
73 73
 
74
-	/* Mongoose: This code was from a Jeff Lander tutorial which was based
75
-		on MESA GL's InvertMatrix */
74
+    /* Mongoose: This code was from a Jeff Lander tutorial which was based
75
+       on MESA GL's InvertMatrix */
76 76
 
77
-	/* NB. OpenGL Matrices are COLUMN major. */
77
+    /* NB. OpenGL Matrices are COLUMN major. */
78 78
 #define SWAP_ROWS(a, b) { float *_tmp = a; (a)=(b); (b)=_tmp; }
79 79
 #define MAT(m,r,c) (m)[(c)*4+(r)]
80 80
 
81
-	float wtmp[4][8];
82
-	float m0, m1, m2, m3, s;
83
-	float *r0, *r1, *r2, *r3;
84
-
85
-	r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
86
-
87
-	r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
88
-	r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
89
-	r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
90
-
91
-	r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
92
-	r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
93
-	r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
94
-
95
-	r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
96
-	r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
97
-	r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
98
-
99
-	r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
100
-	r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
101
-	r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
102
-
103
-	/* choose pivot - or die */
104
-	if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
105
-	if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
106
-	if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
107
-	if (0.0 == r0[0])  return false;
108
-
109
-	/* eliminate first variable     */
110
-	m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
111
-	s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
112
-	s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
113
-	s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
114
-	s = r0[4];
115
-	if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
116
-	s = r0[5];
117
-	if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
118
-	s = r0[6];
119
-	if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
120
-	s = r0[7];
121
-	if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
122
-
123
-	/* choose pivot - or die */
124
-	if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
125
-	if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
126
-	if (0.0 == r1[1])  return false;
127
-
128
-	/* eliminate second variable */
129
-	m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
130
-	r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
131
-	r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
132
-	s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
133
-	s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
134
-	s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
135
-	s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
136
-
137
-	/* choose pivot - or die */
138
-	if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
139
-	if (0.0 == r2[2])  return false;
140
-
141
-	/* eliminate third variable */
142
-	m3 = r3[2]/r2[2];
143
-	r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
144
-	r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
145
-	r3[7] -= m3 * r2[7];
146
-
147
-	/* last check */
148
-	if (0.0 == r3[3]) return false;
149
-
150
-	s = 1.0/r3[3];              /* now back substitute row 3 */
151
-	r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
152
-
153
-	m2 = r2[3];                 /* now back substitute row 2 */
154
-	s  = 1.0/r2[2];
155
-	r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
156
-	r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
157
-	m1 = r1[3];
158
-	r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
159
-	r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
160
-	m0 = r0[3];
161
-	r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
162
-	r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
163
-
164
-	m1 = r1[2];                 /* now back substitute row 1 */
165
-	s  = 1.0/r1[1];
166
-	r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
167
-	r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
168
-	m0 = r0[2];
169
-	r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
170
-	r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
171
-
172
-	m0 = r0[1];                 /* now back substitute row 0 */
173
-	s  = 1.0/r0[0];
174
-	r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
175
-	r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
176
-
177
-	MAT(out,0,0) = r0[4];
178
-	MAT(out,0,1) = r0[5], MAT(out,0,2) = r0[6];
179
-	MAT(out,0,3) = r0[7], MAT(out,1,0) = r1[4];
180
-	MAT(out,1,1) = r1[5], MAT(out,1,2) = r1[6];
181
-	MAT(out,1,3) = r1[7], MAT(out,2,0) = r2[4];
182
-	MAT(out,2,1) = r2[5], MAT(out,2,2) = r2[6];
183
-	MAT(out,2,3) = r2[7], MAT(out,3,0) = r3[4];
184
-	MAT(out,3,1) = r3[5], MAT(out,3,2) = r3[6];
185
-	MAT(out,3,3) = r3[7];
186
-
187
-	return true;
81
+    float wtmp[4][8];
82
+    float m0, m1, m2, m3, s;
83
+    float *r0, *r1, *r2, *r3;
84
+
85
+    r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
86
+
87
+    r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
88
+        r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
89
+        r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
90
+
91
+        r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
92
+        r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
93
+        r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
94
+
95
+        r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
96
+        r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
97
+        r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
98
+
99
+        r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
100
+        r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
101
+        r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
102
+
103
+    /* choose pivot - or die */
104
+    if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
105
+    if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
106
+    if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
107
+    if (0.0 == r0[0])  return false;
108
+
109
+    /* eliminate first variable     */
110
+    m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
111
+    s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
112
+    s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
113
+    s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
114
+    s = r0[4];
115
+    if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
116
+    s = r0[5];
117
+    if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
118
+    s = r0[6];
119
+    if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
120
+    s = r0[7];
121
+    if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
122
+
123
+    /* choose pivot - or die */
124
+    if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
125
+    if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
126
+    if (0.0 == r1[1])  return false;
127
+
128
+    /* eliminate second variable */
129
+    m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
130
+    r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
131
+    r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
132
+    s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
133
+    s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
134
+    s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
135
+    s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
136
+
137
+    /* choose pivot - or die */
138
+    if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
139
+    if (0.0 == r2[2])  return false;
140
+
141
+    /* eliminate third variable */
142
+    m3 = r3[2]/r2[2];
143
+    r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
144
+        r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
145
+        r3[7] -= m3 * r2[7];
146
+
147
+    /* last check */
148
+    if (0.0 == r3[3]) return false;
149
+
150
+    s = 1.0/r3[3];              /* now back substitute row 3 */
151
+    r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
152
+
153
+    m2 = r2[3];                 /* now back substitute row 2 */
154
+    s  = 1.0/r2[2];
155
+    r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
156
+        r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
157
+    m1 = r1[3];
158
+    r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
159
+        r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
160
+    m0 = r0[3];
161
+    r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
162
+        r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
163
+
164
+    m1 = r1[2];                 /* now back substitute row 1 */
165
+    s  = 1.0/r1[1];
166
+    r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
167
+        r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
168
+    m0 = r0[2];
169
+    r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
170
+        r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
171
+
172
+    m0 = r0[1];                 /* now back substitute row 0 */
173
+    s  = 1.0/r0[0];
174
+    r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
175
+        r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
176
+
177
+    MAT(out,0,0) = r0[4];
178
+    MAT(out,0,1) = r0[5], MAT(out,0,2) = r0[6];
179
+    MAT(out,0,3) = r0[7], MAT(out,1,0) = r1[4];
180
+    MAT(out,1,1) = r1[5], MAT(out,1,2) = r1[6];
181
+    MAT(out,1,3) = r1[7], MAT(out,2,0) = r2[4];
182
+    MAT(out,2,1) = r2[5], MAT(out,2,2) = r2[6];
183
+    MAT(out,2,3) = r2[7], MAT(out,3,0) = r3[4];
184
+    MAT(out,3,1) = r3[5], MAT(out,3,2) = r3[6];
185
+    MAT(out,3,3) = r3[7];
186
+
187
+    return true;
188 188
 #undef MAT
189 189
 #undef SWAP_ROWS
190 190
 }
@@ -192,120 +192,120 @@ bool Matrix::getInvert(matrix_t out)
192 192
 
193 193
 void Matrix::getMatrix(matrix_t mat)
194 194
 {
195
-	copy(mMatrix, mat);
195
+    copy(mMatrix, mat);
196 196
 }
197 197
 
198 198
 
199 199
 void Matrix::getTransposeMatrix(matrix_t m)
200 200
 {
201
-	m[ 0]= mMatrix[0]; m[ 1]= mMatrix[4]; m[ 2]= mMatrix[ 8]; m[ 3]=mMatrix[12];
202
-	m[ 4]= mMatrix[1]; m[ 5]= mMatrix[5]; m[ 6]= mMatrix[ 9]; m[ 7]=mMatrix[13];
203
-	m[ 8]= mMatrix[2]; m[ 9]= mMatrix[6]; m[10]= mMatrix[10]; m[11]=mMatrix[14];
204
-	m[12]= mMatrix[3]; m[13]= mMatrix[7]; m[14]= mMatrix[11]; m[15]=mMatrix[15];
201
+    m[ 0]= mMatrix[0]; m[ 1]= mMatrix[4]; m[ 2]= mMatrix[ 8]; m[ 3]=mMatrix[12];
202
+    m[ 4]= mMatrix[1]; m[ 5]= mMatrix[5]; m[ 6]= mMatrix[ 9]; m[ 7]=mMatrix[13];
203
+    m[ 8]= mMatrix[2]; m[ 9]= mMatrix[6]; m[10]= mMatrix[10]; m[11]=mMatrix[14];
204
+    m[12]= mMatrix[3]; m[13]= mMatrix[7]; m[14]= mMatrix[11]; m[15]=mMatrix[15];
205 205
 }
206 206
 
207 207
 
208 208
 Matrix Matrix::multiply(const Matrix &a, const Matrix &b)
209 209
 {
210
-	Matrix c;
210
+    Matrix c;
211 211
 
212 212
 
213
-	multiply(a.mMatrix, b.mMatrix, c.mMatrix);
213
+    multiply(a.mMatrix, b.mMatrix, c.mMatrix);
214 214
 
215
-	return c;
215
+    return c;
216 216
 }
217 217
 
218 218
 
219 219
 Matrix Matrix::operator *(const Matrix &a)
220 220
 {
221
-	return multiply(a, *this);
221
+    return multiply(a, *this);
222 222
 }
223 223
 
224 224
 
225 225
 Vector3d Matrix::operator *(Vector3d v)
226 226
 {
227
-	vec_t x = v.mVec[0], y = v.mVec[1], z = v.mVec[2];
227
+    vec_t x = v.mVec[0], y = v.mVec[1], z = v.mVec[2];
228 228
 
229 229
 
230 230
 #ifdef COLUMN_ORDER
231
-	// Column order
232
-	return Vector3d(mMatrix[0]*x + mMatrix[4]*y + mMatrix[ 8]*z + mMatrix[12],
233
-						 mMatrix[1]*x + mMatrix[5]*y + mMatrix[ 9]*z + mMatrix[13],
234
-						 mMatrix[2]*x + mMatrix[6]*y + mMatrix[10]*z + mMatrix[14]);
231
+    // Column order
232
+    return Vector3d(mMatrix[0]*x + mMatrix[4]*y + mMatrix[ 8]*z + mMatrix[12],
233
+            mMatrix[1]*x + mMatrix[5]*y + mMatrix[ 9]*z + mMatrix[13],
234
+            mMatrix[2]*x + mMatrix[6]*y + mMatrix[10]*z + mMatrix[14]);
235 235
 #else
236
-	// Row order
237
-	return Vector3d(mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3],
238
-						 mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7],
239
-						 mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11]);
236
+    // Row order
237
+    return Vector3d(mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3],
238
+            mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7],
239
+            mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11]);
240 240
 #endif
241 241
 }
242 242
 
243 243
 
244 244
 void Matrix::multiply3v(vec3_t v, vec3_t result)
245 245
 {
246
-	vec_t x = v[0], y = v[1], z = v[2];
246
+    vec_t x = v[0], y = v[1], z = v[2];
247 247
 
248 248
 
249
-   result[0] = mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3];
250
-	result[1] = mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7];
251
-	result[2] = mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11];
249
+    result[0] = mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3];
250
+    result[1] = mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7];
251
+    result[2] = mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11];
252 252
 }
253 253
 
254 254
 
255 255
 void Matrix::multiply4d(double *v, double *result)
256 256
 {
257
-	double x = v[0], y = v[1], z = v[2], w = v[3];
257
+    double x = v[0], y = v[1], z = v[2], w = v[3];
258 258
 
259 259
 
260
-   result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
261
-	result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
262
-	result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
263
-	result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
260
+    result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
261
+    result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
262
+    result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
263
+    result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
264 264
 }
265 265
 
266 266
 
267 267
 void Matrix::multiply4v(vec4_t v, vec4_t result)
268 268
 {
269
-	vec_t x = v[0], y = v[1], z = v[2], w = v[3];
269
+    vec_t x = v[0], y = v[1], z = v[2], w = v[3];
270 270
 
271 271
 
272
-   result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
273
-	result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
274
-	result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
275
-	result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
272
+    result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
273
+    result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
274
+    result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
275
+    result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
276 276
 }
277 277
 
278 278
 
279 279
 void Matrix::print()
280 280
 {
281 281
 #ifdef COLUMN_ORDER
282
-	printf("{\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n}\n",
283
-			 mMatrix[0], mMatrix[4], mMatrix[ 8], mMatrix[12],
284
-			 mMatrix[1], mMatrix[5], mMatrix[ 9], mMatrix[13],
285
-			 mMatrix[2], mMatrix[6], mMatrix[10], mMatrix[14],
286
-			 mMatrix[3], mMatrix[7], mMatrix[11], mMatrix[15]);
282
+    printf("{\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n}\n",
283
+            mMatrix[0], mMatrix[4], mMatrix[ 8], mMatrix[12],
284
+            mMatrix[1], mMatrix[5], mMatrix[ 9], mMatrix[13],
285
+            mMatrix[2], mMatrix[6], mMatrix[10], mMatrix[14],
286
+            mMatrix[3], mMatrix[7], mMatrix[11], mMatrix[15]);
287 287
 #else
288
-	printf("{\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n}\n",
289
-			 mMatrix[ 0], mMatrix[ 1], mMatrix[ 2], mMatrix[ 3],
290
-			 mMatrix[ 4], mMatrix[ 5], mMatrix[ 6], mMatrix[ 7],
291
-			 mMatrix[ 8], mMatrix[ 9], mMatrix[10], mMatrix[11],
292
-			 mMatrix[12], mMatrix[13], mMatrix[14], mMatrix[15]);
288
+    printf("{\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n}\n",
289
+            mMatrix[ 0], mMatrix[ 1], mMatrix[ 2], mMatrix[ 3],
290
+            mMatrix[ 4], mMatrix[ 5], mMatrix[ 6], mMatrix[ 7],
291
+            mMatrix[ 8], mMatrix[ 9], mMatrix[10], mMatrix[11],
292
+            mMatrix[12], mMatrix[13], mMatrix[14], mMatrix[15]);
293 293
 #endif
294 294
 }
295 295
 
296 296
 
297 297
 bool Matrix::isIdentity()
298 298
 {
299
-	// Hhhmm... floating point using direct comparisions
300
-	if (mMatrix[ 0] == 1 && mMatrix[ 1] == 0 && mMatrix[ 2] == 0 &&
301
-		 mMatrix[ 3] == 0 &&	mMatrix[ 4] == 0 && mMatrix[ 5] == 1 &&
302
-		 mMatrix[ 6] == 0 && mMatrix[ 7] == 0 && mMatrix[ 8] == 0 &&
303
-		 mMatrix[ 9] == 0 && mMatrix[10] == 1 && mMatrix[11] == 0 &&
304
-		 mMatrix[12] == 0 && mMatrix[13] == 0 && mMatrix[14] == 0 &&
305
-		 mMatrix[15] == 1)
306
-		return true;
307
-
308
-	return false;
299
+    // Hhhmm... floating point using direct comparisions
300
+    if (mMatrix[ 0] == 1 && mMatrix[ 1] == 0 && mMatrix[ 2] == 0 &&
301
+            mMatrix[ 3] == 0 &&    mMatrix[ 4] == 0 && mMatrix[ 5] == 1 &&
302
+            mMatrix[ 6] == 0 && mMatrix[ 7] == 0 && mMatrix[ 8] == 0 &&
303
+            mMatrix[ 9] == 0 && mMatrix[10] == 1 && mMatrix[11] == 0 &&
304
+            mMatrix[12] == 0 && mMatrix[13] == 0 && mMatrix[14] == 0 &&
305
+            mMatrix[15] == 1)
306
+        return true;
307
+
308
+    return false;
309 309
 }
310 310
 
311 311
 
@@ -315,91 +315,91 @@ bool Matrix::isIdentity()
315 315
 
316 316
 void Matrix::setMatrix(matrix_t mat)
317 317
 {
318
-	copy(mat, mMatrix);
318
+    copy(mat, mMatrix);
319 319
 }
320 320
 
321 321
 
322 322
 void Matrix::setIdentity()
323 323
 {
324
-	mMatrix[ 0] = 1; mMatrix[ 1] = 0; mMatrix[ 2] = 0; mMatrix[ 3] = 0;
325
-	mMatrix[ 4] = 0; mMatrix[ 5] = 1; mMatrix[ 6] = 0; mMatrix[ 7] = 0;
326
-	mMatrix[ 8] = 0; mMatrix[ 9] = 0; mMatrix[10] = 1; mMatrix[11] = 0;
327
-	mMatrix[12] = 0; mMatrix[13] = 0; mMatrix[14] = 0; mMatrix[15] = 1;
324
+    mMatrix[ 0] = 1; mMatrix[ 1] = 0; mMatrix[ 2] = 0; mMatrix[ 3] = 0;
325
+    mMatrix[ 4] = 0; mMatrix[ 5] = 1; mMatrix[ 6] = 0; mMatrix[ 7] = 0;
326
+    mMatrix[ 8] = 0; mMatrix[ 9] = 0; mMatrix[10] = 1; mMatrix[11] = 0;
327
+    mMatrix[12] = 0; mMatrix[13] = 0; mMatrix[14] = 0; mMatrix[15] = 1;
328 328
 }
329 329
 
330 330
 
331 331
 void Matrix::scale(const vec_t *xyz)
332 332
 {
333
-	scale(xyz[0], xyz[1], xyz[2]);
333
+    scale(xyz[0], xyz[1], xyz[2]);
334 334
 }
335 335
 
336 336
 
337 337
 void Matrix::scale(vec_t sx, vec_t sy, vec_t sz)
338 338
 {
339
-   matrix_t smatrix;
340
-	matrix_t tmp;
339
+    matrix_t smatrix;
340
+    matrix_t tmp;
341 341
 
342 342
 
343
-   smatrix[ 0] = sx;smatrix[ 1] = 0; smatrix[ 2] = 0; smatrix[ 3] = 0;
344
-   smatrix[ 4] = 0; smatrix[ 5] = sy;smatrix[ 6] = 0; smatrix[ 7] = 0;
345
-   smatrix[ 8] = 0; smatrix[ 9] = 0; smatrix[10] = sz;smatrix[11] = 0;
346
-   smatrix[12] = 0; smatrix[13] = 0; smatrix[14] = 0; smatrix[15] = 1;
343
+    smatrix[ 0] = sx;smatrix[ 1] = 0; smatrix[ 2] = 0; smatrix[ 3] = 0;
344
+    smatrix[ 4] = 0; smatrix[ 5] = sy;smatrix[ 6] = 0; smatrix[ 7] = 0;
345
+    smatrix[ 8] = 0; smatrix[ 9] = 0; smatrix[10] = sz;smatrix[11] = 0;
346
+    smatrix[12] = 0; smatrix[13] = 0; smatrix[14] = 0; smatrix[15] = 1;
347 347
 
348
-	copy(mMatrix, tmp);
349
-	multiply(tmp, smatrix, mMatrix);
348
+    copy(mMatrix, tmp);
349
+    multiply(tmp, smatrix, mMatrix);
350 350
 }
351 351
 
352 352
 
353 353
 void Matrix::rotate(const vec_t *xyz)
354 354
 {
355
-	rotate(xyz[0], xyz[1], xyz[2]);
355
+    rotate(xyz[0], xyz[1], xyz[2]);
356 356
 }
357 357
 
358 358
 
359 359
 void Matrix::rotate(vec_t ax, vec_t ay, vec_t az)
360 360
 {
361
-   matrix_t xmat, ymat, zmat, tmp, tmp2;
361
+    matrix_t xmat, ymat, zmat, tmp, tmp2;
362 362
 
363 363
 
364
-   xmat[ 0]=1;        xmat[ 1]=0;        xmat[ 2]=0;        xmat[ 3]=0;
365
-   xmat[ 4]=0;        xmat[ 5]=cos(ax);  xmat[ 6]=sin(ax);  xmat[ 7]=0;
366
-   xmat[ 8]=0;        xmat[ 9]=-sin(ax); xmat[10]=cos(ax);  xmat[11]=0;
367
-   xmat[12]=0;        xmat[13]=0;        xmat[14]=0;        xmat[15]=1;
364
+    xmat[ 0]=1;        xmat[ 1]=0;        xmat[ 2]=0;        xmat[ 3]=0;
365
+    xmat[ 4]=0;        xmat[ 5]=cos(ax);  xmat[ 6]=sin(ax);  xmat[ 7]=0;
366
+    xmat[ 8]=0;        xmat[ 9]=-sin(ax); xmat[10]=cos(ax);  xmat[11]=0;
367
+    xmat[12]=0;        xmat[13]=0;        xmat[14]=0;        xmat[15]=1;
368 368
 
369
-   ymat[ 0]=cos(ay);  ymat[ 1]=0;        ymat[ 2]=-sin(ay); ymat[ 3]=0;
370
-   ymat[ 4]=0;        ymat[ 5]=1;        ymat[ 6]=0;        ymat[ 7]=0;
371
-   ymat[ 8]=sin(ay);  ymat[ 9]=0;        ymat[10]=cos(ay);  ymat[11]=0;
372
-   ymat[12]=0;        ymat[13]=0;        ymat[14]=0;        ymat[15]=1;
369
+    ymat[ 0]=cos(ay);  ymat[ 1]=0;        ymat[ 2]=-sin(ay); ymat[ 3]=0;
370
+    ymat[ 4]=0;        ymat[ 5]=1;        ymat[ 6]=0;        ymat[ 7]=0;
371
+    ymat[ 8]=sin(ay);  ymat[ 9]=0;        ymat[10]=cos(ay);  ymat[11]=0;
372
+    ymat[12]=0;        ymat[13]=0;        ymat[14]=0;        ymat[15]=1;
373 373
 
374
-   zmat[ 0]=cos(az);  zmat[ 1]=sin(az);  zmat[ 2]=0;        zmat[ 3]=0;
375
-   zmat[ 4]=-sin(az); zmat[ 5]=cos(az);  zmat[ 6]=0;        zmat[ 7]=0;
376
-   zmat[ 8]=0;        zmat[ 9]=0;        zmat[10]=1;        zmat[11]=0;
377
-   zmat[12]=0;        zmat[13]=0;        zmat[14]=0;        zmat[15]=1;
374
+    zmat[ 0]=cos(az);  zmat[ 1]=sin(az);  zmat[ 2]=0;        zmat[ 3]=0;
375
+    zmat[ 4]=-sin(az); zmat[ 5]=cos(az);  zmat[ 6]=0;        zmat[ 7]=0;
376
+    zmat[ 8]=0;        zmat[ 9]=0;        zmat[10]=1;        zmat[11]=0;
377
+    zmat[12]=0;        zmat[13]=0;        zmat[14]=0;        zmat[15]=1;
378 378
 
379
-   multiply(mMatrix, ymat, tmp);
380
-   multiply(tmp, xmat, tmp2);
381
-   multiply(tmp2, zmat, mMatrix);
379
+    multiply(mMatrix, ymat, tmp);
380
+    multiply(tmp, xmat, tmp2);
381
+    multiply(tmp2, zmat, mMatrix);
382 382
 }
383 383
 
384 384
 
385 385
 void Matrix::translate(const vec_t *xyz)
386 386
 {
387
-	translate(xyz[0], xyz[1], xyz[2]);
387
+    translate(xyz[0], xyz[1], xyz[2]);
388 388
 }
389 389
 
390 390
 
391 391
 void Matrix::translate(vec_t tx, vec_t ty, vec_t tz)
392 392
 {
393
-   matrix_t tmat, tmp;
393
+    matrix_t tmat, tmp;
394 394
 
395 395
 
396
-   tmat[ 0]=1;  tmat[ 1]=0;  tmat[ 2]=0;  tmat[ 3]=0;
397
-   tmat[ 4]=0;  tmat[ 5]=1;  tmat[ 6]=0;  tmat[ 7]=0;
398
-   tmat[ 8]=0;  tmat[ 9]=0;  tmat[10]=1;  tmat[11]=0;
399
-   tmat[12]=tx; tmat[13]=ty; tmat[14]=tz; tmat[15]=1;
396
+    tmat[ 0]=1;  tmat[ 1]=0;  tmat[ 2]=0;  tmat[ 3]=0;
397
+    tmat[ 4]=0;  tmat[ 5]=1;  tmat[ 6]=0;  tmat[ 7]=0;
398
+    tmat[ 8]=0;  tmat[ 9]=0;  tmat[10]=1;  tmat[11]=0;
399
+    tmat[12]=tx; tmat[13]=ty; tmat[14]=tz; tmat[15]=1;
400 400
 
401
-	copy(mMatrix, tmp);
402
-	multiply(tmp, tmat, mMatrix);
401
+    copy(mMatrix, tmp);
402
+    multiply(tmp, tmat, mMatrix);
403 403
 }
404 404
 
405 405
 
@@ -415,131 +415,131 @@ void Matrix::translate(vec_t tx, vec_t ty, vec_t tz)
415 415
 void Matrix::copy(matrix_t source, matrix_t dest)
416 416
 {
417 417
 #ifdef FASTER_MATRIX
418
-	memcpy(dest, source, sizeof(matrix_t));
418
+    memcpy(dest, source, sizeof(matrix_t));
419 419
 #else
420
-	dest[ 0] = source[ 0];
421
-	dest[ 1] = source[ 1];
422
-	dest[ 2] = source[ 2];
423
-	dest[ 3] = source[ 3];
424
-
425
-	dest[ 4] = source[ 4];
426
-	dest[ 5] = source[ 5];
427
-	dest[ 6] = source[ 6];
428
-	dest[ 7] = source[ 7];
429
-
430
-	dest[ 8] = source[8];
431
-	dest[ 9] = source[9];
432
-	dest[10] = source[10];
433
-	dest[11] = source[11];
434
-
435
-	dest[12] = source[12];
436
-	dest[13] = source[13];
437
-	dest[14] = source[14];
438
-	dest[15] = source[15];
420
+    dest[ 0] = source[ 0];
421
+    dest[ 1] = source[ 1];
422
+    dest[ 2] = source[ 2];
423
+    dest[ 3] = source[ 3];
424
+
425
+    dest[ 4] = source[ 4];
426
+    dest[ 5] = source[ 5];
427
+    dest[ 6] = source[ 6];
428
+    dest[ 7] = source[ 7];
429
+
430
+    dest[ 8] = source[8];
431
+    dest[ 9] = source[9];
432
+    dest[10] = source[10];
433
+    dest[11] = source[11];
434
+
435
+    dest[12] = source[12];
436
+    dest[13] = source[13];
437
+    dest[14] = source[14];
438
+    dest[15] = source[15];
439 439
 #endif
440 440
 }
441 441
 
442 442
 
443 443
 void Matrix::multiply(const matrix_t a, const matrix_t b, matrix_t result)
444 444
 {
445
-	/* Generated code for matrix mult
445
+    /* Generated code for matrix mult
446 446
      * Code used:
447 447
 
448 448
     // char order is argument
449
-	int i, j, k;
450
-	if (order == 'r')
451
-	{
452
-		printf("// Row order\n");
453
-	}
454
-	else
455
-	{
456
-		printf("// Column order\n");
457
-	}
458
-	for (i = 0; i < 4; ++i)
459
-	{
460
-		for (j = 0; j < 4; ++j)
461
-		{
462
-			if (order == 'r')
463
-			{
464
-				printf("result[%2i] = ", j+i*4);
465
-			}
466
-			else
467
-			{
468
-				printf("result[%2i] = ", j+i*4);
469
-			}
470
-			for (k = 0; k < 4; ++k)
471
-			{
472
-				if (order == 'r')
473
-				{
474
-					printf("a[%2i] * b[%2i]%s",
475
-							  k+i*4, j+k*4, (k == 3) ? ";\n" : " + ");
476
-				}
477
-				else
478
-				{
479
-					printf("a[%2i] * b[%2i]%s",
480
-							 i+k*4, k+j*4, (k == 3) ? ";\n" : " + ");
481
-				}
482
-				//sum+=(elements[i+k*4]*m.elements[k+j*4]);
483
-			}
484
-			//result.elements[i+j*4]=sum;
485
-		}
486
-		printf("\n");
487
-	}
488
-	printf("\n");
489
-	printf("// Transpose\n");
490
-	for(i = 0; i < 4; ++i)
491
-	{
492
-		for (j = 0; j < 4; ++j)
493
-		{
494
-			printf("a[%2i] = b[%2i]%s",
495
-					 j+i*4, i+j*4, (j == 3) ? ";\n" : "; ");
496
-		}
497
-	}
449
+    int i, j, k;
450
+    if (order == 'r')
451
+    {
452
+        printf("// Row order\n");
453
+    }
454
+    else
455
+    {
456
+        printf("// Column order\n");
457
+    }
458
+    for (i = 0; i < 4; ++i)
459
+    {
460
+        for (j = 0; j < 4; ++j)
461
+        {
462
+            if (order == 'r')
463
+            {
464
+                printf("result[%2i] = ", j+i*4);
465
+            }
466
+            else
467
+            {
468
+                printf("result[%2i] = ", j+i*4);
469
+            }
470
+            for (k = 0; k < 4; ++k)
471
+            {
472
+                if (order == 'r')
473
+                {
474
+                    printf("a[%2i] * b[%2i]%s",
475
+                    k+i*4, j+k*4, (k == 3) ? ";\n" : " + ");
476
+                }
477
+                else
478
+                {
479
+                    printf("a[%2i] * b[%2i]%s",
480
+                    i+k*4, k+j*4, (k == 3) ? ";\n" : " + ");
481
+                }
482
+                //sum+=(elements[i+k*4]*m.elements[k+j*4]);
483
+            }
484
+            //result.elements[i+j*4]=sum;
485
+        }
486
+        printf("\n");
487
+    }
488
+    printf("\n");
489
+    printf("// Transpose\n");
490
+    for(i = 0; i < 4; ++i)
491
+    {
492
+        for (j = 0; j < 4; ++j)
493
+        {
494
+            printf("a[%2i] = b[%2i]%s",
495
+            j+i*4, i+j*4, (j == 3) ? ";\n" : "; ");
496
+        }
497
+    }
498 498
 
499 499
      * was in test/Matrix.cpp
500 500
      */
501 501
 #ifdef COLUMN_ORDER
502
-	/* Column order */
503
-	result[ 0] = a[ 0] * b[ 0] + a[ 4] * b[ 1] + a[ 8] * b[ 2] + a[12] * b[ 3];
504
-	result[ 1] = a[ 0] * b[ 4] + a[ 4] * b[ 5] + a[ 8] * b[ 6] + a[12] * b[ 7];
505
-	result[ 2] = a[ 0] * b[ 8] + a[ 4] * b[ 9] + a[ 8] * b[10] + a[12] * b[11];
506
-	result[ 3] = a[ 0] * b[12] + a[ 4] * b[13] + a[ 8] * b[14] + a[12] * b[15];
507
-
508
-	result[ 4] = a[ 1] * b[ 0] + a[ 5] * b[ 1] + a[ 9] * b[ 2] + a[13] * b[ 3];
509
-	result[ 5] = a[ 1] * b[ 4] + a[ 5] * b[ 5] + a[ 9] * b[ 6] + a[13] * b[ 7];
510
-	result[ 6] = a[ 1] * b[ 8] + a[ 5] * b[ 9] + a[ 9] * b[10] + a[13] * b[11];
511
-	result[ 7] = a[ 1] * b[12] + a[ 5] * b[13] + a[ 9] * b[14] + a[13] * b[15];
512
-
513
-	result[ 8] = a[ 2] * b[ 0] + a[ 6] * b[ 1] + a[10] * b[ 2] + a[14] * b[ 3];
514
-	result[ 9] = a[ 2] * b[ 4] + a[ 6] * b[ 5] + a[10] * b[ 6] + a[14] * b[ 7];
515
-	result[10] = a[ 2] * b[ 8] + a[ 6] * b[ 9] + a[10] * b[10] + a[14] * b[11];
516
-	result[11] = a[ 2] * b[12] + a[ 6] * b[13] + a[10] * b[14] + a[14] * b[15];
517
-
518
-	result[12] = a[ 3] * b[ 0] + a[ 7] * b[ 1] + a[11] * b[ 2] + a[15] * b[ 3];
519
-	result[13] = a[ 3] * b[ 4] + a[ 7] * b[ 5] + a[11] * b[ 6] + a[15] * b[ 7];
520
-	result[14] = a[ 3] * b[ 8] + a[ 7] * b[ 9] + a[11] * b[10] + a[15] * b[11];
521
-	result[15] = a[ 3] * b[12] + a[ 7] * b[13] + a[11] * b[14] + a[15] * b[15];
502
+    /* Column order */
503
+    result[ 0] = a[ 0] * b[ 0] + a[ 4] * b[ 1] + a[ 8] * b[ 2] + a[12] * b[ 3];
504
+    result[ 1] = a[ 0] * b[ 4] + a[ 4] * b[ 5] + a[ 8] * b[ 6] + a[12] * b[ 7];
505
+    result[ 2] = a[ 0] * b[ 8] + a[ 4] * b[ 9] + a[ 8] * b[10] + a[12] * b[11];
506
+    result[ 3] = a[ 0] * b[12] + a[ 4] * b[13] + a[ 8] * b[14] + a[12] * b[15];
507
+
508
+    result[ 4] = a[ 1] * b[ 0] + a[ 5] * b[ 1] + a[ 9] * b[ 2] + a[13] * b[ 3];
509
+    result[ 5] = a[ 1] * b[ 4] + a[ 5] * b[ 5] + a[ 9] * b[ 6] + a[13] * b[ 7];
510
+    result[ 6] = a[ 1] * b[ 8] + a[ 5] * b[ 9] + a[ 9] * b[10] + a[13] * b[11];
511
+    result[ 7] = a[ 1] * b[12] + a[ 5] * b[13] + a[ 9] * b[14] + a[13] * b[15];
512
+
513
+    result[ 8] = a[ 2] * b[ 0] + a[ 6] * b[ 1] + a[10] * b[ 2] + a[14] * b[ 3];
514
+    result[ 9] = a[ 2] * b[ 4] + a[ 6] * b[ 5] + a[10] * b[ 6] + a[14] * b[ 7];
515
+    result[10] = a[ 2] * b[ 8] + a[ 6] * b[ 9] + a[10] * b[10] + a[14] * b[11];
516
+    result[11] = a[ 2] * b[12] + a[ 6] * b[13] + a[10] * b[14] + a[14] * b[15];
517
+
518
+    result[12] = a[ 3] * b[ 0] + a[ 7] * b[ 1] + a[11] * b[ 2] + a[15] * b[ 3];
519
+    result[13] = a[ 3] * b[ 4] + a[ 7] * b[ 5] + a[11] * b[ 6] + a[15] * b[ 7];
520
+    result[14] = a[ 3] * b[ 8] + a[ 7] * b[ 9] + a[11] * b[10] + a[15] * b[11];
521
+    result[15] = a[ 3] * b[12] + a[ 7] * b[13] + a[11] * b[14] + a[15] * b[15];
522 522
 #else
523
-	/* Row order */
524
-	result[ 0] = a[ 0] * b[ 0] + a[ 1] * b[ 4] + a[ 2] * b[ 8] + a[ 3] * b[12];
525
-	result[ 1] = a[ 0] * b[ 1] + a[ 1] * b[ 5] + a[ 2] * b[ 9] + a[ 3] * b[13];
526
-	result[ 2] = a[ 0] * b[ 2] + a[ 1] * b[ 6] + a[ 2] * b[10] + a[ 3] * b[14];
527
-	result[ 3] = a[ 0] * b[ 3] + a[ 1] * b[ 7] + a[ 2] * b[11] + a[ 3] * b[15];
528
-
529
-	result[ 4] = a[ 4] * b[ 0] + a[ 5] * b[ 4] + a[ 6] * b[ 8] + a[ 7] * b[12];
530
-	result[ 5] = a[ 4] * b[ 1] + a[ 5] * b[ 5] + a[ 6] * b[ 9] + a[ 7] * b[13];
531
-	result[ 6] = a[ 4] * b[ 2] + a[ 5] * b[ 6] + a[ 6] * b[10] + a[ 7] * b[14];
532
-	result[ 7] = a[ 4] * b[ 3] + a[ 5] * b[ 7] + a[ 6] * b[11] + a[ 7] * b[15];
533
-
534
-	result[ 8] = a[ 8] * b[ 0] + a[ 9] * b[ 4] + a[10] * b[ 8] + a[11] * b[12];
535
-	result[ 9] = a[ 8] * b[ 1] + a[ 9] * b[ 5] + a[10] * b[ 9] + a[11] * b[13];
536
-	result[10] = a[ 8] * b[ 2] + a[ 9] * b[ 6] + a[10] * b[10] + a[11] * b[14];
537
-	result[11] = a[ 8] * b[ 3] + a[ 9] * b[ 7] + a[10] * b[11] + a[11] * b[15];
538
-
539
-	result[12] = a[12] * b[ 0] + a[13] * b[ 4] + a[14] * b[ 8] + a[15] * b[12];
540
-	result[13] = a[12] * b[ 1] + a[13] * b[ 5] + a[14] * b[ 9] + a[15] * b[13];
541
-	result[14] = a[12] * b[ 2] + a[13] * b[ 6] + a[14] * b[10] + a[15] * b[14];
542
-	result[15] = a[12] * b[ 3] + a[13] * b[ 7] + a[14] * b[11] + a[15] * b[15];
523
+    /* Row order */
524
+    result[ 0] = a[ 0] * b[ 0] + a[ 1] * b[ 4] + a[ 2] * b[ 8] + a[ 3] * b[12];
525
+    result[ 1] = a[ 0] * b[ 1] + a[ 1] * b[ 5] + a[ 2] * b[ 9] + a[ 3] * b[13];
526
+    result[ 2] = a[ 0] * b[ 2] + a[ 1] * b[ 6] + a[ 2] * b[10] + a[ 3] * b[14];
527
+    result[ 3] = a[ 0] * b[ 3] + a[ 1] * b[ 7] + a[ 2] * b[11] + a[ 3] * b[15];
528
+
529
+    result[ 4] = a[ 4] * b[ 0] + a[ 5] * b[ 4] + a[ 6] * b[ 8] + a[ 7] * b[12];
530
+    result[ 5] = a[ 4] * b[ 1] + a[ 5] * b[ 5] + a[ 6] * b[ 9] + a[ 7] * b[13];
531
+    result[ 6] = a[ 4] * b[ 2] + a[ 5] * b[ 6] + a[ 6] * b[10] + a[ 7] * b[14];
532
+    result[ 7] = a[ 4] * b[ 3] + a[ 5] * b[ 7] + a[ 6] * b[11] + a[ 7] * b[15];
533
+
534
+    result[ 8] = a[ 8] * b[ 0] + a[ 9] * b[ 4] + a[10] * b[ 8] + a[11] * b[12];
535
+    result[ 9] = a[ 8] * b[ 1] + a[ 9] * b[ 5] + a[10] * b[ 9] + a[11] * b[13];
536
+    result[10] = a[ 8] * b[ 2] + a[ 9] * b[ 6] + a[10] * b[10] + a[11] * b[14];
537
+    result[11] = a[ 8] * b[ 3] + a[ 9] * b[ 7] + a[10] * b[11] + a[11] * b[15];
538
+
539
+    result[12] = a[12] * b[ 0] + a[13] * b[ 4] + a[14] * b[ 8] + a[15] * b[12];
540
+    result[13] = a[12] * b[ 1] + a[13] * b[ 5] + a[14] * b[ 9] + a[15] * b[13];
541
+    result[14] = a[12] * b[ 2] + a[13] * b[ 6] + a[14] * b[10] + a[15] * b[14];
542
+    result[15] = a[12] * b[ 3] + a[13] * b[ 7] + a[14] * b[11] + a[15] * b[15];
543 543
 #endif
544 544
 }
545 545
 

+ 480
- 480
src/Network.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 470
- 470
src/OpenGLMesh.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 3120
- 3120
src/OpenRaider.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 71
- 71
src/Particle.cpp Переглянути файл

@@ -17,13 +17,13 @@
17 17
 
18 18
 Particle::Particle()
19 19
 {
20
-	setActive(true);
21
-	TextureId(0);
22
-	Speed(2000.0, 2000.0, 2000.0);
23
-	Color(1.0, 1.0, 1.0);
24
-	Force(0.0, 0.8, 0.0);
20
+    setActive(true);
21
+    TextureId(0);
22
+    Speed(2000.0, 2000.0, 2000.0);
23
+    Color(1.0, 1.0, 1.0);
24
+    Force(0.0, 0.8, 0.0);
25 25
 
26
-	Reset();
26
+    Reset();
27 27
 }
28 28
 
29 29
 
@@ -34,130 +34,130 @@ Particle::~Particle()
34 34
 
35 35
 void Particle::TextureId(int id)
36 36
 {
37
-	_texture = id;
37
+    _texture = id;
38 38
 }
39 39
 
40 40
 
41 41
 void Particle::setActive(bool active)
42 42
 {
43
-	_active = active;
43
+    _active = active;
44 44
 }
45 45
 
46 46
 
47 47
 void Particle::Speed(float x, float y, float z)
48 48
 {
49
-	_speed[0] = x;
50
-	_speed[1] = y;
51
-	_speed[2] = z;
49
+    _speed[0] = x;
50
+    _speed[1] = y;
51
+    _speed[2] = z;
52 52
 }
53 53
 
54 54
 
55 55
 void Particle::Color(float r, float g, float b)
56 56
 {
57
-	_color[0] = r;
58
-	_color[1] = g;
59
-	_color[2] = b;
57
+    _color[0] = r;
58
+    _color[1] = g;
59
+    _color[2] = b;
60 60
 }
61 61
 
62 62
 
63 63
 void Particle::Force(float x, float y, float z)
64 64
 {
65
-	_force[0] = x;
66
-	_force[1] = y;
67
-	_force[2] = z;
65
+    _force[0] = x;
66
+    _force[1] = y;
67
+    _force[2] = z;
68 68
 }
69 69
 
70 70
 
71 71
 void Particle::Reset()
72 72
 {
73
-	// Mongoose 2002.01.01, Ah, how old is that code?
73
+    // Mongoose 2002.01.01, Ah, how old is that code?
74 74
 #ifdef OBSOLOETE
75
-	_active = true;
76
-	_life = 1.0;
77
-	_blend = (float)(rand() % 100) / 1000.0 + 0.003;
75
+    _active = true;
76
+    _life = 1.0;
77
+    _blend = (float)(rand() % 100) / 1000.0 + 0.003;
78 78
 
79
-	_pos[0] = _pos[1] = _pos[2] = 0.0;
79
+    _pos[0] = _pos[1] = _pos[2] = 0.0;
80 80
 
81
-	_dir[0] = (float)((rand() % 50) - 26.0) * 10.0;
82
-	_dir[1] = (float)((rand() % 50) - 25.0) * 10.0;
83
-	_dir[2] = _dir[1];
81
+    _dir[0] = (float)((rand() % 50) - 26.0) * 10.0;
82
+    _dir[1] = (float)((rand() % 50) - 25.0) * 10.0;
83
+    _dir[2] = _dir[1];
84 84
 
85
-	_force[0] = 0.0;
86
-	_force[1] = -0.8;
87
-	_force[2] = 0.0;
85
+    _force[0] = 0.0;
86
+    _force[1] = -0.8;
87
+    _force[2] = 0.0;
88 88
 #else
89
-	//! \fixme _blend prob should have nonstatic range
90
-	_blend = (float)(0.003 + (0.1 * rand() / (RAND_MAX + 1.0))); // high order
91
-	//_blend = (float)(rand() % 100) / 1000.0 + 0.003;
92
-
93
-	//! \fixme Reset these using some nonstatic functions and values later
94
-	_life = 1.0;
95
-
96
-	_pos[0] = _pos[1] = _pos[2] = 0.0;
97
-
98
-	_dir[0] = (float)(-26.0 + (50.0 * rand() / (RAND_MAX + 1.0))); // high order
99
-	_dir[0] *= 10.0;
100
-	//_dir[0] = (float)((rand() % 50) - 26.0) * 10.0;
101
-	_dir[1] = (float)(-25.0 + (50.0 * rand() / (RAND_MAX + 1.0))); // high order
102
-	_dir[1] *= 10.0;
103
-	//_dir[1] = (float)((rand() % 50) - 25.0) * 10.0;
104
-	_dir[2] = _dir[1];
89
+    //! \fixme _blend prob should have nonstatic range
90
+    _blend = (float)(0.003 + (0.1 * rand() / (RAND_MAX + 1.0))); // high order
91
+    //_blend = (float)(rand() % 100) / 1000.0 + 0.003;
92
+
93
+    //! \fixme Reset these using some nonstatic functions and values later
94
+    _life = 1.0;
95
+
96
+    _pos[0] = _pos[1] = _pos[2] = 0.0;
97
+
98
+    _dir[0] = (float)(-26.0 + (50.0 * rand() / (RAND_MAX + 1.0))); // high order
99
+    _dir[0] *= 10.0;
100
+    //_dir[0] = (float)((rand() % 50) - 26.0) * 10.0;
101
+    _dir[1] = (float)(-25.0 + (50.0 * rand() / (RAND_MAX + 1.0))); // high order
102
+    _dir[1] *= 10.0;
103
+    //_dir[1] = (float)((rand() % 50) - 25.0) * 10.0;
104
+    _dir[2] = _dir[1];
105 105
 #endif
106 106
 }
107 107
 
108 108
 
109 109
 void Particle::Pos(float *x, float *y, float *z)
110 110
 {
111
-	*x = _pos[0];
112
-	*y = _pos[1];
113
-	*z = _pos[2];
111
+    *x = _pos[0];
112
+    *y = _pos[1];
113
+    *z = _pos[2];
114 114
 }
115 115
 
116 116
 
117 117
 void Particle::Color(float *r, float *g, float *b)
118 118
 {
119
-	*r = _color[0];
120
-	*g = _color[1];
121
-	*b = _color[2];
119
+    *r = _color[0];
120
+    *g = _color[1];
121
+    *b = _color[2];
122 122
 }
123 123
 
124 124
 
125 125
 float Particle::Life()
126 126
 {
127
-	return _life;
127
+    return _life;
128 128
 }
129 129
 
130 130
 
131 131
 void Particle::Update()
132 132
 {
133
-	// Adjust particle position
134
-	_pos[0] += _dir[0] / _speed[0];
135
-	_pos[1] += _dir[1] / _speed[1];
136
-	_pos[2] += _dir[2] / _speed[2];
137
-
138
-	// Adjust particle direction
139
-	_dir[0] += _force[0];
140
-	_dir[1] += _force[1];
141
-	_dir[2] += _force[2];
142
-
143
-	// Adjust particle blending/life
144
-	_life -= _blend;
145
-
146
-	// Reset 'dead' OR fully blended particles
147
-	if (_life < 0.0)
148
-	{
149
-		Reset();
150
-	}
133
+    // Adjust particle position
134
+    _pos[0] += _dir[0] / _speed[0];
135
+    _pos[1] += _dir[1] / _speed[1];
136
+    _pos[2] += _dir[2] / _speed[2];
137
+
138
+    // Adjust particle direction
139
+    _dir[0] += _force[0];
140
+    _dir[1] += _force[1];
141
+    _dir[2] += _force[2];
142
+
143
+    // Adjust particle blending/life
144
+    _life -= _blend;
145
+
146
+    // Reset 'dead' OR fully blended particles
147
+    if (_life < 0.0)
148
+    {
149
+        Reset();
150
+    }
151 151
 }
152 152
 
153 153
 
154 154
 int Particle::Texture()
155 155
 {
156
-	return _texture;
156
+    return _texture;
157 157
 }
158 158
 
159 159
 
160 160
 bool Particle::isActive()
161 161
 {
162
-	return _active;
162
+    return _active;
163 163
 }

+ 218
- 218
src/Quaternion.cpp Переглянути файл

@@ -30,28 +30,28 @@
30 30
 
31 31
 Quaternion::Quaternion()
32 32
 {
33
-	mW = 0;
34
-	mX = 0;
35
-	mY = 0;
36
-	mZ = 0;
33
+    mW = 0;
34
+    mX = 0;
35
+    mY = 0;
36
+    mZ = 0;
37 37
 }
38 38
 
39 39
 
40 40
 Quaternion::Quaternion(vec_t w, vec_t x, vec_t y, vec_t z)
41 41
 {
42
-	mW = w;
43
-	mX = x;
44
-	mY = y;
45
-	mZ = z;
42
+    mW = w;
43
+    mX = x;
44
+    mY = y;
45
+    mZ = z;
46 46
 }
47 47
 
48 48
 
49 49
 Quaternion::Quaternion(vec4_t v)
50 50
 {
51
-	mW = v[0];
52
-	mX = v[1];
53
-	mY = v[2];
54
-	mZ = v[3];
51
+    mW = v[0];
52
+    mX = v[1];
53
+    mY = v[2];
54
+    mZ = v[3];
55 55
 }
56 56
 
57 57
 
@@ -66,96 +66,96 @@ Quaternion::~Quaternion()
66 66
 
67 67
 void Quaternion::getMatrix(matrix_t m)
68 68
 {
69
-	m[ 0] = 1.0f - 2.0f * (mY*mY + mZ*mZ);
70
-	m[ 1] = 2.0f * (mX*mY - mW*mZ);
71
-	m[ 2] = 2.0f * (mX*mZ + mW*mY);
72
-	m[ 3] = 0.0f;
73
-
74
-	m[ 4] = 2.0f * (mX*mY + mW*mZ);
75
-	m[ 5] = 1.0f - 2.0f * (mX*mX + mZ*mZ);
76
-	m[ 6] = 2.0f * (mY*mZ - mW*mX);
77
-	m[ 7] = 0.0f;
78
-
79
-	m[ 8] = 2.0f * (mX*mZ - mW*mY);
80
-	m[ 9] = 2.0f * (mY*mZ + mW*mX);
81
-	m[10] = 1.0 - 2.0f * (mX*mX + mY*mY);
82
-	m[11] = 0.0f;
83
-
84
-	m[12] = 0.0f;
85
-	m[13] = 0.0f;
86
-	m[14] = 0.0f;
87
-	m[15] = 1.0f;
69
+    m[ 0] = 1.0f - 2.0f * (mY*mY + mZ*mZ);
70
+    m[ 1] = 2.0f * (mX*mY - mW*mZ);
71
+    m[ 2] = 2.0f * (mX*mZ + mW*mY);
72
+    m[ 3] = 0.0f;
73
+
74
+    m[ 4] = 2.0f * (mX*mY + mW*mZ);
75
+    m[ 5] = 1.0f - 2.0f * (mX*mX + mZ*mZ);
76
+    m[ 6] = 2.0f * (mY*mZ - mW*mX);
77
+    m[ 7] = 0.0f;
78
+
79
+    m[ 8] = 2.0f * (mX*mZ - mW*mY);
80
+    m[ 9] = 2.0f * (mY*mZ + mW*mX);
81
+    m[10] = 1.0 - 2.0f * (mX*mX + mY*mY);
82
+    m[11] = 0.0f;
83
+
84
+    m[12] = 0.0f;
85
+    m[13] = 0.0f;
86
+    m[14] = 0.0f;
87
+    m[15] = 1.0f;
88 88
 }
89 89
 
90 90
 
91 91
 Quaternion Quaternion::operator =(const Quaternion &q)
92 92
 {
93
-	mW	= q.mW;
94
-	mX = q.mX;
95
-	mY = q.mY;
96
-	mZ = q.mZ;
93
+    mW  = q.mW;
94
+    mX = q.mX;
95
+    mY = q.mY;
96
+    mZ = q.mZ;
97 97
 
98
-  return (*this);
98
+    return (*this);
99 99
 }
100 100
 
101 101
 
102 102
 Quaternion Quaternion::operator *(const Quaternion &q)
103 103
 {
104
-	return multiply(*this, q);
104
+    return multiply(*this, q);
105 105
 }
106 106
 
107 107
 
108 108
 Quaternion Quaternion::operator /(const Quaternion &q)
109 109
 {
110
-	return divide(*this, q);
110
+    return divide(*this, q);
111 111
 }
112 112
 
113 113
 
114 114
 Quaternion Quaternion::operator +(const Quaternion &q)
115 115
 {
116
-	return add(*this, q);
116
+    return add(*this, q);
117 117
 }
118 118
 
119 119
 
120 120
 Quaternion Quaternion::operator -(const Quaternion &q)
121 121
 {
122
-	return subtract(*this, q);
122
+    return subtract(*this, q);
123 123
 }
124 124
 
125 125
 
126 126
 bool Quaternion::operator ==(const Quaternion &q)
127 127
 {
128
-	return (mX == q.mX && mY == q.mY && mZ == q.mZ && mW == q.mW);
128
+    return (mX == q.mX && mY == q.mY && mZ == q.mZ && mW == q.mW);
129 129
 }
130 130
 
131 131
 
132 132
 Quaternion Quaternion::conjugate()
133 133
 {
134
-	return Quaternion(mW, -mX, -mY, -mZ);
134
+    return Quaternion(mW, -mX, -mY, -mZ);
135 135
 }
136 136
 
137 137
 
138 138
 Quaternion Quaternion::scale(vec_t s)
139 139
 {
140
-   return Quaternion(mW * s, mX * s, mY * s, mZ * s);
140
+    return Quaternion(mW * s, mX * s, mY * s, mZ * s);
141 141
 }
142 142
 
143 143
 
144 144
 Quaternion Quaternion::inverse()
145 145
 {
146
-	return conjugate().scale(1/magnitude());
146
+    return conjugate().scale(1/magnitude());
147 147
 }
148 148
 
149 149
 
150 150
 vec_t Quaternion::dot(Quaternion a, Quaternion b)
151 151
 {
152
-	return ((a.mW * b.mW) + (a.mX * b.mX) + (a.mY * b.mY) + (a.mZ * b.mZ));
152
+    return ((a.mW * b.mW) + (a.mX * b.mX) + (a.mY * b.mY) + (a.mZ * b.mZ));
153 153
 }
154 154
 
155 155
 
156 156
 vec_t Quaternion::magnitude()
157 157
 {
158
-	return sqrt(dot(*this, *this));
158
+    return sqrt(dot(*this, *this));
159 159
 }
160 160
 
161 161
 
@@ -165,200 +165,200 @@ vec_t Quaternion::magnitude()
165 165
 
166 166
 void Quaternion::setIdentity()
167 167
 {
168
-	mW = 1.0;
169
-	mX = 0.0;
170
-	mY = 0.0;
171
-	mZ = 0.0;
168
+    mW = 1.0;
169
+    mX = 0.0;
170
+    mY = 0.0;
171
+    mZ = 0.0;
172 172
 }
173 173
 
174 174
 
175 175
 void Quaternion::set(vec_t angle, vec_t x, vec_t y, vec_t z)
176 176
 {
177
-	vec_t temp, dist;
177
+    vec_t temp, dist;
178 178
 
179 179
 
180
-	// Normalize
181
-	temp = x*x + y*y + z*z;
180
+    // Normalize
181
+    temp = x*x + y*y + z*z;
182 182
 
183
-	dist = (float)(1.0 / sqrt(temp));
183
+    dist = (float)(1.0 / sqrt(temp));
184 184
 
185
-	x *= dist;
186
-	y *= dist;
187
-	z *= dist;
185
+    x *= dist;
186
+    y *= dist;
187
+    z *= dist;
188 188
 
189
-	mX = x;
190
-	mY = y;
191
-	mZ = z;
189
+    mX = x;
190
+    mY = y;
191
+    mZ = z;
192 192
 
193
-	mW = (float)cos(angle / 2.0f);
193
+    mW = (float)cos(angle / 2.0f);
194 194
 }
195 195
 
196 196
 
197 197
 void Quaternion::normalize()
198 198
 {
199
-	vec_t dist, square;
199
+    vec_t dist, square;
200 200
 
201 201
 
202
-	square = mX * mX + mY * mY + mZ * mZ + mW * mW;
202
+    square = mX * mX + mY * mY + mZ * mZ + mW * mW;
203 203
 
204
-	if (square > 0.0)
205
-	{
206
-		dist = (float)(1.0 / sqrt(square));
207
-	}
208
-	else
209
-	{
210
-		dist = 1;
211
-	}
204
+    if (square > 0.0)
205
+    {
206
+        dist = (float)(1.0 / sqrt(square));
207
+    }
208
+    else
209
+    {
210
+        dist = 1;
211
+    }
212 212
 
213
-	mX *= dist;
214
-	mY *= dist;
215
-	mZ *= dist;
216
-	mW *= dist;
213
+    mX *= dist;
214
+    mY *= dist;
215
+    mZ *= dist;
216
+    mW *= dist;
217 217
 }
218 218
 
219 219
 
220 220
 void Quaternion::copy(Quaternion q)
221 221
 {
222
-	mW = q.mW;
223
-	mX = q.mX;
224
-	mY = q.mY;
225
-	mZ = q.mZ;
222
+    mW = q.mW;
223
+    mX = q.mX;
224
+    mY = q.mY;
225
+    mZ = q.mZ;
226 226
 }
227 227
 
228 228
 
229 229
 Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
230 230
 {
231
-	/*******************************************************************
232
-	 * Spherical Linear Interpolation algorthim
233
-	 *-----------------------------------------------------------------
234
-	 *
235
-	 * Interpolate between A and B rotations ( Find qI )
236
-	 *
237
-	 * qI = (((qB . qA)^ -1)^ Time) qA
238
-	 *
239
-	 * http://www.magic-software.com/Documentation/quat.pdf
240
-	 *
241
-	 * Thanks to digiben for algorithms and basis of the notes in
242
-	 * this func
243
-	 *
244
-	 *******************************************************************/
245
-
246
-	vec_t result, scaleA, scaleB, theta, sinTheta;
247
-	Quaternion i;
248
-
249
-
250
-	// Don't bother if it's the same rotation, it's the same as the result
251
-	if (a == b)
252
-	{
253
-		return a;
254
-	}
255
-
256
-	// A . B
257
-	result = dot(a, b);
258
-
259
-	// If the dot product is less than 0, the angle is greater than 90 degrees
260
-	if (result < 0.0f)
261
-	{
262
-		// Negate quaternion B and the result of the dot product
263
-		b = Quaternion(-b.mW, -b.mX, -b.mY, -b.mZ);
264
-		result = -result;
265
-	}
266
-
267
-	// Set the first and second scale for the interpolation
268
-	scaleA = 1 - time;
269
-	scaleB = time;
270
-
271
-	// Next, we want to actually calculate the spherical interpolation.  Since this
272
-	// calculation is quite computationally expensive, we want to only perform it
273
-	// if the angle between the 2 quaternions is large enough to warrant it.  If the
274
-	// angle is fairly small, we can actually just do a simpler linear interpolation
275
-	// of the 2 quaternions, and skip all the complex math.  We create a "delta" value
276
-	// of 0.1 to say that if the cosine of the angle (result of the dot product) between
277
-	// the 2 quaternions is smaller than 0.1, then we do NOT want to perform the full on
278
-	// interpolation using.  This is because you won't really notice the difference.
279
-
280
-	// Check if the angle between the 2 quaternions was big enough
281
-	// to warrant such calculations
282
-	if (1 - result > 0.1f)
283
-	{
284
-		// Get the angle between the 2 quaternions, and then
285
-		// store the sin() of that angle
286
-		theta = (float)acos(result);
287
-		sinTheta = (float)sin(theta);
288
-
289
-		// Calculate the scale for qA and qB, according to
290
-		// the angle and it's sine value
291
-		scaleA = (float)sin((1 - time) * theta) / sinTheta;
292
-		scaleB = (float)sin((time * theta)) / sinTheta;
293
-	}
294
-
295
-	// Calculate the x, y, z and w values for the quaternion by using a special
296
-	// form of linear interpolation for quaternions.
297
-	return (a.scale(scaleA) + b.scale(scaleB));
231
+    /*******************************************************************
232
+     * Spherical Linear Interpolation algorthim
233
+     *-----------------------------------------------------------------
234
+     *
235
+     * Interpolate between A and B rotations ( Find qI )
236
+     *
237
+     * qI = (((qB . qA)^ -1)^ Time) qA
238
+     *
239
+     * http://www.magic-software.com/Documentation/quat.pdf
240
+     *
241
+     * Thanks to digiben for algorithms and basis of the notes in
242
+     * this func
243
+     *
244
+     *******************************************************************/
245
+
246
+    vec_t result, scaleA, scaleB, theta, sinTheta;
247
+    Quaternion i;
248
+
249
+
250
+    // Don't bother if it's the same rotation, it's the same as the result
251
+    if (a == b)
252
+    {
253
+        return a;
254
+    }
255
+
256
+    // A . B
257
+    result = dot(a, b);
258
+
259
+    // If the dot product is less than 0, the angle is greater than 90 degrees
260
+    if (result < 0.0f)
261
+    {
262
+        // Negate quaternion B and the result of the dot product
263
+        b = Quaternion(-b.mW, -b.mX, -b.mY, -b.mZ);
264
+        result = -result;
265
+    }
266
+
267
+    // Set the first and second scale for the interpolation
268
+    scaleA = 1 - time;
269
+    scaleB = time;
270
+
271
+    // Next, we want to actually calculate the spherical interpolation.  Since this
272
+    // calculation is quite computationally expensive, we want to only perform it
273
+    // if the angle between the 2 quaternions is large enough to warrant it.  If the
274
+    // angle is fairly small, we can actually just do a simpler linear interpolation
275
+    // of the 2 quaternions, and skip all the complex math.  We create a "delta" value
276
+    // of 0.1 to say that if the cosine of the angle (result of the dot product) between
277
+    // the 2 quaternions is smaller than 0.1, then we do NOT want to perform the full on
278
+    // interpolation using.  This is because you won't really notice the difference.
279
+
280
+    // Check if the angle between the 2 quaternions was big enough
281
+    // to warrant such calculations
282
+    if (1 - result > 0.1f)
283
+    {
284
+        // Get the angle between the 2 quaternions, and then
285
+        // store the sin() of that angle
286
+        theta = (float)acos(result);
287
+        sinTheta = (float)sin(theta);
288
+
289
+        // Calculate the scale for qA and qB, according to
290
+        // the angle and it's sine value
291
+        scaleA = (float)sin((1 - time) * theta) / sinTheta;
292
+        scaleB = (float)sin((time * theta)) / sinTheta;
293
+    }
294
+
295
+    // Calculate the x, y, z and w values for the quaternion by using a special
296
+    // form of linear interpolation for quaternions.
297
+    return (a.scale(scaleA) + b.scale(scaleB));
298 298
 }
299 299
 
300 300
 
301 301
 void Quaternion::setByMatrix(matrix_t matrix)
302 302
 {
303
-	float diagonal = matrix[0] + matrix[5] + matrix[10] + 1.0f;
304
-	float scale = 0.0f;
305
-	float w = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f;
306
-
307
-
308
-	if (diagonal > 0.00000001)
309
-	{
310
-		// Calculate the scale of the diagonal
311
-		scale = (float)(sqrt(diagonal) * 2);
312
-
313
-		w = 0.25f * scale;
314
-		x = (matrix[9] - matrix[6]) / scale;
315
-		y = (matrix[2] - matrix[8]) / scale;
316
-		z = (matrix[4] - matrix[1]) / scale;
317
-	}
318
-	else
319
-	{
320
-		 // If the first element of the diagonal is the greatest value
321
-		if (matrix[0] > matrix[5] && matrix[0] > matrix[10])
322
-		{
323
-			 // Find the scale according to the first element, and double it
324
-			scale = (float)sqrt(1.0f + matrix[0] - matrix[5] - matrix[10])*2.0f;
325
-
326
-			// Calculate the quaternion
327
-			w = (matrix[9] - matrix[6]) / scale;
328
-			x = 0.25f * scale;
329
-			y = (matrix[4] + matrix[1]) / scale;
330
-			z = (matrix[2] + matrix[8]) / scale;
331
-		}
332
-		// The second element of the diagonal is the greatest value
333
-		else if (matrix[5] > matrix[10])
334
-		{
335
-			// Find the scale according to the second element, and double it
336
-			scale = (float)sqrt(1.0f + matrix[5] - matrix[0] - matrix[10])*2.0f;
337
-
338
-			// Calculate the quaternion
339
-			w = (matrix[2] - matrix[8]) / scale;
340
-			x = (matrix[4] + matrix[1]) / scale;
341
-			y = 0.25f * scale;
342
-			z = (matrix[9] + matrix[6]) / scale;
343
-		}
344
-		// The third element of the diagonal is the greatest value
345
-		else
346
-		{
347
-			// Find the scale according to the third element, and double it
348
-			scale = (float)sqrt(1.0f + matrix[10] - matrix[0] - matrix[5])*2.0f;
349
-
350
-			// Calculate the quaternion
351
-			w = (matrix[4] - matrix[1]) / scale;
352
-			x = (matrix[2] + matrix[8]) / scale;
353
-			y = (matrix[9] + matrix[6]) / scale;
354
-			z = 0.25f * scale;
355
-		}
356
-	}
357
-
358
-	mW = w;
359
-	mX = x;
360
-	mY = y;
361
-	mZ = z;
303
+    float diagonal = matrix[0] + matrix[5] + matrix[10] + 1.0f;
304
+    float scale = 0.0f;
305
+    float w = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f;
306
+
307
+
308
+    if (diagonal > 0.00000001)
309
+    {
310
+        // Calculate the scale of the diagonal
311
+        scale = (float)(sqrt(diagonal) * 2);
312
+
313
+        w = 0.25f * scale;
314
+        x = (matrix[9] - matrix[6]) / scale;
315
+        y = (matrix[2] - matrix[8]) / scale;
316
+        z = (matrix[4] - matrix[1]) / scale;
317
+    }
318
+    else
319
+    {
320
+        // If the first element of the diagonal is the greatest value
321
+        if (matrix[0] > matrix[5] && matrix[0] > matrix[10])
322
+        {
323
+            // Find the scale according to the first element, and double it
324
+            scale = (float)sqrt(1.0f + matrix[0] - matrix[5] - matrix[10])*2.0f;
325
+
326
+            // Calculate the quaternion
327
+            w = (matrix[9] - matrix[6]) / scale;
328
+            x = 0.25f * scale;
329
+            y = (matrix[4] + matrix[1]) / scale;
330
+            z = (matrix[2] + matrix[8]) / scale;
331
+        }
332
+        // The second element of the diagonal is the greatest value
333
+        else if (matrix[5] > matrix[10])
334
+        {
335
+            // Find the scale according to the second element, and double it
336
+            scale = (float)sqrt(1.0f + matrix[5] - matrix[0] - matrix[10])*2.0f;
337
+
338
+            // Calculate the quaternion
339
+            w = (matrix[2] - matrix[8]) / scale;
340
+            x = (matrix[4] + matrix[1]) / scale;
341
+            y = 0.25f * scale;
342
+            z = (matrix[9] + matrix[6]) / scale;
343
+        }
344
+        // The third element of the diagonal is the greatest value
345
+        else
346
+        {
347
+            // Find the scale according to the third element, and double it
348
+            scale = (float)sqrt(1.0f + matrix[10] - matrix[0] - matrix[5])*2.0f;
349
+
350
+            // Calculate the quaternion
351
+            w = (matrix[4] - matrix[1]) / scale;
352
+            x = (matrix[2] + matrix[8]) / scale;
353
+            y = (matrix[9] + matrix[6]) / scale;
354
+            z = 0.25f * scale;
355
+        }
356
+    }
357
+
358
+    mW = w;
359
+    mX = x;
360
+    mY = y;
361
+    mZ = z;
362 362
 }
363 363
 
364 364
 
@@ -368,34 +368,34 @@ void Quaternion::setByMatrix(matrix_t matrix)
368 368
 
369 369
 Quaternion Quaternion::multiply(Quaternion a, Quaternion b)
370 370
 {
371
-	return Quaternion(a.mW * b.mW - a.mX * b.mX - a.mY * b.mY - a.mZ * b.mZ,
372
-							a.mW * b.mX + a.mX * b.mW + a.mY * b.mZ - a.mZ * b.mY,
373
-							a.mW * b.mY + a.mY * b.mW + a.mZ * b.mX - a.mX * b.mZ,
374
-							a.mW * b.mZ + a.mZ * b.mW + a.mX * b.mY - a.mY * b.mX);
371
+    return Quaternion(a.mW * b.mW - a.mX * b.mX - a.mY * b.mY - a.mZ * b.mZ,
372
+            a.mW * b.mX + a.mX * b.mW + a.mY * b.mZ - a.mZ * b.mY,
373
+            a.mW * b.mY + a.mY * b.mW + a.mZ * b.mX - a.mX * b.mZ,
374
+            a.mW * b.mZ + a.mZ * b.mW + a.mX * b.mY - a.mY * b.mX);
375 375
 }
376 376
 
377 377
 
378 378
 Quaternion Quaternion::divide(Quaternion a, Quaternion b)
379 379
 {
380
-	return (a * (b.inverse()));
380
+    return (a * (b.inverse()));
381 381
 }
382 382
 
383 383
 
384 384
 Quaternion Quaternion::add(Quaternion a, Quaternion b)
385 385
 {
386
-	return Quaternion(a.mW + b.mW,
387
-							a.mX + b.mX,
388
-							a.mY + b.mY,
389
-							a.mZ + b.mZ);
386
+    return Quaternion(a.mW + b.mW,
387
+            a.mX + b.mX,
388
+            a.mY + b.mY,
389
+            a.mZ + b.mZ);
390 390
 }
391 391
 
392 392
 
393 393
 Quaternion Quaternion::subtract(Quaternion a, Quaternion b)
394 394
 {
395
-	return Quaternion(a.mW - b.mW,
396
-							a.mX - b.mX,
397
-							a.mY - b.mY,
398
-							a.mZ - b.mZ);
395
+    return Quaternion(a.mW - b.mW,
396
+            a.mX - b.mX,
397
+            a.mY - b.mY,
398
+            a.mZ - b.mZ);
399 399
 }
400 400
 
401 401
 

+ 1772
- 1772
src/Render.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 326
- 326
src/SDLSystem.cpp Переглянути файл

@@ -55,9 +55,9 @@ unsigned int *gHeight = 0x0;
55 55
 
56 56
 SDLSystem::SDLSystem() : System()
57 57
 {
58
-	mWindow = 0x0;
59
-	gWidth = &m_width;
60
-	gHeight = &m_height;
58
+    mWindow = 0x0;
59
+    gWidth = &m_width;
60
+    gHeight = &m_height;
61 61
     mFirstMouseEvent = false;
62 62
     mFullscreen = false;
63 63
 }
@@ -74,7 +74,7 @@ SDLSystem::~SDLSystem()
74 74
 
75 75
 unsigned int SDLSystem::getTicks()
76 76
 {
77
-	return SDL_GetTicks();
77
+    return SDL_GetTicks();
78 78
 }
79 79
 
80 80
 
@@ -85,89 +85,89 @@ unsigned int SDLSystem::getTicks()
85 85
 #ifdef FIXME
86 86
 void SDLSystem::bindKeyCommand(const char *cmd, int key, int event)
87 87
 {
88
-	if (key > 255)
89
-	{
90
-		printf("Currently key event mapping only handles ASCII characters\n");
91
-		return;
92
-	}
88
+    if (key > 255)
89
+    {
90
+        printf("Currently key event mapping only handles ASCII characters\n");
91
+        return;
92
+    }
93 93
 
94
-	printf("Bound command '%s' -> event %i (0x%x key)\n", cmd, event, key);
94
+    printf("Bound command '%s' -> event %i (0x%x key)\n", cmd, event, key);
95 95
 
96
-	keyEvents[key] = event;
96
+    keyEvents[key] = event;
97 97
 }
98 98
 #endif
99 99
 
100 100
 
101 101
 void SDLSystem::setGrabMouse(bool on)
102 102
 {
103
-	SDL_WM_GrabInput(on ? SDL_GRAB_ON : SDL_GRAB_OFF);
103
+    SDL_WM_GrabInput(on ? SDL_GRAB_ON : SDL_GRAB_OFF);
104 104
 }
105 105
 
106 106
 
107 107
 void SDLSystem::initVideo(unsigned int width, unsigned int height,
108
-								  bool fullscreen)
108
+        bool fullscreen)
109 109
 {
110
-	int flags = 0; //, x, y;
110
+    int flags = 0; //, x, y;
111 111
 
112 112
 
113
-	// Create GL context
114
-	SDL_Init(SDL_INIT_VIDEO);
115
-	printf("Created OpenGL Context\n");
116
-	atexit(SDL_Quit);
113
+    // Create GL context
114
+    SDL_Init(SDL_INIT_VIDEO);
115
+    printf("Created OpenGL Context\n");
116
+    atexit(SDL_Quit);
117 117
 
118
-	m_width = width;
119
-	m_height = height;
118
+    m_width = width;
119
+    m_height = height;
120 120
 
121 121
 #ifndef __APPLE__
122
-	if (!m_driver || !m_driver[0] || SDL_GL_LoadLibrary(m_driver) < 0)
123
-	{
124
-		SDL_ClearError();
125
-
126
-		// Fallback 1
127
-		if (SDL_GL_LoadLibrary("libGL.so") < 0)
128
-		{
129
-			SDL_ClearError();
130
-
131
-			// Fallback 2
132
-			if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
133
-			{
134
-				fprintf(stderr, "initVideo> SDL_GL_LoadLibrary failed!\n");
135
-				fprintf(stderr, "initVideo> Error is [%s].\n", SDL_GetError());
136
-				shutdown(1);
137
-			}
138
-		}
139
-	}
122
+    if (!m_driver || !m_driver[0] || SDL_GL_LoadLibrary(m_driver) < 0)
123
+    {
124
+        SDL_ClearError();
125
+
126
+        // Fallback 1
127
+        if (SDL_GL_LoadLibrary("libGL.so") < 0)
128
+        {
129
+            SDL_ClearError();
130
+
131
+            // Fallback 2
132
+            if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
133
+            {
134
+                fprintf(stderr, "initVideo> SDL_GL_LoadLibrary failed!\n");
135
+                fprintf(stderr, "initVideo> Error is [%s].\n", SDL_GetError());
136
+                shutdown(1);
137
+            }
138
+        }
139
+    }
140 140
 #endif
141 141
 
142
-	flags |= SDL_OPENGL;
142
+    flags |= SDL_OPENGL;
143 143
 
144 144
     mFullscreen = fullscreen;
145
-	if (mFullscreen)
146
-		flags |= SDL_FULLSCREEN;
145
+    if (mFullscreen)
146
+        flags |= SDL_FULLSCREEN;
147 147
 
148 148
     SDL_ShowCursor(SDL_DISABLE);
149 149
     setGrabMouse(true); // Always grab mouse!
150 150
 
151
-	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
152
-	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
153
-	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
154
-	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
155
-	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
156
-	mWindow = SDL_SetVideoMode(width, height, 16, flags);
157
-	SDL_WM_SetCaption(VERSION, VERSION);
158
-	//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
159
-	SDL_EnableKeyRepeat(100, SDL_DEFAULT_REPEAT_INTERVAL);
151
+    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
152
+    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
153
+    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
154
+    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
155
+    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
156
+    mWindow = SDL_SetVideoMode(width, height, 16, flags);
157
+    SDL_WM_SetCaption(VERSION, VERSION);
158
+    //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
159
+    SDL_EnableKeyRepeat(100, SDL_DEFAULT_REPEAT_INTERVAL);
160 160
 
161 161
 #ifdef UNICODE_SUPPORT
162
-	//@JML get Unicode value of key for international keyboard
163
-	SDL_EnableUNICODE(1);
162
+    //@JML get Unicode value of key for international keyboard
163
+    SDL_EnableUNICODE(1);
164 164
 #endif
165 165
 
166
-	// Start game renderer
167
-	initGL();
166
+    // Start game renderer
167
+    initGL();
168 168
 
169
-	// Resize context
170
-	resizeGL(width, height);
169
+    // Resize context
170
+    resizeGL(width, height);
171 171
 }
172 172
 
173 173
 
@@ -175,323 +175,323 @@ void SDLSystem::resize(unsigned int width, unsigned int height)
175 175
 {
176 176
     int flags = 0;
177 177
 
178
-	GLfloat aspect;
178
+    GLfloat aspect;
179 179
 
180 180
 
181
-	m_width = width;
182
-	m_height = height;
181
+    m_width = width;
182
+    m_height = height;
183 183
 
184
-	aspect = (GLfloat)width/(GLfloat)height;
184
+    aspect = (GLfloat)width/(GLfloat)height;
185 185
 
186
-	glViewport(0, 0, width, height);
186
+    glViewport(0, 0, width, height);
187 187
 
188
-	glMatrixMode(GL_PROJECTION);
189
-	glLoadIdentity();
188
+    glMatrixMode(GL_PROJECTION);
189
+    glLoadIdentity();
190 190
 
191 191
     // gluPerspective is deprecated!
192
-	// gluPerspective(m_fovY, aspect, m_clipNear, m_clipFar);
192
+    // gluPerspective(m_fovY, aspect, m_clipNear, m_clipFar);
193 193
     // fix: http://stackoverflow.com/a/2417756
194 194
     GLfloat fH = tan(float(m_fovY / 360.0f * 3.14159f) ) * m_clipNear;
195 195
     GLfloat fW = fH * aspect;
196 196
     glFrustum(-fW, fW, -fH, fH, m_clipNear, m_clipFar);
197 197
 
198
-	glMatrixMode(GL_MODELVIEW);
199
-	glLoadIdentity();
198
+    glMatrixMode(GL_MODELVIEW);
199
+    glLoadIdentity();
200 200
 
201
-	// Resize window
201
+    // Resize window
202 202
     flags |= SDL_OPENGL;
203 203
 
204 204
     if (mFullscreen)
205 205
         flags |= SDL_FULLSCREEN;
206 206
 
207
-	mWindow = SDL_SetVideoMode(width, height, 16, flags);
207
+    mWindow = SDL_SetVideoMode(width, height, 16, flags);
208 208
 
209
-	// Resize context
210
-	resizeGL(width, height);
209
+    // Resize context
210
+    resizeGL(width, height);
211 211
 }
212 212
 
213 213
 
214 214
 void SDLSystem::runGame()
215 215
 {
216
-	SDL_Event event;
217
-	unsigned int mkeys, mod, key;
218
-	int btn;
219
-	bool specialKey;
220
-
221
-
222
-	for (;;)
223
-	{
224
-		// Pause for 10-20 ms
225
-		SDL_Delay(10);
226
-
227
-		while (SDL_PollEvent(&event))
228
-		{
229
-			switch (event.type)
230
-			{
231
-			case SDL_QUIT:
232
-				shutdown(0);
233
-				break;
234
-			case SDL_MOUSEMOTION:
235
-				// Wrap motion
236
-                if (!mFirstMouseEvent) {
237
-                    mFirstMouseEvent = true;
238
-                } else {
239
-                    handleMouseMotionEvent(event.motion.xrel/2, event.motion.yrel/2);
240
-                }
241
-				break;
242
-			case SDL_MOUSEBUTTONDOWN:
243
-			case SDL_MOUSEBUTTONUP:
244
-				//handleMouseEvent(event.button.button, event.button.state,
245
-				//			          event.button.x, event.button.y);
246
-
247
-				switch (event.button.button)
248
-				{
249
-				case SDL_BUTTON_LEFT:
250
-					btn = SYS_MOUSE_LEFT;
251
-					break;
252
-				case SDL_BUTTON_RIGHT:
253
-					btn = SYS_MOUSE_RIGHT;
254
-					break;
255
-				case SDL_BUTTON_MIDDLE:
256
-					btn = SYS_MOUSE_MIDDLE;
257
-					break;
258
-				}
259
-
260
-				if (event.button.state == SDL_PRESSED)
261
-				{
262
-					handleKeyPressEvent(btn, 0); //! \fixme mod not used
263
-				}
264
-				else
265
-				{
266
-					handleKeyReleaseEvent(btn, 0); //! \fixme mod not used
267
-				}
268
-				break;
269
-			case SDL_KEYUP:
270
-			case SDL_KEYDOWN:
271
-				//SDL_GetMouseState(&x, &y); // Get cursor pos
272
-
273
-				mkeys = (unsigned int)SDL_GetModState();
274
-				mod = 0;
275
-
276
-				if (mkeys & KMOD_LSHIFT)
277
-					mod |= SYS_MOD_KEY_LSHIFT;
278
-
279
-				if (mkeys & KMOD_RSHIFT)
280
-					mod |= SYS_MOD_KEY_RSHIFT;
281
-
282
-				if (mkeys & KMOD_LCTRL)
283
-					mod |= SYS_MOD_KEY_LCTRL;
284
-
285
-				if (mkeys & KMOD_RCTRL)
286
-					mod |= SYS_MOD_KEY_RCTRL;
287
-
288
-				if (mkeys & KMOD_LALT)
289
-					mod |= SYS_MOD_KEY_LALT;
290
-
291
-				if (mkeys & KMOD_RALT)
292
-					mod |= SYS_MOD_KEY_RALT;
293
-
294
-                if (mkeys & KMOD_LMETA)
295
-					mod |= SYS_MOD_KEY_LMETA;
296
-
297
-				if (mkeys & KMOD_RMETA)
298
-					mod |= SYS_MOD_KEY_RMETA;
299
-
300
-				key = event.key.keysym.sym;
301
-				specialKey = false;
302
-
303
-				switch (key)
304
-				{
305
-				case SDLK_F1:
306
-					key = SYS_KEY_F1;
307
-					specialKey = true;
308
-					break;
309
-				case SDLK_F2:
310
-					key = SYS_KEY_F2;
311
-					specialKey = true;
312
-					break;
313
-				case SDLK_F3:
314
-					key = SYS_KEY_F3;
315
-					specialKey = true;
316
-					break;
317
-				case SDLK_F4:
318
-					key = SYS_KEY_F4;
319
-					specialKey = true;
320
-					break;
321
-				case SDLK_F5:
322
-					key = SYS_KEY_F5;
323
-					specialKey = true;
324
-					break;
325
-				case SDLK_F6:
326
-					key = SYS_KEY_F6;
327
-					specialKey = true;
328
-					break;
329
-				case SDLK_F7:
330
-					key = SYS_KEY_F7;
331
-					specialKey = true;
332
-					break;
333
-				case SDLK_F8:
334
-					key = SYS_KEY_F8;
335
-					specialKey = true;
336
-					break;
337
-				case SDLK_F9:
338
-					key = SYS_KEY_F9;
339
-					specialKey = true;
340
-					break;
341
-				case SDLK_F10:
342
-					key = SYS_KEY_F10;
343
-					specialKey = true;
344
-					break;
345
-				case SDLK_F11:
346
-					key = SYS_KEY_F11;
347
-					specialKey = true;
348
-					break;
349
-				case SDLK_F12:
350
-					key = SYS_KEY_F12;
351
-					specialKey = true;
352
-					break;
353
-				case SDLK_UP:
354
-					key = SYS_KEY_UP;
355
-					specialKey = true;
356
-					break;
357
-				case SDLK_DOWN:
358
-					key = SYS_KEY_DOWN;
359
-					specialKey = true;
360
-					break;
361
-				case SDLK_RIGHT:
362
-					key = SYS_KEY_RIGHT;
363
-					specialKey = true;
364
-					break;
365
-				case SDLK_LEFT:
366
-					key = SYS_KEY_LEFT;
367
-					specialKey = true;
368
-					break;
369
-				case SDLK_PAGEDOWN:
370
-					key = SYS_KEY_PAGEDOWN;
371
-					specialKey = true;
372
-					break;
373
-				case SDLK_PAGEUP:
374
-					key = SYS_KEY_PAGEUP;
375
-					specialKey = true;
376
-					break;
377
-				}
216
+    SDL_Event event;
217
+    unsigned int mkeys, mod, key;
218
+    int btn;
219
+    bool specialKey;
220
+
221
+
222
+    for (;;)
223
+    {
224
+        // Pause for 10-20 ms
225
+        SDL_Delay(10);
226
+
227
+        while (SDL_PollEvent(&event))
228
+        {
229
+            switch (event.type)
230
+            {
231
+                case SDL_QUIT:
232
+                    shutdown(0);
233
+                    break;
234
+                case SDL_MOUSEMOTION:
235
+                    // Wrap motion
236
+                    if (!mFirstMouseEvent) {
237
+                        mFirstMouseEvent = true;
238
+                    } else {
239
+                        handleMouseMotionEvent(event.motion.xrel/2, event.motion.yrel/2);
240
+                    }
241
+                    break;
242
+                case SDL_MOUSEBUTTONDOWN:
243
+                case SDL_MOUSEBUTTONUP:
244
+                    //handleMouseEvent(event.button.button, event.button.state,
245
+                    //                    event.button.x, event.button.y);
246
+
247
+                    switch (event.button.button)
248
+                    {
249
+                        case SDL_BUTTON_LEFT:
250
+                            btn = SYS_MOUSE_LEFT;
251
+                            break;
252
+                        case SDL_BUTTON_RIGHT:
253
+                            btn = SYS_MOUSE_RIGHT;
254
+                            break;
255
+                        case SDL_BUTTON_MIDDLE:
256
+                            btn = SYS_MOUSE_MIDDLE;
257
+                            break;
258
+                    }
259
+
260
+                    if (event.button.state == SDL_PRESSED)
261
+                    {
262
+                        handleKeyPressEvent(btn, 0); //! \fixme mod not used
263
+                    }
264
+                    else
265
+                    {
266
+                        handleKeyReleaseEvent(btn, 0); //! \fixme mod not used
267
+                    }
268
+                    break;
269
+                case SDL_KEYUP:
270
+                case SDL_KEYDOWN:
271
+                    //SDL_GetMouseState(&x, &y); // Get cursor pos
272
+
273
+                    mkeys = (unsigned int)SDL_GetModState();
274
+                    mod = 0;
275
+
276
+                    if (mkeys & KMOD_LSHIFT)
277
+                        mod |= SYS_MOD_KEY_LSHIFT;
278
+
279
+                    if (mkeys & KMOD_RSHIFT)
280
+                        mod |= SYS_MOD_KEY_RSHIFT;
281
+
282
+                    if (mkeys & KMOD_LCTRL)
283
+                        mod |= SYS_MOD_KEY_LCTRL;
284
+
285
+                    if (mkeys & KMOD_RCTRL)
286
+                        mod |= SYS_MOD_KEY_RCTRL;
287
+
288
+                    if (mkeys & KMOD_LALT)
289
+                        mod |= SYS_MOD_KEY_LALT;
290
+
291
+                    if (mkeys & KMOD_RALT)
292
+                        mod |= SYS_MOD_KEY_RALT;
293
+
294
+                    if (mkeys & KMOD_LMETA)
295
+                        mod |= SYS_MOD_KEY_LMETA;
296
+
297
+                    if (mkeys & KMOD_RMETA)
298
+                        mod |= SYS_MOD_KEY_RMETA;
299
+
300
+                    key = event.key.keysym.sym;
301
+                    specialKey = false;
302
+
303
+                    switch (key)
304
+                    {
305
+                        case SDLK_F1:
306
+                            key = SYS_KEY_F1;
307
+                            specialKey = true;
308
+                            break;
309
+                        case SDLK_F2:
310
+                            key = SYS_KEY_F2;
311
+                            specialKey = true;
312
+                            break;
313
+                        case SDLK_F3:
314
+                            key = SYS_KEY_F3;
315
+                            specialKey = true;
316
+                            break;
317
+                        case SDLK_F4:
318
+                            key = SYS_KEY_F4;
319
+                            specialKey = true;
320
+                            break;
321
+                        case SDLK_F5:
322
+                            key = SYS_KEY_F5;
323
+                            specialKey = true;
324
+                            break;
325
+                        case SDLK_F6:
326
+                            key = SYS_KEY_F6;
327
+                            specialKey = true;
328
+                            break;
329
+                        case SDLK_F7:
330
+                            key = SYS_KEY_F7;
331
+                            specialKey = true;
332
+                            break;
333
+                        case SDLK_F8:
334
+                            key = SYS_KEY_F8;
335
+                            specialKey = true;
336
+                            break;
337
+                        case SDLK_F9:
338
+                            key = SYS_KEY_F9;
339
+                            specialKey = true;
340
+                            break;
341
+                        case SDLK_F10:
342
+                            key = SYS_KEY_F10;
343
+                            specialKey = true;
344
+                            break;
345
+                        case SDLK_F11:
346
+                            key = SYS_KEY_F11;
347
+                            specialKey = true;
348
+                            break;
349
+                        case SDLK_F12:
350
+                            key = SYS_KEY_F12;
351
+                            specialKey = true;
352
+                            break;
353
+                        case SDLK_UP:
354
+                            key = SYS_KEY_UP;
355
+                            specialKey = true;
356
+                            break;
357
+                        case SDLK_DOWN:
358
+                            key = SYS_KEY_DOWN;
359
+                            specialKey = true;
360
+                            break;
361
+                        case SDLK_RIGHT:
362
+                            key = SYS_KEY_RIGHT;
363
+                            specialKey = true;
364
+                            break;
365
+                        case SDLK_LEFT:
366
+                            key = SYS_KEY_LEFT;
367
+                            specialKey = true;
368
+                            break;
369
+                        case SDLK_PAGEDOWN:
370
+                            key = SYS_KEY_PAGEDOWN;
371
+                            specialKey = true;
372
+                            break;
373
+                        case SDLK_PAGEUP:
374
+                            key = SYS_KEY_PAGEUP;
375
+                            specialKey = true;
376
+                            break;
377
+                    }
378 378
 
379 379
 #ifdef __APPLE__
380
-                // Handle CMD+Q to quit in all circumstances
381
-                if (key == 'q') {
382
-                    if (mod & SYS_MOD_KEY_LMETA) {
383
-                        shutdown(0);
380
+                    // Handle CMD+Q to quit in all circumstances
381
+                    if (key == 'q') {
382
+                        if (mod & SYS_MOD_KEY_LMETA) {
383
+                            shutdown(0);
384
+                        }
384 385
                     }
385
-                }
386 386
 #endif
387 387
 
388 388
 #ifdef UNICODE_SUPPORT
389
-				// JML: if a std key was pressed get it ascii code
390
-				if (!specialKey && key != 0)
391
-				{
392
-					if ((event.key.keysym.unicode & 0xFF80) == 0)
393
-					{
394
-						key= (unsigned int)(event.key.keysym.unicode & 0x7F);
395
-					}
396
-					else
397
-					{
398
-						key = 0;
399
-					}
400
-				}
389
+                    // JML: if a std key was pressed get it ascii code
390
+                    if (!specialKey && key != 0)
391
+                    {
392
+                        if ((event.key.keysym.unicode & 0xFF80) == 0)
393
+                        {
394
+                            key= (unsigned int)(event.key.keysym.unicode & 0x7F);
395
+                        }
396
+                        else
397
+                        {
398
+                            key = 0;
399
+                        }
400
+                    }
401 401
 #else
402
-				/*! \fixme Avoid passing modifers as a key, since the
403
-				 * consoles using this expect text characters, add unicode
404
-				 * support later when they're able to handle it
405
-                 */
406
-				if (key > 255 && key < 1000)
407
-				{
408
-					key = 0;
409
-				}
402
+                    /*! \fixme Avoid passing modifers as a key, since the
403
+                     * consoles using this expect text characters, add unicode
404
+                     * support later when they're able to handle it
405
+                     */
406
+                    if (key > 255 && key < 1000)
407
+                    {
408
+                        key = 0;
409
+                    }
410 410
 #endif
411 411
 
412
-				if (key == mConsoleKey)
413
-				{
414
-					if (event.type == SDL_KEYDOWN)
415
-					{
416
-						mConsoleMode = !mConsoleMode;
417
-						// Tmp hack
418
-						handleConsoleKeyPressEvent(mConsoleKey, 0);
419
-					}
420
-				}
421
-				else if (mConsoleMode) // Console keying ( text input )
422
-				{
423
-					switch (event.type)
424
-					{
425
-					case SDL_KEYDOWN:
426
-						handleConsoleKeyPressEvent(key, mod);
427
-						break;
428
-					default:
429
-						;
430
-					}
431
-				}
432
-				else if (mKeyEvents[key] != 0)// Bound key
433
-				{
434
-					//if (key < 255 && mKeyEvents[key] != 0)
435
-					key = mKeyEvents[key];
436
-
437
-					switch (event.type)
438
-					{
439
-					case SDL_KEYDOWN:
440
-						handleBoundKeyPressEvent(key);
441
-						break;
442
-					default:
443
-						handleBoundKeyReleaseEvent(key);
444
-					}
445
-				}
446
-				else // 'Classic' key event handlers
447
-				{
448
-					switch (event.type)
449
-					{
450
-					case SDL_KEYDOWN:
451
-						handleKeyPressEvent(key, mod);
452
-						break;
453
-					default:
454
-						handleKeyReleaseEvent(key, mod);
455
-					}
456
-				}
457
-				break;
458
-			case SDL_VIDEORESIZE:
459
-				resizeGL(event.resize.w, event.resize.h);
460
-				gameFrame();
461
-				break;
462
-			}
463
-		}
464
-
465
-		// Game frame
466
-		gameFrame();
467
-	}
412
+                    if (key == mConsoleKey)
413
+                    {
414
+                        if (event.type == SDL_KEYDOWN)
415
+                        {
416
+                            mConsoleMode = !mConsoleMode;
417
+                            // Tmp hack
418
+                            handleConsoleKeyPressEvent(mConsoleKey, 0);
419
+                        }
420
+                    }
421
+                    else if (mConsoleMode) // Console keying ( text input )
422
+                    {
423
+                        switch (event.type)
424
+                        {
425
+                            case SDL_KEYDOWN:
426
+                                handleConsoleKeyPressEvent(key, mod);
427
+                                break;
428
+                            default:
429
+                                ;
430
+                        }
431
+                    }
432
+                    else if (mKeyEvents[key] != 0)// Bound key
433
+                    {
434
+                        //if (key < 255 && mKeyEvents[key] != 0)
435
+                        key = mKeyEvents[key];
436
+
437
+                        switch (event.type)
438
+                        {
439
+                            case SDL_KEYDOWN:
440
+                                handleBoundKeyPressEvent(key);
441
+                                break;
442
+                            default:
443
+                                handleBoundKeyReleaseEvent(key);
444
+                        }
445
+                    }
446
+                    else // 'Classic' key event handlers
447
+                    {
448
+                        switch (event.type)
449
+                        {
450
+                            case SDL_KEYDOWN:
451
+                                handleKeyPressEvent(key, mod);
452
+                                break;
453
+                            default:
454
+                                handleKeyReleaseEvent(key, mod);
455
+                        }
456
+                    }
457
+                    break;
458
+                case SDL_VIDEORESIZE:
459
+                    resizeGL(event.resize.w, event.resize.h);
460
+                    gameFrame();
461
+                    break;
462
+            }
463
+        }
464
+
465
+        // Game frame
466
+        gameFrame();
467
+    }
468 468
 }
469 469
 
470 470
 
471 471
 void SDLSystem::shutdown(int i)
472 472
 {
473
-	//SDL_QuitSubSystem(SDL_OPENGL);
474
-	//SDL_Quit(); // Moved to atexit() call
473
+    //SDL_QuitSubSystem(SDL_OPENGL);
474
+    //SDL_Quit(); // Moved to atexit() call
475 475
 
476
-	//#ifdef DEBUG_MEMORY
477
-	//printf("[Mongoose MEMORY_DEBUG]\nUnfreed memory table:\n");
478
-	//dump_memory_report();
479
-	//#endif
476
+    //#ifdef DEBUG_MEMORY
477
+    //printf("[Mongoose MEMORY_DEBUG]\nUnfreed memory table:\n");
478
+    //dump_memory_report();
479
+    //#endif
480 480
 
481
-	exit(0);
481
+    exit(0);
482 482
 }
483 483
 
484 484
 
485 485
 void SDLSystem::toggleFullscreen()
486 486
 {
487
-	if (mWindow)
488
-	{
487
+    if (mWindow)
488
+    {
489 489
         mFullscreen = !mFullscreen;
490
-		SDL_ShowCursor(SDL_DISABLE);
490
+        SDL_ShowCursor(SDL_DISABLE);
491 491
 
492 492
         // SDL_WM_ToggleFullScreen does not work on all platforms
493 493
         // eg. Mac OS X
494
-		// SDL_WM_ToggleFullScreen(mWindow);
494
+        // SDL_WM_ToggleFullScreen(mWindow);
495 495
 
496 496
         // I added a mFullscreen flag to this class. Then I modified it's
497 497
         // resize() method to use the SDL_FULLSCREEN flag in the
@@ -525,12 +525,12 @@ void SDLSystem::toggleFullscreen()
525 525
             height = m_old_height;
526 526
         }
527 527
         resize(width, height);
528
-	}
528
+    }
529 529
 }
530 530
 
531 531
 
532 532
 void SDLSystem::swapBuffersGL()
533 533
 {
534
-	SDL_GL_SwapBuffers();
534
+    SDL_GL_SwapBuffers();
535 535
 }
536 536
 

+ 65
- 65
src/SkeletalModel.cpp Переглянути файл

@@ -31,54 +31,54 @@
31 31
 
32 32
 SkeletalModel::SkeletalModel()
33 33
 {
34
-	model = 0x0;
35
-	flags = 0;
36
-	mBoneFrame = 0;
37
-	mAnimationFrame = 0;
38
-	mIdleAnimation = 0;
34
+    model = 0x0;
35
+    flags = 0;
36
+    mBoneFrame = 0;
37
+    mAnimationFrame = 0;
38
+    mIdleAnimation = 0;
39 39
 }
40 40
 
41 41
 
42 42
 SkeletalModel::~SkeletalModel()
43 43
 {
44
-	if (model)
45
-	{
46
-		for (model->animation.start();
47
-			  model->animation.forward();
48
-			  model->animation.next())
49
-		{
50
-			animation_frame_t *af = model->animation.current();
44
+    if (model)
45
+    {
46
+        for (model->animation.start();
47
+                model->animation.forward();
48
+                model->animation.next())
49
+        {
50
+            animation_frame_t *af = model->animation.current();
51 51
 
52
-			if (!af)
53
-				continue;
52
+            if (!af)
53
+                continue;
54 54
 
55
-			for (af->frame.start(); af->frame.forward(); af->frame.next())
56
-			{
57
-				bone_frame_t *bf = af->frame.current();
55
+            for (af->frame.start(); af->frame.forward(); af->frame.next())
56
+            {
57
+                bone_frame_t *bf = af->frame.current();
58 58
 
59
-				if (!bf)
60
-					continue;
59
+                if (!bf)
60
+                    continue;
61 61
 
62
-				bf->tag.erase();
62
+                bf->tag.erase();
63 63
 
64
-				//for (bf->tag.start(); bf->tag.forward(); bf->tag.next())
65
-				//{
66
-				//	if (bf->tag.current())
67
-				//		delete bf->tag.current();
68
-				//}
64
+                //for (bf->tag.start(); bf->tag.forward(); bf->tag.next())
65
+                //{
66
+                //  if (bf->tag.current())
67
+                //      delete bf->tag.current();
68
+                //}
69 69
 
70
-				delete bf;
71
-			}
70
+                delete bf;
71
+            }
72 72
 
73
-			af->frame.clear();
73
+            af->frame.clear();
74 74
 
75
-			delete af;
76
-		}
75
+            delete af;
76
+        }
77 77
 
78
-		model->animation.clear();
78
+        model->animation.clear();
79 79
 
80
-		delete model;
81
-	}
80
+        delete model;
81
+    }
82 82
 }
83 83
 
84 84
 
@@ -88,19 +88,19 @@ SkeletalModel::~SkeletalModel()
88 88
 
89 89
 int SkeletalModel::getAnimation()
90 90
 {
91
-	return mAnimationFrame;
91
+    return mAnimationFrame;
92 92
 }
93 93
 
94 94
 
95 95
 int SkeletalModel::getFrame()
96 96
 {
97
-	return mBoneFrame;
97
+    return mBoneFrame;
98 98
 }
99 99
 
100 100
 
101 101
 int SkeletalModel::getIdleAnimation()
102 102
 {
103
-	return mIdleAnimation;
103
+    return mIdleAnimation;
104 104
 }
105 105
 
106 106
 
@@ -110,57 +110,57 @@ int SkeletalModel::getIdleAnimation()
110 110
 
111 111
 void SkeletalModel::setModel(skeletal_model_t *mdl)
112 112
 {
113
-	if (mdl)
114
-		model = mdl;
113
+    if (mdl)
114
+        model = mdl;
115 115
 }
116 116
 
117 117
 
118 118
 void SkeletalModel::setAnimation(int index)
119 119
 {
120
-	if (!model) // index > (int)model->animation.size())
121
-		return;
120
+    if (!model) // index > (int)model->animation.size())
121
+        return;
122 122
 
123
-	animation_frame_t *a = model->animation[index];
123
+    animation_frame_t *a = model->animation[index];
124 124
 
125
-	if (a)
126
-	{
127
-		mAnimationFrame = index;
128
-		mBoneFrame = 0;
129
-		rate = a->rate;
130
-	}
125
+    if (a)
126
+    {
127
+        mAnimationFrame = index;
128
+        mBoneFrame = 0;
129
+        rate = a->rate;
130
+    }
131 131
 }
132 132
 
133 133
 
134 134
 void SkeletalModel::setFrame(int index)
135 135
 {
136
-	if (!model)
137
-		return;
136
+    if (!model)
137
+        return;
138 138
 
139
-	animation_frame_t *a = model->animation[mAnimationFrame];
139
+    animation_frame_t *a = model->animation[mAnimationFrame];
140 140
 
141
-	if (a) // index > (int)a->frame.size())
142
-	{
143
-		bone_frame_t *b = a->frame[index];
141
+    if (a) // index > (int)a->frame.size())
142
+    {
143
+        bone_frame_t *b = a->frame[index];
144 144
 
145
-		if (b)
146
-		{
147
-			mBoneFrame = index;
148
-		}
149
-	}
145
+        if (b)
146
+        {
147
+            mBoneFrame = index;
148
+        }
149
+    }
150 150
 }
151 151
 
152 152
 
153 153
 void SkeletalModel::setIdleAnimation(int index)
154 154
 {
155
-	if (!model)
156
-		return;
155
+    if (!model)
156
+        return;
157 157
 
158
-	animation_frame_t *a = model->animation[index];
158
+    animation_frame_t *a = model->animation[index];
159 159
 
160
-	if (a)
161
-	{
162
-		mIdleAnimation = index;
163
-	}
160
+    if (a)
161
+    {
162
+        mIdleAnimation = index;
163
+    }
164 164
 }
165 165
 
166 166
 

+ 128
- 128
src/Sound.cpp Переглянути файл

@@ -39,73 +39,73 @@
39 39
 
40 40
 Sound::Sound()
41 41
 {
42
-	mSource[0] = 0;
43
-	mBuffer[0] = 0;
44
-	mNextBuffer = 0;
45
-	mNextSource = 0;
46
-	mInit = false;
42
+    mSource[0] = 0;
43
+    mBuffer[0] = 0;
44
+    mNextBuffer = 0;
45
+    mNextSource = 0;
46
+    mInit = false;
47 47
 }
48 48
 
49 49
 
50 50
 Sound::~Sound()
51 51
 {
52
-	if (mInit)
53
-	{
52
+    if (mInit)
53
+    {
54 54
 #ifdef USING_OPENAL
55
-		alutExit();
55
+        alutExit();
56 56
 #endif
57
-	}
57
+    }
58 58
 }
59 59
 
60 60
 
61 61
 int Sound::init()
62 62
 {
63 63
 #ifndef __APPLE__
64
-	int fd;
64
+    int fd;
65 65
 
66
-	fd = open("/dev/dsp", O_RDWR);
66
+    fd = open("/dev/dsp", O_RDWR);
67 67
 
68
-	if (fd < 0)
69
-	{
70
-		perror("Sound::Init> Could not open /dev/dsp : ");
71
-		return -1;
72
-	}
68
+    if (fd < 0)
69
+    {
70
+        perror("Sound::Init> Could not open /dev/dsp : ");
71
+        return -1;
72
+    }
73 73
 
74
-	close(fd);
74
+    close(fd);
75 75
 #endif
76 76
 
77 77
 #ifdef USING_OPENAL
78
-	alutInit(NULL, 0);
78
+    alutInit(NULL, 0);
79 79
 
80
-	mInit = true;
81
-	printf("Created OpenAL Context\n");
80
+    mInit = true;
81
+    printf("Created OpenAL Context\n");
82 82
 #else
83
-	printf("Couldn't create sound Context!\n");
83
+    printf("Couldn't create sound Context!\n");
84 84
 #endif
85 85
 
86
-	return 0;
86
+    return 0;
87 87
 }
88 88
 
89 89
 
90 90
 void Sound::listenAt(float pos[3], float angle[3])
91 91
 {
92
-	if (!mInit)
93
-		return;
92
+    if (!mInit)
93
+        return;
94 94
 
95 95
 #ifdef USING_OPENAL
96
-	alListenerfv(AL_POSITION, pos);
97
-	alListenerfv(AL_ORIENTATION, angle);
96
+    alListenerfv(AL_POSITION, pos);
97
+    alListenerfv(AL_ORIENTATION, angle);
98 98
 #endif
99 99
 }
100 100
 
101 101
 
102 102
 void Sound::sourceAt(int source, float pos[3])
103 103
 {
104
-	if (!mInit || source < 0)
105
-		return;
104
+    if (!mInit || source < 0)
105
+        return;
106 106
 
107 107
 #ifdef USING_OPENAL
108
-	alSourcefv(mSource[source-1], AL_POSITION, pos);
108
+    alSourcefv(mSource[source-1], AL_POSITION, pos);
109 109
 #endif
110 110
 }
111 111
 
@@ -114,111 +114,111 @@ void Sound::sourceAt(int source, float pos[3])
114 114
 int Sound::addFile(const char *filename, int *source, unsigned int flags)
115 115
 {
116 116
 #ifdef USING_OPENAL
117
-   ALsizei size;
118
-   ALfloat freq;
119
-   ALenum format;
120
-   ALvoid *data;
117
+    ALsizei size;
118
+    ALfloat freq;
119
+    ALenum format;
120
+    ALvoid *data;
121 121
 #endif
122 122
 
123 123
 
124
-	if (!mInit || !filename || !source)
125
-	{
126
-		printf("Sound::AddFile> ERROR pre condition assertion failed\n");
127
-		return -1000;
128
-	}
124
+    if (!mInit || !filename || !source)
125
+    {
126
+        printf("Sound::AddFile> ERROR pre condition assertion failed\n");
127
+        return -1000;
128
+    }
129 129
 
130
-	*source = -1;
130
+    *source = -1;
131 131
 
132 132
 #ifdef USING_OPENAL
133
-   alGetError();
133
+    alGetError();
134 134
 
135
-	alGenBuffers(1, &mBuffer[mNextBuffer]);
135
+    alGenBuffers(1, &mBuffer[mNextBuffer]);
136 136
 
137
-	if (alGetError() != AL_NO_ERROR)
138
-   {
139
-		fprintf(stderr, "Sound::AddFile> alGenBuffers call failed\n");
140
-		return -1;
141
-	}
137
+    if (alGetError() != AL_NO_ERROR)
138
+    {
139
+        fprintf(stderr, "Sound::AddFile> alGenBuffers call failed\n");
140
+        return -1;
141
+    }
142 142
 
143
-   alGetError();
143
+    alGetError();
144 144
 
145
-   alGenSources(1, &mSource[mNextSource]);
145
+    alGenSources(1, &mSource[mNextSource]);
146 146
 
147
-	if (alGetError() != AL_NO_ERROR)
148
-   {
149
-		fprintf(stderr, "Sound::AddFile> alGenSources call failed\n");
150
-		return -2;
151
-	}
147
+    if (alGetError() != AL_NO_ERROR)
148
+    {
149
+        fprintf(stderr, "Sound::AddFile> alGenSources call failed\n");
150
+        return -2;
151
+    }
152 152
 
153
-   // err = alutLoadWAV(filename, &data, &format, &size, &bits, &freq);
154
-   // is deprecated!
155
-   data = alutLoadMemoryFromFile(filename, &format, &size, &freq);
153
+    // err = alutLoadWAV(filename, &data, &format, &size, &bits, &freq);
154
+    // is deprecated!
155
+    data = alutLoadMemoryFromFile(filename, &format, &size, &freq);
156 156
 
157
-   if (alGetError() != AL_NO_ERROR)
158
-	{
159
-	   fprintf(stderr, "Could not load %s\n", filename);
160
-	   return -3;
161
-   }
157
+    if (alGetError() != AL_NO_ERROR)
158
+    {
159
+        fprintf(stderr, "Could not load %s\n", filename);
160
+        return -3;
161
+    }
162 162
 
163
-   alBufferData(mBuffer[mNextBuffer], format, data, size, freq);
163
+    alBufferData(mBuffer[mNextBuffer], format, data, size, freq);
164 164
 
165
-   alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
165
+    alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
166 166
 
167
-	if (flags & SoundFlagsLoop)
168
-	{
169
-		alSourcei(mSource[mNextSource], AL_LOOPING, 1);
170
-	}
167
+    if (flags & SoundFlagsLoop)
168
+    {
169
+        alSourcei(mSource[mNextSource], AL_LOOPING, 1);
170
+    }
171 171
 
172
-   ++mNextBuffer;
173
-   ++mNextSource;
172
+    ++mNextBuffer;
173
+    ++mNextSource;
174 174
 
175
-	*source = mNextBuffer;
175
+    *source = mNextBuffer;
176 176
 
177
-   return 0;
177
+    return 0;
178 178
 #else
179
-	return -1;
179
+    return -1;
180 180
 #endif
181 181
 }
182 182
 
183 183
 int Sound::addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags)
184 184
 {
185 185
 #ifdef USING_OPENAL
186
-   ALsizei size;
187
-   ALfloat freq;
188
-   ALenum format;
189
-   ALvoid *data;
186
+    ALsizei size;
187
+    ALfloat freq;
188
+    ALenum format;
189
+    ALvoid *data;
190 190
 #endif
191 191
 
192
-	if (!mInit || !wav || !source)
193
-	{
194
-		printf("Sound::AddWave> ERROR pre condition assertion failed\n");
195
-		return -1000;
196
-	}
192
+    if (!mInit || !wav || !source)
193
+    {
194
+        printf("Sound::AddWave> ERROR pre condition assertion failed\n");
195
+        return -1000;
196
+    }
197 197
 
198
-	*source = -1;
198
+    *source = -1;
199 199
 
200 200
 #ifdef USING_OPENAL
201
-	data = wav;
201
+    data = wav;
202 202
 
203
-   alGetError();
203
+    alGetError();
204 204
 
205
-	alGenBuffers(1, &mBuffer[mNextBuffer]);
205
+    alGenBuffers(1, &mBuffer[mNextBuffer]);
206 206
 
207
-	if (alGetError() != AL_NO_ERROR)
208
-   {
209
-		fprintf(stderr, "Sound::AddWave> alGenBuffers call failed\n");
210
-		return -1;
211
-	}
207
+    if (alGetError() != AL_NO_ERROR)
208
+    {
209
+        fprintf(stderr, "Sound::AddWave> alGenBuffers call failed\n");
210
+        return -1;
211
+    }
212 212
 
213
-   alGetError();
213
+    alGetError();
214 214
 
215
-   alGenSources(1, &mSource[mNextSource]);
215
+    alGenSources(1, &mSource[mNextSource]);
216 216
 
217
-	if (alGetError() != AL_NO_ERROR)
218
-   {
219
-		fprintf(stderr, "Sound::AddWave> alGenSources call failed\n");
220
-		return -2;
221
-	}
217
+    if (alGetError() != AL_NO_ERROR)
218
+    {
219
+        fprintf(stderr, "Sound::AddWave> alGenSources call failed\n");
220
+        return -2;
221
+    }
222 222
 
223 223
     //AL_FORMAT_WAVE_EXT does not exist on Mac!"
224 224
     // alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
@@ -229,62 +229,62 @@ int Sound::addWave(unsigned char *wav, unsigned int length, int *source, unsigne
229 229
     data = alutLoadMemoryFromFileImage(wav, length, &format, &size, &freq);
230 230
 
231 231
     if ((alGetError() != AL_NO_ERROR) || (data == NULL)) {
232
-	   fprintf(stderr, "Could not load wav buffer\n");
233
-	   return -3;
232
+        fprintf(stderr, "Could not load wav buffer\n");
233
+        return -3;
234 234
     }
235 235
 
236 236
 
237
-   alBufferData(mBuffer[mNextBuffer], format, data, size, freq);
237
+    alBufferData(mBuffer[mNextBuffer], format, data, size, freq);
238 238
 
239
-   alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
239
+    alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
240 240
 
241
-	if (flags & SoundFlagsLoop)
242
-	{
243
-		alSourcei(mSource[mNextSource], AL_LOOPING, 1);
244
-	}
241
+    if (flags & SoundFlagsLoop)
242
+    {
243
+        alSourcei(mSource[mNextSource], AL_LOOPING, 1);
244
+    }
245 245
 
246
-   ++mNextBuffer;
247
-   ++mNextSource;
246
+    ++mNextBuffer;
247
+    ++mNextSource;
248 248
 
249
-	*source = mNextBuffer;
249
+    *source = mNextBuffer;
250 250
 
251
-   return 0;
251
+    return 0;
252 252
 #else
253
-	return -1;
253
+    return -1;
254 254
 #endif
255 255
 }
256 256
 
257 257
 
258 258
 void Sound::play(int source)
259 259
 {
260
-	if (!mInit)
261
-	{
262
-		printf("Sound::Play> ERROR: Sound not initialized\n");
263
-		return;
264
-	}
265
-
266
-	if (source < 0)
267
-	{
268
-		printf("Sound::Play> ERROR: Source Id invalid\n");
269
-		return;
270
-	}
260
+    if (!mInit)
261
+    {
262
+        printf("Sound::Play> ERROR: Sound not initialized\n");
263
+        return;
264
+    }
265
+
266
+    if (source < 0)
267
+    {
268
+        printf("Sound::Play> ERROR: Source Id invalid\n");
269
+        return;
270
+    }
271 271
 
272 272
 #ifdef USING_OPENAL
273
-	alSourcePlay(mSource[source-1]);
273
+    alSourcePlay(mSource[source-1]);
274 274
 #endif
275 275
 }
276 276
 
277 277
 
278 278
 void Sound::stop(int source)
279 279
 {
280
-	if (!mInit || source < 0)
281
-	{
282
-		printf("Sound::Stop> ERROR pre condition assertion failed\n");
283
-		return;
284
-	}
280
+    if (!mInit || source < 0)
281
+    {
282
+        printf("Sound::Stop> ERROR pre condition assertion failed\n");
283
+        return;
284
+    }
285 285
 
286 286
 #ifdef USING_OPENAL
287
-	alSourceStop(mSource[source-1]);
287
+    alSourceStop(mSource[source-1]);
288 288
 #endif
289 289
 }
290 290
 

+ 514
- 514
src/System.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 878
- 878
src/Texture.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 5655
- 5655
src/TombRaider.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 54
- 54
src/Vector3d.cpp Переглянути файл

@@ -30,23 +30,23 @@
30 30
 
31 31
 Vector3d::Vector3d()
32 32
 {
33
-	mVec[0] = mVec[1] = mVec[2] = 0.0f;
33
+    mVec[0] = mVec[1] = mVec[2] = 0.0f;
34 34
 }
35 35
 
36 36
 
37 37
 Vector3d::Vector3d(vec3_t v)
38 38
 {
39
-	mVec[0] = v[0];
40
-	mVec[1] = v[1];
41
-	mVec[2] = v[2];
39
+    mVec[0] = v[0];
40
+    mVec[1] = v[1];
41
+    mVec[2] = v[2];
42 42
 }
43 43
 
44 44
 
45 45
 Vector3d::Vector3d(vec_t x, vec_t y, vec_t z)
46 46
 {
47
-	mVec[0] = x;
48
-	mVec[1] = y;
49
-	mVec[2] = z;
47
+    mVec[0] = x;
48
+    mVec[1] = y;
49
+    mVec[2] = z;
50 50
 }
51 51
 
52 52
 
@@ -61,91 +61,91 @@ Vector3d::~Vector3d()
61 61
 
62 62
 vec_t Vector3d::dot(const Vector3d &u, const Vector3d &v)
63 63
 {
64
-	return (u.mVec[0]*v.mVec[0] + u.mVec[1]*v.mVec[1] + u.mVec[2]*v.mVec[2]);
64
+    return (u.mVec[0]*v.mVec[0] + u.mVec[1]*v.mVec[1] + u.mVec[2]*v.mVec[2]);
65 65
 }
66 66
 
67 67
 
68 68
 Vector3d Vector3d::cross(const Vector3d &u, const Vector3d &v)
69 69
 {
70
-	return Vector3d(u.mVec[1] * v.mVec[2] - u.mVec[2] * v.mVec[1],
71
-						 u.mVec[2] * v.mVec[0] - u.mVec[0] * v.mVec[2],
72
-						 u.mVec[0] * v.mVec[1] - u.mVec[1] * v.mVec[0]);
70
+    return Vector3d(u.mVec[1] * v.mVec[2] - u.mVec[2] * v.mVec[1],
71
+            u.mVec[2] * v.mVec[0] - u.mVec[0] * v.mVec[2],
72
+            u.mVec[0] * v.mVec[1] - u.mVec[1] * v.mVec[0]);
73 73
 }
74 74
 
75 75
 
76 76
 vec_t Vector3d::magnitude()
77 77
 {
78
-	return sqrt(mVec[0]*mVec[0] + mVec[1]*mVec[1] + mVec[2]*mVec[2]);
78
+    return sqrt(mVec[0]*mVec[0] + mVec[1]*mVec[1] + mVec[2]*mVec[2]);
79 79
 }
80 80
 
81 81
 
82 82
 Vector3d Vector3d::unit()
83 83
 {
84
-	vec_t norm = magnitude();
84
+    vec_t norm = magnitude();
85 85
 
86
-	return Vector3d(mVec[0] / norm,
87
-						 mVec[1] / norm,
88
-						 mVec[2] / norm);
86
+    return Vector3d(mVec[0] / norm,
87
+            mVec[1] / norm,
88
+            mVec[2] / norm);
89 89
 }
90 90
 
91 91
 
92 92
 Vector3d Vector3d::zeroVector()
93 93
 {
94
-	return Vector3d(0, 0, 0);
94
+    return Vector3d(0, 0, 0);
95 95
 }
96 96
 
97 97
 
98 98
 Vector3d Vector3d::operator +(const Vector3d &v)
99 99
 {
100
-	return Vector3d(mVec[0] + v.mVec[0],
101
-						 mVec[1] + v.mVec[1],
102
-						 mVec[2] + v.mVec[2]);
100
+    return Vector3d(mVec[0] + v.mVec[0],
101
+            mVec[1] + v.mVec[1],
102
+            mVec[2] + v.mVec[2]);
103 103
 }
104 104
 
105 105
 
106 106
 Vector3d Vector3d::operator -(const Vector3d &v)
107 107
 {
108
-	return Vector3d(mVec[0] - v.mVec[0],
109
-						 mVec[1] - v.mVec[1],
110
-						 mVec[2] - v.mVec[2]);
108
+    return Vector3d(mVec[0] - v.mVec[0],
109
+            mVec[1] - v.mVec[1],
110
+            mVec[2] - v.mVec[2]);
111 111
 }
112 112
 
113 113
 
114 114
 Vector3d Vector3d::operator -()
115 115
 {
116
-	return Vector3d(-mVec[0],
117
-						 -mVec[1],
118
-						 -mVec[2]);
116
+    return Vector3d(-mVec[0],
117
+            -mVec[1],
118
+            -mVec[2]);
119 119
 }
120 120
 
121 121
 
122 122
 Vector3d Vector3d::operator *(vec_t s)
123 123
 {
124
-	return Vector3d(s * mVec[0],
125
-						 s * mVec[1],
126
-						 s * mVec[2]);
124
+    return Vector3d(s * mVec[0],
125
+            s * mVec[1],
126
+            s * mVec[2]);
127 127
 }
128 128
 
129 129
 
130 130
 Vector3d Vector3d::operator /(vec_t s)
131 131
 {
132
-	return Vector3d(mVec[0] / s,
133
-						 mVec[1] / s,
134
-						 mVec[2] / s);
132
+    return Vector3d(mVec[0] / s,
133
+            mVec[1] / s,
134
+            mVec[2] / s);
135 135
 }
136 136
 
137 137
 
138 138
 vec_t Vector3d::operator *(const Vector3d &v)
139 139
 {
140
-	return dot(*this, v);
140
+    return dot(*this, v);
141 141
 }
142 142
 
143 143
 
144 144
 //Vector3d Vector3d::operator *(const Matrix &m)
145 145
 //{
146
-//	vec3_t v;
146
+//  vec3_t v;
147 147
 //
148
-//	return
148
+//  return
149 149
 //}
150 150
 
151 151
 
@@ -155,51 +155,51 @@ vec_t Vector3d::operator *(const Vector3d &v)
155 155
 
156 156
 void Vector3d::normalize()
157 157
 {
158
-	vec_t norm = magnitude();
158
+    vec_t norm = magnitude();
159 159
 
160
-	mVec[0] /= norm;
161
-	mVec[1] /= norm;
162
-	mVec[2] /= norm;
160
+    mVec[0] /= norm;
161
+    mVec[1] /= norm;
162
+    mVec[2] /= norm;
163 163
 }
164 164
 
165 165
 
166 166
 void Vector3d::zero()
167 167
 {
168
-	mVec[0] = 0;
169
-	mVec[1] = 0;
170
-	mVec[2] = 0;
168
+    mVec[0] = 0;
169
+    mVec[1] = 0;
170
+    mVec[2] = 0;
171 171
 }
172 172
 
173 173
 
174 174
 void Vector3d::operator =(const Vector3d &v)
175 175
 {
176
-	mVec[0] = v.mVec[0];
177
-	mVec[1] = v.mVec[1];
178
-	mVec[2] = v.mVec[2];
176
+    mVec[0] = v.mVec[0];
177
+    mVec[1] = v.mVec[1];
178
+    mVec[2] = v.mVec[2];
179 179
 }
180 180
 
181 181
 
182 182
 void Vector3d::operator +=(const Vector3d &v)
183 183
 {
184
-	mVec[0] += v.mVec[0];
185
-	mVec[1] += v.mVec[1];
186
-	mVec[2] += v.mVec[2];
184
+    mVec[0] += v.mVec[0];
185
+    mVec[1] += v.mVec[1];
186
+    mVec[2] += v.mVec[2];
187 187
 }
188 188
 
189 189
 
190 190
 void Vector3d::operator -=(const Vector3d &v)
191 191
 {
192
-	mVec[0] -= v.mVec[0];
193
-	mVec[1] -= v.mVec[1];
194
-	mVec[2] -= v.mVec[2];
192
+    mVec[0] -= v.mVec[0];
193
+    mVec[1] -= v.mVec[1];
194
+    mVec[2] -= v.mVec[2];
195 195
 }
196 196
 
197 197
 
198 198
 void Vector3d::operator *=(vec_t s)
199 199
 {
200
-	mVec[0] *= s;
201
-	mVec[1] *= s;
202
-	mVec[2] *= s;
200
+    mVec[0] *= s;
201
+    mVec[1] *= s;
202
+    mVec[2] *= s;
203 203
 }
204 204
 
205 205
 

+ 231
- 231
src/ViewVolume.cpp Переглянути файл

@@ -46,176 +46,176 @@ ViewVolume::~ViewVolume()
46 46
 
47 47
 bool ViewVolume::isBoundingVolumeInFrustum(BoundingVolume bvol)
48 48
 {
49
-	return (isBoundingSphereInFrustum(bvol.mSphere) &&
50
-			  isBoundingBoxInFrustum(bvol.mBox));
49
+    return (isBoundingSphereInFrustum(bvol.mSphere) &&
50
+            isBoundingBoxInFrustum(bvol.mBox));
51 51
 }
52 52
 
53 53
 
54 54
 bool ViewVolume::isBoundingSphereInFrustum(BoundingSphere bvol)
55 55
 {
56
-	return (isSphereInFrustum(bvol.mCenter[0],
57
-									  bvol.mCenter[1],
58
-									  bvol.mCenter[2],
59
-									  bvol.mRadius));
56
+    return (isSphereInFrustum(bvol.mCenter[0],
57
+                bvol.mCenter[1],
58
+                bvol.mCenter[2],
59
+                bvol.mRadius));
60 60
 }
61 61
 
62 62
 
63 63
 bool ViewVolume::isBoundingBoxInFrustum(BoundingBox bvol)
64 64
 {
65
-	return (isBboxInFrustum(bvol.mMin, bvol.mMax));
65
+    return (isBboxInFrustum(bvol.mMin, bvol.mMax));
66 66
 }
67 67
 
68 68
 
69 69
 bool ViewVolume::isPointInFrustum(vec_t x, vec_t y, vec_t z)
70 70
 {
71
-   unsigned int p;
71
+    unsigned int p;
72 72
 
73 73
 
74
-   for (p = 0; p < 6; ++p)
75
-	{
76
-      if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z +
77
-			 mFrustum[p][3] <= 0)
78
-		{
79
-         return false;
80
-		}
81
-	}
74
+    for (p = 0; p < 6; ++p)
75
+    {
76
+        if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z +
77
+                mFrustum[p][3] <= 0)
78
+        {
79
+            return false;
80
+        }
81
+    }
82 82
 
83
-   return true;
83
+    return true;
84 84
 }
85 85
 
86 86
 
87 87
 bool ViewVolume::isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius)
88 88
 {
89
-   unsigned int p;
90
-   vec_t d;
89
+    unsigned int p;
90
+    vec_t d;
91 91
 
92 92
 
93
-   for (p = 0; p < 6; ++p)
94
-   {
95
-      d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
96
-      if (d <= -radius)
97
-         return false;
98
-   }
93
+    for (p = 0; p < 6; ++p)
94
+    {
95
+        d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
96
+        if (d <= -radius)
97
+            return false;
98
+    }
99 99
 
100
-   return true;
100
+    return true;
101 101
 }
102 102
 
103 103
 
104 104
 bool ViewVolume::isBboxInFrustum(vec3_t min, vec3_t max)
105 105
 {
106
-   unsigned int p;
107
-
108
-
109
-   for (p = 0; p < 6; ++p)
110
-   {
111
-      if (mFrustum[p][0] * min[0] +
112
-			 mFrustum[p][1] * min[1] +
113
-			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
114
-         continue;
115
-
116
-      if (mFrustum[p][0] * max[0] +
117
-			 mFrustum[p][1] * max[1] +
118
-			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
119
-         continue;
120
-
121
-      if (mFrustum[p][0] * min[0] +
122
-			 mFrustum[p][1] * max[1] +
123
-			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
124
-         continue;
125
-
126
-      if (mFrustum[p][0] * min[0] +
127
-			 mFrustum[p][1] * min[1] +
128
-			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
129
-         continue;
130
-
131
-      if (mFrustum[p][0] * min[0] +
132
-			 mFrustum[p][1] * max[1] +
133
-			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
134
-         continue;
135
-
136
-      if (mFrustum[p][0] * max[0] +
137
-			 mFrustum[p][1] * min[1] +
138
-			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
139
-         continue;
140
-
141
-      if (mFrustum[p][0] * max[0] +
142
-			 mFrustum[p][1] * max[1] +
143
-			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
144
-         continue;
145
-
146
-      if (mFrustum[p][0] * max[0] +
147
-			 mFrustum[p][1] * min[1] +
148
-			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
149
-         continue;
150
-
151
-      return false;
152
-   }
153
-
154
-   return true;
106
+    unsigned int p;
107
+
108
+
109
+    for (p = 0; p < 6; ++p)
110
+    {
111
+        if (mFrustum[p][0] * min[0] +
112
+                mFrustum[p][1] * min[1] +
113
+                mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
114
+            continue;
115
+
116
+        if (mFrustum[p][0] * max[0] +
117
+                mFrustum[p][1] * max[1] +
118
+                mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
119
+            continue;
120
+
121
+        if (mFrustum[p][0] * min[0] +
122
+                mFrustum[p][1] * max[1] +
123
+                mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
124
+            continue;
125
+
126
+        if (mFrustum[p][0] * min[0] +
127
+                mFrustum[p][1] * min[1] +
128
+                mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
129
+            continue;
130
+
131
+        if (mFrustum[p][0] * min[0] +
132
+                mFrustum[p][1] * max[1] +
133
+                mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
134
+            continue;
135
+
136
+        if (mFrustum[p][0] * max[0] +
137
+                mFrustum[p][1] * min[1] +
138
+                mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
139
+            continue;
140
+
141
+        if (mFrustum[p][0] * max[0] +
142
+                mFrustum[p][1] * max[1] +
143
+                mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
144
+            continue;
145
+
146
+        if (mFrustum[p][0] * max[0] +
147
+                mFrustum[p][1] * min[1] +
148
+                mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
149
+            continue;
150
+
151
+        return false;
152
+    }
153
+
154
+    return true;
155 155
 }
156 156
 
157 157
 
158 158
 vec_t ViewVolume::getDistToSphereFromNear(vec_t x, vec_t y, vec_t z,
159
-														vec_t radius)
159
+        vec_t radius)
160 160
 {
161
-   unsigned int p;
162
-   vec_t d = 0.0;
161
+    unsigned int p;
162
+    vec_t d = 0.0;
163 163
 
164
-   for (p = 0; p < 6; ++p)
165
-   {
166
-      d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
167
-      if (d <= -radius)
168
-         return 0;
169
-   }
164
+    for (p = 0; p < 6; ++p)
165
+    {
166
+        d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
167
+        if (d <= -radius)
168
+            return 0;
169
+    }
170 170
 
171
-   return d + radius;
171
+    return d + radius;
172 172
 }
173 173
 
174 174
 
175 175
 vec_t ViewVolume::getDistToBboxFromNear(vec3_t min, vec3_t max)
176 176
 {
177
-	vec3_t center;
178
-   vec_t d, radius;
177
+    vec3_t center;
178
+    vec_t d, radius;
179 179
 
180 180
 
181
-	helMidpoint3v(min, max, center);
181
+    helMidpoint3v(min, max, center);
182 182
 
183
-	// 5 should be near plane
184
-	d = (mFrustum[5][0] * center[0] +
185
-		  mFrustum[5][1] * center[1] +
186
-		  mFrustum[5][2] * center[2] +
187
-		  mFrustum[5][3]);
183
+    // 5 should be near plane
184
+    d = (mFrustum[5][0] * center[0] +
185
+            mFrustum[5][1] * center[1] +
186
+            mFrustum[5][2] * center[2] +
187
+            mFrustum[5][3]);
188 188
 
189
-	radius = helDist3v(max, center);
189
+    radius = helDist3v(max, center);
190 190
 
191
-	if (d <= -radius)
192
-		return 0;
191
+    if (d <= -radius)
192
+        return 0;
193 193
 
194
-   return d + radius;
194
+    return d + radius;
195 195
 }
196 196
 
197 197
 
198 198
 void ViewVolume::getFrustum(vec_t frustum[6][4])
199 199
 {
200
-	unsigned int plane;
200
+    unsigned int plane;
201 201
 
202 202
 
203
-	for (plane = 0; plane < 6; ++plane)
204
-   {
205
-		frustum[plane][0] = mFrustum[plane][0];
206
-		frustum[plane][1] = mFrustum[plane][1];
207
-		frustum[plane][2] = mFrustum[plane][2];
208
-		frustum[plane][3] = mFrustum[plane][3];
209
-	}
203
+    for (plane = 0; plane < 6; ++plane)
204
+    {
205
+        frustum[plane][0] = mFrustum[plane][0];
206
+        frustum[plane][1] = mFrustum[plane][1];
207
+        frustum[plane][2] = mFrustum[plane][2];
208
+        frustum[plane][3] = mFrustum[plane][3];
209
+    }
210 210
 }
211 211
 
212 212
 
213 213
 void ViewVolume::getPlane(ViewVolumeSide p, vec4_t plane)
214 214
 {
215
-	plane[0] =  mFrustum[p][0];
216
-	plane[1] =  mFrustum[p][1];
217
-	plane[2] =  mFrustum[p][2];
218
-	plane[3] =  mFrustum[p][3];
215
+    plane[0] =  mFrustum[p][0];
216
+    plane[1] =  mFrustum[p][1];
217
+    plane[2] =  mFrustum[p][2];
218
+    plane[3] =  mFrustum[p][3];
219 219
 }
220 220
 
221 221
 
@@ -225,42 +225,42 @@ void ViewVolume::getPlane(ViewVolumeSide p, vec4_t plane)
225 225
 
226 226
 void ViewVolume::updateFrame(matrix_t proj, matrix_t mdl)
227 227
 {
228
-	setModel(mdl);
229
-	setProjection(proj);
230
-	updateClip();
231
-	updateFrustum();
228
+    setModel(mdl);
229
+    setProjection(proj);
230
+    updateClip();
231
+    updateFrustum();
232 232
 }
233 233
 
234 234
 
235 235
 void ViewVolume::updateFrame()
236 236
 {
237
-	updateClip();
238
-	updateFrustum();
237
+    updateClip();
238
+    updateFrustum();
239 239
 }
240 240
 
241 241
 
242 242
 void ViewVolume::setModel(matrix_t mdl)
243 243
 {
244
-	mModel.setMatrix(mdl);
244
+    mModel.setMatrix(mdl);
245 245
 }
246 246
 
247 247
 
248 248
 void ViewVolume::setProjection(matrix_t proj)
249 249
 {
250
-	/*void setProjection(viewAngle, aspectRatio, near, far)
251
-    ****************************
252
-	 *float far = 4000.0f;
253
-	 *float near = 4.0f;
254
-	 *float viewAngle = 45.0f;
255
-	 *float aspectRatio = 800.0f/600.0f;
256
-	 ****************************
257
-	 *float top = near * tan(PI/180 * viewAngle/2)
258
-    *float bottom = -top
259
-    *float right = top * aspectRatio
260
-    *float left = - right
261
-	 */
262
-
263
-	mProjection.setMatrix(proj);
250
+    /*void setProjection(viewAngle, aspectRatio, near, far)
251
+     ****************************
252
+     *float far = 4000.0f;
253
+     *float near = 4.0f;
254
+     *float viewAngle = 45.0f;
255
+     *float aspectRatio = 800.0f/600.0f;
256
+     ****************************
257
+     *float top = near * tan(PI/180 * viewAngle/2)
258
+     *float bottom = -top
259
+     *float right = top * aspectRatio
260
+     *float left = - right
261
+     */
262
+
263
+    mProjection.setMatrix(proj);
264 264
 }
265 265
 
266 266
 
@@ -276,108 +276,108 @@ void ViewVolume::setProjection(matrix_t proj)
276 276
 
277 277
 void ViewVolume::updateClip()
278 278
 {
279
-	//mClip = mModel * mProjection;
280
-	mClip = mProjection * mModel;
279
+    //mClip = mModel * mProjection;
280
+    mClip = mProjection * mModel;
281 281
 }
282 282
 
283 283
 
284 284
 void ViewVolume::updateFrustum()
285 285
 {
286
-	matrix_t clip;
287
-	vec_t t;
288
-
289
-
290
-	mClip.getMatrix(clip);
291
-
292
-   /* Extract the numbers for the RIGHT plane */
293
-   mFrustum[0][0] = clip[ 3] - clip[ 0];
294
-   mFrustum[0][1] = clip[ 7] - clip[ 4];
295
-   mFrustum[0][2] = clip[11] - clip[ 8];
296
-   mFrustum[0][3] = clip[15] - clip[12];
297
-
298
-   /* Normalize the result */
299
-   t = sqrt(mFrustum[0][0] * mFrustum[0][0] +
300
-				mFrustum[0][1] * mFrustum[0][1] +
301
-				mFrustum[0][2] * mFrustum[0][2]);
302
-   mFrustum[0][0] /= t;
303
-   mFrustum[0][1] /= t;
304
-   mFrustum[0][2] /= t;
305
-   mFrustum[0][3] /= t;
306
-
307
-   /* Extract the numbers for the LEFT plane */
308
-   mFrustum[1][0] = clip[ 3] + clip[ 0];
309
-   mFrustum[1][1] = clip[ 7] + clip[ 4];
310
-   mFrustum[1][2] = clip[11] + clip[ 8];
311
-   mFrustum[1][3] = clip[15] + clip[12];
312
-
313
-   /* Normalize the result */
314
-   t = sqrt(mFrustum[1][0] * mFrustum[1][0] +
315
-				mFrustum[1][1] * mFrustum[1][1] +
316
-				mFrustum[1][2] * mFrustum[1][2]);
317
-   mFrustum[1][0] /= t;
318
-   mFrustum[1][1] /= t;
319
-   mFrustum[1][2] /= t;
320
-   mFrustum[1][3] /= t;
321
-
322
-   /* Extract the BOTTOM plane */
323
-   mFrustum[2][0] = clip[ 3] + clip[ 1];
324
-   mFrustum[2][1] = clip[ 7] + clip[ 5];
325
-   mFrustum[2][2] = clip[11] + clip[ 9];
326
-   mFrustum[2][3] = clip[15] + clip[13];
327
-
328
-   /* Normalize the result */
329
-   t = sqrt(mFrustum[2][0] * mFrustum[2][0] +
330
-				mFrustum[2][1] * mFrustum[2][1] +
331
-				mFrustum[2][2] * mFrustum[2][2]);
332
-   mFrustum[2][0] /= t;
333
-   mFrustum[2][1] /= t;
334
-   mFrustum[2][2] /= t;
335
-   mFrustum[2][3] /= t;
336
-
337
-   /* Extract the TOP plane */
338
-   mFrustum[3][0] = clip[ 3] - clip[ 1];
339
-   mFrustum[3][1] = clip[ 7] - clip[ 5];
340
-   mFrustum[3][2] = clip[11] - clip[ 9];
341
-   mFrustum[3][3] = clip[15] - clip[13];
342
-
343
-   /* Normalize the result */
344
-   t = sqrt(mFrustum[3][0] * mFrustum[3][0] +
345
-				mFrustum[3][1] * mFrustum[3][1] +
346
-				mFrustum[3][2] * mFrustum[3][2]);
347
-   mFrustum[3][0] /= t;
348
-   mFrustum[3][1] /= t;
349
-   mFrustum[3][2] /= t;
350
-   mFrustum[3][3] /= t;
351
-
352
-   /* Extract the FAR plane */
353
-   mFrustum[4][0] = clip[ 3] - clip[ 2];
354
-   mFrustum[4][1] = clip[ 7] - clip[ 6];
355
-   mFrustum[4][2] = clip[11] - clip[10];
356
-   mFrustum[4][3] = clip[15] - clip[14];
357
-
358
-   /* Normalize the result */
359
-   t = sqrt(mFrustum[4][0] * mFrustum[4][0] +
360
-				mFrustum[4][1] * mFrustum[4][1] +
361
-				mFrustum[4][2] * mFrustum[4][2]);
362
-   mFrustum[4][0] /= t;
363
-   mFrustum[4][1] /= t;
364
-   mFrustum[4][2] /= t;
365
-   mFrustum[4][3] /= t;
366
-
367
-   /* Extract the NEAR plane */
368
-   mFrustum[5][0] = clip[ 3] + clip[ 2];
369
-   mFrustum[5][1] = clip[ 7] + clip[ 6];
370
-   mFrustum[5][2] = clip[11] + clip[10];
371
-   mFrustum[5][3] = clip[15] + clip[14];
372
-
373
-   /* Normalize the result */
374
-   t = sqrt(mFrustum[5][0] * mFrustum[5][0] +
375
-				mFrustum[5][1] * mFrustum[5][1] +
376
-				mFrustum[5][2] * mFrustum[5][2]);
377
-   mFrustum[5][0] /= t;
378
-   mFrustum[5][1] /= t;
379
-   mFrustum[5][2] /= t;
380
-   mFrustum[5][3] /= t;
286
+    matrix_t clip;
287
+    vec_t t;
288
+
289
+
290
+    mClip.getMatrix(clip);
291
+
292
+    /* Extract the numbers for the RIGHT plane */
293
+    mFrustum[0][0] = clip[ 3] - clip[ 0];
294
+    mFrustum[0][1] = clip[ 7] - clip[ 4];
295
+    mFrustum[0][2] = clip[11] - clip[ 8];
296
+    mFrustum[0][3] = clip[15] - clip[12];
297
+
298
+    /* Normalize the result */
299
+    t = sqrt(mFrustum[0][0] * mFrustum[0][0] +
300
+            mFrustum[0][1] * mFrustum[0][1] +
301
+            mFrustum[0][2] * mFrustum[0][2]);
302
+    mFrustum[0][0] /= t;
303
+    mFrustum[0][1] /= t;
304
+    mFrustum[0][2] /= t;
305
+    mFrustum[0][3] /= t;
306
+
307
+    /* Extract the numbers for the LEFT plane */
308
+    mFrustum[1][0] = clip[ 3] + clip[ 0];
309
+    mFrustum[1][1] = clip[ 7] + clip[ 4];
310
+    mFrustum[1][2] = clip[11] + clip[ 8];
311
+    mFrustum[1][3] = clip[15] + clip[12];
312
+
313
+    /* Normalize the result */
314
+    t = sqrt(mFrustum[1][0] * mFrustum[1][0] +
315
+            mFrustum[1][1] * mFrustum[1][1] +
316
+            mFrustum[1][2] * mFrustum[1][2]);
317
+    mFrustum[1][0] /= t;
318
+    mFrustum[1][1] /= t;
319
+    mFrustum[1][2] /= t;
320
+    mFrustum[1][3] /= t;
321
+
322
+    /* Extract the BOTTOM plane */
323
+    mFrustum[2][0] = clip[ 3] + clip[ 1];
324
+    mFrustum[2][1] = clip[ 7] + clip[ 5];
325
+    mFrustum[2][2] = clip[11] + clip[ 9];
326
+    mFrustum[2][3] = clip[15] + clip[13];
327
+
328
+    /* Normalize the result */
329
+    t = sqrt(mFrustum[2][0] * mFrustum[2][0] +
330
+            mFrustum[2][1] * mFrustum[2][1] +
331
+            mFrustum[2][2] * mFrustum[2][2]);
332
+    mFrustum[2][0] /= t;
333
+    mFrustum[2][1] /= t;
334
+    mFrustum[2][2] /= t;
335
+    mFrustum[2][3] /= t;
336
+
337
+    /* Extract the TOP plane */
338
+    mFrustum[3][0] = clip[ 3] - clip[ 1];
339
+    mFrustum[3][1] = clip[ 7] - clip[ 5];
340
+    mFrustum[3][2] = clip[11] - clip[ 9];
341
+    mFrustum[3][3] = clip[15] - clip[13];
342
+
343
+    /* Normalize the result */
344
+    t = sqrt(mFrustum[3][0] * mFrustum[3][0] +
345
+            mFrustum[3][1] * mFrustum[3][1] +
346
+            mFrustum[3][2] * mFrustum[3][2]);
347
+    mFrustum[3][0] /= t;
348
+    mFrustum[3][1] /= t;
349
+    mFrustum[3][2] /= t;
350
+    mFrustum[3][3] /= t;
351
+
352
+    /* Extract the FAR plane */
353
+    mFrustum[4][0] = clip[ 3] - clip[ 2];
354
+    mFrustum[4][1] = clip[ 7] - clip[ 6];
355
+    mFrustum[4][2] = clip[11] - clip[10];
356
+    mFrustum[4][3] = clip[15] - clip[14];
357
+
358
+    /* Normalize the result */
359
+    t = sqrt(mFrustum[4][0] * mFrustum[4][0] +
360
+            mFrustum[4][1] * mFrustum[4][1] +
361
+            mFrustum[4][2] * mFrustum[4][2]);
362
+    mFrustum[4][0] /= t;
363
+    mFrustum[4][1] /= t;
364
+    mFrustum[4][2] /= t;
365
+    mFrustum[4][3] /= t;
366
+
367
+    /* Extract the NEAR plane */
368
+    mFrustum[5][0] = clip[ 3] + clip[ 2];
369
+    mFrustum[5][1] = clip[ 7] + clip[ 6];
370
+    mFrustum[5][2] = clip[11] + clip[10];
371
+    mFrustum[5][3] = clip[15] + clip[14];
372
+
373
+    /* Normalize the result */
374
+    t = sqrt(mFrustum[5][0] * mFrustum[5][0] +
375
+            mFrustum[5][1] * mFrustum[5][1] +
376
+            mFrustum[5][2] * mFrustum[5][2]);
377
+    mFrustum[5][0] /= t;
378
+    mFrustum[5][1] /= t;
379
+    mFrustum[5][2] /= t;
380
+    mFrustum[5][3] /= t;
381 381
 }
382 382
 
383 383
 
@@ -388,17 +388,17 @@ void ViewVolume::updateFrustum()
388 388
 #ifdef UNIT_TEST_VIEWVOLUME
389 389
 int runViewVolumeUnitTest(int argc, char *argv[])
390 390
 {
391
-	return 0;
391
+    return 0;
392 392
 }
393 393
 
394 394
 
395 395
 int main(int argc, char *argv[])
396 396
 {
397
-	ViewVolume test;
397
+    ViewVolume test;
398 398
 
399 399
 
400
-	printf("[ViewVolume class test]\n");
400
+    printf("[ViewVolume class test]\n");
401 401
 
402
-	return runViewVolumeUnitTest(argc, argv);
402
+    return runViewVolumeUnitTest(argc, argv);
403 403
 }
404 404
 #endif

+ 532
- 532
src/World.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 895
- 895
src/memory_test.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 392
- 392
src/tga.cpp Переглянути файл

@@ -36,458 +36,458 @@
36 36
 
37 37
 int mtk_image__tga_check(FILE *f)
38 38
 {
39
-  char buffer[10];
39
+    char buffer[10];
40 40
 
41 41
 
42
-  if (!f)
43
-  {
44
-    perror("tga_check> Passed invalid file.\n");
45
-    return -1;
46
-  }
42
+    if (!f)
43
+    {
44
+        perror("tga_check> Passed invalid file.\n");
45
+        return -1;
46
+    }
47 47
 
48
-  /* Read the header */
49
-  fseek(f, 0, SEEK_SET);
50
-  fread(buffer, 8, 1, f);
48
+    /* Read the header */
49
+    fseek(f, 0, SEEK_SET);
50
+    fread(buffer, 8, 1, f);
51 51
 
52
-  // buffer[1] = 0 - Means not color mapped ( 1 would mean mapped )
53
-  if (!(buffer[1] == 0 && (buffer[2] == TGA_TYPE__COLOR ||
54
-			   //buffer[2] == TGA_TYPE__GREYSCALE ||
55
-			   buffer[2] == TGA_TYPE__COLOR_RLE)))
56
-  {
57
-    printf("tga_check> Inavlid or unknown TGA format.\n");
58
-    return -2;
59
-  }
52
+    // buffer[1] = 0 - Means not color mapped ( 1 would mean mapped )
53
+    if (!(buffer[1] == 0 && (buffer[2] == TGA_TYPE__COLOR ||
54
+                    //buffer[2] == TGA_TYPE__GREYSCALE ||
55
+                    buffer[2] == TGA_TYPE__COLOR_RLE)))
56
+    {
57
+        printf("tga_check> Inavlid or unknown TGA format.\n");
58
+        return -2;
59
+    }
60 60
 
61
-  return 0;
61
+    return 0;
62 62
 }
63 63
 
64 64
 
65 65
 int mtk_image__tga_load(FILE *f, unsigned char **image,
66
-			unsigned int *width, unsigned int *height, char *type)
66
+        unsigned int *width, unsigned int *height, char *type)
67 67
 {
68
-  mtk_image_tga_t header;
69
-  char comment[256];
70
-  unsigned char pixel[4];
71
-  unsigned char *swap_row = NULL;
72
-  unsigned char tmp, packet;
73
-  bool must_flip = 0;
74
-  unsigned int size;
75
-  unsigned int i, j;
76
-
77
-
78
-  if (!f)
79
-  {
80
-    fprintf(stderr, "mtk_image__tga_load> Invalid parameters.\n");
81
-    return -1;
82
-  }
83
-
84
-  fseek(f, 0, SEEK_SET);
85
-
86
-  // Read TGA header
87
-  fread(&header.comment_lenght, 1, 1, f);
88
-  fread(&header.colormap_type, 1, 1, f);
89
-  fread(&header.image_type, 1, 1, f);
90
-  fread(&header.colormap_index, 2, 1, f);
91
-  fread(&header.colormap_lenght, 2, 1, f);
92
-  fread(&header.colormap_bbp, 1, 1, f);
93
-
94
-  fread(&tmp, 1, 1, f);
95
-  header.origin_x = tmp;
96
-  fread(&tmp, 1, 1, f);
97
-  header.origin_x += tmp * 256;
98
-
99
-  fread(&tmp, 1, 1, f);
100
-  header.origin_y = tmp;
101
-  fread(&tmp, 1, 1, f);
102
-  header.origin_y += tmp * 256;
103
-
104
-  fread(&tmp, 1, 1, f);
105
-  header.width = tmp;
106
-  fread(&tmp, 1, 1, f);
107
-  header.width += tmp * 256;
108
-
109
-  fread(&tmp, 1, 1, f);
110
-  header.height = tmp;
111
-  fread(&tmp, 1, 1, f);
112
-  header.height += tmp * 256;
113
-
114
-  fread(&header.bpp, 1, 1, f);
115
-  fread(&header.desc_flags, 1, 1, f);
116
-
117
-  *width = header.width;
118
-  *height = header.height;
119
-
120
-  switch (header.bpp)
121
-  {
122
-  case 32:
123
-    *type = 2;//32;
124
-    break;
125
-  case 24:
126
-    *type = 1;//24;
127
-    break;
128
-  case 8:
129
-    *type = 0;//8;
130
-    break;
131
-  default:
132
-    *type = 0;
133
-  }
68
+    mtk_image_tga_t header;
69
+    char comment[256];
70
+    unsigned char pixel[4];
71
+    unsigned char *swap_row = NULL;
72
+    unsigned char tmp, packet;
73
+    bool must_flip = 0;
74
+    unsigned int size;
75
+    unsigned int i, j;
134 76
 
135
-#ifdef DEBUG_TGA
136
-  printf("TGA [%ix%i@%ibpp, %it, %ix, %iy, %uf]\n",
137
-	 header.width, header.height, header.bpp, header.image_type,
138
-	 header.origin_x, header.origin_y,
139
-	 header.desc_flags);
140
-#endif
141 77
 
142
-  // Comments can be 0 - 255
143
-  if (header.comment_lenght)
144
-  {
145
-    fread(&comment, 1, header.comment_lenght, f);
146
-
147
-    for (i = 0; i < 255; ++i)
78
+    if (!f)
148 79
     {
149
-      if (comment[i] > 32 && comment[i] < 127)
150
-      {
151
-      }
152
-      else
153
-      {
154
-	comment[i] = 183; // print a dot for invalid text
155
-      }
80
+        fprintf(stderr, "mtk_image__tga_load> Invalid parameters.\n");
81
+        return -1;
156 82
     }
157 83
 
158
-    comment[255] = 0;
84
+    fseek(f, 0, SEEK_SET);
85
+
86
+    // Read TGA header
87
+    fread(&header.comment_lenght, 1, 1, f);
88
+    fread(&header.colormap_type, 1, 1, f);
89
+    fread(&header.image_type, 1, 1, f);
90
+    fread(&header.colormap_index, 2, 1, f);
91
+    fread(&header.colormap_lenght, 2, 1, f);
92
+    fread(&header.colormap_bbp, 1, 1, f);
159 93
 
160
-    printf("Comment: '%s'\n", comment);
161
-  }
94
+    fread(&tmp, 1, 1, f);
95
+    header.origin_x = tmp;
96
+    fread(&tmp, 1, 1, f);
97
+    header.origin_x += tmp * 256;
162 98
 
163
-  size = header.width * header.height;
99
+    fread(&tmp, 1, 1, f);
100
+    header.origin_y = tmp;
101
+    fread(&tmp, 1, 1, f);
102
+    header.origin_y += tmp * 256;
164 103
 
165
-  if (!size || (!(header.colormap_type == 0 &&
166
-		  (header.image_type == 2 || header.image_type == 10))))
167
-  {
168
-    fprintf(stderr, "mtk_image__tga_load> Unknown image format.\n");
169
-    return -2;
170
-  }
104
+    fread(&tmp, 1, 1, f);
105
+    header.width = tmp;
106
+    fread(&tmp, 1, 1, f);
107
+    header.width += tmp * 256;
171 108
 
172
-  *image = NULL;
109
+    fread(&tmp, 1, 1, f);
110
+    header.height = tmp;
111
+    fread(&tmp, 1, 1, f);
112
+    header.height += tmp * 256;
173 113
 
174
-  // Mongoose: Added 'screen origin bit' support back here
175
-  if (!(header.desc_flags & 32))
176
-  {
177
-    must_flip = true;
178
-  }
114
+    fread(&header.bpp, 1, 1, f);
115
+    fread(&header.desc_flags, 1, 1, f);
179 116
 
180
-  switch (header.bpp)
181
-  {
182
-  case 32:
183
-    size *= 4;
184
-    *image = new unsigned char [size];
117
+    *width = header.width;
118
+    *height = header.height;
185 119
 
186
-    switch (header.image_type)
120
+    switch (header.bpp)
187 121
     {
188
-    case TGA_TYPE__COLOR_RLE:
189
-      for (i = 0; i < size;)
190
-      {
191
-	fread(&packet, 1, 1, f);
192
-
193
-	if (packet & 0x80)  // Run Lenght
194
-	{
195
-	  packet = (packet &0x7F) + 1;
196
-
197
-	  fread(&pixel, 4, 1, f);
198
-
199
-	  for (j = 0; j < packet; j++)
200
-	  {
201
-	    (*image)[i++] = pixel[2];
202
-	    (*image)[i++] = pixel[1];
203
-	    (*image)[i++] = pixel[0];
204
-	    (*image)[i++] = pixel[3];
205
-	  }
206
-	}
207
-	else // RAW
208
-	{
209
-	  packet = (packet &0x7F) + 1;
210
-
211
-	  for (j = 0; j < packet; j++)
212
-	  {
213
-	    fread(&pixel, 4, 1, f);
214
-
215
-	    (*image)[i++] = pixel[2];
216
-	    (*image)[i++] = pixel[1];
217
-	    (*image)[i++] = pixel[0];
218
-	    (*image)[i++] = pixel[3];
219
-	  }
220
-	}
221
-      }
222
-      break;
223
-    case TGA_TYPE__COLOR:
224
-      if (fread((*image), size, 1, f) < 1)
225
-      {
226
-	fprintf(stderr, "mtk_image__tga_load> Image fread failed.\n");
227
-	delete [] *image;
228
-	return -4;
229
-      }
230
-
231
-      for (i = 0; i < size; i += 4)
232
-      {
233
-	tmp = (*image)[i];
234
-	(*image)[i] = (*image)[i + 2];
235
-	(*image)[i + 2] = tmp;
236
-      }
237
-      break;
238
-    default:
239
-      ;
122
+        case 32:
123
+            *type = 2;//32;
124
+            break;
125
+        case 24:
126
+            *type = 1;//24;
127
+            break;
128
+        case 8:
129
+            *type = 0;//8;
130
+            break;
131
+        default:
132
+            *type = 0;
240 133
     }
241 134
 
242
-    if (must_flip)
135
+#ifdef DEBUG_TGA
136
+    printf("TGA [%ix%i@%ibpp, %it, %ix, %iy, %uf]\n",
137
+            header.width, header.height, header.bpp, header.image_type,
138
+            header.origin_x, header.origin_y,
139
+            header.desc_flags);
140
+#endif
141
+
142
+    // Comments can be 0 - 255
143
+    if (header.comment_lenght)
243 144
     {
244
-      swap_row = new unsigned char [header.width * 4];
145
+        fread(&comment, 1, header.comment_lenght, f);
146
+
147
+        for (i = 0; i < 255; ++i)
148
+        {
149
+            if (comment[i] > 32 && comment[i] < 127)
150
+            {
151
+            }
152
+            else
153
+            {
154
+                comment[i] = 183; // print a dot for invalid text
155
+            }
156
+        }
157
+
158
+        comment[255] = 0;
159
+
160
+        printf("Comment: '%s'\n", comment);
161
+    }
245 162
 
246
-      for (i = 0, j = header.height-1; (int)i < header.height/2; i++, j--)
247
-      {
248
-	memcpy(swap_row, &(*image)[i*header.width*4], header.width*4);
249
-	memcpy(&(*image)[i*header.width*4], &(*image)[j*header.width*4],
250
-	       header.width*4);
251
-	memcpy(&(*image)[j*header.width*4], swap_row, header.width*4);
252
-      }
163
+    size = header.width * header.height;
253 164
 
254
-      delete [] swap_row;
165
+    if (!size || (!(header.colormap_type == 0 &&
166
+                    (header.image_type == 2 || header.image_type == 10))))
167
+    {
168
+        fprintf(stderr, "mtk_image__tga_load> Unknown image format.\n");
169
+        return -2;
255 170
     }
256
-    break;
257
-  case 24:
258
-    size *= 3;
259
-    *image = new unsigned char [size];
260 171
 
261
-    switch (header.image_type)
172
+    *image = NULL;
173
+
174
+    // Mongoose: Added 'screen origin bit' support back here
175
+    if (!(header.desc_flags & 32))
262 176
     {
263
-    case TGA_TYPE__COLOR_RLE:
264
-      for (i = 0; i < size;)
265
-      {
266
-	fread(&packet, 1, 1, f);
267
-
268
-	if (packet & 0x80)  // Run Lenght
269
-	{
270
-	  packet = (packet &0x7F) + 1;
271
-
272
-	  fread(&pixel, 3, 1, f);
273
-
274
-	  for (j = 0; j < packet; j++)
275
-	  {
276
-	    (*image)[i++] = pixel[2];
277
-	    (*image)[i++] = pixel[1];
278
-	    (*image)[i++] = pixel[0];
279
-	  }
280
-	}
281
-	else // RAW
282
-	{
283
-	  packet = (packet &0x7F) + 1;
284
-
285
-	  for (j = 0; j < packet; j++)
286
-	  {
287
-	    fread(&pixel, 3, 1, f);
288
-
289
-	    (*image)[i++] = pixel[2];
290
-	    (*image)[i++] = pixel[1];
291
-	    (*image)[i++] = pixel[0];
292
-	  }
293
-	}
294
-      }
295
-      break;
296
-    case TGA_TYPE__COLOR:
297
-      if (fread((*image), size, 1, f) < 1)
298
-      {
299
-	fprintf(stderr, "mtk_image__tga_load> Image fread failed.\n");
300
-	delete [] *image;
301
-	return -4;
302
-      }
303
-
304
-      for (i = 0; i < size; i += 3)
305
-      {
306
-	tmp = (*image)[i];
307
-	(*image)[i] = (*image)[i + 2];
308
-	(*image)[i + 2] = tmp;
309
-      }
310
-      break;
311
-    default:
312
-      ;
177
+        must_flip = true;
313 178
     }
314 179
 
315
-    if (must_flip)
180
+    switch (header.bpp)
316 181
     {
317
-      swap_row = new unsigned char [header.width * 3];
318
-
319
-      for (i = 0, j = header.height - 1; (int)i < header.height / 2; i++, j--)
320
-      {
321
-	memcpy(swap_row, &(*image)[i*header.width*3], header.width*3);
322
-	memcpy(&(*image)[i*header.width*3], &(*image)[j*header.width*3],
323
-	       header.width*3);
324
-	memcpy(&(*image)[j*header.width*3], swap_row, header.width*3);
325
-      }
326
-
327
-      delete [] swap_row;
182
+        case 32:
183
+            size *= 4;
184
+            *image = new unsigned char [size];
185
+
186
+            switch (header.image_type)
187
+            {
188
+                case TGA_TYPE__COLOR_RLE:
189
+                    for (i = 0; i < size;)
190
+                    {
191
+                        fread(&packet, 1, 1, f);
192
+
193
+                        if (packet & 0x80)  // Run Lenght
194
+                        {
195
+                            packet = (packet &0x7F) + 1;
196
+
197
+                            fread(&pixel, 4, 1, f);
198
+
199
+                            for (j = 0; j < packet; j++)
200
+                            {
201
+                                (*image)[i++] = pixel[2];
202
+                                (*image)[i++] = pixel[1];
203
+                                (*image)[i++] = pixel[0];
204
+                                (*image)[i++] = pixel[3];
205
+                            }
206
+                        }
207
+                        else // RAW
208
+                        {
209
+                            packet = (packet &0x7F) + 1;
210
+
211
+                            for (j = 0; j < packet; j++)
212
+                            {
213
+                                fread(&pixel, 4, 1, f);
214
+
215
+                                (*image)[i++] = pixel[2];
216
+                                (*image)[i++] = pixel[1];
217
+                                (*image)[i++] = pixel[0];
218
+                                (*image)[i++] = pixel[3];
219
+                            }
220
+                        }
221
+                    }
222
+                    break;
223
+                case TGA_TYPE__COLOR:
224
+                    if (fread((*image), size, 1, f) < 1)
225
+                    {
226
+                        fprintf(stderr, "mtk_image__tga_load> Image fread failed.\n");
227
+                        delete [] *image;
228
+                        return -4;
229
+                    }
230
+
231
+                    for (i = 0; i < size; i += 4)
232
+                    {
233
+                        tmp = (*image)[i];
234
+                        (*image)[i] = (*image)[i + 2];
235
+                        (*image)[i + 2] = tmp;
236
+                    }
237
+                    break;
238
+                default:
239
+                    ;
240
+            }
241
+
242
+            if (must_flip)
243
+            {
244
+                swap_row = new unsigned char [header.width * 4];
245
+
246
+                for (i = 0, j = header.height-1; (int)i < header.height/2; i++, j--)
247
+                {
248
+                    memcpy(swap_row, &(*image)[i*header.width*4], header.width*4);
249
+                    memcpy(&(*image)[i*header.width*4], &(*image)[j*header.width*4],
250
+                            header.width*4);
251
+                    memcpy(&(*image)[j*header.width*4], swap_row, header.width*4);
252
+                }
253
+
254
+                delete [] swap_row;
255
+            }
256
+            break;
257
+        case 24:
258
+            size *= 3;
259
+            *image = new unsigned char [size];
260
+
261
+            switch (header.image_type)
262
+            {
263
+                case TGA_TYPE__COLOR_RLE:
264
+                    for (i = 0; i < size;)
265
+                    {
266
+                        fread(&packet, 1, 1, f);
267
+
268
+                        if (packet & 0x80)  // Run Lenght
269
+                        {
270
+                            packet = (packet &0x7F) + 1;
271
+
272
+                            fread(&pixel, 3, 1, f);
273
+
274
+                            for (j = 0; j < packet; j++)
275
+                            {
276
+                                (*image)[i++] = pixel[2];
277
+                                (*image)[i++] = pixel[1];
278
+                                (*image)[i++] = pixel[0];
279
+                            }
280
+                        }
281
+                        else // RAW
282
+                        {
283
+                            packet = (packet &0x7F) + 1;
284
+
285
+                            for (j = 0; j < packet; j++)
286
+                            {
287
+                                fread(&pixel, 3, 1, f);
288
+
289
+                                (*image)[i++] = pixel[2];
290
+                                (*image)[i++] = pixel[1];
291
+                                (*image)[i++] = pixel[0];
292
+                            }
293
+                        }
294
+                    }
295
+                    break;
296
+                case TGA_TYPE__COLOR:
297
+                    if (fread((*image), size, 1, f) < 1)
298
+                    {
299
+                        fprintf(stderr, "mtk_image__tga_load> Image fread failed.\n");
300
+                        delete [] *image;
301
+                        return -4;
302
+                    }
303
+
304
+                    for (i = 0; i < size; i += 3)
305
+                    {
306
+                        tmp = (*image)[i];
307
+                        (*image)[i] = (*image)[i + 2];
308
+                        (*image)[i + 2] = tmp;
309
+                    }
310
+                    break;
311
+                default:
312
+                    ;
313
+            }
314
+
315
+            if (must_flip)
316
+            {
317
+                swap_row = new unsigned char [header.width * 3];
318
+
319
+                for (i = 0, j = header.height - 1; (int)i < header.height / 2; i++, j--)
320
+                {
321
+                    memcpy(swap_row, &(*image)[i*header.width*3], header.width*3);
322
+                    memcpy(&(*image)[i*header.width*3], &(*image)[j*header.width*3],
323
+                            header.width*3);
324
+                    memcpy(&(*image)[j*header.width*3], swap_row, header.width*3);
325
+                }
326
+
327
+                delete [] swap_row;
328
+            }
329
+
330
+            break;
331
+        case 8:
332
+            printf("tga_load> 8bpp Not implemented\n");
333
+            break;
334
+        default:
335
+            ;
328 336
     }
329 337
 
330
-    break;
331
-  case 8:
332
-    printf("tga_load> 8bpp Not implemented\n");
333
-    break;
334
-  default:
335
-    ;
336
-  }
337
-
338 338
 #ifdef DEBUG_TGA
339
-  char c;
339
+    char c;
340 340
 
341
-  printf("Comment:\n");
341
+    printf("Comment:\n");
342 342
 
343
-  while (fread(&c, 1, 1, f) == 1)
344
-  {
345
-    printf("%c", c);
346
-  }
343
+    while (fread(&c, 1, 1, f) == 1)
344
+    {
345
+        printf("%c", c);
346
+    }
347 347
 
348
-  printf("\n");
348
+    printf("\n");
349 349
 #endif
350 350
 
351
-  return 0;
351
+    return 0;
352 352
 }
353 353
 
354 354
 
355 355
 int mtk_image__tga_save(FILE *f, unsigned char *image,
356
-			unsigned int width, unsigned int height, char type)
356
+        unsigned int width, unsigned int height, char type)
357 357
 {
358
-  mtk_image_tga_t header;
359
-  unsigned int size;
360
-  //  unsigned int i;
361
-  //  unsigned char tmp;
362
-  char comment[64];
363
-
364
-
365
-  if (!f || !image || !width || !height)
366
-  {
367
-    fprintf(stderr, "mtk_image__tga_save> Invalid parameters.\n");
368
-    return -1;
369
-  }
370
-
371
-  // Mongoose 2002.01.10, Heh, kind of silly
372
-  strncpy(comment, "Mongoose TGA 20030711", 63);
373
-  comment[63] = 0;
374
-
375
-  header.comment_lenght = strlen(comment);
376
-  header.colormap_type = 0;
377
-
378
-  // No colormaps
379
-  header.colormap_index = 0;
380
-  header.colormap_lenght = 0;
381
-  header.colormap_bbp = 0;
382
-
383
-  header.origin_x = header.origin_y = 0;
384
-  header.width = width;
385
-  header.height = height;
386
-
387
-  header.desc_flags = 0;
388
-
389
-  switch (type)
390
-  {
391
-  case 4:
392
-    header.image_type = TGA_TYPE__COLOR;
393
-    header.desc_flags = 32;
394
-    header.bpp = 32;
395
-    break;
396
-  case 2:
397
-    header.bpp = 32;
398
-    break;
399
-  case 1:
400
-    header.image_type = TGA_TYPE__GREYSCALE;
401
-    header.bpp = 8;
402
-    break;
403
-  default:
404
-    header.image_type = TGA_TYPE__COLOR;
405
-    header.bpp = 24;
406
-  }
407
-
408
-  // Write TGA header
409
-  fwrite(&header.comment_lenght, 1, 1, f);
410
-  fwrite(&header.colormap_type, 1, 1, f);
411
-  fwrite(&header.image_type, 1, 1, f);
412
-  fwrite(&header.colormap_index, 2, 1, f);
413
-  fwrite(&header.colormap_lenght, 2, 1, f);
414
-  fwrite(&header.colormap_bbp, 1, 1, f);
415
-  fwrite(&header.origin_x, 2, 1, f);
416
-  fwrite(&header.origin_y, 2, 1, f);
417
-  fwrite(&header.width, 2, 1, f);
418
-  fwrite(&header.height, 2, 1, f);
419
-  fwrite(&header.bpp, 1, 1, f);
420
-  fwrite(&header.desc_flags, 1, 1, f);
421
-
422
-  // Write comment
423
-  fwrite(&comment, 1, header.comment_lenght, f);
424
-
425
-  size = header.width * header.height;
426
-
427
-  switch (header.bpp)
428
-  {
429
-  case 32:
430
-    size = header.width * header.height * 4;
431
-
432
-    //for (i = 0; i < size; i += 4)
433
-    //{
434
-    //  tmp = image[i];
435
-    //  image[i] = image[i + 2];
436
-    //  image[i + 2] = tmp;
437
-    //}
438
-    break;
439
-  case 24:
440
-    size = header.width * header.height * 3;
441
-
442
-    //for (i = 0; i < size; i += 3)
443
-    //{
444
-    //  tmp = image[i];
445
-    //  image[i] = image[i + 2];
446
-    //  image[i + 2] = tmp;
447
-    //}
448
-    break;
449
-  case 8:
358
+    mtk_image_tga_t header;
359
+    unsigned int size;
360
+    //  unsigned int i;
361
+    //  unsigned char tmp;
362
+    char comment[64];
363
+
364
+
365
+    if (!f || !image || !width || !height)
366
+    {
367
+        fprintf(stderr, "mtk_image__tga_save> Invalid parameters.\n");
368
+        return -1;
369
+    }
370
+
371
+    // Mongoose 2002.01.10, Heh, kind of silly
372
+    strncpy(comment, "Mongoose TGA 20030711", 63);
373
+    comment[63] = 0;
374
+
375
+    header.comment_lenght = strlen(comment);
376
+    header.colormap_type = 0;
377
+
378
+    // No colormaps
379
+    header.colormap_index = 0;
380
+    header.colormap_lenght = 0;
381
+    header.colormap_bbp = 0;
382
+
383
+    header.origin_x = header.origin_y = 0;
384
+    header.width = width;
385
+    header.height = height;
386
+
387
+    header.desc_flags = 0;
388
+
389
+    switch (type)
390
+    {
391
+        case 4:
392
+            header.image_type = TGA_TYPE__COLOR;
393
+            header.desc_flags = 32;
394
+            header.bpp = 32;
395
+            break;
396
+        case 2:
397
+            header.bpp = 32;
398
+            break;
399
+        case 1:
400
+            header.image_type = TGA_TYPE__GREYSCALE;
401
+            header.bpp = 8;
402
+            break;
403
+        default:
404
+            header.image_type = TGA_TYPE__COLOR;
405
+            header.bpp = 24;
406
+    }
407
+
408
+    // Write TGA header
409
+    fwrite(&header.comment_lenght, 1, 1, f);
410
+    fwrite(&header.colormap_type, 1, 1, f);
411
+    fwrite(&header.image_type, 1, 1, f);
412
+    fwrite(&header.colormap_index, 2, 1, f);
413
+    fwrite(&header.colormap_lenght, 2, 1, f);
414
+    fwrite(&header.colormap_bbp, 1, 1, f);
415
+    fwrite(&header.origin_x, 2, 1, f);
416
+    fwrite(&header.origin_y, 2, 1, f);
417
+    fwrite(&header.width, 2, 1, f);
418
+    fwrite(&header.height, 2, 1, f);
419
+    fwrite(&header.bpp, 1, 1, f);
420
+    fwrite(&header.desc_flags, 1, 1, f);
421
+
422
+    // Write comment
423
+    fwrite(&comment, 1, header.comment_lenght, f);
424
+
450 425
     size = header.width * header.height;
451
-    break;
452
-  }
453 426
 
454
-  // Write image data
455
-  if (fwrite(image, size, 1, f) < 1)
456
-  {
457
-    perror("mtk_image__tga_save> Disk write failed.\n");
458
-    return -2;
459
-  }
427
+    switch (header.bpp)
428
+    {
429
+        case 32:
430
+            size = header.width * header.height * 4;
431
+
432
+            //for (i = 0; i < size; i += 4)
433
+            //{
434
+            //  tmp = image[i];
435
+            //  image[i] = image[i + 2];
436
+            //  image[i + 2] = tmp;
437
+            //}
438
+            break;
439
+        case 24:
440
+            size = header.width * header.height * 3;
441
+
442
+            //for (i = 0; i < size; i += 3)
443
+            //{
444
+            //  tmp = image[i];
445
+            //  image[i] = image[i + 2];
446
+            //  image[i + 2] = tmp;
447
+            //}
448
+            break;
449
+        case 8:
450
+            size = header.width * header.height;
451
+            break;
452
+    }
453
+
454
+    // Write image data
455
+    if (fwrite(image, size, 1, f) < 1)
456
+    {
457
+        perror("mtk_image__tga_save> Disk write failed.\n");
458
+        return -2;
459
+    }
460 460
 
461
-  return 0;
461
+    return 0;
462 462
 }
463 463
 
464 464
 
465 465
 int mtk_image__tga_save_filename(unsigned char *image,
466
-				 unsigned int width, unsigned int height,
467
-				 char type,
468
-				 char *s, ...)
466
+        unsigned int width, unsigned int height,
467
+        char type,
468
+        char *s, ...)
469 469
 {
470
-  char buffer[1024];
471
-  FILE *f;
472
-  int v;
473
-  va_list args;
470
+    char buffer[1024];
471
+    FILE *f;
472
+    int v;
473
+    va_list args;
474 474
 
475 475
 
476
-  va_start(args, s);
477
-  vsnprintf(buffer, 1023, s, args);
478
-  va_end(args);
476
+    va_start(args, s);
477
+    vsnprintf(buffer, 1023, s, args);
478
+    va_end(args);
479 479
 
480
-  f = fopen(buffer, "wb");
480
+    f = fopen(buffer, "wb");
481 481
 
482
-  if (!f)
483
-  {
484
-    perror(buffer);
485
-    return -1;
486
-  }
482
+    if (!f)
483
+    {
484
+        perror(buffer);
485
+        return -1;
486
+    }
487 487
 
488
-  v = mtk_image__tga_save(f, image, width, height, type);
489
-  fclose(f);
488
+    v = mtk_image__tga_save(f, image, width, height, type);
489
+    fclose(f);
490 490
 
491
-  return v;
491
+    return v;
492 492
 }
493 493
 

+ 192
- 192
test/GLString.cpp Переглянути файл

@@ -25,72 +25,72 @@ void swap_buffers();
25 25
 
26 26
 void event_resize(int width, int height)
27 27
 {
28
-	GLfloat aspect;
28
+    GLfloat aspect;
29 29
 
30
-	glMatrixMode(GL_PROJECTION);
31
-	aspect = (GLfloat)width/(GLfloat)height;
30
+    glMatrixMode(GL_PROJECTION);
31
+    aspect = (GLfloat)width/(GLfloat)height;
32 32
 
33
-	// Mongoose 2002.01.01, Setup view volume, with a nice FOV
33
+    // Mongoose 2002.01.01, Setup view volume, with a nice FOV
34 34
     // gluPerspective is deprecated!
35
-	// gluPerspective(40.0, aspect, 1, 2000);
35
+    // gluPerspective(40.0, aspect, 1, 2000);
36 36
     // fix: http://stackoverflow.com/a/2417756
37 37
     GLfloat fH = tan(float(40.0 / 360.0f * 3.14159f));
38 38
     GLfloat fW = fH * aspect;
39 39
     glFrustum(-fW, fW, -fH, fH, 1, 2000);
40 40
 
41
-	glMatrixMode(GL_MODELVIEW);
41
+    glMatrixMode(GL_MODELVIEW);
42 42
 }
43 43
 
44 44
 
45 45
 void event_display(int width, int height)
46 46
 {
47
-	static float x = 0.0, y = 0.0, z = -150.0, r = 0.0;
48
-
49
-
50
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
51
-	glLoadIdentity();
52
-
53
-	glTranslatef(0.0, 0.0, -20.0);
54
-	glRotatef((float)cos(r)*180.0, 0.0, 0.0, 1.0);
55
-	r += 0.01;
56
-
57
-	// Mongoose 2002.01.01, Render color quad
58
-	glDisable(GL_TEXTURE_2D);
59
-	glBegin(GL_TRIANGLE_STRIP);
60
-	glColor3f(1.0, 0.0, 0.0);
61
-	glVertex3f(x + 50, y + 50, z);
62
-	glColor3f(0.0, 1.0, 0.0);
63
-	glVertex3f(x - 50, y + 50, z);
64
-	glColor3f(0.0, 0.0, 1.0);
65
-	glVertex3f(x + 50, y - 50, z);
66
-	glColor3f(0.5, 0.5, 0.5);
67
-	glVertex3f(x - 50, y - 50, z);
68
-	glEnd();
69
-
70
-	// Mongoose 2002.01.01, Render text
71
-	glDisable(GL_CULL_FACE);
72
-	glEnable(GL_BLEND);
73
-	glEnable(GL_TEXTURE_2D);
74
-	glColor3f(0.75, 0.5, 1.0);
47
+    static float x = 0.0, y = 0.0, z = -150.0, r = 0.0;
48
+
49
+
50
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
51
+    glLoadIdentity();
52
+
53
+    glTranslatef(0.0, 0.0, -20.0);
54
+    glRotatef((float)cos(r)*180.0, 0.0, 0.0, 1.0);
55
+    r += 0.01;
56
+
57
+    // Mongoose 2002.01.01, Render color quad
58
+    glDisable(GL_TEXTURE_2D);
59
+    glBegin(GL_TRIANGLE_STRIP);
60
+    glColor3f(1.0, 0.0, 0.0);
61
+    glVertex3f(x + 50, y + 50, z);
62
+    glColor3f(0.0, 1.0, 0.0);
63
+    glVertex3f(x - 50, y + 50, z);
64
+    glColor3f(0.0, 0.0, 1.0);
65
+    glVertex3f(x + 50, y - 50, z);
66
+    glColor3f(0.5, 0.5, 0.5);
67
+    glVertex3f(x - 50, y - 50, z);
68
+    glEnd();
69
+
70
+    // Mongoose 2002.01.01, Render text
71
+    glDisable(GL_CULL_FACE);
72
+    glEnable(GL_BLEND);
73
+    glEnable(GL_TEXTURE_2D);
74
+    glColor3f(0.75, 0.5, 1.0);
75 75
 
76 76
     glEnterMode2d(width, height);
77
-	TEXT->Render(width, height);
77
+    TEXT->Render(width, height);
78 78
     glExitMode2d();
79 79
 
80
-	glFlush();
81
-	swap_buffers();
80
+    glFlush();
81
+    swap_buffers();
82 82
 }
83 83
 
84 84
 
85 85
 void swap_buffers()
86 86
 {
87
-	SDL_GL_SwapBuffers();
87
+    SDL_GL_SwapBuffers();
88 88
 }
89 89
 
90 90
 
91 91
 void shutdown_gl()
92 92
 {
93
-	SDL_Quit();
93
+    SDL_Quit();
94 94
 }
95 95
 
96 96
 void init_gl(unsigned int width, unsigned int height)
@@ -98,41 +98,41 @@ void init_gl(unsigned int width, unsigned int height)
98 98
     int i;
99 99
     const char *errorText = "TEXT->glPrintf> ERROR code %i\n";
100 100
 
101
-	// Setup GL
102
-	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
103
-	glShadeModel(GL_SMOOTH);
104
-	glEnable(GL_DEPTH_TEST);
105
-	glDepthFunc(GL_LESS);
106
-	glEnable(GL_BLEND);
107
-	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
101
+    // Setup GL
102
+    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
103
+    glShadeModel(GL_SMOOTH);
104
+    glEnable(GL_DEPTH_TEST);
105
+    glDepthFunc(GL_LESS);
106
+    glEnable(GL_BLEND);
107
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
108 108
 
109
-	event_resize(width, height);
109
+    event_resize(width, height);
110 110
 
111
-	// Mongoose 2002.01.01, Texture setup
112
-	gTexture.reset();
113
-	gTexture.setFlag(Texture::fUseMipmaps);
114
-	gTexture.setMaxTextureCount(32);
111
+    // Mongoose 2002.01.01, Texture setup
112
+    gTexture.reset();
113
+    gTexture.setFlag(Texture::fUseMipmaps);
114
+    gTexture.setMaxTextureCount(32);
115 115
 
116 116
     gTexture.loadFontTTF("data/test.ttf", 32, 126 - 32);  // ASCII
117 117
 
118
-	TEXT->Init(4);
118
+    TEXT->Init(4);
119 119
     i = TEXT->glPrintf((width/2)-50, height/2-32, "OpenRaider");
120 120
     if (i) {
121 121
         printf(errorText, i);
122 122
     }
123
-	i = TEXT->glPrintf((width/2)-50, height/2, "GLString");
124
-	if (i) {
125
-	    printf(errorText, i);
126
-	}
127
-	TEXT->Scale(1.2);
128
-	i = TEXT->glPrintf((width/2)-100, height/2+32, "Unit Test by Mongoose");
129
-	if (i) {
123
+    i = TEXT->glPrintf((width/2)-50, height/2, "GLString");
124
+    if (i) {
125
+        printf(errorText, i);
126
+    }
127
+    TEXT->Scale(1.2);
128
+    i = TEXT->glPrintf((width/2)-100, height/2+32, "Unit Test by Mongoose");
129
+    if (i) {
130 130
         printf(errorText, i);
131 131
     }
132
-	i = TEXT->glPrintf((width/2)-100, height/2+64, "ported to TTF by xythobuz");
133
-	if (i) {
132
+    i = TEXT->glPrintf((width/2)-100, height/2+64, "ported to TTF by xythobuz");
133
+    if (i) {
134 134
         printf(errorText, i);
135
-	}
135
+    }
136 136
     TEXT->setActive(0, true);
137 137
     TEXT->setActive(1, true);
138 138
     TEXT->setActive(2, true);
@@ -142,152 +142,152 @@ void init_gl(unsigned int width, unsigned int height)
142 142
 
143 143
 int main_gl(int argc, char *argv[])
144 144
 {
145
-  SDL_Event event;
146
-  unsigned int mkeys, mod, key;
147
-  int flags;
148
-  unsigned int width = 640;
149
-  unsigned int height = 480;
150
-  bool fullscreen = false;
145
+    SDL_Event event;
146
+    unsigned int mkeys, mod, key;
147
+    int flags;
148
+    unsigned int width = 640;
149
+    unsigned int height = 480;
150
+    bool fullscreen = false;
151 151
 #ifndef __APPLE__
152
-  char *driver = NULL;
152
+    char *driver = NULL;
153 153
 #endif
154 154
 
155 155
 
156
-  // Setup clean up on exit
157
-  atexit(shutdown_gl);
156
+    // Setup clean up on exit
157
+    atexit(shutdown_gl);
158 158
 
159
-  // Get user settings
160
-  //event_init(&width, &height, &fullscreen, &driver, argc, argv);
159
+    // Get user settings
160
+    //event_init(&width, &height, &fullscreen, &driver, argc, argv);
161 161
 
162
-  // Create GL context
163
-  SDL_Init(SDL_INIT_VIDEO);
162
+    // Create GL context
163
+    SDL_Init(SDL_INIT_VIDEO);
164 164
 
165 165
 #ifndef __APPLE__
166
-  if (!driver || !driver[0] || SDL_GL_LoadLibrary(driver) < 0)
167
-  {
168
-	  SDL_ClearError();
169
-
170
-	  // Fallback 1
171
-	  if (SDL_GL_LoadLibrary("libGL.so") < 0)
172
-	  {
173
-		  SDL_ClearError();
174
-
175
-		  // Fallback 2
176
-		  if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
177
-		  {
178
-			  fprintf(stderr, "main_gl> SDL_GL_LoadLibrary failed!\n");
179
-			  fprintf(stderr, "main_gl> Error is [%s].\n", SDL_GetError());
180
-			  exit(1);
181
-		  }
182
-	  }
183
-  }
166
+    if (!driver || !driver[0] || SDL_GL_LoadLibrary(driver) < 0)
167
+    {
168
+        SDL_ClearError();
169
+
170
+        // Fallback 1
171
+        if (SDL_GL_LoadLibrary("libGL.so") < 0)
172
+        {
173
+            SDL_ClearError();
174
+
175
+            // Fallback 2
176
+            if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
177
+            {
178
+                fprintf(stderr, "main_gl> SDL_GL_LoadLibrary failed!\n");
179
+                fprintf(stderr, "main_gl> Error is [%s].\n", SDL_GetError());
180
+                exit(1);
181
+            }
182
+        }
183
+    }
184 184
 #endif
185 185
 
186
-  flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
187
-
188
-  if (fullscreen)
189
-  {
190
-	  flags |= SDL_FULLSCREEN;
191
-	  SDL_ShowCursor(SDL_DISABLE);
192
-  }
193
-
194
-  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
195
-  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
196
-  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
197
-  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
198
-  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
199
-  SDL_WINDOW = SDL_SetVideoMode(width, height, 16, flags);
200
-  SDL_WM_SetCaption("GLString Test", "GLString Test");
201
-  SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
202
-
203
-  // Init rendering
204
-  init_gl(width, height);
205
-
206
-  for (;;)
207
-  {
208
-	  // Pause for 10-20 ms
209
-	  SDL_Delay(10);
210
-
211
-	  event_display(width, height);
212
-
213
-	  while (SDL_PollEvent(&event))
214
-	  {
215
-		  switch (event.type)
216
-		  {
217
-		  case SDL_QUIT:
218
-			  exit(0);
219
-			  break;
220
-		  case SDL_MOUSEMOTION:
221
-			  break;
222
-		  case SDL_MOUSEBUTTONDOWN:
223
-		  case SDL_MOUSEBUTTONUP:
224
-			  break;
225
-		  case SDL_KEYDOWN:
226
-			  mkeys = (unsigned int)SDL_GetModState();
227
-			  mod = 0;
228
-
229
-			  if (mkeys & KMOD_LSHIFT)
230
-				  mod |= KMOD_LSHIFT;
231
-
232
-			  if (mkeys & KMOD_RSHIFT)
233
-				  mod |= KMOD_RSHIFT;
234
-
235
-			  if (mkeys & KMOD_LCTRL)
236
-				  mod |= KMOD_LCTRL;
237
-
238
-			  if (mkeys & KMOD_RCTRL)
239
-				  mod |= KMOD_RCTRL;
240
-
241
-			  if (mkeys & KMOD_LALT)
242
-				  mod |= KMOD_LALT;
243
-
244
-			  if (mkeys & KMOD_RALT)
245
-				  mod |= KMOD_RALT;
246
-
247
-              if (mkeys & KMOD_LMETA)
248
-                  mod |= KMOD_LMETA;
249
-
250
-              if (mkeys & KMOD_RMETA)
251
-                  mod |= KMOD_RMETA;
252
-
253
-			  key = event.key.keysym.sym;
254
-
255
-			  switch (key)
256
-			  {
257
-			  case 0x1B: // 27d, ESC
258
-				  exit(0);
259
-				  break;
186
+    flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
187
+
188
+    if (fullscreen)
189
+    {
190
+        flags |= SDL_FULLSCREEN;
191
+        SDL_ShowCursor(SDL_DISABLE);
192
+    }
193
+
194
+    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
195
+    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
196
+    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
197
+    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
198
+    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
199
+    SDL_WINDOW = SDL_SetVideoMode(width, height, 16, flags);
200
+    SDL_WM_SetCaption("GLString Test", "GLString Test");
201
+    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
202
+
203
+    // Init rendering
204
+    init_gl(width, height);
205
+
206
+    for (;;)
207
+    {
208
+        // Pause for 10-20 ms
209
+        SDL_Delay(10);
210
+
211
+        event_display(width, height);
212
+
213
+        while (SDL_PollEvent(&event))
214
+        {
215
+            switch (event.type)
216
+            {
217
+                case SDL_QUIT:
218
+                    exit(0);
219
+                    break;
220
+                case SDL_MOUSEMOTION:
221
+                    break;
222
+                case SDL_MOUSEBUTTONDOWN:
223
+                case SDL_MOUSEBUTTONUP:
224
+                    break;
225
+                case SDL_KEYDOWN:
226
+                    mkeys = (unsigned int)SDL_GetModState();
227
+                    mod = 0;
228
+
229
+                    if (mkeys & KMOD_LSHIFT)
230
+                        mod |= KMOD_LSHIFT;
231
+
232
+                    if (mkeys & KMOD_RSHIFT)
233
+                        mod |= KMOD_RSHIFT;
234
+
235
+                    if (mkeys & KMOD_LCTRL)
236
+                        mod |= KMOD_LCTRL;
237
+
238
+                    if (mkeys & KMOD_RCTRL)
239
+                        mod |= KMOD_RCTRL;
240
+
241
+                    if (mkeys & KMOD_LALT)
242
+                        mod |= KMOD_LALT;
243
+
244
+                    if (mkeys & KMOD_RALT)
245
+                        mod |= KMOD_RALT;
246
+
247
+                    if (mkeys & KMOD_LMETA)
248
+                        mod |= KMOD_LMETA;
249
+
250
+                    if (mkeys & KMOD_RMETA)
251
+                        mod |= KMOD_RMETA;
252
+
253
+                    key = event.key.keysym.sym;
254
+
255
+                    switch (key)
256
+                    {
257
+                        case 0x1B: // 27d, ESC
258
+                            exit(0);
259
+                            break;
260 260
 #ifdef __APPLE__
261
-              case 113: // q
262
-                  if ((mod & KMOD_RMETA) || (mod & KMOD_LMETA))
263
-                      exit(0);
264
-                  break;
261
+                        case 113: // q
262
+                            if ((mod & KMOD_RMETA) || (mod & KMOD_LMETA))
263
+                                exit(0);
264
+                            break;
265 265
 #endif
266
-              case 114: // r
267
-                  break;
268
-			  }
269
-			  break;
270
-		  case SDL_KEYUP:
271
-			  break;
272
-		  case SDL_VIDEORESIZE:
273
-			  width = event.resize.w;
274
-			  height = event.resize.h;
275
-			  event_resize(width, height);
276
-			  event_display(width, height);
277
-			  break;
278
-		  }
279
-	  }
280
-  }
281
-
282
-  return 0;
266
+                        case 114: // r
267
+                            break;
268
+                    }
269
+                    break;
270
+                case SDL_KEYUP:
271
+                    break;
272
+                case SDL_VIDEORESIZE:
273
+                    width = event.resize.w;
274
+                    height = event.resize.h;
275
+                    event_resize(width, height);
276
+                    event_display(width, height);
277
+                    break;
278
+            }
279
+        }
280
+    }
281
+
282
+    return 0;
283 283
 }
284 284
 
285 285
 int main(int argc, char *argv[])
286 286
 {
287
-  printf("[GLString class test]\n");
287
+    printf("[GLString class test]\n");
288 288
 
289
-  TEXT = new GLString();
290
-  main_gl(argc, argv);
291
-  return 0;
289
+    TEXT = new GLString();
290
+    main_gl(argc, argv);
291
+    return 0;
292 292
 }
293 293
 

+ 29
- 29
test/Matrix.cpp Переглянути файл

@@ -40,19 +40,19 @@ TEST identity(vec_t init[4], int mode) {
40 40
     a.setMatrix(m);
41 41
 
42 42
     switch (mode) {
43
-    case 0:
44
-        a.setIdentity();
45
-        break;
46
-    case 1:
47
-        c.setIdentity();
48
-        b.setIdentity();
49
-        a = c * b;
50
-        break;
51
-    case 2:
52
-        a.setIdentity();
53
-        b.setIdentity();
54
-        a = a * b;
55
-        break;
43
+        case 0:
44
+            a.setIdentity();
45
+            break;
46
+        case 1:
47
+            c.setIdentity();
48
+            b.setIdentity();
49
+            a = c * b;
50
+            break;
51
+        case 2:
52
+            a.setIdentity();
53
+            b.setIdentity();
54
+            a = a * b;
55
+            break;
56 56
     }
57 57
     ASSERT(a.isIdentity());
58 58
     PASS();
@@ -95,22 +95,22 @@ TEST rotation(int axis) {
95 95
 
96 96
 TEST precision() {
97 97
     Matrix a;
98
-	printf("Prescision test...\n");
99
-	a.setIdentity();
100
-	printf(" -> Rotate (0, 0, 90 degrees)\n");
101
-	a.rotate(0, 0, 90*0.01745329251994329f);
102
-	printf(" -> Translate (10, 20, 30)\n");
103
-	a.translate(10, 20, 30);
104
-	printf(" -> scale (10, 10, 10)\n");
105
-	a.scale(10, 10, 10);
106
-	a.print();
107
-	printf("\n -> scale (0.1, 0.1, 0.1)\n");
108
-	a.scale(0.1, 0.1, 0.1);
109
-	printf(" -> Translate (-10, -20, -30)\n");
110
-	a.translate(-10, -20, -30);
111
-	printf(" -> Rotate (0, 0, -90 degrees)\n");
112
-	a.rotate(0, 0, -90*0.01745329251994329f);
113
-	a.print();
98
+    printf("Prescision test...\n");
99
+    a.setIdentity();
100
+    printf(" -> Rotate (0, 0, 90 degrees)\n");
101
+    a.rotate(0, 0, 90*0.01745329251994329f);
102
+    printf(" -> Translate (10, 20, 30)\n");
103
+    a.translate(10, 20, 30);
104
+    printf(" -> scale (10, 10, 10)\n");
105
+    a.scale(10, 10, 10);
106
+    a.print();
107
+    printf("\n -> scale (0.1, 0.1, 0.1)\n");
108
+    a.scale(0.1, 0.1, 0.1);
109
+    printf(" -> Translate (-10, -20, -30)\n");
110
+    a.translate(-10, -20, -30);
111
+    printf(" -> Rotate (0, 0, -90 degrees)\n");
112
+    a.rotate(0, 0, -90*0.01745329251994329f);
113
+    a.print();
114 114
     PASS();
115 115
 }
116 116
 

+ 60
- 60
test/Network.cpp Переглянути файл

@@ -29,82 +29,82 @@ extern network_frame_t gPiggyBack;
29 29
 
30 30
 void from_network_layer(network_packet_t *p, unsigned int *last_id)
31 31
 {
32
-	static unsigned int i = 0;
32
+    static unsigned int i = 0;
33 33
 
34 34
 
35
-	if (!p)
36
-	{
37
-		return;
38
-	}
35
+    if (!p)
36
+    {
37
+        return;
38
+    }
39 39
 
40
-	*last_id = i++;
40
+    *last_id = i++;
41 41
 
42
-	sleep(1);
42
+    sleep(1);
43 43
 
44
-	p->send = 1;
45
-	p->pos[0] = i*3;
46
-	p->pos[1] = i*3+1;
47
-	p->pos[2] = i*3+2;
44
+    p->send = 1;
45
+    p->pos[0] = i*3;
46
+    p->pos[1] = i*3+1;
47
+    p->pos[2] = i*3+2;
48 48
 
49
-	printf("<S>ending { %f %f %f }\n", p->pos[0], p->pos[1], p->pos[2]);
49
+    printf("<S>ending { %f %f %f }\n", p->pos[0], p->pos[1], p->pos[2]);
50 50
 }
51 51
 
52 52
 
53 53
 void to_network_layer(network_packet_t p)
54 54
 {
55
-	printf("<R>ecieved { %f %f %f }\n", p.pos[0], p.pos[1], p.pos[2]);
55
+    printf("<R>ecieved { %f %f %f }\n", p.pos[0], p.pos[1], p.pos[2]);
56 56
 
57
-	gPiggyBack.data.pos[0] = gPiggyBack.seq*4;
58
-	gPiggyBack.data.pos[1] = gPiggyBack.seq*4+1;
59
-	gPiggyBack.data.pos[2] = gPiggyBack.seq*4+2;
60
-	gPiggyBack.data.send = 1;
61
-	gPiggyBack.data.yaw = 90.0f;
57
+    gPiggyBack.data.pos[0] = gPiggyBack.seq*4;
58
+    gPiggyBack.data.pos[1] = gPiggyBack.seq*4+1;
59
+    gPiggyBack.data.pos[2] = gPiggyBack.seq*4+2;
60
+    gPiggyBack.data.send = 1;
61
+    gPiggyBack.data.yaw = 90.0f;
62 62
 }
63 63
 
64 64
 
65 65
 int main(int argc, char *argv[])
66 66
 {
67
-	printf("\n\n[Network class test]\n");
68
-	Network &test = *Network::Instance();
69
-
70
-
71
-	if (argc > 3)
72
-	{
73
-		if (argv[1][1] == 'v')
74
-		{
75
-			test.setDebug(true);
76
-		}
77
-
78
-		switch (argv[1][0])
79
-		{
80
-		case 'c':
81
-			test.setRemoteHost(argv[2]);
82
-			test.setPort(atoi(argv[3]));
83
-			test.runClient();
84
-			break;
85
-		case 's':
86
-			test.setBindHost(argv[2]);
87
-			test.setPort(atoi(argv[3]));
88
-			test.runServer();
89
-			break;
90
-		default:
91
-			printf("Error in command line, run %s for help\n", argv[0]);
92
-		}
93
-	}
94
-	else if (argc > 2)
95
-	{
96
-		test.setPort(atoi(argv[2]));
97
-		test.runServer();
98
-	}
99
-	else
100
-	{
101
-		printf("Server: %s s [bind_host_name] port\n", argv[0]);
102
-		printf("Client: %s c remote_host_name remote_host_port\n", argv[0]);
103
-		printf("Append 'v' behind c/s option for verbose. eg cv\n");
104
-	}
105
-
106
-	killNetworkSingleton();
107
-
108
-	return 0;
67
+    printf("\n\n[Network class test]\n");
68
+    Network &test = *Network::Instance();
69
+
70
+
71
+    if (argc > 3)
72
+    {
73
+        if (argv[1][1] == 'v')
74
+        {
75
+            test.setDebug(true);
76
+        }
77
+
78
+        switch (argv[1][0])
79
+        {
80
+            case 'c':
81
+                test.setRemoteHost(argv[2]);
82
+                test.setPort(atoi(argv[3]));
83
+                test.runClient();
84
+                break;
85
+            case 's':
86
+                test.setBindHost(argv[2]);
87
+                test.setPort(atoi(argv[3]));
88
+                test.runServer();
89
+                break;
90
+            default:
91
+                printf("Error in command line, run %s for help\n", argv[0]);
92
+        }
93
+    }
94
+    else if (argc > 2)
95
+    {
96
+        test.setPort(atoi(argv[2]));
97
+        test.runServer();
98
+    }
99
+    else
100
+    {
101
+        printf("Server: %s s [bind_host_name] port\n", argv[0]);
102
+        printf("Client: %s c remote_host_name remote_host_port\n", argv[0]);
103
+        printf("Append 'v' behind c/s option for verbose. eg cv\n");
104
+    }
105
+
106
+    killNetworkSingleton();
107
+
108
+    return 0;
109 109
 }
110 110
 

+ 9
- 9
test/Sound.cpp Переглянути файл

@@ -52,18 +52,18 @@ TEST loadFile() {
52 52
         FAIL();
53 53
     }
54 54
     fseek(f, 0, SEEK_END);
55
-	l = ftell(f);
56
-	fseek(f, 0, SEEK_SET);
57
-	buf = new unsigned char[l];
58
-	fread(buf, l, 1, f);
59
-	fclose(f);
60
-	if ((ret = sound.addWave(buf, l, &id, sound.SoundFlagsNone)) != 0) {
55
+    l = ftell(f);
56
+    fseek(f, 0, SEEK_SET);
57
+    buf = new unsigned char[l];
58
+    fread(buf, l, 1, f);
59
+    fclose(f);
60
+    if ((ret = sound.addWave(buf, l, &id, sound.SoundFlagsNone)) != 0) {
61 61
         printf("Couldn't add buffer (%d)!", ret);
62 62
         FAIL();
63 63
     }
64
-	sound.play(id);
65
-	delete [] buf;
66
-	sleep(2);
64
+    sound.play(id);
65
+    delete [] buf;
66
+    sleep(2);
67 67
     PASS();
68 68
 }
69 69
 

+ 486
- 486
test/TombRaider.cpp
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 126
- 126
test/memory_test.cpp Переглянути файл

@@ -36,140 +36,140 @@ extern long MAX_MEMORYC_USED;
36 36
 
37 37
 void tree_valid_report(rbtree_t *root);
38 38
 
39
-#define PRINT_TEST_BREAK_LINE	printf("\n############################################################\n\n");
39
+#define PRINT_TEST_BREAK_LINE   printf("\n############################################################\n\n");
40 40
 
41 41
 int memory_test_unit_test(int argc, char *argv[])
42 42
 {
43
-	int *i, *j, *k, *l, *m, *n, *o;
44
-
45
-
46
-	PRINT_TEST_BREAK_LINE
47
-	printf("Memory test\n");
48
-	PRINT_TEST_BREAK_LINE
49
-
50
-	i = new int;
51
-	printf(">\ti = new int; (%p)  %s:%i\n", i, __FILE__, __LINE__);
52
-	dump_memory_report();
53
-	tree_valid_report(MEMORY_INFO);
54
-
55
-	delete i;
56
-	printf(">\tdelete i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
57
-	dump_memory_report();
58
-	tree_valid_report(MEMORY_INFO);
59
-
60
-	PRINT_TEST_BREAK_LINE
61
-
62
-	i = new int[3];
63
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
64
-	dump_memory_report();
65
-	tree_valid_report(MEMORY_INFO);
66
-
67
-	delete [] i;
68
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
69
-	dump_memory_report();
70
-	tree_valid_report(MEMORY_INFO);
71
-
72
-	PRINT_TEST_BREAK_LINE
73
-
74
-	i = new int[3];
75
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
76
-	j = new int;
77
-	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
78
-	k = new int[3];
79
-	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
80
-	dump_memory_report();
81
-	tree_valid_report(MEMORY_INFO);
82
-	delete [] i;
83
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
84
-	delete j;
85
-	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
86
-	delete [] k;
87
-	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
88
-	dump_memory_report();
89
-	tree_valid_report(MEMORY_INFO);
90
-
91
-	PRINT_TEST_BREAK_LINE
92
-
93
-	i = new int[3];
94
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
95
-	j = new int;
96
-	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
97
-	k = new int[3];
98
-	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
99
-	dump_memory_report();
100
-	tree_valid_report(MEMORY_INFO);
101
-	delete j;
102
-	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
103
-	dump_memory_report();
104
-	tree_valid_report(MEMORY_INFO);
105
-	j = new int[3];
106
-	printf(">\tj = new int[3]; (%p)  %s:%i\n", j, __FILE__, __LINE__);
107
-	dump_memory_report();
108
-	tree_valid_report(MEMORY_INFO);
109
-	l = new int[3];
110
-	printf(">\tl = new int[3]; (%p)  %s:%i\n", l, __FILE__, __LINE__);
111
-	dump_memory_report();
112
-	tree_valid_report(MEMORY_INFO);
113
-	m = new int[3];
114
-	printf(">\tm = new int[3]; (%p)  %s:%i\n", m, __FILE__, __LINE__);
115
-	dump_memory_report();
116
-	tree_valid_report(MEMORY_INFO);
117
-
118
-	n = new int[3];
119
-	printf(">\tn = new int[3]; (%p)  %s:%i\n", n, __FILE__, __LINE__);
120
-	dump_memory_report();
121
-	tree_valid_report(MEMORY_INFO);
122
-
123
-	o = new int[3];
124
-	printf(">\to = new int[3]; (%p)  %s:%i\n", o, __FILE__, __LINE__);
125
-	dump_memory_report();
126
-	tree_valid_report(MEMORY_INFO);
127
-
128
-	delete [] k;
129
-	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
130
-	dump_memory_report();
131
-	tree_valid_report(MEMORY_INFO);
132
-
133
-	delete [] j;
134
-	printf(">\tdelete [] j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
135
-	dump_memory_report();
136
-	tree_valid_report(MEMORY_INFO);
137
-
138
-	delete [] l;
139
-	printf(">\tdelete [] l; (%p)  %s:%i\n", l, __FILE__, __LINE__);
140
-	dump_memory_report();
141
-	tree_valid_report(MEMORY_INFO);
142
-
143
-	delete [] m;
144
-	printf(">\tdelete [] m; (%p)  %s:%i\n", m, __FILE__, __LINE__);
145
-	dump_memory_report();
146
-	tree_valid_report(MEMORY_INFO);
147
-
148
-	delete [] n;
149
-	printf(">\tdelete [] n; (%p)  %s:%i\n", n, __FILE__, __LINE__);
150
-	dump_memory_report();
151
-	tree_valid_report(MEMORY_INFO);
152
-
153
-	delete [] o;
154
-	printf(">\tdelete [] o; (%p)  %s:%i\n", o, __FILE__, __LINE__);
155
-	dump_memory_report();
156
-	tree_valid_report(MEMORY_INFO);
157
-
158
-	delete [] i;
159
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
160
-	dump_memory_report();
161
-	tree_valid_report(MEMORY_INFO);
162
-
163
-	PRINT_TEST_BREAK_LINE
164
-
165
-	return 0;
43
+    int *i, *j, *k, *l, *m, *n, *o;
44
+
45
+
46
+    PRINT_TEST_BREAK_LINE
47
+        printf("Memory test\n");
48
+    PRINT_TEST_BREAK_LINE
49
+
50
+        i = new int;
51
+    printf(">\ti = new int; (%p)  %s:%i\n", i, __FILE__, __LINE__);
52
+    dump_memory_report();
53
+    tree_valid_report(MEMORY_INFO);
54
+
55
+    delete i;
56
+    printf(">\tdelete i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
57
+    dump_memory_report();
58
+    tree_valid_report(MEMORY_INFO);
59
+
60
+    PRINT_TEST_BREAK_LINE
61
+
62
+        i = new int[3];
63
+    printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
64
+    dump_memory_report();
65
+    tree_valid_report(MEMORY_INFO);
66
+
67
+    delete [] i;
68
+    printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
69
+    dump_memory_report();
70
+    tree_valid_report(MEMORY_INFO);
71
+
72
+    PRINT_TEST_BREAK_LINE
73
+
74
+        i = new int[3];
75
+    printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
76
+    j = new int;
77
+    printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
78
+    k = new int[3];
79
+    printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
80
+    dump_memory_report();
81
+    tree_valid_report(MEMORY_INFO);
82
+    delete [] i;
83
+    printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
84
+    delete j;
85
+    printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
86
+    delete [] k;
87
+    printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
88
+    dump_memory_report();
89
+    tree_valid_report(MEMORY_INFO);
90
+
91
+    PRINT_TEST_BREAK_LINE
92
+
93
+        i = new int[3];
94
+    printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
95
+    j = new int;
96
+    printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
97
+    k = new int[3];
98
+    printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
99
+    dump_memory_report();
100
+    tree_valid_report(MEMORY_INFO);
101
+    delete j;
102
+    printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
103
+    dump_memory_report();
104
+    tree_valid_report(MEMORY_INFO);
105
+    j = new int[3];
106
+    printf(">\tj = new int[3]; (%p)  %s:%i\n", j, __FILE__, __LINE__);
107
+    dump_memory_report();
108
+    tree_valid_report(MEMORY_INFO);
109
+    l = new int[3];
110
+    printf(">\tl = new int[3]; (%p)  %s:%i\n", l, __FILE__, __LINE__);
111
+    dump_memory_report();
112
+    tree_valid_report(MEMORY_INFO);
113
+    m = new int[3];
114
+    printf(">\tm = new int[3]; (%p)  %s:%i\n", m, __FILE__, __LINE__);
115
+    dump_memory_report();
116
+    tree_valid_report(MEMORY_INFO);
117
+
118
+    n = new int[3];
119
+    printf(">\tn = new int[3]; (%p)  %s:%i\n", n, __FILE__, __LINE__);
120
+    dump_memory_report();
121
+    tree_valid_report(MEMORY_INFO);
122
+
123
+    o = new int[3];
124
+    printf(">\to = new int[3]; (%p)  %s:%i\n", o, __FILE__, __LINE__);
125
+    dump_memory_report();
126
+    tree_valid_report(MEMORY_INFO);
127
+
128
+    delete [] k;
129
+    printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
130
+    dump_memory_report();
131
+    tree_valid_report(MEMORY_INFO);
132
+
133
+    delete [] j;
134
+    printf(">\tdelete [] j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
135
+    dump_memory_report();
136
+    tree_valid_report(MEMORY_INFO);
137
+
138
+    delete [] l;
139
+    printf(">\tdelete [] l; (%p)  %s:%i\n", l, __FILE__, __LINE__);
140
+    dump_memory_report();
141
+    tree_valid_report(MEMORY_INFO);
142
+
143
+    delete [] m;
144
+    printf(">\tdelete [] m; (%p)  %s:%i\n", m, __FILE__, __LINE__);
145
+    dump_memory_report();
146
+    tree_valid_report(MEMORY_INFO);
147
+
148
+    delete [] n;
149
+    printf(">\tdelete [] n; (%p)  %s:%i\n", n, __FILE__, __LINE__);
150
+    dump_memory_report();
151
+    tree_valid_report(MEMORY_INFO);
152
+
153
+    delete [] o;
154
+    printf(">\tdelete [] o; (%p)  %s:%i\n", o, __FILE__, __LINE__);
155
+    dump_memory_report();
156
+    tree_valid_report(MEMORY_INFO);
157
+
158
+    delete [] i;
159
+    printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
160
+    dump_memory_report();
161
+    tree_valid_report(MEMORY_INFO);
162
+
163
+    PRINT_TEST_BREAK_LINE
164
+
165
+        return 0;
166 166
 }
167 167
 
168 168
 
169 169
 int main(int argc, char *argv[])
170 170
 {
171
-	printf("[memory_test test]\n");
171
+    printf("[memory_test test]\n");
172 172
 
173
-	return memory_test_unit_test(argc, argv);
173
+    return memory_test_unit_test(argc, argv);
174 174
 }
175 175
 

Завантаження…
Відмінити
Зберегти