Procházet zdrojové kódy

Added stub for missing hel/CollisionObject.

Now compiles on OS X, but segfaults at launch...
Thomas Buck před 10 roky
rodič
revize
3f365336f9
33 změnil soubory, kde provedl 2380 přidání a 2142 odebrání
  1. 1
    0
      .gitignore
  2. 10
    10
      Makefile
  3. 7
    8
      deps.sh
  4. 11
    11
      src/Camera.cpp
  5. 55
    55
      src/Camera.h
  6. 28
    23
      src/Emitter.cpp
  7. 40
    36
      src/GLString.cpp
  8. 14
    8
      src/GLUTSystem.cpp
  9. 10
    10
      src/Light.h
  10. 90
    86
      src/Md3.cpp
  11. 120
    116
      src/Md3AnimModel.cpp
  12. 45
    41
      src/OpenGLMesh.cpp
  13. 60
    60
      src/OpenGLMesh.h
  14. 59
    59
      src/OpenRaider.h
  15. 162
    157
      src/PSKModel.cpp
  16. 31
    31
      src/Particle.h
  17. 159
    154
      src/Render.cpp
  18. 73
    73
      src/Render.h
  19. 31
    26
      src/SDLSystem.cpp
  20. 24
    19
      src/SDLUnitTest.cpp
  21. 12
    12
      src/SkeletalModel.h
  22. 18
    13
      src/Sound.cpp
  23. 54
    49
      src/System.cpp
  24. 81
    81
      src/System.h
  25. 97
    92
      src/Texture.cpp
  26. 730
    730
      src/TombRaider.cpp
  27. 47
    47
      src/World.h
  28. 84
    0
      src/hel/CollisionObject.cpp
  29. 92
    0
      src/hel/CollisionObject.h
  30. 29
    29
      src/hel/Simulation.h
  31. 53
    53
      src/mstl/Tree.h
  32. 22
    22
      src/mstl/Vector.h
  33. 31
    31
      src/mtk_tga.cpp

+ 1
- 0
.gitignore Zobrazit soubor

@@ -0,0 +1 @@
1
+.DS_Store

+ 10
- 10
Makefile Zobrazit soubor

@@ -29,13 +29,13 @@ ARCH=i386
29 29
 # -DMULTITEXTURE		Add OpenGL multitexturing
30 30
 # -DUNICODE_SUPPORT		Add unicode/internation keyboard support
31 31
 # -DUSING_EMITTER_IN_GAME	Run particle test in game
32
-BASE_DEFS=$(shell sdl-config --cflags) -DSDL_INTERFACE \
32
+BASE_DEFS=$(shell sdl-config --cflags) -Isrc -I/opt/local/include -DSDL_INTERFACE \
33 33
 	-DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
34 34
 	-DUSING_OPENAL -DUSING_MTK_TGA -DUSING_PTHREADS \
35 35
 	-DUSING_HEL -DHAVE_SDL_TTF -DHAVE_OPENGL
36 36
 
37 37
 BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
38
-	-lopenal -lpthread -lSDL_ttf
38
+	-lpthread -lSDL_ttf
39 39
 
40 40
 # -DDEBUG_GL
41 41
 DEBUG_DEFS=-DDEBUG -DEXPERIMENTAL
@@ -43,8 +43,8 @@ DEBUG_OBJ=
43 43
 
44 44
 ###############################################################
45 45
 # OpenAL, Sound support
46
-BASE_DEFS += -DHAVE_OPENAL
47
-BASE_LIBS += -lopenal
46
+#BASE_DEFS += -DHAVE_OPENAL
47
+#BASE_LIBS += -lopenal
48 48
 
49 49
 # libferit, File transfer via HTTP/FTP/etc support
50 50
 LIBFERIT_LIB=/usr/local/lib/libferit.so
@@ -77,11 +77,11 @@ INSTALL_INCLUDE=$(DESTDIR)/usr/include
77 77
 ###############################################################
78 78
 CC=gcc
79 79
 
80
-BASE_CFLAGS=-Wall -Isrc $(BASE_DEFS) \
80
+BASE_CFLAGS=-Wall $(BASE_DEFS) \
81 81
 	-DVERSION=\"\\\"$(NAME)-$(VERSION)-$(BUILD_ID)\\\"\" \
82 82
 	-DBUILD_HOST=\"\\\"$(BUILD_HOST)\\\"\"
83 83
 
84
-LD_FLAGS=-L/usr/X11R6/lib -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi \
84
+LD_FLAGS=-L/opt/X11/lib -L/opt/local/lib -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi \
85 85
 	-lGL -lGLU -lm $(BASE_LIBS)
86 86
 
87 87
 RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
@@ -160,12 +160,12 @@ HEL_OBJ = \
160 160
 	$(BUILDDIR)/Vector3d.o \
161 161
 	$(BUILDDIR)/Matrix.o \
162 162
 	$(BUILDDIR)/ViewVolume.o \
163
-	$(BUILDDIR)/Spring.o \
164 163
 	$(BUILDDIR)/CollisionObject.o \
165 164
 	$(BUILDDIR)/BoundingVolume.o \
166 165
 	$(BUILDDIR)/Quaternion.o \
167
-	$(BUILDDIR)/math.o
168
-
166
+	$(BUILDDIR)/math.o \
167
+	$(BUILDDIR)/Entity.o
168
+	#$(BUILDDIR)/Spring.o
169 169
 
170 170
 OBJS = \
171 171
 	$(DEBUG_OBJ) \
@@ -498,4 +498,4 @@ UTPackage.test:
498 498
 	CFLAGS="-Wall -O0 -g -Isrc -DUNIT_TEST_UTPACKAGE -DUSING_MTK_TGA" \
499 499
 	LD_FLAGS="-lm -lstdc++"
500 500
 
501
-#################################################################
501
+#################################################################

+ 7
- 8
deps.sh Zobrazit soubor

@@ -3,11 +3,10 @@
3 3
 # Call it passing CFLAGS and a source filename
4 4
 # to generate a dep line
5 5
 
6
-echo "# deps.sh was passed:"
7
-echo -n "# "
8
-echo $@
9
-
10
-echo "# Then made this line:"
11
-echo -n "\$(BUILDDIR)/"
12
-cc -MM $@
13
-printf "\t \$(DO_CC)\n\n"
6
+cc -MM $@ > /dev/null
7
+OUT=$?
8
+if [ $OUT -eq 0 ];then
9
+    printf "\$(BUILDDIR)/"
10
+    cc -MM $@
11
+    printf "\t \$(DO_CC)\n\n"
12
+fi

+ 11
- 11
src/Camera.cpp Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Mongoose
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -9,15 +9,15 @@
9 9
  * License : No use w/o permission (C) 2001 Mongoose
10 10
  * Comments: OpenGL camera class for Freyja
11 11
  *
12
- *           This file was generated using Mongoose's C++ 
12
+ *           This file was generated using Mongoose's C++
13 13
  *           template generator script.  <stu7440@westga.edu>
14
- * 
15
- *-- History ------------------------------------------------- 
14
+ *
15
+ *-- History -------------------------------------------------
16 16
  *
17 17
  * 2002.12.16:
18 18
  * Mongoose - Removed perspective setting and OpenGL dependency
19 19
  *            API changes to reflect new direction of this object:
20
- *              Removing outdated algorithms and code 
20
+ *              Removing outdated algorithms and code
21 21
  *              And refactoring the class in general
22 22
  *
23 23
  * 2001.06.06:
@@ -33,7 +33,7 @@
33 33
  =================================================================*/
34 34
 
35 35
 #include <math.h>
36
-#include <hel/math.h>
36
+#include "hel/math.h"
37 37
 #include "Camera.h"
38 38
 
39 39
 #ifdef DEBUG_MEMEORY
@@ -130,7 +130,7 @@ void Camera::rotate(float angle, float x, float y, float z)
130 130
 	double look[4] = { 0, 0, -1, 1 };
131 131
  	unsigned int i;
132 132
 	matrix_t m;
133
-   
133
+
134 134
 
135 135
 	t.set(angle, x, y, z);
136 136
 	n = mQ * t;
@@ -148,7 +148,7 @@ void Camera::rotate(float angle, float x, float y, float z)
148 148
 		mTarget[i] += mPos[i];
149 149
 		mUp[i] += mPos[i];
150 150
 	}
151
-    
151
+
152 152
 	mQ = n;
153 153
 }
154 154
 
@@ -197,7 +197,7 @@ void Camera::translate(float x, float y, float z)
197 197
 
198 198
 	mPos[0] = x;
199 199
 	mPos[1] = y;
200
-	mPos[2] = z;	
200
+	mPos[2] = z;
201 201
 }
202 202
 
203 203
 
@@ -248,7 +248,7 @@ void Camera::command(enum camera_command cmd)
248 248
 		{
249 249
 			mPos[2] += (mTranslateDelta * cos(mTheta));
250 250
 		}
251
-		
251
+
252 252
 	  mPos[0] += (mTranslateDelta * sin(mTheta));
253 253
 	  mPos[1] += (mTranslateDelta * sin(mTheta2));
254 254
 	  break;
@@ -306,7 +306,7 @@ void Camera::command(enum camera_command cmd)
306 306
 	  rotate(mTheta, 0.0, 1.0, 0.0);
307 307
 	  break;
308 308
   case CAMERA_MOVE_UP:
309
-	  mPos[1] -= mTranslateDelta / 2.0;   
309
+	  mPos[1] -= mTranslateDelta / 2.0;
310 310
 	  mTarget[1] -= mTranslateDelta / 2.0;
311 311
 	  break;
312 312
   case CAMERA_MOVE_DOWN:

+ 55
- 55
src/Camera.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Hel
5 5
  * Author  : Mongoose
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -9,15 +9,15 @@
9 9
  * License : No use w/o permission (C) 2001 Mongoose
10 10
  * Comments: OpenGL camera class for Freyja
11 11
  *
12
- *           This file was generated using Mongoose's C++ 
12
+ *           This file was generated using Mongoose's C++
13 13
  *           template generator script.  <stu7440@westga.edu>
14
- * 
15
- *-- History ------------------------------------------------ 
14
+ *
15
+ *-- History ------------------------------------------------
16 16
  *
17 17
  * 2002.12.16:
18 18
  * Mongoose - Removed perspective setting and OpenGL dependency
19 19
  *            API changes to reflect new direction of this object:
20
- *              Removing outdated algorithms and code 
20
+ *              Removing outdated algorithms and code
21 21
  *              And refactoring the class in general
22 22
  *
23 23
  * 2001.06.06:
@@ -38,9 +38,9 @@
38 38
 #ifndef __HEL_MONGOOSE_CAMERA_H_
39 39
 #define __HEL_MONGOOSE_CAMERA_H_
40 40
 
41
-#include <hel/math.h>
42
-#include <hel/Matrix.h>
43
-#include <hel/Quaternion.h>
41
+#include "hel/math.h"
42
+#include "hel/Matrix.h"
43
+#include "hel/Quaternion.h"
44 44
 
45 45
 enum camera_command                /* Interactive camera control */
46 46
 {
@@ -74,12 +74,12 @@ class Camera
74 74
 
75 75
 	Camera();
76 76
 	/*------------------------------------------------------
77
-	 * Pre  : 
77
+	 * Pre  :
78 78
 	 * Post : Constructs an object of Camera
79 79
 	 *
80 80
 	 *-- History ------------------------------------------
81 81
 	 *
82
-	 * 2001.05.18: 
82
+	 * 2001.05.18:
83 83
 	 * Mongoose - Created
84 84
 	 ------------------------------------------------------*/
85 85
 
@@ -90,7 +90,7 @@ class Camera
90 90
 	 *
91 91
 	 *-- History ------------------------------------------
92 92
 	 *
93
-	 * 2001.05.18: 
93
+	 * 2001.05.18:
94 94
 	 * Mongoose - Created
95 95
 	 ------------------------------------------------------*/
96 96
 
@@ -101,18 +101,18 @@ class Camera
101 101
 
102 102
 	unsigned int getId();
103 103
 	/*------------------------------------------------------
104
-	 * Pre  : 
104
+	 * Pre  :
105 105
 	 * Post : Returns this camera's id
106 106
 	 *
107 107
 	 *-- History ------------------------------------------
108 108
 	 *
109
-	 * 2001.05.18: 
109
+	 * 2001.05.18:
110 110
 	 * Mongoose - Created
111 111
 	 ------------------------------------------------------*/
112 112
 
113 113
 	void getPosition(vec3_t pos);
114 114
 	/*------------------------------------------------------
115
-	 * Pre  : 
115
+	 * Pre  :
116 116
 	 * Post : Returns current position
117 117
 	 *
118 118
 	 *-- History ------------------------------------------
@@ -123,30 +123,30 @@ class Camera
123 123
 
124 124
 	void getUp(vec3_t up);
125 125
 	/*------------------------------------------------------
126
-	 * Pre  : 
126
+	 * Pre  :
127 127
 	 * Post : Returns up vector
128 128
 	 *
129 129
 	 *-- History ------------------------------------------
130 130
 	 *
131
-	 * 2001.05.18: 
131
+	 * 2001.05.18:
132 132
 	 * Mongoose - Created
133 133
 	 ------------------------------------------------------*/
134 134
 
135 135
 	void getTarget(vec3_t target);
136 136
 	/*------------------------------------------------------
137
-	 * Pre  : 
137
+	 * Pre  :
138 138
 	 * Post : Returns target ( look at pos )
139 139
 	 *
140 140
 	 *-- History ------------------------------------------
141 141
 	 *
142
-	 * 2001.05.18: 
142
+	 * 2001.05.18:
143 143
 	 * Mongoose - Created
144 144
 	 ------------------------------------------------------*/
145
-	
145
+
146 146
 	float getYaw();
147 147
 	/*------------------------------------------------------
148 148
 	 * Pre  : Get current yaw in degrees
149
-	 * Post : 
149
+	 * Post :
150 150
 	 *
151 151
 	 *-- History ------------------------------------------
152 152
 	 *
@@ -156,19 +156,19 @@ class Camera
156 156
 
157 157
 	double getRadianYaw();
158 158
 	/*------------------------------------------------------
159
-	 * Pre  : 
159
+	 * Pre  :
160 160
 	 * Post : Returns theta angle/yaw of camera
161 161
 	 *
162 162
 	 *-- History ------------------------------------------
163 163
 	 *
164
-	 * 2001.05.26: 
164
+	 * 2001.05.26:
165 165
 	 * Mongoose - Created
166 166
 	 ------------------------------------------------------*/
167
-	
167
+
168 168
 	float getPitch();
169 169
 	/*------------------------------------------------------
170 170
 	 * Pre  : Get current pitch in degrees
171
-	 * Post : 
171
+	 * Post :
172 172
 	 *
173 173
 	 *-- History ------------------------------------------
174 174
 	 *
@@ -178,23 +178,23 @@ class Camera
178 178
 
179 179
 	double getRadianPitch();
180 180
 	/*------------------------------------------------------
181
-	 * Pre  : 
181
+	 * Pre  :
182 182
 	 * Post : Returns phi angle/pitch of camera
183 183
 	 *
184 184
 	 *-- History ------------------------------------------
185 185
 	 *
186
-	 * 2001.05.26: 
186
+	 * 2001.05.26:
187 187
 	 * Mongoose - Created
188 188
 	 ------------------------------------------------------*/
189
-	
189
+
190 190
 	bool isBehind(int x, int z);
191 191
 	/*------------------------------------------------------
192
-	 * Pre  : 
192
+	 * Pre  :
193 193
 	 * Post : Returns true if (x, z) is behind camera eye
194 194
 	 *
195 195
 	 *-- History ------------------------------------------
196 196
 	 *
197
-	 * 2001.05.26: 
197
+	 * 2001.05.26:
198 198
 	 * Mongoose - Created
199 199
 	 ------------------------------------------------------*/
200 200
 
@@ -210,29 +210,29 @@ class Camera
210 210
 	 *
211 211
 	 *-- History ------------------------------------------
212 212
 	 *
213
-	 * 2001.06.04: 
213
+	 * 2001.06.04:
214 214
 	 * Mongoose - Created
215 215
 	 ------------------------------------------------------*/
216 216
 
217 217
 	void translate(float x, float y, float z);
218 218
 	/*------------------------------------------------------
219
-	 * Pre  : 
219
+	 * Pre  :
220 220
 	 * Post : Camera position is set to x,y,z
221 221
 	 *
222 222
 	 *-- History ------------------------------------------
223 223
 	 *
224
-	 * 2001.05.18: 
224
+	 * 2001.05.18:
225 225
 	 * Mongoose - Created
226 226
 	 ------------------------------------------------------*/
227 227
 
228 228
 	void reset();
229 229
 	/*------------------------------------------------------
230
-	 * Pre  : 
230
+	 * Pre  :
231 231
 	 * Post : Camera is set to inital state
232 232
 	 *
233 233
 	 *-- History ------------------------------------------
234 234
 	 *
235
-	 * 2001.05.18: 
235
+	 * 2001.05.18:
236 236
 	 * Mongoose - Created
237 237
 	 ------------------------------------------------------*/
238 238
 
@@ -243,7 +243,7 @@ class Camera
243 243
 	 *
244 244
 	 *-- History ------------------------------------------
245 245
 	 *
246
-	 * 2001.06.04: 
246
+	 * 2001.06.04:
247 247
 	 * Mongoose - Created
248 248
 	 ------------------------------------------------------*/
249 249
 
@@ -254,7 +254,7 @@ class Camera
254 254
 	 *
255 255
 	 *-- History ------------------------------------------
256 256
 	 *
257
-	 * 2001.06.04: 
257
+	 * 2001.06.04:
258 258
 	 * Mongoose - Created
259 259
 	 ------------------------------------------------------*/
260 260
 
@@ -265,7 +265,7 @@ class Camera
265 265
 	 *
266 266
 	 *-- History ------------------------------------------
267 267
 	 *
268
-	 * 2001.05.18: 
268
+	 * 2001.05.18:
269 269
 	 * Mongoose - Created
270 270
 	 ------------------------------------------------------*/
271 271
 
@@ -276,25 +276,25 @@ class Camera
276 276
     *
277 277
     *-- History ------------------------------------------
278 278
     *
279
-    * 2002.01.02: 
279
+    * 2002.01.02:
280 280
     * Mongoose - Created
281 281
     ------------------------------------------------------*/
282 282
 
283 283
 	void update();
284 284
 	/*------------------------------------------------------
285
-	 * Pre  : 
285
+	 * Pre  :
286 286
 	 * Post : Updates view target
287 287
 	 *
288 288
 	 *-- History ------------------------------------------
289 289
 	 *
290
-	 * 2001.05.18: 
290
+	 * 2001.05.18:
291 291
 	 * Mongoose - Created
292 292
 	 ------------------------------------------------------*/
293 293
 
294 294
 	void setPosition(vec3_t pos);
295 295
 	/*------------------------------------------------------
296 296
 	 * Pre  : Set current position
297
-	 * Post : 
297
+	 * Post :
298 298
 	 *
299 299
 	 *-- History ------------------------------------------
300 300
 	 *
@@ -304,23 +304,23 @@ class Camera
304 304
 
305 305
 	void setUp(vec3_t up);
306 306
 	/*------------------------------------------------------
307
-	 * Pre  : 
307
+	 * Pre  :
308 308
 	 * Post : Sets up vector
309 309
 	 *
310 310
 	 *-- History ------------------------------------------
311 311
 	 *
312
-	 * 2001.05.18: 
312
+	 * 2001.05.18:
313 313
 	 * Mongoose - Created
314 314
 	 ------------------------------------------------------*/
315 315
 
316 316
 	void setTarget(vec3_t target);
317 317
 	/*------------------------------------------------------
318
-	 * Pre  : 
318
+	 * Pre  :
319 319
 	 * Post : Sets target ( look at pos )
320 320
 	 *
321 321
 	 *-- History ------------------------------------------
322 322
 	 *
323
-	 * 2001.05.18: 
323
+	 * 2001.05.18:
324 324
 	 * Mongoose - Created
325 325
 	 ------------------------------------------------------*/
326 326
 
@@ -341,27 +341,27 @@ class Camera
341 341
 	Quaternion mQ;              /* Quaternion for rotation */
342 342
 
343 343
 	unsigned int mFlags;        /* For testing with flags  */
344
-		
344
+
345 345
 	double mPos[4];             /* Location in 3 space (aka eye) */
346
-	
346
+
347 347
 	double mTarget[4];          /* Postition we're looking at  */
348
-	
348
+
349 349
 	double mUp[4];              /* Up vector  */
350
-	
350
+
351 351
 	double mSide[4];            /* Side vector  */
352
-	
352
+
353 353
 	double mViewDistance;      /* Distance from target */
354
-	
354
+
355 355
 	double mTranslateDelta;    /* Step size to move */
356
-	
356
+
357 357
 	double mRotateDelta;       /* Radians to rotate  Y */
358
-	
358
+
359 359
 	double mTheta;              /* View angle  Y */
360 360
 
361 361
 	double mRotateDelta2;      /* Radians to rotate  Z */
362
-	
362
+
363 363
 	double mTheta2;             /* View angle  Z */
364
-	
364
+
365 365
 	bool mUpdate;               /* Check to see if view needs updating */
366 366
 
367 367
 	static unsigned int mCounter;   /* Id system use */

+ 28
- 23
src/Emitter.cpp Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: Particle emitter for freyja
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2001.06.30:
19 19
  * Mongoose - Created
@@ -22,8 +22,13 @@
22 22
 #include <stdlib.h>
23 23
 #include <string.h>
24 24
 #include <stdio.h>
25
+#ifdef __APPLE__
26
+#include <OpenGL/gl.h>
27
+#include <OpenGL/glu.h>
28
+#else
25 29
 #include <GL/gl.h>
26 30
 #include <GL/glu.h>
31
+#endif
27 32
 #include "Emitter.h"
28 33
 
29 34
 #ifdef DEBUG_MEMEORY
@@ -42,15 +47,15 @@ int compareParticleDist(const void *voidA, const void *voidB)
42 47
 		return -1; // error really
43 48
 
44 49
 	a->Pos(&x, &y, &z);
45
-	distA = (Emitter::mFrustum[5][0] * x + 
46
-				Emitter::mFrustum[5][1] * y + 
47
-				Emitter::mFrustum[5][2] * z + 
50
+	distA = (Emitter::mFrustum[5][0] * x +
51
+				Emitter::mFrustum[5][1] * y +
52
+				Emitter::mFrustum[5][2] * z +
48 53
 				Emitter::mFrustum[5][3]);
49 54
 
50 55
 	b->Pos(&x, &y, &z);
51
-	distB = (Emitter::mFrustum[5][0] * x + 
52
-				Emitter::mFrustum[5][1] * y + 
53
-				Emitter::mFrustum[5][2] * z + 
56
+	distB = (Emitter::mFrustum[5][0] * x +
57
+				Emitter::mFrustum[5][1] * y +
58
+				Emitter::mFrustum[5][2] * z +
54 59
 				Emitter::mFrustum[5][3]);
55 60
 
56 61
 	// reverse less/greater than
@@ -193,13 +198,13 @@ void Emitter::SetTextureId(int id)
193 198
 {
194 199
 	unsigned int i;
195 200
 
196
-	
201
+
197 202
 	for (i = 0; i < _count; i++)
198
-		_particle[i].TextureId(id);		
203
+		_particle[i].TextureId(id);
199 204
 }
200 205
 
201 206
 
202
-void Emitter::TextureId(unsigned int particle_start, 
207
+void Emitter::TextureId(unsigned int particle_start,
203 208
 								unsigned int particle_end, int id)
204 209
 {
205 210
 	unsigned int i;
@@ -210,12 +215,12 @@ void Emitter::TextureId(unsigned int particle_start,
210 215
 		 (particle_start < particle_end))
211 216
 	{
212 217
 		for (i = particle_start; i < particle_end; i++)
213
-			_particle[i].TextureId(id);		
218
+			_particle[i].TextureId(id);
214 219
 	}
215 220
 }
216 221
 
217 222
 
218
-void Emitter::Color(unsigned int particle_start, unsigned int particle_end, 
223
+void Emitter::Color(unsigned int particle_start, unsigned int particle_end,
219 224
 						  float r, float g, float b)
220 225
 {
221 226
 	unsigned int i;
@@ -226,12 +231,12 @@ void Emitter::Color(unsigned int particle_start, unsigned int particle_end,
226 231
 		 (particle_start < particle_end))
227 232
 	{
228 233
 		for (i = particle_start; i < particle_end; i++)
229
-			_particle[i].Color(r, g, b);		
234
+			_particle[i].Color(r, g, b);
230 235
 	}
231 236
 }
232 237
 
233 238
 
234
-void Emitter::Speed(unsigned int particle_start, unsigned int particle_end, 
239
+void Emitter::Speed(unsigned int particle_start, unsigned int particle_end,
235 240
 						  float x, float y, float z)
236 241
 {
237 242
 	unsigned int i;
@@ -242,12 +247,12 @@ void Emitter::Speed(unsigned int particle_start, unsigned int particle_end,
242 247
 		 (particle_start < particle_end))
243 248
 	{
244 249
 		for (i = particle_start; i < particle_end; i++)
245
-			_particle[i].Speed(x, y, z);		
250
+			_particle[i].Speed(x, y, z);
246 251
 	}
247 252
 }
248 253
 
249 254
 
250
-void Emitter::Force(unsigned int particle_start, unsigned int particle_end, 
255
+void Emitter::Force(unsigned int particle_start, unsigned int particle_end,
251 256
 						  float x, float y, float z)
252 257
 {
253 258
 	unsigned int i;
@@ -258,7 +263,7 @@ void Emitter::Force(unsigned int particle_start, unsigned int particle_end,
258 263
 		 (particle_start < particle_end))
259 264
 	{
260 265
 		for (i = particle_start; i < particle_end; i++)
261
-			_particle[i].Force(x, y, z);		
266
+			_particle[i].Force(x, y, z);
262 267
 	}
263 268
 }
264 269
 
@@ -299,9 +304,9 @@ void Emitter::Draw()
299 304
 			{
300 305
 				for (p = 0; p < 6; ++p)
301 306
 				{
302
-					if (mFrustum[p][0] * x + 
303
-						 mFrustum[p][1] * y + 
304
-						 mFrustum[p][2] * z + 
307
+					if (mFrustum[p][0] * x +
308
+						 mFrustum[p][1] * y +
309
+						 mFrustum[p][2] * z +
305 310
 						 mFrustum[p][3] < 0)
306 311
 					{
307 312
 						_particle[i].setActive(false);

+ 40
- 36
src/GLString.cpp Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Mtk
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: Open GL rendering font/string class
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2002.01.01:
19 19
  * Mongoose - Created
@@ -23,7 +23,11 @@
23 23
 #include <stdio.h>
24 24
 #include <stdlib.h>
25 25
 #include <stdarg.h>
26
+#ifdef __APPLE__
27
+#include <OpenGL/gl.h>
28
+#else
26 29
 #include <GL/gl.h>
30
+#endif
27 31
 
28 32
 #include "Texture.h"
29 33
 
@@ -62,7 +66,7 @@ GLString::~GLString()
62 66
 	{
63 67
 		delete [] _font_texture;
64 68
 	}
65
-	
69
+
66 70
 	if (_font_base)
67 71
 	{
68 72
 		delete [] _font_base;
@@ -84,7 +88,7 @@ GLString::~GLString()
84 88
 }
85 89
 
86 90
 
87
-void GLString::Init(unsigned int max_strings, unsigned int max_fonts, 
91
+void GLString::Init(unsigned int max_strings, unsigned int max_fonts,
88 92
 						  int *tex_map)
89 93
 {
90 94
 	unsigned int i;
@@ -105,7 +109,7 @@ void GLString::Init(unsigned int max_strings, unsigned int max_fonts,
105 109
 	for (i = 0; i < max_fonts; ++i)
106 110
 	{
107 111
 		_font_texture[i] = tex_map[i];
108
-		
112
+
109 113
 		if (BuildFontList(i) < 0)
110 114
 		{
111 115
 			printf("GLString::Init> BuildFontList failed for %i\n", i);
@@ -118,7 +122,7 @@ void GLString::SetChar(unsigned int string, unsigned int pos, char c)
118 122
 {
119 123
 	gl_string_t *str = GetString(string);
120 124
 
121
-	
125
+
122 126
 	if (str && pos < str->len)
123 127
 	{
124 128
 		str->text[pos] = c;
@@ -130,7 +134,7 @@ unsigned int GLString::GetStringLen(unsigned int string)
130 134
 {
131 135
 	gl_string_t *str = GetString(string);
132 136
 
133
-	
137
+
134 138
 	if (str)
135 139
 	{
136 140
 		return str->len;
@@ -144,7 +148,7 @@ char *GLString::GetBuffer(unsigned int string)
144 148
 {
145 149
 	gl_string_t *str = GetString(string);
146 150
 
147
-	
151
+
148 152
 	if (str)
149 153
 	{
150 154
 		return str->text;
@@ -189,7 +193,7 @@ void GLString::SetString(unsigned int string, char *s, ...)
189 193
 		}
190 194
 
191 195
 		va_start(args, s);
192
-		vsnprintf(str->text, str->len-2, s, args);	
196
+		vsnprintf(str->text, str->len-2, s, args);
193 197
 		str->text[str->len-1] = 0;
194 198
 		va_end(args);
195 199
 	}
@@ -207,7 +211,7 @@ int GLString::BuildFontList(int index)
207 211
 	int i;
208 212
 	float cx;
209 213
 	float cy;
210
-	
214
+
211 215
 
212 216
 	if (_num_font >= _num_font_max || index < 0 || index >= (int)_num_font_max)
213 217
 	{
@@ -216,7 +220,7 @@ int GLString::BuildFontList(int index)
216 220
 
217 221
 	_font_base[index] = glGenLists(256);
218 222
 	glBindTexture(GL_TEXTURE_2D, _font_texture[index]);
219
-	
223
+
220 224
 	// Mongoose 2002.01.01, Generate 256 lists per font
221 225
 	//   one per symbol
222 226
 	for (i = 0; i < 256; i++)
@@ -225,7 +229,7 @@ int GLString::BuildFontList(int index)
225 229
 		cx = 1 - (float)(i % 16) / 16.0f;
226 230
 		/* Y Position Of Current Character */
227 231
 		cy = 1 - (float)(i / 16) / 16.0f;
228
-		
232
+
229 233
 		/* Start Building A List */
230 234
 		glNewList(_font_base[index] + (255 - i), GL_COMPILE);
231 235
 		/* Use A Quad For Each Character */
@@ -234,23 +238,23 @@ int GLString::BuildFontList(int index)
234 238
 		glTexCoord2f(cx - 0.0625, cy);
235 239
 		/* Vertex Coord (Bottom Left) */
236 240
 		glVertex2i(0, 0);
237
-		
241
+
238 242
 		/* Texture Coord (Bottom Right) */
239 243
 		glTexCoord2f(cx, cy);
240 244
 		/* Vertex Coord (Bottom Right) */
241 245
 		glVertex2i(16, 0);
242
-		
246
+
243 247
 		/* Texture Coord (Top Right) */
244 248
 		glTexCoord2f(cx, cy - 0.0625f);
245 249
 		 /* Vertex Coord (Top Right) */
246 250
 		glVertex2i(16, 16);
247
-		
251
+
248 252
 		/* Texture Coord (Top Left) */
249 253
 		glTexCoord2f(cx - 0.0625f, cy - 0.0625f);
250 254
 		/* Vertex Coord (Top Left) */
251 255
 		glVertex2i(0, 16);
252 256
 		glEnd();
253
-		
257
+
254 258
 		/* Move To The Left Of The Character */
255 259
 		glTranslated(10, 0, 0);
256 260
 		glEndList();
@@ -266,7 +270,7 @@ int GLString::glPrintf(int x, int y, int font, char *string, ...)
266 270
 	int n;
267 271
 	va_list args;
268 272
 
269
-	
273
+
270 274
 	// Mongoose 2002.01.01, Only allow valid strings
271 275
 	//   we must assume it's NULL terminated also if it passes...
272 276
 	if (!string || !string[0])
@@ -336,7 +340,7 @@ int GLString::glPrintf(int x, int y, int font, char *string, ...)
336 340
 	// Mongoose 2002.01.04, Remeber string size, for future rebuffering use
337 341
 	_string[_num_string].len = sz;
338 342
 
339
-	// Mongoose 2002.01.01, Incement string counter, since we just 
343
+	// Mongoose 2002.01.01, Incement string counter, since we just
340 344
 	//   allocated a string
341 345
 	++_num_string;
342 346
 
@@ -383,7 +387,7 @@ void GLString::Render(int width, int height)
383 387
 	// Mongoose 2001.12.31, Restore scene projection
384 388
 	glMatrixMode(GL_PROJECTION);
385 389
 	glPopMatrix();
386
-	
390
+
387 391
 	// Mongoose 2001.12.31, Restore scene matrix
388 392
 	glMatrixMode(GL_MODELVIEW);
389 393
 	glPopMatrix();
@@ -394,8 +398,8 @@ void GLString::Render(int width, int height)
394 398
 	{
395 399
 		if (_string[i].active)
396 400
 		{
397
-			glPrint2d(_string[i].x, _string[i].y, 
398
-						 _string[i].scale, 
401
+			glPrint2d(_string[i].x, _string[i].y,
402
+						 _string[i].scale,
399 403
 						 _string[i].text);
400 404
 		}
401 405
 	}
@@ -444,7 +448,7 @@ void event_resize(int width, int height)
444 448
 
445 449
 	glMatrixMode(GL_PROJECTION);
446 450
 	aspect = (GLfloat)width/(GLfloat)height;
447
-	
451
+
448 452
 	// Mongoose 2002.01.01, Setup view volume, with a nice FOV
449 453
 	gluPerspective(40.0, aspect, 1, 2000);
450 454
 
@@ -508,7 +512,7 @@ void shutdown_gl()
508 512
 }
509 513
 
510 514
 
511
-void init_gl(unsigned int width, unsigned int height, 
515
+void init_gl(unsigned int width, unsigned int height,
512 516
 				 int argc, char *argv[])
513 517
 {
514 518
 	int i, j;
@@ -523,14 +527,14 @@ void init_gl(unsigned int width, unsigned int height,
523 527
 	glDepthFunc(GL_LESS);
524 528
 	glEnable(GL_BLEND);
525 529
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
526
-	
530
+
527 531
 	event_resize(width, height);
528 532
 
529 533
 	// Mongoose 2002.01.01, Texture setup
530 534
 	gTexture.reset();
531 535
 	gTexture.setFlag(Texture::fUseMipmaps);
532 536
 	gTexture.setMaxTextureCount(32);
533
-	
537
+
534 538
 	if (argc > 1)
535 539
 	{
536 540
 		for (i = 1, j = 0; i < argc; ++i, ++j)
@@ -552,14 +556,14 @@ void init_gl(unsigned int width, unsigned int height,
552 556
 	printf("%i %i %i %i\n", id[0], id[1], id[2], id[3]);
553 557
 
554 558
 	TEXT->Init(4, 4, id);
555
-	i = TEXT->glPrintf((width/2)-12*5, height/2, 0, 
559
+	i = TEXT->glPrintf((width/2)-12*5, height/2, 0,
556 560
 							 "[font %i] GLString Test", id[0]);
557 561
 	if (i)
558 562
 	{
559 563
 		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
560 564
 	}
561 565
 
562
-	i = TEXT->glPrintf((width/2)-10*7, height/2+32, 1, 
566
+	i = TEXT->glPrintf((width/2)-10*7, height/2+32, 1,
563 567
 							 "[font %i] GLString Test", id[1]);
564 568
 
565 569
 	if (i)
@@ -570,14 +574,14 @@ void init_gl(unsigned int width, unsigned int height,
570 574
 	s = 1.1;
571 575
 	TEXT->Scale(s);
572 576
 
573
-	i = TEXT->glPrintf((width/2)-10*7, height/2+64, 1, 
577
+	i = TEXT->glPrintf((width/2)-10*7, height/2+64, 1,
574 578
 							 "[font %i] Scaled by %.3f", id[1], s);
575 579
 
576 580
 	if (i)
577 581
 	{
578 582
 		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
579 583
 	}
580
-	i = TEXT->glPrintf((width/2)-10*7, height/2-32, 0, 
584
+	i = TEXT->glPrintf((width/2)-10*7, height/2-32, 0,
581 585
 							 "[font %i] Scaled by %.3f", id[0], s);
582 586
 
583 587
 	if (i)
@@ -615,7 +619,7 @@ int main_gl(int argc, char *argv[])
615 619
 	  if (SDL_GL_LoadLibrary("libGL.so") < 0)
616 620
 	  {
617 621
 		  SDL_ClearError();
618
-    
622
+
619 623
 		  // Fallback 2
620 624
 		  if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
621 625
 		  {
@@ -642,7 +646,7 @@ int main_gl(int argc, char *argv[])
642 646
   SDL_WINDOW = SDL_SetVideoMode(width, height, 16, flags);
643 647
   SDL_WM_SetCaption("GLString Test", "GLString Test");
644 648
   SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
645
-  
649
+
646 650
   // Init rendering
647 651
   init_gl(width, height, argc, argv);
648 652
 
@@ -664,7 +668,7 @@ int main_gl(int argc, char *argv[])
664 668
 			  break;
665 669
 		  case SDL_MOUSEBUTTONDOWN:
666 670
 		  case SDL_MOUSEBUTTONUP:
667
-			  break;	
671
+			  break;
668 672
 		  case SDL_KEYDOWN:
669 673
 			  mkeys = (unsigned int)SDL_GetModState();
670 674
 			  mod = 0;
@@ -698,7 +702,7 @@ int main_gl(int argc, char *argv[])
698 702
 			  break;
699 703
 		  case SDL_KEYUP:
700 704
 			  break;
701
-		  case SDL_VIDEORESIZE:			  
705
+		  case SDL_VIDEORESIZE:
702 706
 			  event_resize(event.resize.w, event.resize.h);
703 707
 
704 708
 			  width = event.resize.w;
@@ -708,7 +712,7 @@ int main_gl(int argc, char *argv[])
708 712
 		  }
709 713
 	  }
710 714
   }
711
-  
715
+
712 716
   return 0;
713 717
 }
714 718
 #else

+ 14
- 8
src/GLUTSystem.cpp Zobrazit soubor

@@ -1,19 +1,19 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : UnRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
7 7
  * Email   : stu7440@westga.edu
8 8
  * Object  : GLUTSystem
9 9
  * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 
10
+ * Comments:
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2002.08.09:
19 19
  * Mongoose - Created
@@ -23,9 +23,15 @@
23 23
 #include <stdio.h>
24 24
 #include <string.h>
25 25
 
26
+#ifdef __APPLE__
27
+#include <OpenGL/gl.h>
28
+#include <OpenGL/glu.h>
29
+#include <GLUT/glut.h>
30
+#else
26 31
 #include <GL/gl.h>
27 32
 #include <GL/glu.h>
28 33
 #include <GL/glut.h>
34
+#endif
29 35
 
30 36
 #ifdef PS2_LINUX
31 37
 #   include "ps2.h"
@@ -92,7 +98,7 @@ void GLUTSystem::shutdown(int i)
92 98
 	//printf("[Mongoose MEMEORY_DEBUG]\nUnfreed memory table:\n");
93 99
 	//dump_memory_report();
94 100
 	//#endif
95
-	
101
+
96 102
 	printf("\n\n\tThanks for testing %s\n", VERSION);
97 103
 	printf("\tPlease file bug reports and submit video card performance\n\n");
98 104
 	printf("\tBuild date : %s @ %s\n", __DATE__, __TIME__);
@@ -104,12 +110,12 @@ void GLUTSystem::shutdown(int i)
104 110
 }
105 111
 
106 112
 
107
-void GLUTSystem::initVideo(unsigned int width, unsigned int height, 
113
+void GLUTSystem::initVideo(unsigned int width, unsigned int height,
108 114
 								  bool fullscreen)
109 115
 {
110 116
 	glutInit(NULL, 0);
111 117
 	printf("@Created OpenGL Context...\n");
112
-	
118
+
113 119
 	m_width = width;
114 120
 	m_height = height;
115 121
 

+ 10
- 10
src/Light.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: This is the GL light class
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------ 
15
+ *
16
+ *-- History ------------------------------------------------
17 17
  *
18 18
  * 2002.01.27:
19 19
  * Mongoose - Created
@@ -23,7 +23,7 @@
23 23
 #ifndef __FREYJA_MONGOOSE_LIGHT_H_
24 24
 #define __FREYJA_MONGOOSE_LIGHT_H_
25 25
 
26
-#include <hel/math.h>
26
+#include "hel/math.h"
27 27
 
28 28
 
29 29
 class Light
@@ -32,20 +32,20 @@ class Light
32 32
 
33 33
 	typedef enum
34 34
    {
35
-		typePoint = 1, 
36
-		typeSpot = 2, 
35
+		typePoint = 1,
36
+		typeSpot = 2,
37 37
 		typeDirectional = 3
38 38
 	} FreyjaLightType;
39 39
 
40 40
 
41 41
 	Light();
42 42
 	/*------------------------------------------------------
43
-	 * Pre  : 
43
+	 * Pre  :
44 44
 	 * Post : Constructs an object of Light
45 45
 	 *
46 46
 	 *-- History ------------------------------------------
47 47
 	 *
48
-	 * 2002.01.27: 
48
+	 * 2002.01.27:
49 49
 	 * Mongoose - Created
50 50
 	 ------------------------------------------------------*/
51 51
 
@@ -56,7 +56,7 @@ class Light
56 56
 	 *
57 57
 	 *-- History ------------------------------------------
58 58
 	 *
59
-	 * 2002.01.27: 
59
+	 * 2002.01.27:
60 60
 	 * Mongoose - Created
61 61
 	 ------------------------------------------------------*/
62 62
 

+ 90
- 86
src/Md3.cpp Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*==========================================================================
3
- * 
3
+ *
4 4
  * Project : GooseEgg
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440
@@ -17,7 +17,7 @@
17 17
  *           so - since this class is desgined using their specs...
18 18
  *
19 19
  *
20
- *-- History ---------------------------------------------------------- 
20
+ *-- History ----------------------------------------------------------
21 21
  *
22 22
  * 2000-10-06:
23 23
  * Mongoose - The new code for the new interface
@@ -35,7 +35,11 @@
35 35
 #include <math.h>
36 36
 
37 37
 #ifdef USING_OPENGL
38
-#   include <GL/gl.h>
38
+#ifdef __APPLE__
39
+#include <OpenGL/gl.h>
40
+#else
41
+#include <GL/gl.h>
42
+#endif
39 43
 #endif
40 44
 
41 45
 #include "endian.h"
@@ -48,23 +52,23 @@ Md3::Md3()
48 52
 {
49 53
 	mFlags = fDecodeNormals;
50 54
 
51
-	memset(m_filename, 0, 68);     
52
- 
55
+	memset(m_filename, 0, 68);
56
+
53 57
 	m_id = 0;
54
-	m_version = 0;           
55
-	m_num_bones = 0;   
56
-	m_num_tags = 0;          
57
-	m_num_meshes = 0;        
58
+	m_version = 0;
59
+	m_num_bones = 0;
60
+	m_num_tags = 0;
61
+	m_num_meshes = 0;
58 62
 	m_max_skins = 0;
59 63
 
60
-	m_header_length = 0;     
61
-	m_tag_start = 0;         
62
-	m_surfaces_start = 0;          
63
-	m_file_size = 0;        
64
+	m_header_length = 0;
65
+	m_tag_start = 0;
66
+	m_surfaces_start = 0;
67
+	m_file_size = 0;
64 68
 
65 69
 	m_debug = 1;
66 70
 
67
-	m_tags = NULL;     
71
+	m_tags = NULL;
68 72
 	m_bones = NULL;
69 73
 	m_meshes = NULL;
70 74
 	slaveTest = NULL;
@@ -73,28 +77,28 @@ Md3::Md3()
73 77
 
74 78
 
75 79
 Md3::Md3(unsigned int num_meshes, unsigned int num_bones, unsigned int num_tags)
76
-{	
77
-	memset(m_filename, 0, 68);     
78
- 
80
+{
81
+	memset(m_filename, 0, 68);
82
+
79 83
 	m_id = 0;
80 84
 	m_version = 0;
81 85
 	m_max_skins = 0;
82 86
 
83
-	m_header_length = 0;     
84
-	m_tag_start = 0;         
85
-	m_surfaces_start = 0;          
86
-	m_file_size = 0;        
87
+	m_header_length = 0;
88
+	m_tag_start = 0;
89
+	m_surfaces_start = 0;
90
+	m_file_size = 0;
87 91
 
88 92
 	m_debug = 1;
89 93
 
90
-	m_tags = NULL;     
94
+	m_tags = NULL;
91 95
 	m_bones = NULL;
92 96
 	m_meshes = NULL;
93 97
 	slaveTest = NULL;
94 98
 	texTest = NULL;
95 99
 
96
-	m_num_bones = num_bones;   
97
-	m_num_tags = num_tags;          
100
+	m_num_bones = num_bones;
101
+	m_num_tags = num_tags;
98 102
 	m_num_meshes = num_meshes;
99 103
 	createMeshes(num_meshes);
100 104
 	createTags(num_tags*num_bones);
@@ -162,18 +166,18 @@ void Md3::reset()
162 166
 {
163 167
 	int i;
164 168
 
165
-	memset(m_filename, 0, 68);     
169
+	memset(m_filename, 0, 68);
166 170
 
167 171
 	m_id = 0;
168
-	m_version = 0;           
169
-	m_num_bones = 0;   
170
-	m_num_tags = 0;          
171
-	m_num_meshes = 0;        
172
+	m_version = 0;
173
+	m_num_bones = 0;
174
+	m_num_tags = 0;
175
+	m_num_meshes = 0;
172 176
 	m_max_skins = 0;
173
-	m_header_length = 0;     
174
-	m_tag_start = 0;         
175
-	m_surfaces_start = 0;          
176
-	m_file_size = 0;  
177
+	m_header_length = 0;
178
+	m_tag_start = 0;
179
+	m_surfaces_start = 0;
180
+	m_file_size = 0;
177 181
 
178 182
 	if (m_meshes)
179 183
 	{
@@ -222,7 +226,7 @@ void Md3::reset()
222 226
 	{
223 227
 		delete [] texTest;
224 228
 	}
225
-} 
229
+}
226 230
 
227 231
 
228 232
 void Md3::setDebug(unsigned char level)
@@ -240,7 +244,7 @@ int Md3::load(char *filename)
240 244
 	int16_t ss;
241 245
 	int8_t sb;
242 246
 
243
-  
247
+
244 248
 	npherno_warn = 0;
245 249
 
246 250
 	f = fopen(filename, "rb");
@@ -255,13 +259,13 @@ int Md3::load(char *filename)
255 259
 
256 260
 	fread_int_small(&m_id, f);
257 261
 	printDebug("load", "id = 0x%x\n", m_id);
258
-  
262
+
259 263
 	if (m_id != MD3_IDALIASHEADER)
260 264
 	{
261 265
 		printError("load", "header not 0x%x\n", MD3_IDALIASHEADER);
262 266
 		return -2;
263 267
 	}
264
-  
268
+
265 269
 	fread_int_small(&m_version, f);
266 270
 	printDebug("load", "version = %i\n", m_version);
267 271
 
@@ -270,7 +274,7 @@ int Md3::load(char *filename)
270 274
 		printError("load", "version not %i\n", MD3_ALIAS_VERSION);
271 275
 		return -3;
272 276
 	}
273
-  
277
+
274 278
 	fread(&m_filename, 68, 1, f);
275 279
 	printDebug("load", "filename = '%s'\n", m_filename);
276 280
 
@@ -297,7 +301,7 @@ int Md3::load(char *filename)
297 301
 
298 302
 	fread_int_small(&m_file_size, f);
299 303
 	printDebug("load", "file_size = %i\n", m_file_size);
300
- 
304
+
301 305
 	// End Header //////////////////
302 306
 	printDebug("load", "Loading %i bones\n", m_num_bones);
303 307
 	createBones(m_num_bones);
@@ -325,11 +329,11 @@ int Md3::load(char *filename)
325 329
 			npherno_warn = 1;
326 330
 		}
327 331
 
328
-		printDebug("load", "bone[%i].mins = %f %f %f\n", i, 
332
+		printDebug("load", "bone[%i].mins = %f %f %f\n", i,
329 333
 				 m_bones[i].mins[0], m_bones[i].mins[1], m_bones[i].mins[2]);
330
-		printDebug("load", "bone[%i].maxs = %f %f %f\n", i, 
334
+		printDebug("load", "bone[%i].maxs = %f %f %f\n", i,
331 335
 				 m_bones[i].maxs[0], m_bones[i].maxs[1], m_bones[i].maxs[2]);
332
-		printDebug("load", "bone[%i].center = %f %f %f\n", i, 
336
+		printDebug("load", "bone[%i].center = %f %f %f\n", i,
333 337
 				 m_bones[i].center[0], m_bones[i].center[1], m_bones[i].center[2]);
334 338
 		printDebug("load", "bone[%i].scale = %f\n", i, m_bones[i].scale);
335 339
 		printDebug("load", "bone[%i].creator = '%s'\n", i, m_bones[i].creator);
@@ -338,7 +342,7 @@ int Md3::load(char *filename)
338 342
 
339 343
 	if (m_tag_start != ftell(f))
340 344
 	{
341
-		printWarning("load", "tag_start %i != file pos %lu\n", 
345
+		printWarning("load", "tag_start %i != file pos %lu\n",
342 346
 						 m_tag_start,ftell(f));
343 347
 
344 348
 		fseek(f, m_tag_start, SEEK_SET);
@@ -362,13 +366,13 @@ int Md3::load(char *filename)
362 366
 
363 367
 	if (m_surfaces_start != ftell(f))
364 368
 	{
365
-		printWarning("load", "surfaces_start %i != file pos %lu\n", 
369
+		printWarning("load", "surfaces_start %i != file pos %lu\n",
366 370
 						 m_surfaces_start, ftell(f));
367 371
 
368 372
 		fseek(f, m_surfaces_start, SEEK_SET);
369 373
 		printWarning("load", "File position set to %lu\n", ftell(f));
370 374
 	}
371
- 
375
+
372 376
 	printDebug("load", "Loading %i meshes\n", m_num_meshes);
373 377
 	createMeshes(m_num_meshes);
374 378
 
@@ -380,10 +384,10 @@ int Md3::load(char *filename)
380 384
 		fread(&m_meshes[i].name, 64, 1, f);
381 385
 		fread(&m_meshes[i].flags, 4, 1, f);
382 386
 		fread(&m_meshes[i].num_frames, 4, 1, f);
383
-    
387
+
384 388
 		fread(&m_meshes[i].num_shaders, 4, 1, f);
385 389
 		m_meshes[i].num_skins = m_meshes[i].num_shaders;
386
-    
390
+
387 391
 		fread(&m_meshes[i].num_vertices, 4, 1, f);
388 392
 		fread(&m_meshes[i].num_triangles, 4, 1, f);
389 393
 		fread(&m_meshes[i].tris_offset, 4, 1, f);
@@ -394,29 +398,29 @@ int Md3::load(char *filename)
394 398
 		// num_verts * num_frames
395 399
 		fread(&m_meshes[i].mesh_size, 4, 1, f);     // next surface
396 400
 
397
-		printDebug("load", "mesh[%i].id = '%c%c%c%c'\n", i, 
401
+		printDebug("load", "mesh[%i].id = '%c%c%c%c'\n", i,
398 402
 				 m_meshes[i].id[0], m_meshes[i].id[1], m_meshes[i].id[2], m_meshes[i].id[3]);
399
-		printDebug("load", "mesh[%i].name = '%s'\n", i, 
403
+		printDebug("load", "mesh[%i].name = '%s'\n", i,
400 404
 				 m_meshes[i].name);
401
-		printDebug("load", "mesh[%i].flags = %i\n", i, 
405
+		printDebug("load", "mesh[%i].flags = %i\n", i,
402 406
 				 m_meshes[i].flags);
403
-		printDebug("load", "mesh[%i].num_frames = %i\n", i, 
407
+		printDebug("load", "mesh[%i].num_frames = %i\n", i,
404 408
 				 m_meshes[i].num_frames);
405
-		printDebug("load", "mesh[%i].num_shaders = %i\n", i, 
409
+		printDebug("load", "mesh[%i].num_shaders = %i\n", i,
406 410
 				 m_meshes[i].num_shaders);
407
-		printDebug("load", "mesh[%i].num_vertices = %i\n", i, 
411
+		printDebug("load", "mesh[%i].num_vertices = %i\n", i,
408 412
 				 m_meshes[i].num_vertices);
409
-		printDebug("load", "mesh[%i].num_triangles = %i\n", i, 
413
+		printDebug("load", "mesh[%i].num_triangles = %i\n", i,
410 414
 				 m_meshes[i].num_triangles);
411
-		printDebug("load", "mesh[%i].tris_offset = %i\n", i, 
415
+		printDebug("load", "mesh[%i].tris_offset = %i\n", i,
412 416
 				 m_meshes[i].tris_offset+m_surfaces_start);
413
-		printDebug("load", "mesh[%i].shader_offset = %i\n", i, 
417
+		printDebug("load", "mesh[%i].shader_offset = %i\n", i,
414 418
 				 m_meshes[i].header_size+m_surfaces_start);
415
-		printDebug("load", "mesh[%i].texel_offset = %i\n", i, 
419
+		printDebug("load", "mesh[%i].texel_offset = %i\n", i,
416 420
 				 m_meshes[i].texel_offset+m_surfaces_start);
417
-		printDebug("load", "mesh[%i].vertex_offset = %i\n", i, 
421
+		printDebug("load", "mesh[%i].vertex_offset = %i\n", i,
418 422
 				 m_meshes[i].vertex_offset+m_surfaces_start);
419
-		printDebug("load", "mesh[%i].mesh_end = %i\n", i, 
423
+		printDebug("load", "mesh[%i].mesh_end = %i\n", i,
420 424
 				 m_meshes[i].mesh_size+m_surfaces_start);
421 425
 
422 426
 		// This will kind of handle bad mesh reads here
@@ -442,7 +446,7 @@ int Md3::load(char *filename)
442 446
 		{
443 447
 			printWarning("load", "_mesh[%i] shader offset %i != file pos %lu\n",
444 448
 							 i, m_surfaces_start+m_meshes[i].header_size, ftell(f));
445
-      
449
+
446 450
 			fseek(f, m_surfaces_start+m_meshes[i].header_size, SEEK_SET);
447 451
 			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
448 452
 		}
@@ -475,7 +479,7 @@ int Md3::load(char *filename)
475 479
 
476 480
 				for (k = 0; k < 68; ++k)
477 481
 				{
478
-					if (m_meshes[i].skin[j].name[k] > 32 && 
482
+					if (m_meshes[i].skin[j].name[k] > 32 &&
479 483
 						 m_meshes[i].skin[j].name[k] < 127)
480 484
 					{
481 485
 						printf("%c", m_meshes[i].skin[j].name[k]);
@@ -489,16 +493,16 @@ int Md3::load(char *filename)
489 493
 				printf("'\n");
490 494
 			}
491 495
 
492
-			printDebug("load", "mesh[%i].skin[%i].name = '%s'\n", 
496
+			printDebug("load", "mesh[%i].skin[%i].name = '%s'\n",
493 497
 					 i, j, m_meshes[i].skin[j].name);
494 498
 		}
495 499
 
496 500
 		// Start triangles ////////////////////////
497 501
 		if (m_surfaces_start+m_meshes[i].tris_offset != ftell(f))
498 502
 		{
499
-			printWarning("load", "mesh[%i] tris offset %i != file pos %lu\n", i, 
503
+			printWarning("load", "mesh[%i] tris offset %i != file pos %lu\n", i,
500 504
 							 m_surfaces_start+m_meshes[i].tris_offset, ftell(f));
501
-      
505
+
502 506
 			fseek(f, m_surfaces_start+m_meshes[i].tris_offset, SEEK_SET);
503 507
 			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
504 508
 		}
@@ -513,9 +517,9 @@ int Md3::load(char *filename)
513 517
 		// Start texels /////////////////////
514 518
 		if (m_surfaces_start+m_meshes[i].texel_offset != ftell(f))
515 519
 		{
516
-			printWarning("load", "mesh[%i] texel offset %i != file pos %lu\n", i, 
520
+			printWarning("load", "mesh[%i] texel offset %i != file pos %lu\n", i,
517 521
 							 m_surfaces_start+m_meshes[i].texel_offset, ftell(f));
518
-      
522
+
519 523
 			fseek(f, m_surfaces_start+m_meshes[i].texel_offset, SEEK_SET);
520 524
 			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
521 525
 		}
@@ -531,15 +535,15 @@ int Md3::load(char *filename)
531 535
 		// Start vertices /////////////////////
532 536
 		if (m_surfaces_start+m_meshes[i].vertex_offset != ftell(f))
533 537
 		{
534
-			printWarning("load", "mesh[%i] vertex offset %i != file pos %lu\n", 
538
+			printWarning("load", "mesh[%i] vertex offset %i != file pos %lu\n",
535 539
 							 i, m_surfaces_start+m_meshes[i].vertex_offset, ftell(f));
536
-      
540
+
537 541
 			fseek(f, m_surfaces_start+m_meshes[i].vertex_offset, SEEK_SET);
538 542
 			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
539 543
 		}
540 544
 
541 545
 		// Should be num_vertices * num_frames??
542
-		m_meshes[i].vertex = 
546
+		m_meshes[i].vertex =
543 547
       new md3_vertex_t[m_meshes[i].num_vertices * m_meshes[i].num_frames];
544 548
 
545 549
 		for (j = 0; j < m_meshes[i].num_vertices * m_meshes[i].num_frames; ++j)
@@ -566,12 +570,12 @@ int Md3::load(char *filename)
566 570
 				normal = (unsigned short)m_meshes[i].vertex[j].st;
567 571
 				lat = (unsigned char)((normal & 255) * (2 * M_PI) / 255.0);
568 572
 				lng = (unsigned char)(((normal >> 8) & 255) * (2 * M_PI) / 255.0);
569
-				
573
+
570 574
 				m_meshes[i].vertex[j].norm[0] = cos(lat) * sin(lng);
571 575
 				m_meshes[i].vertex[j].norm[1] = sin(lat) * sin(lng);
572 576
 				m_meshes[i].vertex[j].norm[2] = cos(lng);
573 577
 
574
-				printDebug("load", "%f %f %f\n", 
578
+				printDebug("load", "%f %f %f\n",
575 579
 							  m_meshes[i].vertex[j].norm[0],
576 580
 							  m_meshes[i].vertex[j].norm[1],
577 581
 							  m_meshes[i].vertex[j].norm[2]);
@@ -581,9 +585,9 @@ int Md3::load(char *filename)
581 585
 		// Start next surface/mesh /////////////////////
582 586
 		if (m_surfaces_start+m_meshes[i].mesh_size != ftell(f))
583 587
 		{
584
-			printWarning("load", "_mesh[%i] next mesh offset %i != file pos %lu\n", 
588
+			printWarning("load", "_mesh[%i] next mesh offset %i != file pos %lu\n",
585 589
 						  i, m_surfaces_start+m_meshes[i].mesh_size, ftell(f));
586
-      
590
+
587 591
 			fseek(f, m_surfaces_start+m_meshes[i].mesh_size, SEEK_SET);
588 592
 			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
589 593
 		}
@@ -603,9 +607,9 @@ int Md3::save(char *filename)
603 607
   FILE *f;
604 608
   int i, ii, tmp, hms;
605 609
   int32_t si;
606
-  
607 610
 
608
-  if ((!m_tags && m_num_tags) || (!m_bones && m_num_bones) || 
611
+
612
+  if ((!m_tags && m_num_tags) || (!m_bones && m_num_bones) ||
609 613
 		(!m_meshes && m_num_meshes))
610 614
   {
611 615
     printError("save", "invalid md3\n");
@@ -624,7 +628,7 @@ int Md3::save(char *filename)
624 628
   si = m_id;
625 629
   fwrite(&si, 4, 1, f);
626 630
   printDebug("save", "id = 0x%x\n", m_id);
627
-  
631
+
628 632
   m_version = MD3_ALIAS_VERSION;
629 633
 
630 634
   fwrite(&m_version, 4, 1, f);
@@ -664,7 +668,7 @@ int Md3::save(char *filename)
664 668
   // store file postiion for now
665 669
   m_file_size = ftell(f);
666 670
   fwrite(&m_file_size, 4, 1, f);
667
- 
671
+
668 672
   // End Header //////////////////
669 673
   tmp = m_header_length;
670 674
   m_header_length = ftell(f);
@@ -757,14 +761,14 @@ int Md3::save(char *filename)
757 761
 
758 762
 #ifdef TEST_MD3
759 763
       printf("Viewing full skin buffer:\n'");
760
-		
764
+
761 765
       for (int foo = 0; foo < 68; ++foo)
762 766
 	printf("%c", m_meshes[i].skin[ii].name[foo]);
763 767
 
764 768
       printf("'\n");
765 769
 #endif
766 770
 
767
-      printDebug("save", "_mesh[%i].skin[%i].name = '%s'\n", 
771
+      printDebug("save", "_mesh[%i].skin[%i].name = '%s'\n",
768 772
 	     i, ii, m_meshes[i].skin[ii].name);
769 773
     }
770 774
 
@@ -774,7 +778,7 @@ int Md3::save(char *filename)
774 778
     m_meshes[i].tris_offset = tmp - hms;
775 779
     fwrite(&m_meshes[i].tris_offset, 4, 1, f);
776 780
     printDebug("save", "_mesh[%i].tris_offset = %i\n",i,m_meshes[i].tris_offset);
777
-    fseek(f, tmp, SEEK_SET);   
781
+    fseek(f, tmp, SEEK_SET);
778 782
 
779 783
     for(ii = 0; ii < m_meshes[i].num_triangles; ++ii)
780 784
     {
@@ -788,7 +792,7 @@ int Md3::save(char *filename)
788 792
     fwrite(&m_meshes[i].texel_offset, 4, 1, f);
789 793
     printDebug("save", "_mesh[%i].texel_offset = %i\n",
790 794
 	   i,m_meshes[i].texel_offset);
791
-    fseek(f, tmp, SEEK_SET);   
795
+    fseek(f, tmp, SEEK_SET);
792 796
 
793 797
     for(ii = 0; ii < m_meshes[i].num_vertices; ++ii)
794 798
     {
@@ -802,7 +806,7 @@ int Md3::save(char *filename)
802 806
     fwrite(&m_meshes[i].vertex_offset, 4, 1, f);
803 807
     printDebug("save", "_mesh[%i]._vertexoffset = %i\n",
804 808
 	   i,m_meshes[i].vertex_offset);
805
-    fseek(f, tmp, SEEK_SET);  
809
+    fseek(f, tmp, SEEK_SET);
806 810
 
807 811
     // Should be num_vertices * num_frames??
808 812
     for(ii = 0; ii < m_meshes[i].num_vertices * m_meshes[i].num_frames; ++ii)
@@ -892,7 +896,7 @@ void Md3::createMeshes(unsigned int num)
892 896
 	m_meshes = new md3_mesh_t[num];
893 897
 
894 898
 	texTest = new int[num];
895
-	memset(texTest, 0, num*4);	
899
+	memset(texTest, 0, num*4);
896 900
 }
897 901
 
898 902
 
@@ -923,7 +927,7 @@ int main(int argc, char *argv[])
923 927
 
924 928
 
925 929
 	printf("[MD3 class test]\n");
926
-	
930
+
927 931
 	md3.setDebug(2);
928 932
 
929 933
 	if (argc > 2)
@@ -958,13 +962,13 @@ int main(int argc, char *argv[])
958 962
 		}
959 963
 		else
960 964
 		{
961
-			printf("\n\n%s [save | load | test] filename.md3 [testout.md3]\n", 
965
+			printf("\n\n%s [save | load | test] filename.md3 [testout.md3]\n",
962 966
 					 argv[0]);
963 967
 		}
964 968
 	}
965 969
 	else
966 970
 	{
967
-		printf("\n\n%s [save | load | test] filename.md3 [testout.md3]\n", 
971
+		printf("\n\n%s [save | load | test] filename.md3 [testout.md3]\n",
968 972
 				 argv[0]);
969 973
 	}
970 974
 }

+ 120
- 116
src/Md3AnimModel.cpp Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: Md3 animation model class
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2002.06.19:
19 19
  * Mongoose - Created
@@ -25,11 +25,15 @@
25 25
 #include <ctype.h>
26 26
 
27 27
 #ifdef USING_OPENGL
28
-#   include <GL/gl.h>
28
+#ifdef __APPLE__
29
+#include <OpenGL/gl.h>
30
+#else
31
+#include <GL/gl.h>
32
+#endif
29 33
 #endif
30 34
 
31
-#include <hel/math.h>
32
-#include <hel/Quaternion.h>
35
+#include "hel/math.h"
36
+#include "hel/Quaternion.h"
33 37
 #include "Md3AnimModel.h"
34 38
 
35 39
 
@@ -104,7 +108,7 @@ void Md3AnimModel::toggleFlag(Md3AnimModelFlags flag)
104 108
 }
105 109
 
106 110
 
107
-// Mongoose 2002.06.29, FIXME: Add handler here to avoid 
111
+// Mongoose 2002.06.29, FIXME: Add handler here to avoid
108 112
 //   using animations not loaded
109 113
 void Md3AnimModel::setAnimUpper(md3_animation_id_t anim)
110 114
 {
@@ -165,7 +169,7 @@ void Md3AnimModel::setAnimUpper(md3_animation_id_t anim)
165 169
 }
166 170
 
167 171
 
168
-// Mongoose 2002.06.29, FIXME: Add handler here to avoid 
172
+// Mongoose 2002.06.29, FIXME: Add handler here to avoid
169 173
 //   using animations not loaded
170 174
 void Md3AnimModel::setAnimLower(md3_animation_id_t anim)
171 175
 {
@@ -409,22 +413,22 @@ int Md3AnimModel::loadAnimations(char *modelPath)
409 413
 					firstFrame = atoi(buffer);
410 414
 					++state;
411 415
 					i = 0;
412
-					break; 
416
+					break;
413 417
 				case 1:
414 418
 					numFrames = atoi(buffer);
415 419
 					++state;
416 420
 					i = 0;
417
-					break; 
421
+					break;
418 422
 				case 2:
419 423
 					loopingFrames = atoi(buffer);
420 424
 					++state;
421 425
 					i = 0;
422
-					break; 
426
+					break;
423 427
 				case 3:
424 428
 					framesPerSecond = atoi(buffer);
425 429
 					state = 4; // override comment buffer block
426 430
 					i = 0;
427
-					break; 
431
+					break;
428 432
 				}
429 433
 			}
430 434
 			break;
@@ -439,7 +443,7 @@ int Md3AnimModel::loadAnimations(char *modelPath)
439 443
 			{
440 444
 				for (j = 0; j < i; ++j)
441 445
 				{
442
-					if (!isdigit(buffer[j]) && !isupper(buffer[j]) && 
446
+					if (!isdigit(buffer[j]) && !isupper(buffer[j]) &&
443 447
 						 buffer[j] != '_')
444 448
 					{
445 449
 						printf("WARNING: Stripping '%s'.\n", buffer);
@@ -447,7 +451,7 @@ int Md3AnimModel::loadAnimations(char *modelPath)
447 451
 						j = i;
448 452
 					}
449 453
 				}
450
-				
454
+
451 455
 				i = 0;
452 456
 			}
453 457
 			else
@@ -488,19 +492,19 @@ int Md3AnimModel::loadAnimations(char *modelPath)
488 492
 
489 493
 				if (m_debug > 0)
490 494
 				{
491
-					printf("<%s> %3i %3i %3i %3i \t'%s' \t(%i)\n", 
495
+					printf("<%s> %3i %3i %3i %3i \t'%s' \t(%i)\n",
492 496
 							 (id == UNSUPPORTED) ? "Unsupported" : "",
493
-							 firstFrame, numFrames, 
497
+							 firstFrame, numFrames,
494 498
 							 loopingFrames, framesPerSecond, buffer, id);
495 499
 				}
496 500
 
497
-				addAnim(buffer, id, firstFrame, numFrames, 
501
+				addAnim(buffer, id, firstFrame, numFrames,
498 502
 								loopingFrames, framesPerSecond);
499 503
 
500 504
 				i = 0;
501 505
 			}
502 506
 			else if (strncmp("TORSO_", buffer, 6) == 0)
503
-			{				
507
+			{
504 508
 				if (strncmp("TORSO_GESTURE\0", buffer, 14) == 0)
505 509
 				{
506 510
 					id = TORSO_GESTURE;
@@ -533,25 +537,25 @@ int Md3AnimModel::loadAnimations(char *modelPath)
533 537
 				{
534 538
 					id = UNSUPPORTED;
535 539
 				}
536
-			
540
+
537 541
 				if (m_debug > 0)
538 542
 				{
539
-					printf("<%s> %3i %3i %3i %3i \t'%s' (%i)\n", 
543
+					printf("<%s> %3i %3i %3i %3i \t'%s' (%i)\n",
540 544
 							 (id == UNSUPPORTED) ? "Unsupported" : "",
541
-							 firstFrame, numFrames, 
545
+							 firstFrame, numFrames,
542 546
 							 loopingFrames, framesPerSecond, buffer, id);
543 547
 				}
544 548
 
545 549
 				if (id != UNSUPPORTED)
546 550
 				{
547
-					addAnim(buffer, id, firstFrame, numFrames, 
551
+					addAnim(buffer, id, firstFrame, numFrames,
548 552
 							  loopingFrames, framesPerSecond);
549 553
 				}
550 554
 
551 555
 				i = 0;
552 556
 			}
553 557
 			else if (strncmp("LEGS_", buffer, 5) == 0)
554
-			{				
558
+			{
555 559
 				if (strncmp("LEGS_WALKCR\0", buffer, 12) == 0)
556 560
 				{
557 561
 					id = LEGS_WALKCR;
@@ -559,43 +563,43 @@ int Md3AnimModel::loadAnimations(char *modelPath)
559 563
 				else if (strncmp("LEGS_WALK\0", buffer, 10) == 0)
560 564
 				{
561 565
 					id = LEGS_WALK;
562
-				}	
566
+				}
563 567
 				else if (strncmp("LEGS_RUN\0", buffer, 9) == 0)
564 568
 				{
565 569
 					id = LEGS_RUN;
566
-				}	
570
+				}
567 571
 				else if (strncmp("LEGS_BACK\0", buffer, 10) == 0)
568 572
 				{
569 573
 					id = LEGS_BACK;
570
-				}	
574
+				}
571 575
 				else if (strncmp("LEGS_SWIM\0", buffer, 10) == 0)
572 576
 				{
573 577
 					id = LEGS_SWIM;
574
-				}	
578
+				}
575 579
 				else if (strncmp("LEGS_JUMPB\0", buffer, 11) == 0)
576 580
 				{
577 581
 					id = LEGS_JUMPB;
578
-				}	
582
+				}
579 583
 				else if (strncmp("LEGS_LANDB\0", buffer, 11) == 0)
580 584
 				{
581 585
 					id = LEGS_LANDB;
582
-				}	
586
+				}
583 587
 				else if (strncmp("LEGS_IDLECR\0", buffer, 12) == 0)
584 588
 				{
585 589
 					id = LEGS_IDLECR;
586
-				}	
590
+				}
587 591
 				else if (strncmp("LEGS_JUMP\0", buffer, 10) == 0)
588 592
 				{
589 593
 					id = LEGS_JUMP;
590
-				}	
594
+				}
591 595
 				else if (strncmp("LEGS_LAND\0", buffer, 10) == 0)
592 596
 				{
593 597
 					id = LEGS_LAND;
594
-				}	
598
+				}
595 599
 				else if (strncmp("LEGS_IDLE\0", buffer, 10) == 0)
596 600
 				{
597 601
 					id = LEGS_IDLE;
598
-				}	
602
+				}
599 603
 				else if (strncmp("LEGS_TURN\0", buffer, 10) == 0)
600 604
 				{
601 605
 					id = LEGS_TURN;
@@ -603,19 +607,19 @@ int Md3AnimModel::loadAnimations(char *modelPath)
603 607
 				else
604 608
 				{
605 609
 					id = UNSUPPORTED;
606
-				}	
610
+				}
607 611
 
608 612
 				if (m_debug > 0)
609 613
 				{
610
-					printf("<%s> %3i %3i %3i %3i \t'%s' (%i)\n", 
614
+					printf("<%s> %3i %3i %3i %3i \t'%s' (%i)\n",
611 615
 							 (id == UNSUPPORTED) ? "Unsupported" : "",
612
-							 firstFrame, numFrames, 
616
+							 firstFrame, numFrames,
613 617
 							 loopingFrames, framesPerSecond, buffer, id);
614 618
 				}
615 619
 
616 620
 				if (id != UNSUPPORTED)
617 621
 				{
618
-					addAnim(buffer, id, firstFrame, numFrames, 
622
+					addAnim(buffer, id, firstFrame, numFrames,
619 623
 							  loopingFrames, framesPerSecond);
620 624
 				}
621 625
 
@@ -624,7 +628,7 @@ int Md3AnimModel::loadAnimations(char *modelPath)
624 628
 			else if (strncmp("sexf", buffer, 4) == 0)
625 629
 			{
626 630
 				m_sex = MD3_SEX_FEMALE;
627
-				
631
+
628 632
 				if (m_debug > 0)
629 633
 				{
630 634
 					printf("<> sex = female\n");
@@ -734,12 +738,12 @@ int Md3AnimModel::loadAnimations(char *modelPath)
734 738
 ////////////////////////////////////////////////////////////
735 739
 
736 740
 void Md3AnimModel::setCurrentTime(Md3 &model)
737
-{ 
741
+{
738 742
 	int animationSpeed;
739 743
 	float elapsedTime = 0.0f;
740 744
 	float time, t;
741 745
 
742
-	
746
+
743 747
 	// No animations in this model
744 748
 	if (model.numAnimations == 0)
745 749
 	{
@@ -759,10 +763,10 @@ void Md3AnimModel::setCurrentTime(Md3 &model)
759 763
 	// Tells out far from the current key frame to the next key frame.
760 764
 	t = (elapsedTime / (1000.0f / animationSpeed));
761 765
 
762
-	//printf("t = %f, et = %f, lt = %f, fps = %i\n", 
766
+	//printf("t = %f, et = %f, lt = %f, fps = %i\n",
763 767
 	//		 t, elapsedTime, model.lastTime, animationSpeed);
764 768
 
765
-	// If our elapsed time goes over the desired time segment, start over 
769
+	// If our elapsed time goes over the desired time segment, start over
766 770
 	// and go to the next key frame.
767 771
 	if (elapsedTime >= (1000.0f / animationSpeed))
768 772
 	{
@@ -797,11 +801,11 @@ void Md3AnimModel::updateModel(Md3 &model)
797 801
 	model.nextFrame = (model.currentFrame + 1) % endFrame;
798 802
 
799 803
 	// Wrap to first frame if past last
800
-	if (model.nextFrame == 0) 
804
+	if (model.nextFrame == 0)
801 805
 	{
802 806
 		model.nextFrame = startFrame;
803 807
 	}
804
-	
808
+
805 809
 	// Set interpolating time 0.0 - 1.0 ( start to end of animation)
806 810
 	setCurrentTime(model);
807 811
 }
@@ -820,9 +824,9 @@ void Md3AnimModel::initMd3(Md3 &model, unsigned int id)
820 824
 
821 825
 
822 826
 int Md3AnimModel::addAnim(char *modelPath, md3_animation_id_t id,
823
-								  unsigned int firstFrame, 
824
-								  unsigned int numFrames, 
825
-								  unsigned int loopingFrames, 
827
+								  unsigned int firstFrame,
828
+								  unsigned int numFrames,
829
+								  unsigned int loopingFrames,
826 830
 								  unsigned int framesPerSecond)
827 831
 {
828 832
 	if (m_animCount == 30)
@@ -853,7 +857,7 @@ int Md3AnimModel::addAnim(char *modelPath, md3_animation_id_t id,
853 857
 }
854 858
 
855 859
 
856
-int Md3AnimModel::loadMd3(Md3 &model, char *base, char *modelPath, char *skin, 
860
+int Md3AnimModel::loadMd3(Md3 &model, char *base, char *modelPath, char *skin,
857 861
 								  md3_lod_t modelLoD)
858 862
 {
859 863
 	char filename[256];
@@ -869,10 +873,10 @@ int Md3AnimModel::loadMd3(Md3 &model, char *base, char *modelPath, char *skin,
869 873
 	len = strlen(modelPath);
870 874
 
871 875
 	// Load model with requested LoD
872
-	snprintf(filename, l, "%s%s%s%s", modelPath, 
873
-				(modelPath[len-1] == '/') ? "" : "/", 
876
+	snprintf(filename, l, "%s%s%s%s", modelPath,
877
+				(modelPath[len-1] == '/') ? "" : "/",
874 878
 				base,
875
-				(modelLoD == MD3_LOD_HIGH) ? ".md3" : 
879
+				(modelLoD == MD3_LOD_HIGH) ? ".md3" :
876 880
 				(modelLoD == MD3_LOD_MED) ? "_1.md3" : "_2.md3");
877 881
 
878 882
 	model.reset();
@@ -886,7 +890,7 @@ int Md3AnimModel::loadMd3(Md3 &model, char *base, char *modelPath, char *skin,
886 890
 	// Load skin if requested
887 891
 	if (skin && skin[0])
888 892
 	{
889
-		snprintf(filename, l, "%s%s%s_%s.skin", modelPath, 
893
+		snprintf(filename, l, "%s%s%s_%s.skin", modelPath,
890 894
 					(modelPath[len-1] == '/') ? "" : "/", base, skin);
891 895
 
892 896
 		if (loadSkin(model, filename))
@@ -917,7 +921,7 @@ int Md3AnimModel::loadMd3(Md3 &model, char *base, char *modelPath, char *skin,
917 921
 					filename[j] = '/';
918 922
 				}
919 923
 
920
-				// Lowercase alphabet MSDOS is case insensitive 
924
+				// Lowercase alphabet MSDOS is case insensitive
921 925
 				// data created with it's skin names are bad
922 926
 				if (filename[j] > 64 && filename[j] < 91)
923 927
 				{
@@ -962,9 +966,9 @@ int Md3AnimModel::cacheTexture(char *texture)
962 966
 		texTest[texNumTest].name_len = len+1;
963 967
 		strncpy(texTest[texNumTest].name, texture, len+1);
964 968
 		texTest[texNumTest].name[len] = 0;
965
-				
969
+
966 970
 		id = texNumTest;
967
-				
971
+
968 972
 		texNumTest++;
969 973
 	}
970 974
 
@@ -1049,7 +1053,7 @@ int Md3AnimModel::loadSkin(Md3 &model, char *filename)
1049 1053
 				for (j = 0; j < m; ++j)
1050 1054
 				{
1051 1055
 					if (strncmp(mesh, meshes[j].name, 68) == 0)
1052
-					{				
1056
+					{
1053 1057
 						switch (i)
1054 1058
 						{
1055 1059
 						case 1:
@@ -1097,7 +1101,7 @@ int Md3AnimModel::loadShader(Md3 &model, char *filename)
1097 1101
 	if (model.idTest == 4)
1098 1102
 	{
1099 1103
 		m_weapon.texTest[0] = cacheTexture("models/weapons/machinegun/skin2.tga");
1100
-		
1104
+
1101 1105
 		for (i = m_weapon.getNumMeshes() - 1; i > 0; --i)
1102 1106
 		{
1103 1107
 			m_weapon.texTest[i] = m_weapon.texTest[0];
@@ -1143,7 +1147,7 @@ void Md3AnimModel::render()
1143 1147
 
1144 1148
 		if (errors < 8)
1145 1149
 		{
1146
-			printf("ERROR: %i. Not all animations loaded %i/24\n", 
1150
+			printf("ERROR: %i. Not all animations loaded %i/24\n",
1147 1151
 					 errors+1, m_animCount);
1148 1152
 			++errors;
1149 1153
 		}
@@ -1179,13 +1183,13 @@ void Md3AnimModel::renderModel(Md3 &model)
1179 1183
 #ifdef USING_OPENGL
1180 1184
 	unsigned int i, j, k, numBones, numMeshes;
1181 1185
 	unsigned int index, currentIndex, nextIndex, maxIndex;
1182
-	md3_mesh_t *meshes, *mesh;	
1186
+	md3_mesh_t *meshes, *mesh;
1183 1187
 	md3_bone_t *bones, *bone;
1184 1188
 
1185 1189
 
1186 1190
 	numMeshes = model.getNumMeshes();
1187 1191
 	meshes = model.getMeshes();
1188
-	
1192
+
1189 1193
 	if (mFlags & fRenderBones)
1190 1194
 	{
1191 1195
 		numBones = model.getNumBones();
@@ -1219,9 +1223,9 @@ void Md3AnimModel::renderModel(Md3 &model)
1219 1223
 
1220 1224
 		// Try to avoid bad models/loading taking down the subsystem
1221 1225
 		// and also handle bad data as well as we can
1222
-		if ((int)model.currentFrame >= mesh->num_frames || 
1226
+		if ((int)model.currentFrame >= mesh->num_frames ||
1223 1227
 			 (int)model.nextFrame >= mesh->num_frames)
1224
-		{			
1228
+		{
1225 1229
 			if (mFlags & fRenderingWarnings)
1226 1230
 			{
1227 1231
 				fprintf(stderr, "renderModel> WARNING: Frame index would be out of bounds\n model[%i].mesh[%i], %i out of %i frames\n",
@@ -1243,7 +1247,7 @@ void Md3AnimModel::renderModel(Md3 &model)
1243 1247
 			{
1244 1248
 				index = mesh->tris[j].triangle[k];
1245 1249
 
1246
-				if (index + nextIndex > maxIndex || 
1250
+				if (index + nextIndex > maxIndex ||
1247 1251
 					 index + currentIndex > maxIndex)
1248 1252
 				{
1249 1253
 					currentIndex = 0;
@@ -1260,7 +1264,7 @@ void Md3AnimModel::renderModel(Md3 &model)
1260 1264
 				{
1261 1265
 					glTexCoord2fv(mesh->texel[index].st);
1262 1266
 				}
1263
-				
1267
+
1264 1268
 				if (mFlags & fDisableMeshInterpolate)
1265 1269
 				{
1266 1270
 					glVertex3f(mesh->vertex[index + currentIndex].pos[0],
@@ -1292,7 +1296,7 @@ void Md3AnimModel::renderModel(Md3 &model)
1292 1296
 void renderBone(vec3_t min, vec3_t max, vec3_t center, vec_t scale)
1293 1297
 {
1294 1298
 	glDisable(GL_TEXTURE_2D);
1295
-	
1299
+
1296 1300
 	//scale *= 0.2f;
1297 1301
 
1298 1302
 	glPushMatrix();
@@ -1335,7 +1339,7 @@ void renderBone(vec3_t min, vec3_t max, vec3_t center, vec_t scale)
1335 1339
 	// min, bottom quad
1336 1340
 	glVertex3f(min[0], min[1], min[2]);
1337 1341
 	glVertex3f(min[0], max[1], min[2]);
1338
-    
1342
+
1339 1343
 	glVertex3f(min[0], min[1], min[2]);
1340 1344
 	glVertex3f(max[0], min[1], min[2]);
1341 1345
 
@@ -1356,7 +1360,7 @@ void renderLaserSight()
1356 1360
 
1357 1361
 	glDisable(GL_TEXTURE_2D);
1358 1362
 
1359
-	glPushMatrix();			
1363
+	glPushMatrix();
1360 1364
 	glScalef(100, 100, 100);
1361 1365
 
1362 1366
 	// Draw two long quads that skrink and fade the they go further out
@@ -1367,14 +1371,14 @@ void renderLaserSight()
1367 1371
 	glColor4f(0.3-d, 0.1, 0.1, 0.5);
1368 1372
 	glVertex3f(lenght, 0.1, 0.0);
1369 1373
 	glVertex3f(lenght,  0.0, 0.0);
1370
-	
1374
+
1371 1375
 	glColor4f(0.9-d, 0.1, 0.1, 0.5);
1372 1376
 	glVertex3f(start, 0.0, 0.0);
1373 1377
 	glVertex3f(start, 0.0, 0.2);
1374
-	glColor4f(0.3-d, 0.1, 0.1, 0.5);		
1378
+	glColor4f(0.3-d, 0.1, 0.1, 0.5);
1375 1379
 	glVertex3f(lenght, 0.0, 0.1);
1376 1380
 	glVertex3f(lenght, 0.0, 0.0);
1377
-	glEnd();		
1381
+	glEnd();
1378 1382
 
1379 1383
 	glPopMatrix();
1380 1384
 
@@ -1468,40 +1472,40 @@ void Md3AnimModel::renderTag(unsigned int id)
1468 1472
 	for (i = 0; i < t; ++i)
1469 1473
 	{
1470 1474
 		if (slaves[i] > 0)
1471
-		{	
1475
+		{
1472 1476
 			// Using digiben's tag anim notes
1473
-			// To find the current translation position for 
1477
+			// To find the current translation position for
1474 1478
 			// this frame of animation, we multiply
1475
-			// the currentFrame by the number of tags, 
1479
+			// the currentFrame by the number of tags,
1476 1480
 			// then add i.  This is similar to how
1477 1481
 			// the vertex key frames are interpolated.
1478 1482
 			pos[0] = tags[f*t+i].center[0];
1479 1483
 			pos[1] = tags[f*t+i].center[1];
1480 1484
 			pos[2] = tags[f*t+i].center[2];
1481
-			
1485
+
1482 1486
 			// Grab the next key frame translation position
1483 1487
 			nextPos[0] = tags[nf*t+i].center[0];
1484 1488
 			nextPos[1] = tags[nf*t+i].center[1];
1485 1489
 			nextPos[2] = tags[nf*t+i].center[2];
1486 1490
 
1487 1491
 			// By using the equation: p(t) = p0 + t(p1 - p0), with a time t,
1488
-			// we create a new translation position that 
1489
-			// is closer to the next key frame.			
1492
+			// we create a new translation position that
1493
+			// is closer to the next key frame.
1490 1494
 			pos[0] = pos[0] + time * (nextPos[0] - pos[0]);
1491 1495
 			pos[1] = pos[1] + time * (nextPos[1] - pos[1]);
1492 1496
 			pos[2] = pos[2] + time * (nextPos[2] - pos[2]);
1493 1497
 
1494
-			// Now comes the more complex interpolation.  Just like 
1495
-			// the translation, we want to store the current and 
1498
+			// Now comes the more complex interpolation.  Just like
1499
+			// the translation, we want to store the current and
1496 1500
 			// next key frame rotation matrix, then interpolate
1497 1501
 			// between the 2.
1498 1502
 
1499
-			// Get a pointer to the start of the 3x3 rotation matrix 
1503
+			// Get a pointer to the start of the 3x3 rotation matrix
1500 1504
 			// for the current frame
1501 1505
 			//matrix = &tags[f*t+i].rotation[0][0];
1502 1506
 			convertQuake3ToHelMatrix(tags[f*t+i].rotation, matrix);
1503 1507
 
1504
-			// Get a pointer to the start of the 3x3 rotation matrix 
1508
+			// Get a pointer to the start of the 3x3 rotation matrix
1505 1509
 			// for the next frame
1506 1510
 			//nextMatrix = &tags[nf*t+i].rotation[0][0];
1507 1511
 			convertQuake3ToHelMatrix(tags[nf*t+i].rotation, nextMatrix);
@@ -1511,13 +1515,13 @@ void Md3AnimModel::renderTag(unsigned int id)
1511 1515
 			q.setByMatrix(matrix);
1512 1516
 			qNext.setByMatrix(nextMatrix);
1513 1517
 
1514
-			// Using spherical linear interpolation, find the 
1518
+			// Using spherical linear interpolation, find the
1515 1519
 			// interpolated quaternion
1516 1520
 			qInterpolate = Quaternion::slerp(q, qNext, time);
1517 1521
 
1518 1522
 			// Here we convert the interpolated quaternion into a matrix
1519 1523
 			qInterpolate.getMatrix(finalMatrix);
1520
-			
1524
+
1521 1525
 			glPushMatrix();
1522 1526
 
1523 1527
 			if (mFlags & fDisableTagInterpolate)
@@ -1526,7 +1530,7 @@ void Md3AnimModel::renderTag(unsigned int id)
1526 1530
 				//glTranslatef(pos[0]*64, pos[1]*64, pos[2]*64);
1527 1531
 				matrix[12] = pos[0]*scaleHack;
1528 1532
 				matrix[13] = pos[1]*scaleHack;
1529
-				matrix[14] = pos[2]*scaleHack;	
1533
+				matrix[14] = pos[2]*scaleHack;
1530 1534
 				glMultMatrixf(matrix);
1531 1535
 			}
1532 1536
 			else
@@ -1535,7 +1539,7 @@ void Md3AnimModel::renderTag(unsigned int id)
1535 1539
 				//glTranslatef(pos[0]*64, pos[1]*64, pos[2]*64);
1536 1540
 				finalMatrix[12] = pos[0]*scaleHack;
1537 1541
 				finalMatrix[13] = pos[1]*scaleHack;
1538
-				finalMatrix[14] = pos[2]*scaleHack;	
1542
+				finalMatrix[14] = pos[2]*scaleHack;
1539 1543
 				glMultMatrixf(finalMatrix);
1540 1544
 			}
1541 1545
 
@@ -1587,10 +1591,10 @@ void loadMd3(char *model, char *skin, char *weapon)
1587 1591
 	snprintf(pathname, 255, "data/models/players/%s", model);
1588 1592
 	pathname[255] = 0;
1589 1593
 
1590
-	if (gMd3.load(pathname, skin, MD3_LOD_HIGH) < 0) 
1591
-	{ 
1594
+	if (gMd3.load(pathname, skin, MD3_LOD_HIGH) < 0)
1595
+	{
1592 1596
 		printf("ERROR: MD3 '%s' not loaded\n", pathname);
1593
-	} 
1597
+	}
1594 1598
 	else
1595 1599
 	{
1596 1600
 		snprintf(pathname, 255, "data/models/weapons2/%s", weapon);
@@ -1601,23 +1605,23 @@ void loadMd3(char *model, char *skin, char *weapon)
1601 1605
 			printf("Couldn't load weapon model '%s'.\n", pathname);
1602 1606
 		}
1603 1607
 
1604
-		gMd3.setAnimUpper(TORSO_STAND); 
1608
+		gMd3.setAnimUpper(TORSO_STAND);
1605 1609
 		gMd3.setAnimLower(LEGS_IDLE);
1606 1610
 
1607 1611
 		// Setup textures
1608 1612
 		printf("\nLoading textures: ");
1609
-		for (i = 0; i < gMd3.texNumTest; ++i) 
1610
-		{ 
1611
-			snprintf(pathname, 255, "data/%s", gMd3.texTest[i].name); 
1613
+		for (i = 0; i < gMd3.texNumTest; ++i)
1614
+		{
1615
+			snprintf(pathname, 255, "data/%s", gMd3.texTest[i].name);
1612 1616
 			pathname[255] = 0;
1613 1617
 
1614
-			gMd3.texTest[i].gl_texture_id = gTexture.loadTGA(pathname); 
1615
-			
1616
-			if (gMd3.texTest[i].gl_texture_id < 0) 
1617
-			{ 
1618
-				printf("ERROR: Md3 texture '%s' not loaded\n", pathname); 
1618
+			gMd3.texTest[i].gl_texture_id = gTexture.loadTGA(pathname);
1619
+
1620
+			if (gMd3.texTest[i].gl_texture_id < 0)
1621
+			{
1622
+				printf("ERROR: Md3 texture '%s' not loaded\n", pathname);
1619 1623
 			}
1620
-		} 
1624
+		}
1621 1625
 	}
1622 1626
 }
1623 1627
 
@@ -1629,8 +1633,8 @@ void renderScene()
1629 1633
 	float x, y, time;
1630 1634
 
1631 1635
 
1632
-	gluLookAt(0.0, 0.0, -256.0, 
1633
-				 0.0, 8.0, 0.0, 
1636
+	gluLookAt(0.0, 0.0, -256.0,
1637
+				 0.0, 8.0, 0.0,
1634 1638
 				 0.0, 1.0, 0.0);
1635 1639
 
1636 1640
 
@@ -1691,15 +1695,15 @@ void renderScene()
1691 1695
 		glBegin(GL_LINE_LOOP);
1692 1696
 		for (y = -size; y < size; y += step)
1693 1697
 		{
1694
-			glVertex3f(x + step, 0.0f, y);	
1695
-			glVertex3f(x, 0.0f, y);	
1698
+			glVertex3f(x + step, 0.0f, y);
1699
+			glVertex3f(x, 0.0f, y);
1696 1700
 			glVertex3f(x, 0.0f, y + step);
1697 1701
 			glVertex3f(x + step, 0.0f, y + step);
1698 1702
 		}
1699 1703
 		glEnd();
1700 1704
 	}
1701 1705
 	glPopMatrix();
1702
-	
1706
+
1703 1707
 	// Draw model
1704 1708
 	glEnable(GL_TEXTURE_2D);
1705 1709
 	glColor3f(1.0f, 1.0f, 1.0f);
@@ -1763,14 +1767,14 @@ void initScene(int argc, char *argv[])
1763 1767
 	printf("UP/DOWN    - Adjust scene pitch\n");
1764 1768
 	printf("RIGHT/LEFT - Adjust scene yaw\n");
1765 1769
 	printf("----------------------------------\n");
1766
-	printf("1 - Toggle tag interpolating\n");   
1770
+	printf("1 - Toggle tag interpolating\n");
1767 1771
 	printf("2 - Toggle animation\n");
1768 1772
 	printf("3 - Toggle bone rendering\n");
1769 1773
 	printf("4 - Toggle weapon rendering\n");
1770 1774
 	printf("5 - Toggle mesh interpolating\n");
1771 1775
 	printf("6 - Toggle scene rotation\n");
1772
-	printf("7 - Toggle rendering warning reporting\n");      
1773
-	printf("8 - Toggle alpha blending\n");      
1776
+	printf("7 - Toggle rendering warning reporting\n");
1777
+	printf("8 - Toggle alpha blending\n");
1774 1778
 	printf("w - Toggle wireframe rendering\n");
1775 1779
 	printf("[ - Loop through lower animations\n");
1776 1780
 	printf("] - Loop through upper animations\n");
@@ -1911,7 +1915,7 @@ void handleKey(int key)
1911 1915
 
1912 1916
 		if (wireframe)
1913 1917
 		{
1914
-			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
1918
+			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1915 1919
 		}
1916 1920
 		else
1917 1921
 		{
@@ -2070,7 +2074,7 @@ void event_resize(int width, int height)
2070 2074
 	gWidth = width;
2071 2075
 	gHeight = height;
2072 2076
 
2073
-	glViewport(0, 0, width, height); 
2077
+	glViewport(0, 0, width, height);
2074 2078
 
2075 2079
 	glMatrixMode(GL_PROJECTION);
2076 2080
 	glLoadIdentity();
@@ -2117,7 +2121,7 @@ void init_gl(unsigned int width, unsigned int height)
2117 2121
 	gTexture.reset();
2118 2122
 	gTexture.setFlag(Texture::fUseMipmaps);
2119 2123
 	gTexture.setMaxTextureCount(64);
2120
-	
2124
+
2121 2125
 }
2122 2126
 
2123 2127
 
@@ -2148,7 +2152,7 @@ int main_gl(int argc, char *argv[])
2148 2152
 	  if (SDL_GL_LoadLibrary("libGL.so") < 0)
2149 2153
 	  {
2150 2154
 		  SDL_ClearError();
2151
-    
2155
+
2152 2156
 		  // Fallback 2
2153 2157
 		  if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
2154 2158
 		  {
@@ -2175,7 +2179,7 @@ int main_gl(int argc, char *argv[])
2175 2179
   gSDLWindow = SDL_SetVideoMode(width, height, 16, flags);
2176 2180
   SDL_WM_SetCaption("Md3AnimModel Test", "Md3AnimModel Test");
2177 2181
   SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
2178
-  
2182
+
2179 2183
   // Init rendering
2180 2184
   init_gl(width, height);
2181 2185
   initScene(argc, argv);
@@ -2195,7 +2199,7 @@ int main_gl(int argc, char *argv[])
2195 2199
 			  break;
2196 2200
 		  case SDL_MOUSEBUTTONDOWN:
2197 2201
 		  case SDL_MOUSEBUTTONUP:
2198
-			  break;	
2202
+			  break;
2199 2203
 		  case SDL_KEYDOWN:
2200 2204
 			  mkeys = (unsigned int)SDL_GetModState();
2201 2205
 			  mod = 0;
@@ -2235,12 +2239,12 @@ int main_gl(int argc, char *argv[])
2235 2239
 					  SDL_WM_ToggleFullScreen(gSDLWindow);
2236 2240
 				  }
2237 2241
 			  }
2238
-			  
2242
+
2239 2243
 			  handleKey(key);
2240 2244
 			  break;
2241 2245
 		  case SDL_KEYUP:
2242 2246
 			  break;
2243
-		  case SDL_VIDEORESIZE:			  
2247
+		  case SDL_VIDEORESIZE:
2244 2248
 			  event_resize(event.resize.w, event.resize.h);
2245 2249
 
2246 2250
 			  width = event.resize.w;
@@ -2252,7 +2256,7 @@ int main_gl(int argc, char *argv[])
2252 2256
 
2253 2257
 	  event_display(width, height);
2254 2258
   }
2255
-  
2259
+
2256 2260
   return 0;
2257 2261
 }
2258 2262
 
@@ -2295,7 +2299,7 @@ int main(int argc, char *argv[])
2295 2299
 	}
2296 2300
 	else
2297 2301
 	{
2298
-		printf("\n\n%s LoD path skin_name\neg %s 0 /usr/local/games/quake3/qbase3/players/slash/ default [weapon_path weapon_name]\n", 
2302
+		printf("\n\n%s LoD path skin_name\neg %s 0 /usr/local/games/quake3/qbase3/players/slash/ default [weapon_path weapon_name]\n",
2299 2303
 				 argv[0], argv[0]);
2300 2304
 	}
2301 2305
 }

+ 45
- 41
src/OpenGLMesh.cpp Zobrazit soubor

@@ -1,25 +1,29 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : OpenRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
7 7
  * Email   : stu7440@westga.edu
8 8
  * Object  : OpenGLMesh
9 9
  * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 
10
+ * Comments:
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2002.08.23:
19 19
  * Mongoose - Created
20 20
  =================================================================*/
21 21
 
22
+#ifdef __APPLE__
23
+#include <OpenGL/gl.h>
24
+#else
22 25
 #include <GL/gl.h>
26
+#endif
23 27
 #include "OpenGLMesh.h"
24 28
 
25 29
 
@@ -68,12 +72,12 @@ OpenGLMesh::~OpenGLMesh()
68 72
 	{
69 73
 		delete [] mVertices;
70 74
 	}
71
-	
75
+
72 76
 	if (mNormals)
73 77
 	{
74 78
 		delete [] mNormals;
75 79
 	}
76
-	
80
+
77 81
 	if (mColors)
78 82
 	{
79 83
 		delete [] mColors;
@@ -98,9 +102,9 @@ OpenGLMesh::~OpenGLMesh()
98 102
 
99 103
 		delete [] mTris;
100 104
 	}
101
-	
105
+
102 106
 	if (mQuads)
103
-	{	
107
+	{
104 108
 		for (i = 0; i < mNumQuads; ++i)
105 109
 		{
106 110
 			if (mQuads[i].quads)
@@ -183,12 +187,12 @@ void OpenGLMesh::drawAlpha()
183 187
 
184 188
 		glBegin(GL_QUADS);
185 189
 
186
-		for (j = 0; j < mQuads[i].num_alpha_quads; ++j) 
190
+		for (j = 0; j < mQuads[i].num_alpha_quads; ++j)
187 191
 		{
188 192
 			for (k = 0; k < 4; ++k)
189
-			{							
193
+			{
190 194
 				index = mQuads[i].alpha_quads[j*4+k];
191
-				
195
+
192 196
 				glTexCoord2fv(mQuads[i].texcoors2[j*4+k]);
193 197
 				glColor4fv(mColors[index]);
194 198
 				glVertex3fv(mVertices[index]);
@@ -216,12 +220,12 @@ void OpenGLMesh::drawAlpha()
216 220
 
217 221
 		glBegin(GL_TRIANGLES);
218 222
 
219
-		for (j = 0; j < mTris[i].num_alpha_triangles; ++j) 
223
+		for (j = 0; j < mTris[i].num_alpha_triangles; ++j)
220 224
 		{
221 225
 			for (k = 0; k < 3; ++k)
222 226
 			{
223 227
 				index = mTris[i].alpha_triangles[j*3+k];
224
-				
228
+
225 229
 				glTexCoord2fv(mTris[i].texcoors2[j*3+k]);
226 230
 				glColor4fv(mColors[index]);
227 231
 				glVertex3fv(mVertices[index]);
@@ -259,12 +263,12 @@ void OpenGLMesh::drawSolid()
259 263
 
260 264
 		return; // FIXME
261 265
 
262
-		for (j = 0; j < mQuads[i].num_quads; ++j) 
266
+		for (j = 0; j < mQuads[i].num_quads; ++j)
263 267
 		{
264 268
 			for (k = 0; k < 4; ++k)
265
-			{							
269
+			{
266 270
 				index = mQuads[i].quads[j*4+k];
267
-				
271
+
268 272
 				glTexCoord2fv(mQuads[i].texcoors[j*4+k]);
269 273
 				glArrayElement(mQuads[i].quads[j*4+k]);
270 274
 			}
@@ -304,20 +308,20 @@ void OpenGLMesh::drawSolid()
304 308
 
305 309
 		glBegin(GL_QUADS);
306 310
 
307
-		for (j = 0; j < mQuads[i].num_quads; ++j) 
311
+		for (j = 0; j < mQuads[i].num_quads; ++j)
308 312
 		{
309 313
 			for (k = 0; k < 4; ++k)
310
-			{							
314
+			{
311 315
 				index = mQuads[i].quads[j*4+k];
312
-					
316
+
313 317
 				glColor4fv(mColors[index]);
314 318
 
315 319
 #ifdef MULTITEXTURE
316 320
 				if (mMode == OpenGLMeshModeMultiTexture)
317 321
 				{
318
-					glMultiTexCoord2fvARB(GL_TEXTURE0_ARB, 
322
+					glMultiTexCoord2fvARB(GL_TEXTURE0_ARB,
319 323
 												 mQuads[i].texcoors[j*4+k]);
320
-					glMultiTexCoord2fvARB(GL_TEXTURE1_ARB, 
324
+					glMultiTexCoord2fvARB(GL_TEXTURE1_ARB,
321 325
 												 mQuads[i].texcoors[j*4+k]);
322 326
 				}
323 327
 				else
@@ -362,7 +366,7 @@ void OpenGLMesh::drawSolid()
362 366
 
363 367
 		glBegin(GL_TRIANGLES);
364 368
 
365
-		for (j = 0; j < mTris[i].num_triangles; ++j) 
369
+		for (j = 0; j < mTris[i].num_triangles; ++j)
366 370
 		{
367 371
 			for (k = 0; k < 3; ++k)
368 372
 			{
@@ -371,9 +375,9 @@ void OpenGLMesh::drawSolid()
371 375
 #ifdef MULTITEXTURE
372 376
 				if (mMode == OpenGLMeshModeMultiTexture)
373 377
 				{
374
-					glMultiTexCoord2fvARB(GL_TEXTURE0_ARB, 
378
+					glMultiTexCoord2fvARB(GL_TEXTURE0_ARB,
375 379
 												 mTris[i].texcoors[j*3+k]);
376
-					glMultiTexCoord2fvARB(GL_TEXTURE1_ARB, 
380
+					glMultiTexCoord2fvARB(GL_TEXTURE1_ARB,
377 381
 												 mTris[i].texcoors[j*3+k]);
378 382
 				}
379 383
 				else
@@ -500,15 +504,15 @@ void OpenGLMesh::bufferColorArray(unsigned int colorCount, vec_t *colors,
500 504
 		mNumColors = 0;
501 505
 		delete [] mColors;
502 506
 	}
503
-	
507
+
504 508
 	if (!colorCount)
505 509
 	{
506 510
 		return;
507 511
 	}
508
-	
512
+
509 513
 		//mColorWidth = colorWidth;  // for now assume 4 always
510 514
 	mNumColors = colorCount;
511
-	mColorArray = colors; 
515
+	mColorArray = colors;
512 516
 }
513 517
 
514 518
 
@@ -519,22 +523,22 @@ void OpenGLMesh::bufferNormalArray(unsigned int normalCount, vec_t *normals)
519 523
 		mNumNormals = 0;
520 524
 		delete [] mNormals;
521 525
 	}
522
-	
526
+
523 527
 	if (!normalCount)
524 528
 	{
525 529
 		return;
526 530
 	}
527
-	
531
+
528 532
 	mNumNormals = normalCount;
529 533
 	mNormalArray = normals;
530 534
 }
531 535
 
532 536
 
533
-void OpenGLMesh::bufferTriangles(unsigned int count, 
534
-											unsigned int *indices, vec_t *texCoords, 
537
+void OpenGLMesh::bufferTriangles(unsigned int count,
538
+											unsigned int *indices, vec_t *texCoords,
535 539
 											int *textures, unsigned int *flags)
536 540
 {
537
-	
541
+
538 542
 	mTriangleCount = count;
539 543
 	mTriangleTextures = textures;
540 544
 	mTriangleIndices = indices;
@@ -552,26 +556,26 @@ void OpenGLMesh::bufferVertexArray(unsigned int vertexCount, vec_t *vertices)
552 556
 		mNumVertices = 0;
553 557
 		delete [] mVertices;
554 558
 	}
555
-	
559
+
556 560
 	if (!vertexCount)
557 561
 	{
558 562
 		return;
559 563
 	}
560
-	
564
+
561 565
 	mNumVertices = vertexCount;
562
-	mVertexArray = vertices; 
566
+	mVertexArray = vertices;
563 567
 	mFlags |= fOpenGLMesh_UseVertexArray;
564 568
 }
565 569
 
566 570
 
567
-void OpenGLMesh::setColor(unsigned int index, 
571
+void OpenGLMesh::setColor(unsigned int index,
568 572
 								  float r, float g, float b, float a)
569 573
 {
570 574
 	if (index > mNumColors)
571 575
 	{
572 576
 		return;
573 577
 	}
574
-	
578
+
575 579
 	mColors[index][0] = r;
576 580
 	mColors[index][1] = g;
577 581
 	mColors[index][2] = b;
@@ -585,7 +589,7 @@ void OpenGLMesh::setColor(unsigned int index, float rgba[4])
585 589
 	{
586 590
 		return;
587 591
 	}
588
-	
592
+
589 593
 	mColors[index][0] = rgba[0];
590 594
 	mColors[index][1] = rgba[1];
591 595
 	mColors[index][2] = rgba[2];
@@ -599,7 +603,7 @@ void OpenGLMesh::setNormal(unsigned int index, float i, float j, float k)
599 603
 	{
600 604
 		return;
601 605
 	}
602
-	
606
+
603 607
 	mNormals[index][0] = i;
604 608
 	mNormals[index][1] = j;
605 609
 	mNormals[index][2] = k;
@@ -612,7 +616,7 @@ void OpenGLMesh::setVertex(unsigned int index, float x, float y, float z)
612 616
 	{
613 617
 		return;
614 618
 	}
615
-	
619
+
616 620
 	mVertices[index][0] = x;
617 621
 	mVertices[index][1] = y;
618 622
 	mVertices[index][2] = z;

+ 60
- 60
src/OpenGLMesh.h Zobrazit soubor

@@ -1,23 +1,23 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : OpenRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
7 7
  * Email   : stu7440@westga.edu
8 8
  * Object  : OpenGLMesh
9 9
  * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 
10
+ * Comments:
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
15
+ *
16 16
  *-- Test Defines -----------------------------------------------
17
- *           
18
- * UNIT_TEST_OPENGLMESH - Builds OpenGLMesh class as a console unit test 
19 17
  *
20
- *-- History ------------------------------------------------ 
18
+ * UNIT_TEST_OPENGLMESH - Builds OpenGLMesh class as a console unit test
19
+ *
20
+ *-- History ------------------------------------------------
21 21
  *
22 22
  * 2002.08.23:
23 23
  * Mongoose - Created
@@ -27,7 +27,7 @@
27 27
 #ifndef GUARD__OPENRAIDER_MONGOOSE_OPENGLMESH_H_
28 28
 #define GUARD__OPENRAIDER_MONGOOSE_OPENGLMESH_H_
29 29
 
30
-#include <hel/math.h>
30
+#include "hel/math.h"
31 31
 
32 32
 // TODO: Unify the parallel systems here, arrays and the allocate/set
33 33
 
@@ -36,7 +36,7 @@ typedef enum
36 36
 {
37 37
 	OpenGLMeshModeSolid          = 0,
38 38
 	OpenGLMeshModeWireframe      = 1,
39
-	OpenGLMeshModeTexture        = 2,	
39
+	OpenGLMeshModeTexture        = 2,
40 40
 	OpenGLMeshModeMultiTexture   = 3
41 41
 
42 42
 } OpenGLMeshMode;
@@ -60,10 +60,10 @@ typedef struct tris_s
60 60
 	unsigned int cnum_alpha_triangles;
61 61
 
62 62
 	unsigned int num_texcoors;
63
-	vec2_t *texcoors; 
63
+	vec2_t *texcoors;
64 64
 
65 65
 	unsigned int num_texcoors2;
66
-	vec2_t *texcoors2; 
66
+	vec2_t *texcoors2;
67 67
 
68 68
 	// Arrays of triangle indices sorted by texture
69 69
 	unsigned int num_triangles;
@@ -71,7 +71,7 @@ typedef struct tris_s
71 71
 
72 72
 	// Arrays of alpha triangle indices sorted by texture
73 73
 	unsigned int num_alpha_triangles;
74
-	unsigned int *alpha_triangles; // ABCABCABC... 
74
+	unsigned int *alpha_triangles; // ABCABCABC...
75 75
 
76 76
 } tris_t;
77 77
 
@@ -87,10 +87,10 @@ typedef struct rect_s
87 87
 	unsigned int cnum_alpha_quads;
88 88
 
89 89
 	unsigned int num_texcoors;
90
-	vec2_t *texcoors; 
90
+	vec2_t *texcoors;
91 91
 
92 92
 	unsigned int num_texcoors2;
93
-	vec2_t *texcoors2; 
93
+	vec2_t *texcoors2;
94 94
 
95 95
 	// Arrays of rectangle indices sorted by texture
96 96
 	unsigned int num_quads;
@@ -113,12 +113,12 @@ class OpenGLMesh
113 113
 
114 114
 	OpenGLMesh();
115 115
 	/*------------------------------------------------------
116
-	 * Pre  : 
116
+	 * Pre  :
117 117
 	 * Post : Constructs an object of OpenGLMesh
118 118
 	 *
119 119
 	 *-- History ------------------------------------------
120 120
 	 *
121
-	 * 2002.08.23: 
121
+	 * 2002.08.23:
122 122
 	 * Mongoose - Created
123 123
 	 ------------------------------------------------------*/
124 124
 
@@ -129,7 +129,7 @@ class OpenGLMesh
129 129
 	 *
130 130
 	 *-- History ------------------------------------------
131 131
 	 *
132
-	 * 2002.08.23: 
132
+	 * 2002.08.23:
133 133
 	 * Mongoose - Created
134 134
 	 ------------------------------------------------------*/
135 135
 
@@ -140,7 +140,7 @@ class OpenGLMesh
140 140
 
141 141
 	void drawAlpha();
142 142
 	/*------------------------------------------------------
143
-	 * Pre  : 
143
+	 * Pre  :
144 144
 	 * Post : Render alpha polygons
145 145
 	 *
146 146
 	 *-- History ------------------------------------------
@@ -151,7 +151,7 @@ class OpenGLMesh
151 151
 
152 152
 	void drawSolid();
153 153
 	/*------------------------------------------------------
154
-	 * Pre  : 
154
+	 * Pre  :
155 155
 	 * Post : Render solid polygons
156 156
 	 *
157 157
 	 *-- History ------------------------------------------
@@ -167,8 +167,8 @@ class OpenGLMesh
167 167
 
168 168
 	void allocateColors(unsigned int n);
169 169
 	/*------------------------------------------------------
170
-	 * Pre  : 
171
-	 * Post : 
170
+	 * Pre  :
171
+	 * Post :
172 172
 	 *
173 173
 	 *-- History ------------------------------------------
174 174
 	 *
@@ -178,8 +178,8 @@ class OpenGLMesh
178 178
 
179 179
 	void allocateNormals(unsigned int n);
180 180
 	/*------------------------------------------------------
181
-	 * Pre  : 
182
-	 * Post : 
181
+	 * Pre  :
182
+	 * Post :
183 183
 	 *
184 184
 	 *-- History ------------------------------------------
185 185
 	 *
@@ -189,8 +189,8 @@ class OpenGLMesh
189 189
 
190 190
 	void allocateRectangles(unsigned int n);
191 191
 	/*------------------------------------------------------
192
-	 * Pre  : 
193
-	 * Post : 
192
+	 * Pre  :
193
+	 * Post :
194 194
 	 *
195 195
 	 *-- History ------------------------------------------
196 196
 	 *
@@ -200,8 +200,8 @@ class OpenGLMesh
200 200
 
201 201
 	void allocateTriangles(unsigned int n);
202 202
 	/*------------------------------------------------------
203
-	 * Pre  : 
204
-	 * Post : 
203
+	 * Pre  :
204
+	 * Post :
205 205
 	 *
206 206
 	 *-- History ------------------------------------------
207 207
 	 *
@@ -211,8 +211,8 @@ class OpenGLMesh
211 211
 
212 212
 	void allocateVertices(unsigned int n);
213 213
 	/*------------------------------------------------------
214
-	 * Pre  : 
215
-	 * Post : 
214
+	 * Pre  :
215
+	 * Post :
216 216
 	 *
217 217
 	 *-- History ------------------------------------------
218 218
 	 *
@@ -223,8 +223,8 @@ class OpenGLMesh
223 223
 	void bufferColorArray(unsigned int colorCount, vec_t *colors,
224 224
 								 unsigned int colorWidth);
225 225
 	/*------------------------------------------------------
226
-	 * Pre  : 
227
-	 * Post : 
226
+	 * Pre  :
227
+	 * Post :
228 228
 	 *
229 229
 	 *-- History ------------------------------------------
230 230
 	 *
@@ -234,8 +234,8 @@ class OpenGLMesh
234 234
 
235 235
 	void bufferNormalArray(unsigned int normalCount, vec_t *normals);
236 236
 	/*------------------------------------------------------
237
-	 * Pre  : 
238
-	 * Post : 
237
+	 * Pre  :
238
+	 * Post :
239 239
 	 *
240 240
 	 *-- History ------------------------------------------
241 241
 	 *
@@ -243,12 +243,12 @@ class OpenGLMesh
243 243
 	 * Mongoose - Created
244 244
 	 ------------------------------------------------------*/
245 245
 
246
-	void bufferTriangles(unsigned int count, 
247
-								unsigned int *indices, vec_t *texCoords, 
246
+	void bufferTriangles(unsigned int count,
247
+								unsigned int *indices, vec_t *texCoords,
248 248
 								int *textures, unsigned int *flags);
249 249
 	/*------------------------------------------------------
250
-	 * Pre  : 
251
-	 * Post : 
250
+	 * Pre  :
251
+	 * Post :
252 252
 	 *
253 253
 	 *-- History ------------------------------------------
254 254
 	 *
@@ -258,8 +258,8 @@ class OpenGLMesh
258 258
 
259 259
 	void bufferVertexArray(unsigned int vertexCount, vec_t *vertices);
260 260
 	/*------------------------------------------------------
261
-	 * Pre  : 
262
-	 * Post : 
261
+	 * Pre  :
262
+	 * Post :
263 263
 	 *
264 264
 	 *-- History ------------------------------------------
265 265
 	 *
@@ -269,8 +269,8 @@ class OpenGLMesh
269 269
 
270 270
 	void setColor(unsigned int index, float r, float g, float b, float a);
271 271
 	/*------------------------------------------------------
272
-	 * Pre  : 
273
-	 * Post : 
272
+	 * Pre  :
273
+	 * Post :
274 274
 	 *
275 275
 	 *-- History ------------------------------------------
276 276
 	 *
@@ -280,8 +280,8 @@ class OpenGLMesh
280 280
 
281 281
 	void setColor(unsigned int index, float rgba[4]);
282 282
 	/*------------------------------------------------------
283
-	 * Pre  : 
284
-	 * Post : 
283
+	 * Pre  :
284
+	 * Post :
285 285
 	 *
286 286
 	 *-- History ------------------------------------------
287 287
 	 *
@@ -291,8 +291,8 @@ class OpenGLMesh
291 291
 
292 292
 	void setNormal(unsigned int index, float i, float j, float k);
293 293
 	/*------------------------------------------------------
294
-	 * Pre  : 
295
-	 * Post : 
294
+	 * Pre  :
295
+	 * Post :
296 296
 	 *
297 297
 	 *-- History ------------------------------------------
298 298
 	 *
@@ -302,8 +302,8 @@ class OpenGLMesh
302 302
 
303 303
 	void setVertex(unsigned int index, float x, float y, float z);
304 304
 	/*------------------------------------------------------
305
-	 * Pre  : 
306
-	 * Post : 
305
+	 * Pre  :
306
+	 * Post :
307 307
 	 *
308 308
 	 *-- History ------------------------------------------
309 309
 	 *
@@ -314,8 +314,8 @@ class OpenGLMesh
314 314
 #ifdef NOT_IMPLEMENTED
315 315
 	void sortFacesByTexture();
316 316
 	/*------------------------------------------------------
317
-	 * Pre  : 
318
-	 * Post : 
317
+	 * Pre  :
318
+	 * Post :
319 319
 	 *
320 320
 	 *-- History ------------------------------------------
321 321
 	 *
@@ -326,8 +326,8 @@ class OpenGLMesh
326 326
 	void addFace(int textureIndex, int textureIndexB, unsigned int flags,
327 327
 					 unsigned int vertexIndexCount, vec_t *vertexIndices);
328 328
 	/*------------------------------------------------------
329
-	 * Pre  : 
330
-	 * Post : 
329
+	 * Pre  :
330
+	 * Post :
331 331
 	 *
332 332
 	 *-- History ------------------------------------------
333 333
 	 *
@@ -335,12 +335,12 @@ class OpenGLMesh
335 335
 	 * Mongoose - Created
336 336
 	 ------------------------------------------------------*/
337 337
 
338
-	void addTexTiledFace(int textureIndex, int textureIndexB, 
339
-								unsigned int flags, unsigned int indexCount, 
338
+	void addTexTiledFace(int textureIndex, int textureIndexB,
339
+								unsigned int flags, unsigned int indexCount,
340 340
 								vec_t *vertexIndices, vec_t *texcoords);
341 341
 	/*------------------------------------------------------
342
-	 * Pre  : 
343
-	 * Post : 
342
+	 * Pre  :
343
+	 * Post :
344 344
 	 *
345 345
 	 *-- History ------------------------------------------
346 346
 	 *
@@ -350,8 +350,8 @@ class OpenGLMesh
350 350
 
351 351
 	void bufferTexcoords(unsigned int texcoordCount, vec_t *texcoords);
352 352
 	/*------------------------------------------------------
353
-	 * Pre  : 
354
-	 * Post : 
353
+	 * Pre  :
354
+	 * Post :
355 355
 	 *
356 356
 	 *-- History ------------------------------------------
357 357
 	 *
@@ -361,8 +361,8 @@ class OpenGLMesh
361 361
 
362 362
 	void duplicateArraysForTexTiledTexcoords();
363 363
 	/*------------------------------------------------------
364
-	 * Pre  : 
365
-	 * Post : 
364
+	 * Pre  :
365
+	 * Post :
366 366
 	 *
367 367
 	 *-- History ------------------------------------------
368 368
 	 *
@@ -391,7 +391,7 @@ class OpenGLMesh
391 391
 	unsigned int mNumQuads;
392 392
 	rect_t *mQuads;
393 393
 
394
-	
394
+
395 395
 	unsigned int mTriangleCount;
396 396
 	int *mTriangleTextures;
397 397
 	unsigned int *mTriangleIndices;

+ 59
- 59
src/OpenRaider.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : OpenRaider
5 5
  * Author  : Mongoose
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: This is the main class for OpenRaider
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------ 
15
+ *
16
+ *-- History ------------------------------------------------
17 17
  *
18 18
  * 2002.08.24:
19 19
  * Mongoose - Finally made into Singleton
@@ -27,9 +27,9 @@
27 27
 #define GUARD__OPENRAIDER_MONGOOSE_OPENRAIDER_H_
28 28
 
29 29
 
30
-#include <mstl/List.h>
31
-#include <mstl/Map.h>
32
-#include <mstl/Vector.h>
30
+#include "mstl/List.h"
31
+#include "mstl/Map.h"
32
+#include "mstl/Vector.h"
33 33
 #include "TombRaider.h"
34 34
 #include "Camera.h"
35 35
 #include "Render.h"
@@ -87,13 +87,13 @@ class OpenRaider : public SDLSystem
87 87
 
88 88
 	static OpenRaider *Instance();
89 89
 	/*------------------------------------------------------
90
-	 * Pre  : 
90
+	 * Pre  :
91 91
 	 * Post : Constructs the object of OpenRaider or
92 92
 	 *        returns pointer to it if previously allocated
93 93
 	 *
94 94
 	 *-- History ------------------------------------------
95 95
 	 *
96
-	 * 2001.08.24: 
96
+	 * 2001.08.24:
97 97
 	 * Mongoose - Created
98 98
 	 ------------------------------------------------------*/
99 99
 
@@ -104,7 +104,7 @@ class OpenRaider : public SDLSystem
104 104
 	 *
105 105
 	 *-- History ------------------------------------------
106 106
 	 *
107
-	 * 2001.05.21: 
107
+	 * 2001.05.21:
108 108
 	 * Mongoose - Created
109 109
 	 ------------------------------------------------------*/
110 110
 
@@ -120,23 +120,23 @@ class OpenRaider : public SDLSystem
120 120
 
121 121
 	void start();
122 122
 	/*------------------------------------------------------
123
-	 * Pre  : 
123
+	 * Pre  :
124 124
 	 * Post : Init the Game
125 125
 	 *
126 126
 	 *-- History ------------------------------------------
127 127
 	 *
128
-	 * 2001.05.21: 
128
+	 * 2001.05.21:
129 129
 	 * Mongoose - Created
130 130
 	 ------------------------------------------------------*/
131 131
 
132 132
 	void handleMouseMotionEvent(float x, float y);
133 133
 	/*------------------------------------------------------
134
-	 * Pre  : 
134
+	 * Pre  :
135 135
 	 * Post : Mouse motion input used
136 136
 	 *
137 137
 	 *-- History ------------------------------------------
138 138
 	 *
139
-	 * 2001.06.04: 
139
+	 * 2001.06.04:
140 140
 	 * Mongoose - Created
141 141
 	 ------------------------------------------------------*/
142 142
 
@@ -144,7 +144,7 @@ class OpenRaider : public SDLSystem
144 144
 	/*------------------------------------------------------
145 145
 	 * Pre  : <Key> is a valid keyboard code
146 146
 	 *
147
-	 * Post : Recieves <Event> bound to <Cmd> from <Key> press 
147
+	 * Post : Recieves <Event> bound to <Cmd> from <Key> press
148 148
 	 *
149 149
 	 *-- History ------------------------------------------
150 150
 	 *
@@ -166,7 +166,7 @@ class OpenRaider : public SDLSystem
166 166
 
167 167
 	 void handleCommand(char *command, unsigned int mode);
168 168
 	/*------------------------------------------------------
169
-	 * Pre  : <Command> is valid keyword optionally followed 
169
+	 * Pre  : <Command> is valid keyword optionally followed
170 170
 	 *        by ' ' (space) seperated and argument(s)
171 171
 	 *
172 172
 	 *        <Mode> is the current type or resource mode
@@ -199,14 +199,14 @@ class OpenRaider : public SDLSystem
199 199
 	 *
200 200
 	 *-- History ------------------------------------------
201 201
 	 *
202
-	 * 2001.05.27: 
202
+	 * 2001.05.27:
203 203
 	 * Mongoose - Created
204 204
 	 ------------------------------------------------------*/
205 205
 
206 206
 	void initGL();
207 207
 	/*------------------------------------------------------
208
-	 * Pre  : 
209
-	 * Post : 
208
+	 * Pre  :
209
+	 * Post :
210 210
 	 *
211 211
 	 *-- History ------------------------------------------
212 212
 	 *
@@ -216,13 +216,13 @@ class OpenRaider : public SDLSystem
216 216
 
217 217
 	void gameFrame();
218 218
 	/*------------------------------------------------------
219
-	 * Pre  : 
219
+	 * Pre  :
220 220
 	 * Post : One game physics/time frame passes
221 221
 	 *        Also renders one frame per call
222 222
 	 *
223 223
 	 *-- History ------------------------------------------
224 224
 	 *
225
-	 * 2001.05.21: 
225
+	 * 2001.05.21:
226 226
 	 * Mongoose - Created
227 227
 	 ------------------------------------------------------*/
228 228
 
@@ -249,12 +249,12 @@ class OpenRaider : public SDLSystem
249 249
 
250 250
 	OpenRaider();
251 251
 	/*------------------------------------------------------
252
-	 * Pre  : 
252
+	 * Pre  :
253 253
 	 * Post : Constructs an object of OpenRaider
254 254
 	 *
255 255
 	 *-- History ------------------------------------------
256 256
 	 *
257
-	 * 2001.05.21: 
257
+	 * 2001.05.21:
258 258
 	 * Mongoose - Created
259 259
 	 ------------------------------------------------------*/
260 260
 
@@ -272,45 +272,45 @@ class OpenRaider : public SDLSystem
272 272
 
273 273
 	void consoleCommand(char *cmd);
274 274
 	/*------------------------------------------------------
275
-	 * Pre  : 
276
-	 * Post : 
275
+	 * Pre  :
276
+	 * Post :
277 277
 	 *
278 278
 	 *-- History ------------------------------------------
279 279
 	 *
280
-	 * ????.??.??: 
280
+	 * ????.??.??:
281 281
 	 * Mongoose - Created
282 282
 	 ------------------------------------------------------*/
283 283
 
284 284
 	void soundEvent(int type, int id, vec3_t pos, vec3_t angles);
285 285
 	/*------------------------------------------------------
286
-	 * Pre  : 
287
-	 * Post : 
286
+	 * Pre  :
287
+	 * Post :
288 288
 	 *
289 289
 	 *-- History ------------------------------------------
290 290
 	 *
291
-	 * 2002.06.16: 
291
+	 * 2002.06.16:
292 292
 	 * Mongoose - Created
293 293
 	 ------------------------------------------------------*/
294 294
 
295 295
 //	void entityEvent(entity_t &e, RaiderEvent event);
296 296
 	/*------------------------------------------------------
297
-	 * Pre  : 
298
-	 * Post : 
297
+	 * Pre  :
298
+	 * Post :
299 299
 	 *
300 300
 	 *-- History ------------------------------------------
301 301
 	 *
302
-	 * 2002.06.16: 
302
+	 * 2002.06.16:
303 303
 	 * Mongoose - Created
304 304
 	 ------------------------------------------------------*/
305 305
 
306 306
 	void processPakSounds();
307 307
 	/*------------------------------------------------------
308
-	 * Pre  : 
309
-	 * Post : 
308
+	 * Pre  :
309
+	 * Post :
310 310
 	 *
311 311
 	 *-- History ------------------------------------------
312 312
 	 *
313
-	 * 2001.06.04: 
313
+	 * 2001.06.04:
314 314
 	 * Mongoose - Created
315 315
 	 ------------------------------------------------------*/
316 316
 
@@ -321,37 +321,37 @@ class OpenRaider : public SDLSystem
321 321
 	 *
322 322
 	 *-- History ------------------------------------------
323 323
 	 *
324
-	 * 2001.06.04: 
324
+	 * 2001.06.04:
325 325
 	 * Mongoose - Created
326 326
 	 ------------------------------------------------------*/
327 327
 
328 328
 	void initTextures();
329 329
 	/*------------------------------------------------------
330
-	 * Pre  : 
330
+	 * Pre  :
331 331
 	 * Post : Generates all textures or mipmaps
332 332
 	 *        needed for fonts, splash, ext particles
333 333
 	 *
334 334
 	 *-- History ------------------------------------------
335 335
 	 *
336
-	 * 2001.05.28: 
336
+	 * 2001.05.28:
337 337
 	 * Mongoose - Created
338 338
 	 ------------------------------------------------------*/
339 339
 
340 340
 	void processTextures();
341 341
 	/*------------------------------------------------------
342
-	 * Pre  : 
342
+	 * Pre  :
343 343
 	 * Post : Generates tombraider textures or mipmaps
344 344
 	 *        needed for sprites, rooms, and models
345 345
 	 *
346 346
 	 *-- History ------------------------------------------
347 347
 	 *
348
-	 * 2001.05.28: 
348
+	 * 2001.05.28:
349 349
 	 * Mongoose - Created
350 350
 	 ------------------------------------------------------*/
351 351
 
352 352
 	void processSprites();
353 353
 	/*------------------------------------------------------
354
-	 * Pre  : 
354
+	 * Pre  :
355 355
 	 * Post : Generates render sprite sequences
356 356
 	 *
357 357
 	 *-- History ------------------------------------------
@@ -359,29 +359,29 @@ class OpenRaider : public SDLSystem
359 359
 	 * 2001.06.06:
360 360
 	 * Mongoose - All new functionality
361 361
 	 *
362
-	 * 2001.05.28: 
362
+	 * 2001.05.28:
363 363
 	 * Mongoose - Created
364 364
 	 ------------------------------------------------------*/
365
-	
365
+
366 366
 	void processMoveables();
367 367
 	/*------------------------------------------------------
368
-	 * Pre  : 
369
-	 * Post : 
368
+	 * Pre  :
369
+	 * Post :
370 370
 	 *
371 371
 	 *-- History ------------------------------------------
372 372
 	 *
373
-	 * 2001.06.08: 
373
+	 * 2001.06.08:
374 374
 	 * Mongoose - Created
375 375
 	 ------------------------------------------------------*/
376
-	
376
+
377 377
 	void processMoveable(int index, int i, int *ent, List <skeletal_model_t *> &cache2, List <unsigned int> &cache, int object_id);
378 378
 	/*------------------------------------------------------
379
-	 * Pre  : 
380
-	 * Post : 
379
+	 * Pre  :
380
+	 * Post :
381 381
 	 *
382 382
 	 *-- History ------------------------------------------
383 383
 	 *
384
-	 * 2002.04.06: 
384
+	 * 2002.04.06:
385 385
 	 * Mongoose - Created
386 386
 	 ------------------------------------------------------*/
387 387
 
@@ -393,7 +393,7 @@ class OpenRaider : public SDLSystem
393 393
 	 *
394 394
 	 *-- History ------------------------------------------
395 395
 	 *
396
-	 * 2001.05.26: 
396
+	 * 2001.05.26:
397 397
 	 * Mongoose - Created
398 398
 	 ------------------------------------------------------*/
399 399
 
@@ -405,19 +405,19 @@ class OpenRaider : public SDLSystem
405 405
 	 *
406 406
 	 *-- History ------------------------------------------
407 407
 	 *
408
-	 * 2001.05.21: 
408
+	 * 2001.05.21:
409 409
 	 * Mongoose - Created
410 410
 	 ------------------------------------------------------*/
411
-	
411
+
412 412
 	void loadLevel(char *filename);
413 413
 	/*------------------------------------------------------
414
-	 * Pre  : 
415
-	 * Post : Loads validated level pak from diskfile 
414
+	 * Pre  :
415
+	 * Post : Loads validated level pak from diskfile
416 416
 	 *        using maplist
417 417
 	 *
418 418
 	 *-- History ------------------------------------------
419 419
 	 *
420
-	 * 2001.05.21: 
420
+	 * 2001.05.21:
421 421
 	 * Mongoose - Created
422 422
 	 ------------------------------------------------------*/
423 423
 
@@ -453,10 +453,10 @@ class OpenRaider : public SDLSystem
453 453
 
454 454
 	// Game vars //////////////
455 455
 
456
-	Vector <char *> mMusicList;  /* List of game level music */ 
456
+	Vector <char *> mMusicList;  /* List of game level music */
457
+
458
+	Vector <char *> mMapList;    /* List of game maps */
457 459
 
458
-	Vector <char *> mMapList;    /* List of game maps */ 
459
-	
460 460
 	char m_mapName[32];          /* Current map filename */
461 461
 
462 462
 	char *m_pakDir;              /* Current pak directory */

+ 162
- 157
src/PSKModel.cpp Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: Unreal Tournament skeletal model
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2003.07.12:
19 19
  * Mongoose - UT Package prototype code moved into 'UTPackage'
@@ -35,10 +35,10 @@
35 35
  *
36 36
  * 2003.01.20:
37 37
  * Mongoose - Fixed triangle rendering thanks to debugging by
38
- *            Steven Fuller, who found the tris -> UV -> vert 
38
+ *            Steven Fuller, who found the tris -> UV -> vert
39 39
  *            connection
40 40
  *
41
- *            Finished up basic rendering, lots of 
41
+ *            Finished up basic rendering, lots of
42 42
  *            small fixes/features
43 43
  *
44 44
  * 2003.01.06:
@@ -52,8 +52,13 @@
52 52
 #include <math.h>
53 53
 
54 54
 #ifdef USING_OPENGL
55
-#   include <GL/gl.h>
56
-#   include <GL/glu.h>
55
+#ifdef __APPLE__
56
+#include <OpenGL/gl.h>
57
+#include <OpenGL/glu.h>
58
+#else
59
+#include <GL/gl.h>
60
+#include <GL/glu.h>
61
+#endif
57 62
 #endif
58 63
 
59 64
 #include "UTPackage.h"
@@ -70,17 +75,17 @@ void multiply_matrix(float *a, float *b, float *result)
70 75
 	result[ 1] = a[ 0] * b[ 4] + a[ 4] * b[ 5] + a[ 8] * b[ 6] + a[12] * b[ 7];
71 76
 	result[ 2] = a[ 0] * b[ 8] + a[ 4] * b[ 9] + a[ 8] * b[10] + a[12] * b[11];
72 77
 	result[ 3] = a[ 0] * b[12] + a[ 4] * b[13] + a[ 8] * b[14] + a[12] * b[15];
73
-	
78
+
74 79
 	result[ 4] = a[ 1] * b[ 0] + a[ 5] * b[ 1] + a[ 9] * b[ 2] + a[13] * b[ 3];
75 80
 	result[ 5] = a[ 1] * b[ 4] + a[ 5] * b[ 5] + a[ 9] * b[ 6] + a[13] * b[ 7];
76 81
 	result[ 6] = a[ 1] * b[ 8] + a[ 5] * b[ 9] + a[ 9] * b[10] + a[13] * b[11];
77 82
 	result[ 7] = a[ 1] * b[12] + a[ 5] * b[13] + a[ 9] * b[14] + a[13] * b[15];
78
-	
83
+
79 84
 	result[ 8] = a[ 2] * b[ 0] + a[ 6] * b[ 1] + a[10] * b[ 2] + a[14] * b[ 3];
80 85
 	result[ 9] = a[ 2] * b[ 4] + a[ 6] * b[ 5] + a[10] * b[ 6] + a[14] * b[ 7];
81 86
 	result[10] = a[ 2] * b[ 8] + a[ 6] * b[ 9] + a[10] * b[10] + a[14] * b[11];
82 87
 	result[11] = a[ 2] * b[12] + a[ 6] * b[13] + a[10] * b[14] + a[14] * b[15];
83
-	
88
+
84 89
 	result[12] = a[ 3] * b[ 0] + a[ 7] * b[ 1] + a[11] * b[ 2] + a[15] * b[ 3];
85 90
 	result[13] = a[ 3] * b[ 4] + a[ 7] * b[ 5] + a[11] * b[ 6] + a[15] * b[ 7];
86 91
 	result[14] = a[ 3] * b[ 8] + a[ 7] * b[ 9] + a[11] * b[10] + a[15] * b[11];
@@ -110,7 +115,7 @@ void translate_matrix(float tx, float ty, float tz, float *m)
110 115
    tmat[12]=tx; tmat[13]=ty; tmat[14]=tz; tmat[15]=1;
111 116
 
112 117
 	//copy_matrix(m, tmp);
113
-	
118
+
114 119
 	for (i = 0; i < 16; ++i)
115 120
 		tmp[i] = m[i];
116 121
 
@@ -129,25 +134,25 @@ bool invert_matrix(float *m, float *out)
129 134
 	/* NB. OpenGL Matrices are COLUMN major. */
130 135
 #define SWAP_ROWS(a, b) { float *_tmp = a; (a)=(b); (b)=_tmp; }
131 136
 #define MAT(m,r,c) (m)[(c)*4+(r)]
132
-	
137
+
133 138
 	float wtmp[4][8];
134 139
 	float m0, m1, m2, m3, s;
135 140
 	float *r0, *r1, *r2, *r3;
136
-	
141
+
137 142
 	r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
138
-	
143
+
139 144
 	r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
140 145
 	r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
141 146
 	r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
142
-	
147
+
143 148
 	r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
144 149
 	r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
145 150
 	r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
146
-	
151
+
147 152
 	r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
148 153
 	r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
149 154
 	r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
150
-	
155
+
151 156
 	r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
152 157
 	r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
153 158
 	r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
@@ -157,7 +162,7 @@ bool invert_matrix(float *m, float *out)
157 162
 	if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
158 163
 	if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
159 164
 	if (0.0 == r0[0])  return false;
160
-	
165
+
161 166
 	/* eliminate first variable     */
162 167
 	m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
163 168
 	s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
@@ -171,12 +176,12 @@ bool invert_matrix(float *m, float *out)
171 176
 	if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
172 177
 	s = r0[7];
173 178
 	if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
174
-	
179
+
175 180
 	/* choose pivot - or die */
176 181
 	if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
177 182
 	if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
178 183
 	if (0.0 == r1[1])  return false;
179
-	
184
+
180 185
 	/* eliminate second variable */
181 186
 	m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
182 187
 	r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
@@ -185,23 +190,23 @@ bool invert_matrix(float *m, float *out)
185 190
 	s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
186 191
 	s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
187 192
 	s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
188
-	
193
+
189 194
 	/* choose pivot - or die */
190 195
 	if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
191 196
 	if (0.0 == r2[2])  return false;
192
-	
197
+
193 198
 	/* eliminate third variable */
194 199
 	m3 = r3[2]/r2[2];
195 200
 	r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
196 201
 	r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
197 202
 	r3[7] -= m3 * r2[7];
198
-	
203
+
199 204
 	/* last check */
200 205
 	if (0.0 == r3[3]) return false;
201
-	
206
+
202 207
 	s = 1.0/r3[3];              /* now back substitute row 3 */
203 208
 	r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
204
-	
209
+
205 210
 	m2 = r2[3];                 /* now back substitute row 2 */
206 211
 	s  = 1.0/r2[2];
207 212
 	r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
@@ -212,7 +217,7 @@ bool invert_matrix(float *m, float *out)
212 217
 	m0 = r0[3];
213 218
 	r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
214 219
 	r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
215
-	
220
+
216 221
 	m1 = r1[2];                 /* now back substitute row 1 */
217 222
 	s  = 1.0/r1[1];
218 223
 	r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
@@ -220,22 +225,22 @@ bool invert_matrix(float *m, float *out)
220 225
 	m0 = r0[2];
221 226
 	r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
222 227
 	r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
223
-	
228
+
224 229
 	m0 = r0[1];                 /* now back substitute row 0 */
225 230
 	s  = 1.0/r0[0];
226 231
 	r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
227 232
 	r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
228
-	
229
-	MAT(out,0,0) = r0[4]; 
230
-	MAT(out,0,1) = r0[5], MAT(out,0,2) = r0[6]; 
233
+
234
+	MAT(out,0,0) = r0[4];
235
+	MAT(out,0,1) = r0[5], MAT(out,0,2) = r0[6];
231 236
 	MAT(out,0,3) = r0[7], MAT(out,1,0) = r1[4];
232 237
 	MAT(out,1,1) = r1[5], MAT(out,1,2) = r1[6];
233 238
 	MAT(out,1,3) = r1[7], MAT(out,2,0) = r2[4];
234 239
 	MAT(out,2,1) = r2[5], MAT(out,2,2) = r2[6];
235 240
 	MAT(out,2,3) = r2[7], MAT(out,3,0) = r3[4];
236 241
 	MAT(out,3,1) = r3[5], MAT(out,3,2) = r3[6];
237
-	MAT(out,3,3) = r3[7]; 
238
-	
242
+	MAT(out,3,3) = r3[7];
243
+
239 244
 	return true;
240 245
 #undef MAT
241 246
 #undef SWAP_ROWS
@@ -248,17 +253,17 @@ void quaternion_to_matrix(float mW, float mX, float mY, float mZ, float *m)
248 253
 	m[ 1] = 2.0f * (mX*mY - mW*mZ);
249 254
 	m[ 2] = 2.0f * (mX*mZ + mW*mY);
250 255
 	m[ 3] = 0.0f;
251
-	
256
+
252 257
 	m[ 4] = 2.0f * (mX*mY + mW*mZ);
253 258
 	m[ 5] = 1.0f - 2.0f * (mX*mX + mZ*mZ);
254 259
 	m[ 6] = 2.0f * (mY*mZ - mW*mX);
255 260
 	m[ 7] = 0.0f;
256
-	
261
+
257 262
 	m[ 8] = 2.0f * (mX*mZ - mW*mY);
258 263
 	m[ 9] = 2.0f * (mY*mZ + mW*mX);
259 264
 	m[10] = 1.0 - 2.0f * (mX*mX + mY*mY);
260 265
 	m[11] = 0.0f;
261
-	
266
+
262 267
 	m[12] = 0.0f;
263 268
 	m[13] = 0.0f;
264 269
 	m[14] = 0.0f;
@@ -266,7 +271,7 @@ void quaternion_to_matrix(float mW, float mX, float mY, float mZ, float *m)
266 271
 }
267 272
 
268 273
 
269
-void quaternion_to_axis_angles(float qw, float qx, float qy, float qz, 
274
+void quaternion_to_axis_angles(float qw, float qx, float qy, float qz,
270 275
 										 float *theta, float *x, float *y, float *z)
271 276
 {
272 277
 	*theta = (float)acos(qw) * 2.0;
@@ -281,7 +286,7 @@ void quaternion_to_axis_angles(float qw, float qx, float qy, float qz,
281 286
 }
282 287
 
283 288
 
284
-void quaternion_to_euler_angles(float qw, float qx, float qy, float qz, 
289
+void quaternion_to_euler_angles(float qw, float qx, float qy, float qz,
285 290
 										  float *x, float *y, float *z)
286 291
 {
287 292
 	double qw2 = qw*qw;
@@ -322,22 +327,22 @@ PSKModel::PSKModel()
322 327
 
323 328
 PSKModel::~PSKModel()
324 329
 {
325
-	if (mVertices) 
330
+	if (mVertices)
326 331
 		delete [] mVertices;
327 332
 
328
-	if (mWeights) 
333
+	if (mWeights)
329 334
 		delete [] mWeights;
330 335
 
331
-	if (mVTXWs) 
336
+	if (mVTXWs)
332 337
 		delete [] mVTXWs;
333 338
 
334
-	if (mFaces) 
339
+	if (mFaces)
335 340
 		delete [] mFaces;
336 341
 
337
-	if (mMaterials) 
342
+	if (mMaterials)
338 343
 		delete [] mMaterials;
339 344
 
340
-	if (mBones) 
345
+	if (mBones)
341 346
 		delete [] mBones;
342 347
 }
343 348
 
@@ -356,7 +361,7 @@ void PSKModel::printSkeletion(bool printNames)
356 361
 	{
357 362
 		printf("%3i. ", i);
358 363
 		j = i;
359
-			
364
+
360 365
 		while (j > 0)
361 366
 		{
362 367
 			if (printNames)
@@ -370,7 +375,7 @@ void PSKModel::printSkeletion(bool printNames)
370 375
 
371 376
 			j = mBones[j].parentIndex;
372 377
 		}
373
-			
378
+
374 379
 		printf("\n");
375 380
 	}
376 381
 
@@ -426,12 +431,12 @@ int PSKModel::load(char *filename)
426 431
 	{
427 432
 		printf(" ===========================\n");
428 433
 		printf(" Reading Frame[%03u]\n", frame);
429
-		printf(" ===========================\n");		
434
+		printf(" ===========================\n");
430 435
 
431 436
 		/* PNTS0000... */
432 437
 		fread(buffer, 1, 28, f);
433 438
 		buffer[8] = 0;
434
-	
439
+
435 440
 		if (frame == 0 && strncmp("PNTS0000", buffer, 8) != 0)
436 441
 		{
437 442
 			printf("Expected PNTS0000, found '%s'\n", buffer);
@@ -452,10 +457,10 @@ int PSKModel::load(char *filename)
452 457
 			mVertices[i+1] = r;
453 458
 			fread(&r, 1, 4, f);
454 459
 			mVertices[i+2] = r;
455
-			
460
+
456 461
 			if (mFlags & fDebugPointLoad)
457 462
 			{
458
-				printf("\t%5u (%.3f, %.3f, %.3f)\n", 
463
+				printf("\t%5u (%.3f, %.3f, %.3f)\n",
459 464
 						 i/3, mVertices[i], mVertices[i+1], mVertices[i+2]);
460 465
 			}
461 466
 		}
@@ -464,7 +469,7 @@ int PSKModel::load(char *filename)
464 469
 		/* VTXW0000... */
465 470
 		fread(buffer, 1, 28, f);
466 471
 		buffer[8] = 0;
467
-		
472
+
468 473
 		if (frame == 0 && strncmp("VTXW0000", buffer, 8) != 0)
469 474
 		{
470 475
 			printf("Expected VTXW0000, found '%s'\n", buffer);
@@ -472,7 +477,7 @@ int PSKModel::load(char *filename)
472 477
 			printf("This isn't a known VTXW0000\n");
473 478
 			return -2;
474 479
 		}
475
-		
480
+
476 481
 		fread(&mNumVTXWs, 1, 4, f);
477 482
 		printf(" NumVTXWs =\t %u\n", mNumVTXWs);
478 483
 
@@ -497,9 +502,9 @@ int PSKModel::load(char *filename)
497 502
 
498 503
 			if (mFlags & fDebugUVLoad)
499 504
 			{
500
-				printf("\t%5u vertex = %u, unknown1 = 0x%x, UV = (%.3f, %.3f), unknown2 = 0x%x\n", 
501
-						 i, 
502
-						 mVTXWs[i].vertex, mVTXWs[i].unknown1, 
505
+				printf("\t%5u vertex = %u, unknown1 = 0x%x, UV = (%.3f, %.3f), unknown2 = 0x%x\n",
506
+						 i,
507
+						 mVTXWs[i].vertex, mVTXWs[i].unknown1,
503 508
 						 mVTXWs[i].uv[0], mVTXWs[i].uv[1],
504 509
 						 mVTXWs[i].unknown2);
505 510
 			}
@@ -509,7 +514,7 @@ int PSKModel::load(char *filename)
509 514
 		/* FACE0000... */
510 515
 		fread(buffer, 1, 28, f);
511 516
 		buffer[8] = 0;
512
-		
517
+
513 518
 		if (frame == 0 && strncmp("FACE0000", buffer, 8) != 0)
514 519
 		{
515 520
 			printf("Expected FACE0000, found '%s'\n", buffer);
@@ -520,9 +525,9 @@ int PSKModel::load(char *filename)
520 525
 
521 526
 		fread(&mNumFaces, 1, 4, f);
522 527
 		printf(" NumFaces =\t %u\n", mNumFaces);
523
-		
528
+
524 529
 		mFaces = new psk_face_t[mNumFaces];
525
-		
530
+
526 531
 		for (i = 0; i < mNumFaces; ++i)
527 532
 		{
528 533
 			// Vertex indices
@@ -541,11 +546,11 @@ int PSKModel::load(char *filename)
541 546
 
542 547
 			if (mFlags & fDebugFaceLoad)
543 548
 			{
544
-				printf("%5u (%u, %u, %u), material = %u, flags = %u, unknown = 0x%x\n", 
545
-						 i, 
549
+				printf("%5u (%u, %u, %u), material = %u, flags = %u, unknown = 0x%x\n",
550
+						 i,
546 551
 						 mFaces[i].x, mFaces[i].y, mFaces[i].z,
547 552
 						 mFaces[i].material, mFaces[i].flags, mFaces[i].unknown);
548
-						 
553
+
549 554
 			}
550 555
 		}
551 556
 
@@ -553,7 +558,7 @@ int PSKModel::load(char *filename)
553 558
 		/* MATT0000... */
554 559
 		fread(buffer, 1, 28, f);
555 560
 		buffer[8] = 0;
556
-		
561
+
557 562
 		if (frame == 0 && strncmp("MATT0000", buffer, 8) != 0)
558 563
 		{
559 564
 			printf("Expected MATT0000, found '%s'\n", buffer);
@@ -565,7 +570,7 @@ int PSKModel::load(char *filename)
565 570
 		fread(&mNumMaterials, 1, 4, f);
566 571
 		printf(" NumMaterials =\t %u\n", mNumMaterials);
567 572
 		mMaterials = new psk_material_t[mNumMaterials];
568
-		
573
+
569 574
 		for (i = 0; i < mNumMaterials; ++i)
570 575
 		{
571 576
 			fread(&mMaterials[i].name, 1, 64, f);
@@ -612,7 +617,7 @@ int PSKModel::load(char *filename)
612 617
 
613 618
 	fread(&mNumBones, 1, 4, f);
614 619
 	printf(" NumBones =\t %u\n", mNumBones);
615
-	
620
+
616 621
 	mBones = new psk_bone_t[mNumBones];
617 622
 
618 623
 	for (i = 0; i < mNumBones; ++i)
@@ -621,7 +626,7 @@ int PSKModel::load(char *filename)
621 626
 		strncpy(mBones[i].name, buffer, 64);
622 627
 		fread(&mBones[i].flags, 1, 4, f);
623 628
 		fread(&mBones[i].numChildren, 1, 4, f);
624
-		fread(&mBones[i].parentIndex, 1, 4, f); 
629
+		fread(&mBones[i].parentIndex, 1, 4, f);
625 630
 
626 631
 		fread(&r, 1, 4, f);
627 632
 		mBones[i].restDir[0] = r;
@@ -643,25 +648,25 @@ int PSKModel::load(char *filename)
643 648
 		fread(mBones[i].unknown+1, 1, 4, f);
644 649
 		fread(mBones[i].unknown+2, 1, 4, f);
645 650
 		fread(mBones[i].unknown+3, 1, 4, f);
646
-		
651
+
647 652
 		if (mFlags & fDebugBoneLoad)
648 653
 		{
649 654
 			unsigned int offset = ftell(f) - 110;
650 655
 			printf("\n# File offset 0x%x + 110bytes\n", offset);
651 656
 
652 657
 			printf("Bone[%03u] = { '%s'\n", i, buffer);
653
-			printf("\tParent: %u, Children: %u, flags: 0x%80x\n", 
654
-					 mBones[i].parentIndex, mBones[i].numChildren, 
658
+			printf("\tParent: %u, Children: %u, flags: 0x%80x\n",
659
+					 mBones[i].parentIndex, mBones[i].numChildren,
655 660
 					 mBones[i].flags);
656
-			printf("\tRest Loc: (%.3f, %.3f, %.3f)\n", 
657
-					 mBones[i].restLoc[0], mBones[i].restLoc[1], 
661
+			printf("\tRest Loc: (%.3f, %.3f, %.3f)\n",
662
+					 mBones[i].restLoc[0], mBones[i].restLoc[1],
658 663
 					 mBones[i].restLoc[2]);
659
-			printf("\tRest Dir XYZ: (%.3f, %.3f, %.3f), W: %.3f?\n", 
660
-					 mBones[i].restDir[0], mBones[i].restDir[1], 
664
+			printf("\tRest Dir XYZ: (%.3f, %.3f, %.3f), W: %.3f?\n",
665
+					 mBones[i].restDir[0], mBones[i].restDir[1],
661 666
 					 mBones[i].restDir[2], mBones[i].restDir[3]);
662
-			
663
-			printf("\tUnknown: 0x%x, 0x%x, 0x%x, Flags? 0x%x\n", 
664
-					 mBones[i].unknown[0], mBones[i].unknown[1], 
667
+
668
+			printf("\tUnknown: 0x%x, 0x%x, 0x%x, Flags? 0x%x\n",
669
+					 mBones[i].unknown[0], mBones[i].unknown[1],
665 670
 					 mBones[i].unknown[2], mBones[i].unknown[3]);
666 671
 			printf("}\n");
667 672
 		}
@@ -686,7 +691,7 @@ int PSKModel::load(char *filename)
686 691
 
687 692
 	fread(&mNumWeights, 1, 4, f);
688 693
 	printf(" NumWeights =\t %u\n", mNumWeights);
689
-	
694
+
690 695
 	mWeights = new psk_weight_t[mNumWeights];
691 696
 
692 697
 	for (i = 0; i < mNumWeights; ++i)
@@ -697,8 +702,8 @@ int PSKModel::load(char *filename)
697 702
 
698 703
 		if (mFlags & fDebugWeightLoad)
699 704
 		{
700
-			printf("\tWeight[%u] { w = %f, vertexIndex = %u,  boneIndex = %u }\n", i, 
701
-					 mWeights[i].weight, 
705
+			printf("\tWeight[%u] { w = %f, vertexIndex = %u,  boneIndex = %u }\n", i,
706
+					 mWeights[i].weight,
702 707
 					 mWeights[i].vertexIndex, mWeights[i].boneIndex);
703 708
 		}
704 709
 	}
@@ -801,7 +806,7 @@ int PSAAnimation::load(char *filename)
801 806
 		fread(mBones[i].name, 1, 64, f);
802 807
 		fread(&mBones[i].flags, 1, 4, f);
803 808
 		fread(&mBones[i].numChildren, 1, 4, f);
804
-		fread(&mBones[i].parentIndex, 1, 4, f); 
809
+		fread(&mBones[i].parentIndex, 1, 4, f);
805 810
 
806 811
 		fread(&mBones[i].restDir[0], 1, 4, f);
807 812
 		fread(&mBones[i].restDir[1], 1, 4, f);
@@ -820,17 +825,17 @@ int PSAAnimation::load(char *filename)
820 825
 		if (mFlags &fDebugBones)
821 826
 		{
822 827
 			printf("Bone[%03u] = { '%s'\n", i, mBones[i].name);
823
-			printf("\tParent: %u, Children: %u, Flags: 0x%04x\n", 
828
+			printf("\tParent: %u, Children: %u, Flags: 0x%04x\n",
824 829
 					 mBones[i].parentIndex, mBones[i].numChildren,
825 830
 					 mBones[i].flags);
826
-			printf("\tRest Loc: (%.3f, %.3f, %.3f)\n", 
827
-					 mBones[i].restLoc[0], mBones[i].restLoc[1], 
831
+			printf("\tRest Loc: (%.3f, %.3f, %.3f)\n",
832
+					 mBones[i].restLoc[0], mBones[i].restLoc[1],
828 833
 					 mBones[i].restLoc[2]);
829
-			printf("\tRest Dir XYZ: (%.3f, %.3f, %.3f), W: %.3f\n", 
830
-					 mBones[i].restDir[0], mBones[i].restDir[1], 
834
+			printf("\tRest Dir XYZ: (%.3f, %.3f, %.3f), W: %.3f\n",
835
+					 mBones[i].restDir[0], mBones[i].restDir[1],
831 836
 					 mBones[i].restDir[2], mBones[i].restDir[3]);
832
-			printf("\?: 0x%x, 0x%x, 0x%x, Flags? 0x%08x\n", 
833
-					 mBones[i].unknown[0], mBones[i].unknown[1], 
837
+			printf("\?: 0x%x, 0x%x, 0x%x, Flags? 0x%08x\n",
838
+					 mBones[i].unknown[0], mBones[i].unknown[1],
834 839
 					 mBones[i].unknown[2], mBones[i].unknown[3]);
835 840
 			printf("? %f\n", *((float *)&mBones[i].unknown[3]));
836 841
 			printf("}\n");
@@ -871,22 +876,22 @@ int PSAAnimation::load(char *filename)
871 876
 		if (mFlags &fDebugAnimInfos)
872 877
 		{
873 878
 			printf("\n");
874
-			printf("AnimInfo[%u] = { name: '%s', name2: '%s'\n", i, 
879
+			printf("AnimInfo[%u] = { name: '%s', name2: '%s'\n", i,
875 880
 					 mAnimInfos[i].name, mAnimInfos[i].name2);
876 881
 			printf(" numBones = %u, rootId = %u\n",
877 882
 					 mAnimInfos[i].numBones, mAnimInfos[i].rootId);
878
-			printf(" key: %u %u %f\n", 
879
-					 mAnimInfos[i].key[0], mAnimInfos[i].key[1], 
883
+			printf(" key: %u %u %f\n",
884
+					 mAnimInfos[i].key[0], mAnimInfos[i].key[1],
880 885
 					 mAnimInfos[i].keyf);
881
-			printf(" time: %f %f\n", 
886
+			printf(" time: %f %f\n",
882 887
 					 mAnimInfos[i].time[0], mAnimInfos[i].time[1]);
883
-			printf(" unknowns: %f %f %f\n", 
884
-					 mAnimInfos[i].unknown[0], mAnimInfos[i].unknown[1], 
888
+			printf(" unknowns: %f %f %f\n",
889
+					 mAnimInfos[i].unknown[0], mAnimInfos[i].unknown[1],
885 890
 					 mAnimInfos[i].unknown[2]);
886 891
 			printf("}\n");
887 892
 		}
888 893
 	}
889
-	
894
+
890 895
 	printf("COMPUTE: psa.numKeyframes / info.numBones = frames per bone\n");
891 896
 	printf("\n");
892 897
 
@@ -907,7 +912,7 @@ int PSAAnimation::load(char *filename)
907 912
 	mKeyFrames = new psa_key_frame_t[mNumKeyFrames];
908 913
 
909 914
 	for (i = 0; i < mNumKeyFrames; ++i)
910
-	{	
915
+	{
911 916
 		// tx ty tz qx qy qz qw s
912 917
 		fread(&mKeyFrames[i].trans[0], 4, 1, f);
913 918
 		fread(&mKeyFrames[i].trans[1], 4, 1, f);
@@ -921,11 +926,11 @@ int PSAAnimation::load(char *filename)
921 926
 		if (mFlags &fDebugKeyFrames)
922 927
 		{
923 928
 			printf("keyFrame[%u] = {\n", i);
924
-			printf("Trans XYZ: ( %f %f %f )\n", 
929
+			printf("Trans XYZ: ( %f %f %f )\n",
925 930
 					 mKeyFrames[i].trans[0], mKeyFrames[i].trans[1],
926 931
 					 mKeyFrames[i].trans[2]);
927
-			printf("Dir XYZ: ( %f %f %f ) %f\n", 
928
-					 mKeyFrames[i].dir[0], mKeyFrames[i].dir[1], 
932
+			printf("Dir XYZ: ( %f %f %f ) %f\n",
933
+					 mKeyFrames[i].dir[0], mKeyFrames[i].dir[1],
929 934
 					 mKeyFrames[i].dir[2], mKeyFrames[i].dir[3]);
930 935
 			printf("scale = %f\n", mKeyFrames[i].scale);
931 936
 			printf("}\n\n");
@@ -1018,14 +1023,14 @@ void PSKModelRenderer::render()
1018 1023
 	}
1019 1024
 
1020 1025
 	if (mFlags & fRenderPoints)
1021
-	{	
1026
+	{
1022 1027
 		glBegin(GL_POINTS);
1023
-		
1028
+
1024 1029
 		for (i = 0; i < mNumVertices*3; i+= 3)
1025 1030
 		{
1026 1031
 			glVertex3fv(mVertexTransformCache+i);
1027 1032
 		}
1028
-		
1033
+
1029 1034
 		glEnd();
1030 1035
 	}
1031 1036
 
@@ -1035,7 +1040,7 @@ void PSKModelRenderer::render()
1035 1040
 	}
1036 1041
 
1037 1042
 	if (mFlags & fRenderFaces)
1038
-	{		
1043
+	{
1039 1044
 		unsigned int index[3];
1040 1045
 		int lastTexture = 999999;
1041 1046
 
@@ -1078,17 +1083,17 @@ void PSKModelRenderer::render()
1078 1083
 				glTexCoord2fv(mVTXWs[mFaces[i].y].uv);
1079 1084
 				glVertex3fv(mVertexTransformCache+index[1]);
1080 1085
 				glTexCoord2fv(mVTXWs[mFaces[i].z].uv);
1081
-				glVertex3fv(mVertexTransformCache+index[2]); 
1086
+				glVertex3fv(mVertexTransformCache+index[2]);
1082 1087
 			}
1083 1088
 			else
1084 1089
 			{
1085
-				((i % 2) ? 
1090
+				((i % 2) ?
1086 1091
 				 glColor3f(0.0f, 0.0f, (((float)i)/(float)mNumFaces)*.5+.25) :
1087 1092
 				 glColor3f(0.0f, (((float)i)/(float)mNumFaces)*.5+.25, 0.0f));
1088 1093
 
1089
-				glVertex3fv(mVertexTransformCache+index[0]); 
1090
-				glVertex3fv(mVertexTransformCache+index[1]); 
1091
-				glVertex3fv(mVertexTransformCache+index[2]); 
1094
+				glVertex3fv(mVertexTransformCache+index[0]);
1095
+				glVertex3fv(mVertexTransformCache+index[1]);
1096
+				glVertex3fv(mVertexTransformCache+index[2]);
1092 1097
 			}
1093 1098
 
1094 1099
 			glEnd();
@@ -1151,12 +1156,12 @@ void PSKModelRenderer::renderBone(unsigned int id)
1151 1156
 	if (mAnimationFrame > 0 &&
1152 1157
 		 mAnimation && mAnimation->mBones == mBones)
1153 1158
 	{
1154
-		f = id + (mAnimationFrame*mAnimation->mNumBones); 
1159
+		f = id + (mAnimationFrame*mAnimation->mNumBones);
1155 1160
 
1156 1161
 		posB[0] = -mAnimation->mKeyFrames[f].trans[0];
1157 1162
 		posB[1] = -mAnimation->mKeyFrames[f].trans[1];
1158 1163
 		posB[2] = -mAnimation->mKeyFrames[f].trans[2];
1159
-		
1164
+
1160 1165
 		glTranslatef(mAnimation->mKeyFrames[f].trans[0],
1161 1166
 						 mAnimation->mKeyFrames[f].trans[1],
1162 1167
 						 mAnimation->mKeyFrames[f].trans[2]);
@@ -1166,7 +1171,7 @@ void PSKModelRenderer::renderBone(unsigned int id)
1166 1171
 		posB[0] = -mBones[id].restLoc[0];
1167 1172
 		posB[1] = -mBones[id].restLoc[1];
1168 1173
 		posB[2] = -mBones[id].restLoc[2];
1169
-		
1174
+
1170 1175
 		glTranslatef(mBones[id].restLoc[0],
1171 1176
 						 mBones[id].restLoc[1],
1172 1177
 						 mBones[id].restLoc[2]);
@@ -1259,7 +1264,7 @@ void PSKModelRenderer::renderBone(unsigned int id)
1259 1264
 		{
1260 1265
 			if (i == mBones[i].parentIndex)
1261 1266
 				continue;
1262
-			
1267
+
1263 1268
 			if (mBones[i].parentIndex == id)
1264 1269
 			{
1265 1270
 				renderBone(i);
@@ -1319,7 +1324,7 @@ void PSKModelRenderer::convertBoneAngles()
1319 1324
 												&mBoneRotationCache[i*4],    // x
1320 1325
 												&mBoneRotationCache[i*4+1],  // y
1321 1326
 												&mBoneRotationCache[i*4+2]); // z
1322
-			
1327
+
1323 1328
 			// Convert radians to degrees
1324 1329
 			mBoneRotationCache[i*4] *= 57.295779513082323;
1325 1330
 			mBoneRotationCache[i*4+1] *= 57.295779513082323;
@@ -1334,11 +1339,11 @@ void PSKModelRenderer::convertBoneAngles()
1334 1339
 											  mBones[i].restDir[2], // qz
1335 1340
 											  &mBoneRotationCache[i*4],  // theta
1336 1341
 											  &mBoneRotationCache[i*4+1],  // x
1337
-											  &mBoneRotationCache[i*4+2],  // y  
1342
+											  &mBoneRotationCache[i*4+2],  // y
1338 1343
 											  &mBoneRotationCache[i*4+3]); // z
1339 1344
 
1340 1345
 			// Convert radians to degrees, negated to account for UT coords
1341
-			mBoneRotationCache[i*4] *= -57.295779513082323; 
1346
+			mBoneRotationCache[i*4] *= -57.295779513082323;
1342 1347
 		}
1343 1348
 	}
1344 1349
 }
@@ -1412,7 +1417,7 @@ void PSKModelRenderer::convertBoneAnglesPSA(unsigned int frame)
1412 1417
 												&mBoneRotationCache[b*4],    // x
1413 1418
 												&mBoneRotationCache[b*4+1],  // y
1414 1419
 												&mBoneRotationCache[b*4+2]); // z
1415
-			
1420
+
1416 1421
 			// Convert radians to degrees
1417 1422
 			mBoneRotationCache[b*4] *= 57.295779513082323;
1418 1423
 			mBoneRotationCache[b*4+1] *= 57.295779513082323;
@@ -1424,7 +1429,7 @@ void PSKModelRenderer::convertBoneAnglesPSA(unsigned int frame)
1424 1429
 			quaternion_to_axis_angles(qw, qx, qy, qz,
1425 1430
 											  &mBoneRotationCache[b*4],    // theta
1426 1431
 											  &mBoneRotationCache[b*4+1],  // x
1427
-											  &mBoneRotationCache[b*4+2],  // y  
1432
+											  &mBoneRotationCache[b*4+2],  // y
1428 1433
 											  &mBoneRotationCache[b*4+3]); // z
1429 1434
 
1430 1435
 			// Convert radians to degrees, negated to account for UT coords
@@ -1466,7 +1471,7 @@ void PSKModelRenderer::setAnimation(PSAAnimation *anim)
1466 1471
 	if (!anim || !mModel || anim->mNumBones != mModel->mNumBones)
1467 1472
 	{
1468 1473
 		printf("Error: Unable to load PSA Animation, [%s]\n",
1469
-				 (!mModel) ? "No PSK model loaded" : 
1474
+				 (!mModel) ? "No PSK model loaded" :
1470 1475
 				 (!anim) ? "Null PSA given" :
1471 1476
 				 "PSA animation doesn't match loaded PSK model");
1472 1477
 		return;
@@ -1515,7 +1520,7 @@ void PSKModelRenderer::setModel(PSKModel *model)
1515 1520
 	mFaces = model->mFaces;
1516 1521
 	mMaterials = model->mMaterials;
1517 1522
 	mBones = model->mBones;
1518
-	mWeights = model->mWeights;		
1523
+	mWeights = model->mWeights;
1519 1524
 
1520 1525
 	/* Setup vertices */
1521 1526
 	if (mVertexTransformCache)
@@ -1527,7 +1532,7 @@ void PSKModelRenderer::setModel(PSKModel *model)
1527 1532
 	/* Setup bones */
1528 1533
 	if (mBoneRotationCache)
1529 1534
 		delete [] mBoneRotationCache;
1530
-	
1535
+
1531 1536
 	mBoneRotationCache = new float[model->mNumBones*4];
1532 1537
 	convertBoneAngles();
1533 1538
 
@@ -1579,7 +1584,7 @@ void PSKModelRenderer::setupRestMatrices(unsigned int id)
1579 1584
 	/* OpenGL axis angles rotation */
1580 1585
 	glRotatef(theta, x, y, z);
1581 1586
 
1582
-	/* Store this bones tranform matrix inverted to 
1587
+	/* Store this bones tranform matrix inverted to
1583 1588
 		get bone rest position of model vertices */
1584 1589
 	glGetFloatv(GL_MODELVIEW_MATRIX, m);
1585 1590
 	invert_matrix(m, mInvertedMatrices[id]);
@@ -1590,7 +1595,7 @@ void PSKModelRenderer::setupRestMatrices(unsigned int id)
1590 1595
 		{
1591 1596
 			if (i == mBones[i].parentIndex)
1592 1597
 				continue;
1593
-			
1598
+
1594 1599
 			if (mBones[i].parentIndex == id)
1595 1600
 			{
1596 1601
 				setupRestMatrices(i);
@@ -1616,8 +1621,8 @@ void PSKModelRenderer::setupWorldMatrices(unsigned int id)
1616 1621
 	if (mAnimationFrame > 0 &&
1617 1622
 		 mAnimation && mAnimation->mBones == mBones)
1618 1623
 	{
1619
-		f = id + (mAnimationFrame*mAnimation->mNumBones); 
1620
-		
1624
+		f = id + (mAnimationFrame*mAnimation->mNumBones);
1625
+
1621 1626
 		glTranslatef(mAnimation->mKeyFrames[f].trans[0],
1622 1627
 						 mAnimation->mKeyFrames[f].trans[1],
1623 1628
 						 mAnimation->mKeyFrames[f].trans[2]);
@@ -1654,7 +1659,7 @@ void PSKModelRenderer::setupWorldMatrices(unsigned int id)
1654 1659
 		{
1655 1660
 			if (i == mBones[i].parentIndex)
1656 1661
 				continue;
1657
-			
1662
+
1658 1663
 			if (mBones[i].parentIndex == id)
1659 1664
 			{
1660 1665
 				setupWorldMatrices(i);
@@ -1669,7 +1674,7 @@ void PSKModelRenderer::setupWorldMatrices(unsigned int id)
1669 1674
 	float m[16], m2[16], m3[16];
1670 1675
 
1671 1676
 
1672
-	/* Currently inline transforms all vertices to produce 
1677
+	/* Currently inline transforms all vertices to produce
1673 1678
 		one deformed mesh keyframe */
1674 1679
 	if (id == 0)
1675 1680
 		copyVertices();
@@ -1685,7 +1690,7 @@ void PSKModelRenderer::setupWorldMatrices(unsigned int id)
1685 1690
 								mModel->mBones[id].restDir[1], // qy
1686 1691
 								mModel->mBones[id].restDir[2], // qz
1687 1692
 								m2);
1688
-	
1693
+
1689 1694
 	multiply_matrix(m, m2, m3);
1690 1695
 
1691 1696
 	if (id == 0)
@@ -1695,8 +1700,8 @@ void PSKModelRenderer::setupWorldMatrices(unsigned int id)
1695 1700
 	else
1696 1701
 	{
1697 1702
 		invert_matrix(m3, m2);
1698
-		multiply_matrix(mInvertedMatrices[mModel->mBones[id].parent], 
1699
-							 m2, mInvertedMatrices[id]);	
1703
+		multiply_matrix(mInvertedMatrices[mModel->mBones[id].parent],
1704
+							 m2, mInvertedMatrices[id]);
1700 1705
 	}
1701 1706
 
1702 1707
 	/* Transformed skeleton matrices */
@@ -1723,9 +1728,9 @@ void PSKModelRenderer::setupWorldMatrices(unsigned int id)
1723 1728
 	else
1724 1729
 	{
1725 1730
 		multiply_matrix(mInvertedMatrices[id], m3, m2);
1726
-		multiply_matrix(mInvertedMatrices[mModel->mBones[id].parent], 
1731
+		multiply_matrix(mInvertedMatrices[mModel->mBones[id].parent],
1727 1732
 							 m2, m);
1728
-	}	
1733
+	}
1729 1734
 	//copy_matrix(m, mInvertedMatrices[id]);
1730 1735
 
1731 1736
 	for (i = 0; i < mModel->mNumWeights; ++i)
@@ -1775,11 +1780,11 @@ void PSKModelRenderer::transformVertices()
1775 1780
 			if (mModel->mWeights[i].boneIndex == id)
1776 1781
 			{
1777 1782
 				j = mModel->mWeights[i].vertexIndex;
1778
-				
1783
+
1779 1784
 				x = mVertexTransformCache[j*3+0] * mModel->mWeights[i].weight;
1780 1785
 				y = mVertexTransformCache[j*3+1] * mModel->mWeights[i].weight;
1781 1786
 				z = mVertexTransformCache[j*3+2] * mModel->mWeights[i].weight;
1782
-				
1787
+
1783 1788
 				mVertexTransformCache[j*3+0] = m[0]*x + m[4]*y + m[ 8]*z + m[12];
1784 1789
 				mVertexTransformCache[j*3+1] = m[1]*x + m[5]*y + m[ 9]*z + m[13];
1785 1790
 				mVertexTransformCache[j*3+2] = m[2]*x + m[6]*y + m[10]*z + m[14];
@@ -1829,8 +1834,8 @@ void renderScene()
1829 1834
 	float x, y, time;
1830 1835
 
1831 1836
 
1832
-	gluLookAt(0.0, 0.0, -256.0, 
1833
-				 0.0, 8.0, 0.0, 
1837
+	gluLookAt(0.0, 0.0, -256.0,
1838
+				 0.0, 8.0, 0.0,
1834 1839
 				 0.0, 1.0, 0.0);
1835 1840
 
1836 1841
 	glDisable(GL_TEXTURE_2D);
@@ -1865,7 +1870,7 @@ void renderScene()
1865 1870
 	// Draw light symbol
1866 1871
 	glPushMatrix();
1867 1872
 	glTranslatef(gLightPos[0], gLightPos[1], gLightPos[2]);
1868
-	
1873
+
1869 1874
 	glBegin(GL_LINES);
1870 1875
 	glColor3f(1.0f, 1.0f, 1.0f);
1871 1876
 	glVertex3f(0.0f, 0.0f, 0.0f);
@@ -1926,15 +1931,15 @@ void renderScene()
1926 1931
 		glBegin(GL_LINE_LOOP);
1927 1932
 		for (y = -size; y < size; y += step)
1928 1933
 		{
1929
-			glVertex3f(x + step, 0.0f, y);	
1930
-			glVertex3f(x, 0.0f, y);	
1934
+			glVertex3f(x + step, 0.0f, y);
1935
+			glVertex3f(x, 0.0f, y);
1931 1936
 			glVertex3f(x, 0.0f, y + step);
1932 1937
 			glVertex3f(x + step, 0.0f, y + step);
1933 1938
 		}
1934 1939
 		glEnd();
1935 1940
 	}
1936 1941
 	glPopMatrix();
1937
-	
1942
+
1938 1943
 	// Draw model
1939 1944
 	glEnable(GL_TEXTURE_2D);
1940 1945
 	glColor3f(1.0f, 1.0f, 1.0f);
@@ -2025,14 +2030,14 @@ void initScene(int argc, char *argv[])
2025 2030
 	printf(";/'        - Switch PSA frame (EXPERIMENTAL)\n");
2026 2031
 	printf("/          - Show PSK frame\n");
2027 2032
 	printf("----------------------------------\n");
2028
-	printf("1 - Toggle polygon rendering\n");   
2029
-	printf("2 - Toggle polygon render debugging\n"); 
2030
-	printf("3 - Toggle textured polygons\n");  
2031
-	printf("4 - Toggle points\n");  
2033
+	printf("1 - Toggle polygon rendering\n");
2034
+	printf("2 - Toggle polygon render debugging\n");
2035
+	printf("3 - Toggle textured polygons\n");
2036
+	printf("4 - Toggle points\n");
2032 2037
 	printf("7 - Toggle scene rotation\n");
2033
-	printf("8 - Toggle alpha blending\n");      
2034
-	printf("8 - Toggle OpenGL Lighting\n"); 
2035
-	printf("r - Reset mesh to default\n");  
2038
+	printf("8 - Toggle alpha blending\n");
2039
+	printf("8 - Toggle OpenGL Lighting\n");
2040
+	printf("r - Reset mesh to default\n");
2036 2041
 	printf("w - Toggle wireframe rendering\n");
2037 2042
 #ifdef INTERACTIVE_BONE_RENDER
2038 2043
 	printf("g,h - Select bone Id\n");
@@ -2251,7 +2256,7 @@ void handleKey(int key)
2251 2256
 
2252 2257
 		if (gWireframe)
2253 2258
 		{
2254
-			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
2259
+			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
2255 2260
 		}
2256 2261
 		else
2257 2262
 		{
@@ -2295,13 +2300,13 @@ void event_resize(unsigned int width, unsigned int height)
2295 2300
 {
2296 2301
 	GLfloat aspect;
2297 2302
 
2298
-	
2303
+
2299 2304
 	gWidth = width;
2300 2305
 	gHeight = height;
2301 2306
 
2302 2307
 	aspect = (GLfloat)width/(GLfloat)height;
2303 2308
 
2304
-	glViewport(0, 0, width, height); 
2309
+	glViewport(0, 0, width, height);
2305 2310
 
2306 2311
 	glMatrixMode(GL_PROJECTION);
2307 2312
 	glLoadIdentity();
@@ -2376,7 +2381,7 @@ int main_gl(int argc, char *argv[])
2376 2381
 	  if (SDL_GL_LoadLibrary("libGL.so") < 0)
2377 2382
 	  {
2378 2383
 		  SDL_ClearError();
2379
-    
2384
+
2380 2385
 		  // Fallback 2
2381 2386
 		  if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
2382 2387
 		  {
@@ -2402,7 +2407,7 @@ int main_gl(int argc, char *argv[])
2402 2407
   SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
2403 2408
   gSDLWindow = SDL_SetVideoMode(width, height, 16, flags);
2404 2409
   SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
2405
-  
2410
+
2406 2411
   // Init rendering
2407 2412
   init_gl(width, height);
2408 2413
   initScene(argc, argv);
@@ -2423,7 +2428,7 @@ int main_gl(int argc, char *argv[])
2423 2428
 			  break;
2424 2429
 		  case SDL_MOUSEBUTTONDOWN:
2425 2430
 		  case SDL_MOUSEBUTTONUP:
2426
-			  break;	
2431
+			  break;
2427 2432
 		  case SDL_KEYDOWN:
2428 2433
 			  mkeys = (unsigned int)SDL_GetModState();
2429 2434
 			  mod = 0;
@@ -2460,12 +2465,12 @@ int main_gl(int argc, char *argv[])
2460 2465
 					  SDL_WM_ToggleFullScreen(gSDLWindow);
2461 2466
 				  }
2462 2467
 			  }
2463
-			  
2468
+
2464 2469
 			  handleKey(key);
2465 2470
 			  break;
2466 2471
 		  case SDL_KEYUP:
2467 2472
 			  break;
2468
-		  case SDL_VIDEORESIZE:			  
2473
+		  case SDL_VIDEORESIZE:
2469 2474
 			  event_resize(event.resize.w, event.resize.h);
2470 2475
 
2471 2476
 			  width = event.resize.w;
@@ -2477,7 +2482,7 @@ int main_gl(int argc, char *argv[])
2477 2482
 
2478 2483
 	  event_display(width, height);
2479 2484
   }
2480
-  
2485
+
2481 2486
   return 0;
2482 2487
 }
2483 2488
 #endif
@@ -2496,13 +2501,13 @@ int runPSKModelUnitTest(int argc, char *argv[])
2496 2501
 			{
2497 2502
 			case '.':
2498 2503
 				gAnim.mFlags = (PSAAnimation::fDebugBones |
2499
-									 PSAAnimation::fDebugAnimInfos | 
2504
+									 PSAAnimation::fDebugAnimInfos |
2500 2505
 									 PSAAnimation::fDebugKeyFrames);
2501 2506
 				gAnim.load(argv[2]);
2502 2507
 				break;
2503 2508
 			case 'p':
2504
-				gAnim.mFlags = (PSAAnimation::fDebugBones |	
2505
-									 PSAAnimation::fDebugAnimInfos | 
2509
+				gAnim.mFlags = (PSAAnimation::fDebugBones |
2510
+									 PSAAnimation::fDebugAnimInfos |
2506 2511
 									 PSAAnimation::fDebugKeyFrames);
2507 2512
 				break;
2508 2513
 			case 'g':
@@ -2544,7 +2549,7 @@ int runPSKModelUnitTest(int argc, char *argv[])
2544 2549
 				break;
2545 2550
 			}
2546 2551
 		}
2547
-		
2552
+
2548 2553
 		if (argc > 3)
2549 2554
 		{
2550 2555
 			/* Load PSK model */

+ 31
- 31
src/Particle.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: Partcle system's atomic base
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------ 
15
+ *
16
+ *-- History ------------------------------------------------
17 17
  *
18 18
  * 2001.08.13:
19 19
  * Mongoose - Created
@@ -23,7 +23,7 @@
23 23
 #ifndef __FREYJA_MONGOOSE_PARTICLE_H_
24 24
 #define __FREYJA_MONGOOSE_PARTICLE_H_
25 25
 
26
-#include <hel/math.h>
26
+#include "hel/math.h"
27 27
 
28 28
 class Particle
29 29
 {
@@ -31,12 +31,12 @@ class Particle
31 31
 
32 32
   Particle();
33 33
   /*------------------------------------------------------
34
-   * Pre  : 
34
+   * Pre  :
35 35
    * Post : Constructs an object of Particle
36 36
    *
37 37
    *-- History ------------------------------------------
38 38
    *
39
-   * 2001.08.13: 
39
+   * 2001.08.13:
40 40
    * Mongoose - Created
41 41
    ------------------------------------------------------*/
42 42
 
@@ -47,40 +47,40 @@ class Particle
47 47
    *
48 48
    *-- History ------------------------------------------
49 49
    *
50
-   * 2001.08.13: 
50
+   * 2001.08.13:
51 51
    * Mongoose - Created
52 52
    ------------------------------------------------------*/
53 53
 
54 54
 	void setActive(bool active);
55 55
   /*------------------------------------------------------
56
-   * Pre  : 
56
+   * Pre  :
57 57
    * Post : Toggles active state of particle
58 58
    *
59 59
    *-- History ------------------------------------------
60 60
    *
61
-   * 2001.08.13: 
61
+   * 2001.08.13:
62 62
    * Mongoose - Created
63 63
    ------------------------------------------------------*/
64 64
 
65 65
   void Force(float x, float y, float z);
66 66
   /*------------------------------------------------------
67
-   * Pre  : 
67
+   * Pre  :
68 68
    * Post : Sets gravity/force acting on particle
69 69
    *
70 70
    *-- History ------------------------------------------
71 71
    *
72
-   * 2001.08.13: 
72
+   * 2001.08.13:
73 73
    * Mongoose - Created
74 74
    ------------------------------------------------------*/
75 75
 
76 76
   void Reset();
77 77
   /*------------------------------------------------------
78
-   * Pre  : 
78
+   * Pre  :
79 79
    * Post : Resets particle to defaults
80 80
    *
81 81
    *-- History ------------------------------------------
82 82
    *
83
-   * 2001.08.13: 
83
+   * 2001.08.13:
84 84
    * Mongoose - Created
85 85
    ------------------------------------------------------*/
86 86
 
@@ -91,7 +91,7 @@ class Particle
91 91
    *
92 92
    *-- History ------------------------------------------
93 93
    *
94
-   * 2001.08.14: 
94
+   * 2001.08.14:
95 95
    * Mongoose - Created
96 96
    ------------------------------------------------------*/
97 97
 
@@ -104,7 +104,7 @@ class Particle
104 104
    *
105 105
    *-- History ------------------------------------------
106 106
    *
107
-   * 2001.08.14: 
107
+   * 2001.08.14:
108 108
    * Mongoose - Created
109 109
    ------------------------------------------------------*/
110 110
 
@@ -115,7 +115,7 @@ class Particle
115 115
    *
116 116
    *-- History ------------------------------------------
117 117
    *
118
-   * 2001.08.13: 
118
+   * 2001.08.13:
119 119
    * Mongoose - Created
120 120
    ------------------------------------------------------*/
121 121
 
@@ -126,62 +126,62 @@ class Particle
126 126
    *
127 127
    *-- History ------------------------------------------
128 128
    *
129
-   * 2001.08.13: 
129
+   * 2001.08.13:
130 130
    * Mongoose - Created
131 131
    ------------------------------------------------------*/
132 132
 
133 133
   float Life();
134 134
   /*------------------------------------------------------
135
-   * Pre  : 
135
+   * Pre  :
136 136
    * Post : Returns current life ( blend ) of particle
137 137
    *
138 138
    *-- History ------------------------------------------
139 139
    *
140
-   * 2001.08.13: 
140
+   * 2001.08.13:
141 141
    * Mongoose - Created
142 142
    ------------------------------------------------------*/
143 143
 
144 144
   void Update();
145 145
   /*------------------------------------------------------
146
-   * Pre  : 
146
+   * Pre  :
147 147
    * Post : Ajusts for particle life cycle
148 148
    *
149 149
    *-- History ------------------------------------------
150 150
    *
151
-   * 2001.08.13: 
151
+   * 2001.08.13:
152 152
    * Mongoose - Created
153 153
    ------------------------------------------------------*/
154 154
 
155 155
   int Texture();
156 156
   /*------------------------------------------------------
157
-   * Pre  : 
157
+   * Pre  :
158 158
    * Post : Returens texture binding for this particle
159 159
    *
160 160
    *-- History ------------------------------------------
161 161
    *
162
-   * 2001.08.13: 
162
+   * 2001.08.13:
163 163
    * Mongoose - Created
164 164
    ------------------------------------------------------*/
165 165
 
166 166
   bool isActive();
167 167
   /*------------------------------------------------------
168
-   * Pre  : 
168
+   * Pre  :
169 169
    * Post : Returns active value
170 170
    *
171 171
    *-- History ------------------------------------------
172 172
    *
173
-   * 2001.08.13: 
173
+   * 2001.08.13:
174 174
    * Mongoose - Created
175 175
    ------------------------------------------------------*/
176 176
 
177 177
   void TextureId(int t);
178 178
   /*------------------------------------------------------
179
-   * Pre  : 
180
-   * Post : 
179
+   * Pre  :
180
+   * Post :
181 181
    *
182 182
    *-- History ------------------------------------------
183 183
    *
184
-   * 2001.08.13: 
184
+   * 2001.08.13:
185 185
    * Mongoose - Created
186 186
    ------------------------------------------------------*/
187 187
 
@@ -189,9 +189,9 @@ class Particle
189 189
  private:
190 190
 
191 191
 	bool _active;           /* Is this particle in use? */
192
-	
192
+
193 193
 	float _life;            /* Life of particle  */
194
-	
194
+
195 195
 	float _blend;           /* Blend amount or fade */
196 196
 
197 197
 	int _texture;           /* Texture polygon to use */

+ 159
- 154
src/Render.cpp
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 73
- 73
src/Render.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Render
5 5
  * Author  : Mongoose
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: This is the renderer class for OpenRaider
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------ 
15
+ *
16
+ *-- History ------------------------------------------------
17 17
  *
18 18
  * 2001.05.21:
19 19
  * Mongoose - Created
@@ -23,10 +23,10 @@
23 23
 #ifndef GUARD__RENDER_MONGOOSE_RENDER_H_
24 24
 #define GUARD__RENDER_MONGOOSE_RENDER_H_
25 25
 
26
-#include <mstl/List.h>
27
-#include <mstl/Vector.h>
28
-#include <hel/Matrix.h>
29
-#include <hel/ViewVolume.h>
26
+#include "mstl/List.h"
27
+#include "mstl/Vector.h"
28
+#include "hel/Matrix.h"
29
+#include "hel/ViewVolume.h"
30 30
 #include "Light.h"
31 31
 #include "World.h"
32 32
 #include "SkeletalModel.h"
@@ -120,18 +120,18 @@ class Render
120 120
 	////////////////////////////////////////////////////////////
121 121
 	// Constructors
122 122
 	////////////////////////////////////////////////////////////
123
-	
123
+
124 124
 	Render();
125 125
 	/*------------------------------------------------------
126
-	 * Pre  : 
126
+	 * Pre  :
127 127
 	 * Post : Constructs an object of Render
128 128
 	 *
129 129
 	 *-- History ------------------------------------------
130 130
 	 *
131
-	 * 2001.05.21: 
131
+	 * 2001.05.21:
132 132
 	 * Mongoose - Created
133 133
 	 ------------------------------------------------------*/
134
-	
134
+
135 135
 	~Render();
136 136
 	/*------------------------------------------------------
137 137
 	 * Pre  : Render object is allocated
@@ -139,10 +139,10 @@ class Render
139 139
 	 *
140 140
 	 *-- History ------------------------------------------
141 141
 	 *
142
-	 * 2001.05.21: 
142
+	 * 2001.05.21:
143 143
 	 * Mongoose - Created
144 144
 	 ------------------------------------------------------*/
145
-	
145
+
146 146
 
147 147
 	////////////////////////////////////////////////////////////
148 148
 	// Public Accessors
@@ -150,23 +150,23 @@ class Render
150 150
 
151 151
 	void screenShot(char *filenameBase);
152 152
 	/*------------------------------------------------------
153
-	 * Pre  : 
153
+	 * Pre  :
154 154
 	 * Post : Makes a screenshot, writes to disk as file
155 155
 	 *
156 156
 	 *-- History ------------------------------------------
157 157
 	 *
158
-	 * 2002.12.20: 
158
+	 * 2002.12.20:
159 159
 	 * Mongoose - Created, factored out of OpenRaider class
160 160
 	 ------------------------------------------------------*/
161 161
 
162 162
 	int getMode();
163 163
 	/*------------------------------------------------------
164
-	 * Pre  : 
164
+	 * Pre  :
165 165
 	 * Post : Gets current rendering mode
166 166
 	 *
167 167
 	 *-- History ------------------------------------------
168 168
 	 *
169
-	 * 2001.05.21: 
169
+	 * 2001.05.21:
170 170
 	 * Mongoose - Created
171 171
 	 ------------------------------------------------------*/
172 172
 
@@ -177,8 +177,8 @@ class Render
177 177
 
178 178
 	void addRoom(RenderRoom *rRoom);
179 179
 	/*------------------------------------------------------
180
-	 * Pre  : 
181
-	 * Post : 
180
+	 * Pre  :
181
+	 * Post :
182 182
 	 *
183 183
 	 *-- History ------------------------------------------
184 184
 	 *
@@ -188,34 +188,34 @@ class Render
188 188
 
189 189
 	void Init(int width, int height, bool fastCard);
190 190
 	/*------------------------------------------------------
191
-	 * Pre  : 
191
+	 * Pre  :
192 192
 	 * Post : Starts and sets up OpenGL target
193 193
 	 *
194 194
 	 *-- History ------------------------------------------
195 195
 	 *
196
-	 * 2001.05.21: 
196
+	 * 2001.05.21:
197 197
 	 * Mongoose - Created
198 198
 	 ------------------------------------------------------*/
199 199
 
200
-	void loadTexture(unsigned char *image, 
200
+	void loadTexture(unsigned char *image,
201 201
 						  unsigned int width, unsigned int height,
202 202
 						  unsigned int id);
203 203
 	/*------------------------------------------------------
204
-	 * Pre  : 
204
+	 * Pre  :
205 205
 	 * Post : Loads textures in a certian id slot
206 206
 	 *
207 207
 	 *-- History ------------------------------------------
208 208
 	 *
209
-	 * 2002.12.20: 
209
+	 * 2002.12.20:
210 210
 	 * Mongoose - Created, factored out of OpenRaider class
211 211
 	 ------------------------------------------------------*/
212 212
 
213
-	void initTextures(char *textureDir, unsigned int *numLoaded, 
213
+	void initTextures(char *textureDir, unsigned int *numLoaded,
214 214
 							unsigned int *nextId);
215 215
 	/*------------------------------------------------------
216 216
 	 * Pre  : textureDir is valid and exists with textures
217 217
 	 * Post : Sets up textures for OpenRaider
218
-	 *        Returns number of loaded textures and 
218
+	 *        Returns number of loaded textures and
219 219
 	 *
220 220
 	 *        numLoaded will update number of
221 221
 	 *        external textures loaded
@@ -224,7 +224,7 @@ class Render
224 224
 	 *
225 225
 	 *-- History ------------------------------------------
226 226
 	 *
227
-	 * 2002.12.20: 
227
+	 * 2002.12.20:
228 228
 	 * Mongoose - Created, factored out of OpenRaider class
229 229
 	 ------------------------------------------------------*/
230 230
 
@@ -238,11 +238,11 @@ class Render
238 238
 	 *
239 239
 	 *-- History ------------------------------------------
240 240
 	 *
241
-	 * 2002.12.25: 
241
+	 * 2002.12.25:
242 242
 	 * Mongoose - Created, factored out of UnRaider class
243 243
 	 ------------------------------------------------------*/
244 244
 
245
-	void initEmitter(char *name, unsigned int size, 
245
+	void initEmitter(char *name, unsigned int size,
246 246
 						  unsigned int snowTex1, unsigned int snowTex2);
247 247
 	/*------------------------------------------------------
248 248
 	 * Pre  : Textures are init and these args are valid
@@ -257,12 +257,12 @@ class Render
257 257
 
258 258
 	void ClearWorld();
259 259
   /*------------------------------------------------------
260
-   * Pre  : 
260
+   * Pre  :
261 261
    * Post : Removes current world/entity/etc geometery
262 262
    *
263 263
    *-- History ------------------------------------------
264 264
    *
265
-   * 2001.05.21: 
265
+   * 2001.05.21:
266 266
    * Mongoose - Created
267 267
    ------------------------------------------------------*/
268 268
 
@@ -275,84 +275,84 @@ class Render
275 275
    *
276 276
    *-- History ------------------------------------------
277 277
    *
278
-   * 2002.03.21: 
278
+   * 2002.03.21:
279 279
    * Mongoose - Created
280 280
    ------------------------------------------------------*/
281 281
 
282 282
 	void setMode(int n);
283 283
   /*------------------------------------------------------
284
-   * Pre  : 
285
-   * Post : 
284
+   * Pre  :
285
+   * Post :
286 286
    *
287 287
    *-- History ------------------------------------------
288 288
    *
289
-   * 2001.05.21: 
289
+   * 2001.05.21:
290 290
    * Mongoose - Created
291 291
    ------------------------------------------------------*/
292 292
 
293 293
 	void Update(int width, int height);
294 294
   /*------------------------------------------------------
295
-   * Pre  : 
296
-   * Post : 
295
+   * Pre  :
296
+   * Post :
297 297
    *
298 298
    *-- History ------------------------------------------
299 299
    *
300
-   * 2001.05.21: 
300
+   * 2001.05.21:
301 301
    * Mongoose - Created
302 302
    ------------------------------------------------------*/
303 303
 
304 304
 	void Display();
305 305
   /*------------------------------------------------------
306
-   * Pre  : 
306
+   * Pre  :
307 307
    * Post : Renders a single game frame
308 308
    *
309 309
    *-- History ------------------------------------------
310 310
    *
311
-   * 2001.05.21: 
311
+   * 2001.05.21:
312 312
    * Mongoose - Created
313 313
    ------------------------------------------------------*/
314
-	
314
+
315 315
 	void setSkyMesh(int index, bool rot);
316 316
   /*------------------------------------------------------
317
-   * Pre  : 
318
-   * Post : 
317
+   * Pre  :
318
+   * Post :
319 319
    *
320 320
    *-- History ------------------------------------------
321 321
    *
322
-   * 2001.05.21: 
322
+   * 2001.05.21:
323 323
    * Mongoose - Created
324 324
    ------------------------------------------------------*/
325
-	
325
+
326 326
 	void ViewModel(entity_t *ent, int index);
327 327
   /*------------------------------------------------------
328
-   * Pre  : 
329
-   * Post : 
328
+   * Pre  :
329
+   * Post :
330 330
    *
331 331
    *-- History ------------------------------------------
332 332
    *
333
-   * 2001.05.21: 
333
+   * 2001.05.21:
334 334
    * Mongoose - Created
335 335
    ------------------------------------------------------*/
336
-	
336
+
337 337
 	void RegisterCamera(Camera *camera);
338 338
   /*------------------------------------------------------
339
-   * Pre  : 
340
-   * Post : 
339
+   * Pre  :
340
+   * Post :
341 341
    *
342 342
    *-- History ------------------------------------------
343 343
    *
344
-   * 2001.05.21: 
344
+   * 2001.05.21:
345 345
    * Mongoose - Created
346 346
    ------------------------------------------------------*/
347 347
 
348 348
    GLString *GetString();
349 349
    /*------------------------------------------------------
350
-    * Pre  : 
350
+    * Pre  :
351 351
     * Post : Returns GL text output agent
352 352
     *
353 353
     *-- History ------------------------------------------
354 354
     *
355
-    * 2002.01.04: 
355
+    * 2002.01.04:
356 356
     * Mongoose - Created
357 357
     ------------------------------------------------------*/
358 358
 
@@ -364,7 +364,7 @@ class Render
364 364
     *
365 365
     *-- History ------------------------------------------
366 366
     *
367
-    * 2002.01.01: 
367
+    * 2002.01.01:
368 368
     * Mongoose - Created
369 369
     ------------------------------------------------------*/
370 370
 
@@ -375,7 +375,7 @@ class Render
375 375
     *
376 376
     *-- History ------------------------------------------
377 377
     *
378
-    * 2002.01.01: 
378
+    * 2002.01.01:
379 379
     * Mongoose - Created
380 380
     ------------------------------------------------------*/
381 381
 
@@ -397,13 +397,13 @@ private:
397 397
 	 * 2002.12.16:
398 398
 	 * Mongoose - Moved to Render class
399 399
 	 *
400
-	 * 2001.06.06: 
400
+	 * 2001.06.06:
401 401
 	 * Mongoose - Created
402 402
 	 ------------------------------------------------------*/
403 403
 
404 404
 	bool isVisible(float x, float y, float z);
405 405
 	/*------------------------------------------------------
406
-	 * Pre  : 
406
+	 * Pre  :
407 407
 	 * Post : Is point in view volume?
408 408
 	 *
409 409
 	 *-- History ------------------------------------------
@@ -414,7 +414,7 @@ private:
414 414
 
415 415
 	bool isVisible(float x, float y, float z, float radius);
416 416
 	/*------------------------------------------------------
417
-	 * Pre  : 
417
+	 * Pre  :
418 418
 	 * Post : Is sphere in view volume?
419 419
 	 *
420 420
 	 *-- History ------------------------------------------
@@ -435,7 +435,7 @@ private:
435 435
     *
436 436
     *-- History ------------------------------------------
437 437
     *
438
-    * 2002.01.01: 
438
+    * 2002.01.01:
439 439
     * Mongoose - Created
440 440
     ------------------------------------------------------*/
441 441
 
@@ -448,7 +448,7 @@ private:
448 448
     *
449 449
     *-- History ------------------------------------------
450 450
     *
451
-    * 2002.01.01: 
451
+    * 2002.01.01:
452 452
     * Mongoose - Created
453 453
     ------------------------------------------------------*/
454 454
 
@@ -459,7 +459,7 @@ private:
459 459
     *
460 460
     *-- History ------------------------------------------
461 461
     *
462
-    * 2002.01.01: 
462
+    * 2002.01.01:
463 463
     * Mongoose - Created
464 464
     ------------------------------------------------------*/
465 465
 
@@ -471,7 +471,7 @@ private:
471 471
     *
472 472
     *-- History ------------------------------------------
473 473
     *
474
-    * 2002.01.01: 
474
+    * 2002.01.01:
475 475
     * Mongoose - Created
476 476
     ------------------------------------------------------*/
477 477
 
@@ -482,7 +482,7 @@ private:
482 482
     *
483 483
     *-- History ------------------------------------------
484 484
     *
485
-    * 2002.01.01: 
485
+    * 2002.01.01:
486 486
     * Mongoose - Created
487 487
     ------------------------------------------------------*/
488 488
 
@@ -498,10 +498,10 @@ private:
498 498
     *
499 499
     *-- History ------------------------------------------
500 500
     *
501
-    * 2002.01.01: 
501
+    * 2002.01.01:
502 502
     * Mongoose - Created
503 503
     ------------------------------------------------------*/
504
-	
504
+
505 505
 	void drawRoomModel(static_model_t *mesh);
506 506
    /*------------------------------------------------------
507 507
     * Pre  : Texture is init
@@ -509,10 +509,10 @@ private:
509 509
     *
510 510
     *-- History ------------------------------------------
511 511
     *
512
-    * 2002.01.01: 
512
+    * 2002.01.01:
513 513
     * Mongoose - Created
514 514
     ------------------------------------------------------*/
515
-	
515
+
516 516
 	void drawModelMesh(model_mesh_t *r_mesh, RenderMeshType type);
517 517
    /*------------------------------------------------------
518 518
     * Pre  : Texture is init, type is object containing mesh
@@ -520,10 +520,10 @@ private:
520 520
     *
521 521
     *-- History ------------------------------------------
522 522
     *
523
-    * 2002.01.01: 
523
+    * 2002.01.01:
524 524
     * Mongoose - Created
525 525
     ------------------------------------------------------*/
526
-	
526
+
527 527
 	void drawSprite(sprite_t *sprite);
528 528
    /*------------------------------------------------------
529 529
     * Pre  : Texture is init
@@ -531,7 +531,7 @@ private:
531 531
     *
532 532
     *-- History ------------------------------------------
533 533
     *
534
-    * 2002.01.01: 
534
+    * 2002.01.01:
535 535
     * Mongoose - Created
536 536
     ------------------------------------------------------*/
537 537
 
@@ -548,7 +548,7 @@ private:
548 548
 
549 549
 	void tmpRenderModelMesh(model_mesh_t *r_mesh, texture_tri_t *ttri);
550 550
 	/*------------------------------------------------------
551
-	 * Pre  : 
551
+	 * Pre  :
552 552
 	 * Post : Let them eat cake...
553 553
 	 *
554 554
 	 *-- History ------------------------------------------

+ 31
- 26
src/SDLSystem.cpp Zobrazit soubor

@@ -1,26 +1,26 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : OpenRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
7 7
  * Email   : stu7440@westga.edu
8 8
  * Object  : SDL
9 9
  * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 
10
+ * Comments:
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
17 15
  *
18
- * 2003.06.30, 
16
+ *-- History -------------------------------------------------
17
+ *
18
+ * 2003.06.30,
19 19
  * Mongoose - SDL_TTF support moved to Texture class
20 20
  *
21 21
  * 2003.06.03:
22 22
  * Mongoose - SDL_TTF support based on Sam Lantinga's public domain
23
- *            SDL_TTF demo functions and algorithms 
23
+ *            SDL_TTF demo functions and algorithms
24 24
  *
25 25
  * 2002.06.06:
26 26
  * Mongoose - Created
@@ -36,8 +36,13 @@
36 36
 #endif
37 37
 
38 38
 #ifdef HAVE_OPENGL
39
-#   include <GL/gl.h>
40
-#   include <GL/glu.h>
39
+#ifdef __APPLE__
40
+#include <OpenGL/gl.h>
41
+#include <OpenGL/glu.h>
42
+#else
43
+#include <GL/gl.h>
44
+#include <GL/glu.h>
45
+#endif
41 46
 #else
42 47
 #   error "SDLSystem requires -DHAVE_OPENGL"
43 48
 #endif
@@ -68,8 +73,8 @@ void glDrawGrid(float size, float step)
68 73
 		glBegin(GL_LINE_LOOP);
69 74
 		for (y = -size; y < size; y += step)
70 75
 		{
71
-			glVertex3f(x + step, 0.0f, y);	
72
-			glVertex3f(x, 0.0f, y);	
76
+			glVertex3f(x + step, 0.0f, y);
77
+			glVertex3f(x, 0.0f, y);
73 78
 			glVertex3f(x, 0.0f, y + step);
74 79
 			glVertex3f(x + step, 0.0f, y + step);
75 80
 		}
@@ -162,7 +167,7 @@ void SDLSystem::bindKeyCommand(char *cmd, int key, int event)
162 167
 	}
163 168
 
164 169
 	printf("Bound command '%s' -> event %i (0x%x key)\n", cmd, event, key);
165
-	
170
+
166 171
 	keyEvents[key] = event;
167 172
 }
168 173
 #endif
@@ -208,7 +213,7 @@ void SDLSystem::setGrabMouse(bool on)
208 213
 }
209 214
 
210 215
 
211
-void SDLSystem::initVideo(unsigned int width, unsigned int height, 
216
+void SDLSystem::initVideo(unsigned int width, unsigned int height,
212 217
 								  bool fullscreen)
213 218
 {
214 219
 	int flags; //, x, y;
@@ -225,12 +230,12 @@ void SDLSystem::initVideo(unsigned int width, unsigned int height,
225 230
 	if (!m_driver || !m_driver[0] || SDL_GL_LoadLibrary(m_driver) < 0)
226 231
 	{
227 232
 		SDL_ClearError();
228
-		
233
+
229 234
 		// Fallback 1
230 235
 		if (SDL_GL_LoadLibrary("libGL.so") < 0)
231 236
 		{
232 237
 			SDL_ClearError();
233
-    
238
+
234 239
 			// Fallback 2
235 240
 			if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
236 241
 			{
@@ -268,7 +273,7 @@ void SDLSystem::initVideo(unsigned int width, unsigned int height,
268 273
 
269 274
 	// Start game renderer
270 275
 	initGL();
271
-	
276
+
272 277
 	// Resize context
273 278
 	resizeGL(width, height);
274 279
 }
@@ -278,13 +283,13 @@ void SDLSystem::resize(unsigned int width, unsigned int height)
278 283
 {
279 284
 	GLfloat aspect;
280 285
 
281
-	
286
+
282 287
 	m_width = width;
283 288
 	m_height = height;
284 289
 
285 290
 	aspect = (GLfloat)width/(GLfloat)height;
286 291
 
287
-	glViewport(0, 0, width, height); 
292
+	glViewport(0, 0, width, height);
288 293
 
289 294
 	glMatrixMode(GL_PROJECTION);
290 295
 	glLoadIdentity();
@@ -334,10 +339,10 @@ void SDLSystem::runGame()
334 339
 				{
335 340
 				case SDL_BUTTON_LEFT:
336 341
 					btn = SYS_MOUSE_LEFT;
337
-					break; 
342
+					break;
338 343
 				case SDL_BUTTON_RIGHT:
339 344
 					btn = SYS_MOUSE_RIGHT;
340
-					break; 
345
+					break;
341 346
 				case SDL_BUTTON_MIDDLE:
342 347
 					btn = SYS_MOUSE_MIDDLE;
343 348
 					break;
@@ -352,7 +357,7 @@ void SDLSystem::runGame()
352 357
 					handleKeyReleaseEvent(btn, 0); // FIXME: mod not used
353 358
 				}
354 359
 				break;
355
-			case SDL_KEYUP:	
360
+			case SDL_KEYUP:
356 361
 			case SDL_KEYDOWN:
357 362
 				//SDL_GetMouseState(&x, &y); // Get cursor pos
358 363
 
@@ -464,13 +469,13 @@ void SDLSystem::runGame()
464 469
 					{
465 470
 						key= (unsigned int)(event.key.keysym.unicode & 0x7F);
466 471
 					}
467
-					else 
472
+					else
468 473
 					{
469 474
 						key = 0;
470 475
 					}
471 476
 				}
472 477
 #else
473
-				// FIXME: Avoid passing modifers as a key, since the 
478
+				// FIXME: Avoid passing modifers as a key, since the
474 479
 				// consoles using this expect text characters, add unicode
475 480
 				// support later when they're able to handle it
476 481
 				if (key > 255 && key < 1000)
@@ -478,7 +483,7 @@ void SDLSystem::runGame()
478 483
 					key = 0;
479 484
 				}
480 485
 #endif
481
-				
486
+
482 487
 				if (key == mConsoleKey)
483 488
 				{
484 489
 					if (event.type == SDL_KEYDOWN)
@@ -525,7 +530,7 @@ void SDLSystem::runGame()
525 530
 					}
526 531
 				}
527 532
 				break;
528
-			case SDL_VIDEORESIZE:			  
533
+			case SDL_VIDEORESIZE:
529 534
 				resizeGL(event.resize.w, event.resize.h);
530 535
 				gameFrame();
531 536
 				break;
@@ -555,7 +560,7 @@ void SDLSystem::shutdown(int i)
555 560
 void SDLSystem::toggleFullscreen()
556 561
 {
557 562
 	if (mWindow)
558
-	{		
563
+	{
559 564
 		SDL_ShowCursor(SDL_DISABLE);
560 565
 		SDL_WM_ToggleFullScreen(mWindow);
561 566
 	}

+ 24
- 19
src/SDLUnitTest.cpp Zobrazit soubor

@@ -6,8 +6,13 @@
6 6
 
7 7
 #ifdef USING_OPENGL
8 8
 
9
-#   include <GL/gl.h>
10
-#   include <GL/glu.h>
9
+#ifdef __APPLE__
10
+#include <OpenGL/gl.h>
11
+#include <OpenGL/glu.h>
12
+#else
13
+#include <GL/gl.h>
14
+#include <GL/glu.h>
15
+#endif
11 16
 #   include <SDL/SDL.h>
12 17
 #   include <Texture.h>
13 18
 
@@ -47,7 +52,7 @@ void handle_key(int key)
47 52
 
48 53
 		if (wireframe)
49 54
 		{
50
-			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
55
+			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
51 56
 		}
52 57
 		else
53 58
 		{
@@ -223,13 +228,13 @@ void event_resize(unsigned int width, unsigned int height)
223 228
 {
224 229
 	GLfloat aspect;
225 230
 
226
-	
231
+
227 232
 	gWidth = width;
228 233
 	gHeight = height;
229 234
 
230 235
 	aspect = (GLfloat)width/(GLfloat)height;
231 236
 
232
-	glViewport(0, 0, width, height); 
237
+	glViewport(0, 0, width, height);
233 238
 
234 239
 	glMatrixMode(GL_PROJECTION);
235 240
 	glLoadIdentity();
@@ -287,7 +292,7 @@ void draw_axis(float length, float arrowLenght)
287 292
 #endif
288 293
 
289 294
 
290
-void renderUnitTestScene() 
295
+void renderUnitTestScene()
291 296
 {
292 297
 
293 298
 	static float lastTime = 0.0f;
@@ -295,8 +300,8 @@ void renderUnitTestScene()
295 300
 	float x, y, time;
296 301
 
297 302
 
298
-	gluLookAt(0.0, 0.0, -256.0, 
299
-				 0.0, 8.0, 0.0, 
303
+	gluLookAt(0.0, 0.0, -256.0,
304
+				 0.0, 8.0, 0.0,
300 305
 				 0.0, 1.0, 0.0);
301 306
 
302 307
 	glDisable(GL_TEXTURE_2D);
@@ -331,7 +336,7 @@ void renderUnitTestScene()
331 336
 	// Draw light symbol
332 337
 	glPushMatrix();
333 338
 	glTranslatef(gLightPos[0], gLightPos[1], gLightPos[2]);
334
-	
339
+
335 340
 	glBegin(GL_LINES);
336 341
 	glColor3f(1.0f, 1.0f, 1.0f);
337 342
 	glVertex3f(0.0f, 0.0f, 0.0f);
@@ -370,8 +375,8 @@ void renderUnitTestScene()
370 375
 		glBegin(GL_LINE_LOOP);
371 376
 		for (y = -size; y < size; y += step)
372 377
 		{
373
-			glVertex3f(x + step, 0.0f, y);	
374
-			glVertex3f(x, 0.0f, y);	
378
+			glVertex3f(x + step, 0.0f, y);
379
+			glVertex3f(x, 0.0f, y);
375 380
 			glVertex3f(x, 0.0f, y + step);
376 381
 			glVertex3f(x + step, 0.0f, y + step);
377 382
 		}
@@ -380,7 +385,7 @@ void renderUnitTestScene()
380 385
 
381 386
 	glPopMatrix();
382 387
 
383
-	
388
+
384 389
 	glEnable(GL_TEXTURE_2D);
385 390
 	glColor3f(1.0f, 1.0f, 1.0f);
386 391
 	glPushMatrix();
@@ -458,7 +463,7 @@ int main_gl(int argc, char *argv[])
458 463
 	  if (SDL_GL_LoadLibrary("libGL.so") < 0)
459 464
 	  {
460 465
 		  SDL_ClearError();
461
-    
466
+
462 467
 		  // Fallback 2
463 468
 		  if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
464 469
 		  {
@@ -484,7 +489,7 @@ int main_gl(int argc, char *argv[])
484 489
   SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
485 490
   gSDLWindow = SDL_SetVideoMode(width, height, 16, flags);
486 491
   SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
487
-  
492
+
488 493
   // Init rendering
489 494
   init_gl(width, height);
490 495
   initScene(argc, argv);
@@ -505,7 +510,7 @@ int main_gl(int argc, char *argv[])
505 510
 			  break;
506 511
 		  case SDL_MOUSEBUTTONDOWN:
507 512
 		  case SDL_MOUSEBUTTONUP:
508
-			  break;	
513
+			  break;
509 514
 		  case SDL_KEYDOWN:
510 515
 			  mkeys = (unsigned int)SDL_GetModState();
511 516
 			  mod = 0;
@@ -542,12 +547,12 @@ int main_gl(int argc, char *argv[])
542 547
 					  SDL_WM_ToggleFullScreen(gSDLWindow);
543 548
 				  }
544 549
 			  }
545
-			  
550
+
546 551
 			  handle_key(key);
547 552
 			  break;
548 553
 		  case SDL_KEYUP:
549 554
 			  break;
550
-		  case SDL_VIDEORESIZE:			  
555
+		  case SDL_VIDEORESIZE:
551 556
 			  event_resize(event.resize.w, event.resize.h);
552 557
 
553 558
 			  width = event.resize.w;
@@ -559,7 +564,7 @@ int main_gl(int argc, char *argv[])
559 564
 
560 565
 	  event_display(width, height);
561 566
   }
562
-  
567
+
563 568
   return 0;
564 569
 }
565 570
 #endif
@@ -585,7 +590,7 @@ int runSDLUnitTest(int argc, char *argv[])
585 590
 		printf("'%s h' for help\n", argv[0]);
586 591
 	}
587 592
 
588
-	
593
+
589 594
 #ifdef USING_OPENGL
590 595
 	main_gl(argc, argv);
591 596
 #else

+ 12
- 12
src/SkeletalModel.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : OpenRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,20 +10,20 @@
10 10
  * Comments: This is the factored out skeletal model class
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
15
+ *
16 16
  *-- Test Defines -----------------------------------------------
17
- *           
18
- * UNIT_TEST_SKELETALMODEL - Builds SkeletalModel class as a console unit test 
19 17
  *
20
- *-- History ------------------------------------------------ 
18
+ * UNIT_TEST_SKELETALMODEL - Builds SkeletalModel class as a console unit test
19
+ *
20
+ *-- History ------------------------------------------------
21 21
  *
22 22
  * 2003.05.19:
23 23
  * Mongoose - Created
24 24
  ================================================================*/
25 25
 
26
-// TODO 
26
+// TODO
27 27
 // Start cutting off old hacks by simple force use of method interface
28 28
 // Also move the publicly exposed attributes out  =)
29 29
 // Better animation system in general - this is memory wasteful
@@ -31,8 +31,8 @@
31 31
 #ifndef GUARD__OPENRAIDER_MONGOOSE_SKELETALMODEL_H_
32 32
 #define GUARD__OPENRAIDER_MONGOOSE_SKELETALMODEL_H_
33 33
 
34
-#include <mstl/Vector.h>
35
-#include <hel/math.h>
34
+#include "mstl/Vector.h"
35
+#include "hel/math.h"
36 36
 
37 37
 
38 38
 typedef struct bone_tag_s
@@ -90,12 +90,12 @@ class SkeletalModel
90 90
 
91 91
 	SkeletalModel();
92 92
 	/*------------------------------------------------------
93
-	 * Pre  : 
93
+	 * Pre  :
94 94
 	 * Post : Constructs an object of SkeletalModel
95 95
 	 *
96 96
 	 *-- History ------------------------------------------
97 97
 	 *
98
-	 * 2003.05.19: 
98
+	 * 2003.05.19:
99 99
 	 * Mongoose - Created
100 100
 	 ------------------------------------------------------*/
101 101
 
@@ -106,7 +106,7 @@ class SkeletalModel
106 106
 	 *
107 107
 	 *-- History ------------------------------------------
108 108
 	 *
109
-	 * 2003.05.19: 
109
+	 * 2003.05.19:
110 110
 	 * Mongoose - Created
111 111
 	 ------------------------------------------------------*/
112 112
 

+ 18
- 13
src/Sound.cpp Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : OpenRaider
5 5
  * Author  : Mongoose
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,21 +10,26 @@
10 10
  * Comments: This is the audio manager for OpenRaider
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2001.05.23:
19 19
  * Mongoose - Created
20 20
  =================================================================*/
21 21
 
22 22
 #ifdef HAVE_OPENAL
23
+#ifdef __APPLE__
24
+#include <OpenAL/al.h>
25
+#include <OpenAL/alc.h>
26
+#else
23 27
 #   include <AL/al.h>
24 28
 #   include <AL/alc.h>
25 29
 #   include <AL/alut.h>
26 30
 #   include <AL/alext.h>
27 31
 #endif
32
+#endif
28 33
 
29 34
 #include <time.h>
30 35
 #include <stdio.h>
@@ -65,7 +70,7 @@ Sound::~Sound()
65 70
 
66 71
 int Sound::init()
67 72
 {
68
-	int fd;	
73
+	int fd;
69 74
 
70 75
 	fd = open("/dev/dsp", O_RDWR);
71 76
 
@@ -97,7 +102,7 @@ void Sound::listenAt(float pos[3], float angle[3])
97 102
 
98 103
 #ifdef HAVE_OPENAL
99 104
 	alListenerfv(AL_POSITION, pos);
100
-	alListenerfv(AL_ORIENTATION, angle);	
105
+	alListenerfv(AL_ORIENTATION, angle);
101 106
 #endif
102 107
 }
103 108
 
@@ -137,7 +142,7 @@ int Sound::add(char *filename, int *source, unsigned int flags)
137 142
 
138 143
 	alGenBuffers(1, &mBuffer[mNextBuffer]);
139 144
 
140
-	if (alGetError() != AL_NO_ERROR)	
145
+	if (alGetError() != AL_NO_ERROR)
141 146
    {
142 147
 		fprintf(stderr, "Sound::Init> alGenBuffers call failed\n");
143 148
 		return -1;
@@ -152,10 +157,10 @@ int Sound::add(char *filename, int *source, unsigned int flags)
152 157
 		fprintf(stderr, "Sound::Init> alGenSources call failed\n");
153 158
 		return -2;
154 159
 	}
155
-   
160
+
156 161
    err = alutLoadWAV(filename, &data, &format, &size, &bits, &freq);
157 162
 
158
-   if (err == AL_FALSE) 
163
+   if (err == AL_FALSE)
159 164
 	{
160 165
 	   fprintf(stderr, "Could not load %s\n", filename);
161 166
 	   return -3;
@@ -204,7 +209,7 @@ int Sound::add(unsigned char *wav, int *source, unsigned int flags)
204 209
 
205 210
 	alGenBuffers(1, &mBuffer[mNextBuffer]);
206 211
 
207
-	if (alGetError() != AL_NO_ERROR)	
212
+	if (alGetError() != AL_NO_ERROR)
208 213
    {
209 214
 		fprintf(stderr, "Sound::Init> alGenBuffers call failed\n");
210 215
 		return -1;
@@ -219,7 +224,7 @@ int Sound::add(unsigned char *wav, int *source, unsigned int flags)
219 224
 		fprintf(stderr, "Sound::Init> alGenSources call failed\n");
220 225
 		return -2;
221 226
 	}
222
-   
227
+
223 228
 	// AL_FORMAT_WAVE_EXT
224 229
    alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
225 230
 
@@ -280,7 +285,7 @@ void Sound::stop(int source)
280 285
 
281 286
 
282 287
 #ifdef UNIT_TEST_SOUND
283
-int main(int argc, char* argv[]) 
288
+int main(int argc, char* argv[])
284 289
 {
285 290
 	Sound snd;
286 291
 	FILE *f;
@@ -313,7 +318,7 @@ int main(int argc, char* argv[])
313 318
 			fread(buf, l, 1, f);
314 319
 
315 320
 			fclose(f);
316
-			
321
+
317 322
 			printf("Loading buffer of %s\n", argv[1]);
318 323
 			ret = snd.add(buf, &id, SoundFlagsNone);
319 324
 			printf("Load returned %i\n", ret);

+ 54
- 49
src/System.cpp Zobrazit soubor

@@ -1,19 +1,19 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : UnRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
7 7
  * Email   : stu7440@westga.edu
8 8
  * Object  : System
9 9
  * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 
10
+ * Comments:
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2002.08.09:
19 19
  * Mongoose - Created
@@ -27,8 +27,13 @@
27 27
 #include <stdarg.h>
28 28
 
29 29
 #ifdef USING_OPENGL
30
-#   include <GL/gl.h>
31
-#   include <GL/glu.h>
30
+#ifdef __APPLE__
31
+#include <OpenGL/gl.h>
32
+#include <OpenGL/glu.h>
33
+#else
34
+#include <GL/gl.h>
35
+#include <GL/glu.h>
36
+#endif
32 37
 #endif
33 38
 
34 39
 #ifdef HAVE_LIBFERIT
@@ -38,7 +43,7 @@
38 43
 #   include <ferit/Ftp.h>
39 44
 #endif
40 45
 
41
-#ifdef linux
46
+#if defined(linux) || defined(__APPLE__)
42 47
 #   include <time.h>
43 48
 #   include <sys/time.h>
44 49
 #endif
@@ -75,7 +80,7 @@ System::System()
75 80
 	printf("[System.Core]\n");
76 81
 
77 82
 	// Hack for bad Map class, as well as reserved commands
78
-	addCommandMode("[System.Console]"); 
83
+	addCommandMode("[System.Console]");
79 84
 	mConsoleKey = '`';
80 85
 	bindKeyCommand("+console", mConsoleKey, 0);
81 86
 
@@ -103,7 +108,7 @@ char *System::bufferString(char *string, ...)
103 108
 	char *text;
104 109
 	va_list args;
105 110
 
106
-	
111
+
107 112
 	// Mongoose 2002.01.01, Only allow valid strings
108 113
 	//   we must assume it's NULL terminated also if it passes...
109 114
 	if (!string || !string[0])
@@ -197,13 +202,13 @@ char *System::fullPath(char *path, char end)
197 202
 
198 203
 		i = lenPath;
199 204
 	}
200
-	
205
+
201 206
 	// Make sure ends in "end" char
202 207
 	if (end && dir[i-1] != end)
203 208
 	{
204 209
 		dir[i++] = end;
205 210
 	}
206
-		
211
+
207 212
 	dir[i] = 0;
208 213
 
209 214
 	return dir;
@@ -217,17 +222,17 @@ char *System::getFileFromFullPath(char *filename)
217 222
 
218 223
 
219 224
 	len = strlen(filename);
220
-	
225
+
221 226
 	for (i = len, j = 0; i > 0; --i, ++j)
222 227
 	{
223 228
 		if (filename[i] == '/' || filename[i] == '\\')
224 229
 			break;
225 230
 	}
226
-	
231
+
227 232
 	j--;
228
-	
233
+
229 234
 	str = new char[len - j + 1];
230
-	
235
+
231 236
 	for (i = 0; i < len - j; ++i)
232 237
 	{
233 238
 		str[i] = filename[i + len - j];
@@ -255,7 +260,7 @@ int System::createDir(char *path)
255 260
 }
256 261
 
257 262
 
258
-int System::downloadToBuffer(char *urlString, 
263
+int System::downloadToBuffer(char *urlString,
259 264
 									  unsigned char **buffer, unsigned int *size)
260 265
 {
261 266
 #ifdef HAVE_LIBFERIT
@@ -295,12 +300,12 @@ int System::downloadToFile(char *urlString, char *filename)
295 300
 		break;
296 301
 	default:
297 302
 		printf("Sorry the protocol used in the URL isn't unsupported.\n");
298
-	
303
+
299 304
 		if (client)
300 305
 		{
301 306
 			delete client;
302 307
 		}
303
-		
308
+
304 309
 		return -2;
305 310
 	}
306 311
 
@@ -312,7 +317,7 @@ int System::downloadToFile(char *urlString, char *filename)
312 317
 
313 318
 	if (url)
314 319
 		delete url;
315
-	
320
+
316 321
 	return err;
317 322
 #else
318 323
 	printf("ERROR: This build not libferit enabled, unable to download\n");
@@ -341,7 +346,7 @@ unsigned int System::addCommandMode(char *command)
341 346
 // FIXME: Modifer support later
342 347
 void System::bindKeyCommand(char *cmd, unsigned int key, int event)
343 348
 {
344
-	printf("Bound command '%s' -> event %i (0x%x key)\n", cmd, event, key);	
349
+	printf("Bound command '%s' -> event %i (0x%x key)\n", cmd, event, key);
345 350
 	mKeyEvents.Add(key, event);
346 351
 }
347 352
 
@@ -399,19 +404,19 @@ int System::loadResourceFile(char *filename)
399 404
 
400 405
 	i = 0;
401 406
 	buffer[0] = 0;
402
-	
407
+
403 408
 	// Strip out whitespace and comments
404 409
 	while (fscanf(f, "%c", &c) != EOF)
405 410
 	{
406 411
 		if (line_comment && c != '\n')
407 412
 			continue;
408
-		
413
+
409 414
 		if (i > 254)
410 415
 		{
411 416
 			printf("loadResourceFile> Overflow handled\n");
412 417
 			i = 254;
413 418
 		}
414
-		
419
+
415 420
 		switch (c)
416 421
 		{
417 422
 		case '\v':
@@ -426,13 +431,13 @@ int System::loadResourceFile(char *filename)
426 431
 			{
427 432
 				line_comment = false;
428 433
 			}
429
-			
434
+
430 435
 			if (buffer[0] == 0)
431 436
 			{
432 437
 				i = 0;
433 438
 				continue;
434 439
 			}
435
-			
440
+
436 441
 			buffer[i] = 0;
437 442
 			//printf("'%s'\n", buffer);
438 443
 
@@ -446,9 +451,9 @@ int System::loadResourceFile(char *filename)
446 451
 						buffer[j-9] = buffer[j];
447 452
 						buffer[j-8] = 0;
448 453
 					}
449
-					
454
+
450 455
 					printf("Importing '%s'\n", buffer);
451
-					
456
+
452 457
 					loadResourceFile(fullPath(buffer, '/'));
453 458
 				}
454 459
 			}
@@ -464,7 +469,7 @@ int System::loadResourceFile(char *filename)
464 469
 			buffer[i++] = c;
465 470
 		}
466 471
 	}
467
-	
472
+
468 473
 	fclose(f);
469 474
 
470 475
 	return 0;
@@ -561,11 +566,11 @@ void System::initGL()
561 566
 	// Set background to black
562 567
 	glClearColor(0.0, 0.0, 0.0, 1.0);
563 568
 
564
-	// Disable lighting 
569
+	// Disable lighting
565 570
 	glDisable(GL_LIGHTING);
566 571
 
567 572
 	// Set up alpha blending
568
-	if (m_fastCard) 
573
+	if (m_fastCard)
569 574
 	{
570 575
 		glEnable(GL_BLEND);
571 576
 		glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@@ -584,13 +589,13 @@ void System::initGL()
584 589
 	// Setup shading
585 590
 	glShadeModel(GL_SMOOTH);
586 591
 
587
-	if (m_fastCard) 
592
+	if (m_fastCard)
588 593
 	{
589 594
 		glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
590 595
 		glHint(GL_FOG_HINT, GL_NICEST);
591 596
 		glDisable(GL_COLOR_MATERIAL);
592 597
 		glEnable(GL_DITHER);
593
-		
598
+
594 599
 		// AA polygon edges
595 600
 		//glEnable(GL_POLYGON_SMOOTH);
596 601
 		//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
@@ -637,8 +642,8 @@ void System::resizeGL(unsigned int w, unsigned int h)
637 642
 	}
638 643
 
639 644
 	glViewport(0, 0, w, h);
640
-	glMatrixMode(GL_PROJECTION); 
641
-	glLoadIdentity(); 
645
+	glMatrixMode(GL_PROJECTION);
646
+	glLoadIdentity();
642 647
 
643 648
 	// Adjust clipping
644 649
 	gluPerspective(m_fovY, ((GLdouble)w)/((GLdouble)h), m_clipNear, m_clipFar);
@@ -660,7 +665,7 @@ void System::resizeGL(unsigned int w, unsigned int h)
660 665
 // Gobal helper functions
661 666
 ////////////////////////////////////////////////////////////
662 667
 
663
-// Mongoose 2002.03.23, Checks command to see if it's same 
668
+// Mongoose 2002.03.23, Checks command to see if it's same
664 669
 //   as symbol, then returns the arg list in command buffer
665 670
 bool rc_command(char *symbol, char *command)
666 671
 {
@@ -687,7 +692,7 @@ bool rc_command(char *symbol, char *command)
687 692
 
688 693
 		return true;
689 694
 	}
690
-		
695
+
691 696
 	return false;
692 697
 }
693 698
 
@@ -698,7 +703,7 @@ int rc_get_bool(char *buffer, bool *val)
698 703
 	{
699 704
 		return -1;
700 705
 	}
701
-	
706
+
702 707
 	if (strncmp(buffer, "true", 4) == 0)
703 708
 		*val = true;
704 709
 	else if (strncmp(buffer, "false", 5) == 0)
@@ -727,29 +732,29 @@ unsigned int system_timer(int state)
727 732
 		break;
728 733
 	case 1:
729 734
 		gettimeofday(&stop, &tz);
730
-		
731
-		if (start.tv_usec > stop.tv_usec) 
732
-		{ 
735
+
736
+		if (start.tv_usec > stop.tv_usec)
737
+		{
733 738
 #ifdef OBSOLETE
734
-			stop.tv_usec = (1000000 + stop.tv_usec); 
739
+			stop.tv_usec = (1000000 + stop.tv_usec);
735 740
 #else
736
-			stop.tv_usec = (1000 + stop.tv_usec); 
741
+			stop.tv_usec = (1000 + stop.tv_usec);
737 742
 #endif
738
-			stop.tv_sec--; 
739
-		} 
743
+			stop.tv_sec--;
744
+		}
740 745
 
741
-		stop.tv_usec -= start.tv_usec; 
746
+		stop.tv_usec -= start.tv_usec;
742 747
 		stop.tv_sec -= start.tv_sec;
743 748
 
744 749
 #ifdef OBSOLETE
745 750
 		total.tv_sec += stop.tv_sec;
746 751
 		total.tv_usec += stop.tv_usec;
747 752
 
748
-		while (total.tv_usec > 1000000) 
753
+		while (total.tv_usec > 1000000)
749 754
 		{
750 755
 			total.tv_usec -= 1000000;
751
-			total.tv_sec++; 
752
-		} 
756
+			total.tv_sec++;
757
+		}
753 758
 
754 759
 		return total.tv_sec * 1000000 + total.tv_usec;
755 760
 #else

+ 81
- 81
src/System.h Zobrazit soubor

@@ -1,23 +1,23 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : UnRaider, OpenRaider, RaiderUnification 2003
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
7 7
  * Email   : stu7440@westga.edu
8 8
  * Object  : System
9 9
  * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 
10
+ * Comments:
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
15
+ *
16 16
  *-- Test Defines -----------------------------------------------
17 17
  *
18
- * UNIT_TEST_SYSTEM - Builds System class as a console unit test 
18
+ * UNIT_TEST_SYSTEM - Builds System class as a console unit test
19 19
  *
20
- *-- History ------------------------------------------------ 
20
+ *-- History ------------------------------------------------
21 21
  *
22 22
  * 2002.08.09:
23 23
  * Mongoose - Created
@@ -27,8 +27,8 @@
27 27
 #ifndef GUARD__UNRAIDER_MONGOOSE_SYSTEM_H_
28 28
 #define GUARD__UNRAIDER_MONGOOSE_SYSTEM_H_
29 29
 
30
-#include <mstl/Map.h>
31
-#include <mstl/Vector.h>
30
+#include "mstl/Map.h"
31
+#include "mstl/Vector.h"
32 32
 
33 33
 // TODO: Replace with unicode compatible key codes
34 34
 #define SYS_MOUSE_LEFT    6000
@@ -55,12 +55,12 @@
55 55
 #define SYS_KEY_F11       1010
56 56
 #define SYS_KEY_F12       1011
57 57
 
58
-typedef enum 
58
+typedef enum
59 59
 {
60 60
   SYS_MOD_KEY_LSHIFT = 1,
61 61
   SYS_MOD_KEY_RSHIFT = 2,
62
-  SYS_MOD_KEY_LCTRL  = 4, 
63
-  SYS_MOD_KEY_RCTRL  = 8, 
62
+  SYS_MOD_KEY_LCTRL  = 4,
63
+  SYS_MOD_KEY_RCTRL  = 8,
64 64
   SYS_MOD_KEY_LALT   = 16,
65 65
   SYS_MOD_KEY_RALT   = 32
66 66
 
@@ -77,12 +77,12 @@ public:
77 77
 
78 78
 	System();
79 79
 	/*------------------------------------------------------
80
-	 * Pre  : 
80
+	 * Pre  :
81 81
 	 * Post : Constructs an object of System
82 82
 	 *
83 83
 	 *-- History ------------------------------------------
84 84
 	 *
85
-	 * 2002.08.09: 
85
+	 * 2002.08.09:
86 86
 	 * Mongoose - Created
87 87
 	 ------------------------------------------------------*/
88 88
 
@@ -93,7 +93,7 @@ public:
93 93
 	 *
94 94
 	 *-- History ------------------------------------------
95 95
 	 *
96
-	 * 2002.08.09: 
96
+	 * 2002.08.09:
97 97
 	 * Mongoose - Created
98 98
 	 ------------------------------------------------------*/
99 99
 
@@ -114,13 +114,13 @@ public:
114 114
 	 * 2003.06.03:
115 115
 	 * Mongoose - Made into a printf string caching system
116 116
 	 *
117
-    * 2001.12.31: 
117
+    * 2001.12.31:
118 118
     * Mongoose - Created, was GLString::glPrintf
119 119
     ------------------------------------------------------*/
120 120
 
121 121
 	static char *fullPath(char *path, char end);
122 122
 	/*------------------------------------------------------
123
-	 * Pre  : 
123
+	 * Pre  :
124 124
 	 * Post : Returns allocated string of path, with
125 125
 	 *        expansion of unix home enviroment char and
126 126
 	 *        makes sure string ends in "end" char
@@ -129,14 +129,14 @@ public:
129 129
 	 *
130 130
 	 *-- History ------------------------------------------
131 131
 	 *
132
-	 * 2002.08.17: 
132
+	 * 2002.08.17:
133 133
 	 * Mongoose - Created
134 134
 	 ------------------------------------------------------*/
135 135
 
136 136
 	static char *getFileFromFullPath(char *filename);
137 137
 	/*------------------------------------------------------
138
-	 * Pre  : 
139
-	 * Post : 
138
+	 * Pre  :
139
+	 * Post :
140 140
 	 *
141 141
 	 *-- History ------------------------------------------
142 142
 	 *
@@ -146,20 +146,20 @@ public:
146 146
 
147 147
 	virtual unsigned int getTicks();
148 148
 	/*------------------------------------------------------
149
-	 * Pre  : 
149
+	 * Pre  :
150 150
 	 * Post : Returns number of milliseconds since start of
151 151
 	 *        program
152 152
 	 *
153 153
 	 *-- History ------------------------------------------
154 154
 	 *
155
-	 * 2002.06.06: 
155
+	 * 2002.06.06:
156 156
 	 * Mongoose - Created
157 157
 	 ------------------------------------------------------*/
158 158
 
159
-	static int downloadToBuffer(char *urlString, 
159
+	static int downloadToBuffer(char *urlString,
160 160
 										 unsigned char **buffer, unsigned int *size);
161 161
 	/*------------------------------------------------------
162
-	 * Pre  : 
162
+	 * Pre  :
163 163
 	 * Post : Downloads something into passed buffer,
164 164
 	 *        Returns < 0 on error, 0 on sucess
165 165
 	 *
@@ -171,7 +171,7 @@ public:
171 171
 
172 172
 	static int downloadToFile(char *urlString, char *filename);
173 173
 	/*------------------------------------------------------
174
-	 * Pre  : 
174
+	 * Pre  :
175 175
 	 * Post : Downloads something into a disk file,
176 176
 	 *        Returns < 0 on error, 0 on sucess
177 177
 	 *
@@ -216,7 +216,7 @@ public:
216 216
 	 *        <Key> is a valid keyboard code
217 217
 	 *        <Event> is a valid game event Id
218 218
 	 *
219
-	 * Post : Sets <Event> binding <Cmd> to <Key> press 
219
+	 * Post : Sets <Event> binding <Cmd> to <Key> press
220 220
 	 *
221 221
 	 *-- History ------------------------------------------
222 222
 	 *
@@ -231,29 +231,29 @@ public:
231 231
 	 *
232 232
 	 *-- History ------------------------------------------
233 233
 	 *
234
-	 * 2001.05.27: 
234
+	 * 2001.05.27:
235 235
 	 * Mongoose - Created
236 236
 	 ------------------------------------------------------*/
237 237
 
238 238
 	virtual void gameFrame() = 0;
239 239
 	/*------------------------------------------------------
240
-	 * Pre  : 
241
-	 * Post : 
240
+	 * Pre  :
241
+	 * Post :
242 242
 	 *
243 243
 	 *-- History ------------------------------------------
244 244
 	 *
245
-	 * 2002.08.09?: 
245
+	 * 2002.08.09?:
246 246
 	 * Mongoose - Created
247 247
 	 ------------------------------------------------------*/
248 248
 
249 249
 	virtual void handleMouseMotionEvent(float x, float y) = 0;
250 250
 	/*------------------------------------------------------
251
-	 * Pre  : 
252
-	 * Post : 
251
+	 * Pre  :
252
+	 * Post :
253 253
 	 *
254 254
 	 *-- History ------------------------------------------
255 255
 	 *
256
-	 * 2002.08.09?: 
256
+	 * 2002.08.09?:
257 257
 	 * Mongoose - Created
258 258
 	 ------------------------------------------------------*/
259 259
 
@@ -261,7 +261,7 @@ public:
261 261
 	/*------------------------------------------------------
262 262
 	 * Pre  : <Key> is a valid keyboard code
263 263
 	 *
264
-	 * Post : Recieves <Event> bound to <Cmd> from <Key> press 
264
+	 * Post : Recieves <Event> bound to <Cmd> from <Key> press
265 265
 	 *
266 266
 	 *-- History ------------------------------------------
267 267
 	 *
@@ -283,7 +283,7 @@ public:
283 283
 
284 284
 	virtual void handleCommand(char *command, unsigned int mode) = 0;
285 285
 	/*------------------------------------------------------
286
-	 * Pre  : <Command> is valid keyword optionally followed 
286
+	 * Pre  : <Command> is valid keyword optionally followed
287 287
 	 *        by ' ' (space) seperated and argument(s)
288 288
 	 *
289 289
 	 *        <Mode> is the current type or resource mode
@@ -296,7 +296,7 @@ public:
296 296
 	 * Mongoose - Created
297 297
 	 ------------------------------------------------------*/
298 298
 
299
-	virtual void handleConsoleKeyPressEvent(unsigned int key, 
299
+	virtual void handleConsoleKeyPressEvent(unsigned int key,
300 300
 														 unsigned int mod) = 0;
301 301
 	/*------------------------------------------------------
302 302
 	 * Pre  : <Key> is a valid keyboard code
@@ -311,100 +311,100 @@ public:
311 311
 
312 312
 	virtual void handleKeyPressEvent(unsigned int key, unsigned int mod) = 0;
313 313
 	/*------------------------------------------------------
314
-	 * Pre  : 
315
-	 * Post : 
314
+	 * Pre  :
315
+	 * Post :
316 316
 	 *
317 317
 	 *-- History ------------------------------------------
318 318
 	 *
319
-	 * 2002.08.09?: 
319
+	 * 2002.08.09?:
320 320
 	 * Mongoose - Created
321 321
 	 ------------------------------------------------------*/
322 322
 
323 323
 	virtual void handleKeyReleaseEvent(unsigned int key, unsigned int mod) = 0;
324 324
 	/*------------------------------------------------------
325
-	 * Pre  : 
326
-	 * Post : 
325
+	 * Pre  :
326
+	 * Post :
327 327
 	 *
328 328
 	 *-- History ------------------------------------------
329 329
 	 *
330
-	 * 2002.08.09?: 
330
+	 * 2002.08.09?:
331 331
 	 * Mongoose - Created
332 332
 	 ------------------------------------------------------*/
333 333
 
334 334
 	virtual void initGL();
335 335
 	/*------------------------------------------------------
336
-	 * Pre  : 
337
-	 * Post : 
336
+	 * Pre  :
337
+	 * Post :
338 338
 	 *
339 339
 	 *-- History ------------------------------------------
340 340
 	 *
341
-	 * 2002.08.09?: 
341
+	 * 2002.08.09?:
342 342
 	 * Mongoose - Created
343 343
 	 ------------------------------------------------------*/
344 344
 
345
-	virtual void initVideo(unsigned int width, unsigned int height, 
345
+	virtual void initVideo(unsigned int width, unsigned int height,
346 346
 								  bool fullscreen) = 0;
347 347
 	/*------------------------------------------------------
348
-	 * Pre  : 
349
-	 * Post : 
348
+	 * Pre  :
349
+	 * Post :
350 350
 	 *
351 351
 	 *-- History ------------------------------------------
352 352
 	 *
353
-	 * 2002.08.09?: 
353
+	 * 2002.08.09?:
354 354
 	 * Mongoose - Created
355 355
 	 ------------------------------------------------------*/
356 356
 
357 357
 	virtual int loadResourceFile(char *filename);
358 358
 	/*------------------------------------------------------
359
-	 * Pre  : 
359
+	 * Pre  :
360 360
 	 * Post : Init the resource vars
361 361
 	 *
362 362
 	 *        Returns less than zero value on error
363 363
 	 *
364 364
 	 *-- History ------------------------------------------
365 365
 	 *
366
-	 * 2001.05.27: 
366
+	 * 2001.05.27:
367 367
 	 * Mongoose - Created
368 368
 	 ------------------------------------------------------*/
369 369
 
370 370
 	static void resetTicks();
371 371
 	/*------------------------------------------------------
372
-	 * Pre  : 
373
-	 * Post : 
372
+	 * Pre  :
373
+	 * Post :
374 374
 	 *
375 375
 	 *-- History ------------------------------------------
376 376
 	 *
377
-	 * 2002.08.09?: 
377
+	 * 2002.08.09?:
378 378
 	 * Mongoose - Created
379 379
 	 ------------------------------------------------------*/
380 380
 
381 381
 	virtual void resizeGL(unsigned int width, unsigned int height);
382 382
 	/*------------------------------------------------------
383
-	 * Pre  : 
384
-	 * Post : 
383
+	 * Pre  :
384
+	 * Post :
385 385
 	 *
386 386
 	 *-- History ------------------------------------------
387 387
 	 *
388
-	 * 2002.08.09?: 
388
+	 * 2002.08.09?:
389 389
 	 * Mongoose - Created
390 390
 	 ------------------------------------------------------*/
391 391
 
392 392
 	virtual void runGame() = 0;
393 393
 	/*------------------------------------------------------
394
-	 * Pre  : 
395
-	 * Post : 
394
+	 * Pre  :
395
+	 * Post :
396 396
 	 *
397 397
 	 *-- History ------------------------------------------
398 398
 	 *
399
-	 * 2002.08.09?: 
399
+	 * 2002.08.09?:
400 400
 	 * Mongoose - Created
401 401
 	 ------------------------------------------------------*/
402 402
 
403 403
 	void setConsoleMode(bool on);
404 404
 	/*------------------------------------------------------
405
-	 * Pre  : 
405
+	 * Pre  :
406 406
 	 * Post : Turns console key events on/off,
407
-	 *        mostly for allowing text entry vs key 
407
+	 *        mostly for allowing text entry vs key
408 408
 	 *        impluse commands
409 409
 	 *
410 410
 	 *-- History ------------------------------------------
@@ -415,56 +415,56 @@ public:
415 415
 
416 416
 	void setDriverGL(const char *driver);
417 417
 	/*------------------------------------------------------
418
-	 * Pre  : 
419
-	 * Post : 
418
+	 * Pre  :
419
+	 * Post :
420 420
 	 *
421 421
 	 *-- History ------------------------------------------
422 422
 	 *
423
-	 * 2002.08.09?: 
423
+	 * 2002.08.09?:
424 424
 	 * Mongoose - Created
425 425
 	 ------------------------------------------------------*/
426 426
 
427 427
 	void setFastCardPerformance(bool isFast);
428 428
 	/*------------------------------------------------------
429
-	 * Pre  : 
430
-	 * Post : 
429
+	 * Pre  :
430
+	 * Post :
431 431
 	 *
432 432
 	 *-- History ------------------------------------------
433 433
 	 *
434
-	 * 2002.08.09?: 
434
+	 * 2002.08.09?:
435 435
 	 * Mongoose - Created
436 436
 	 ------------------------------------------------------*/
437 437
 
438 438
 	virtual void shutdown(int code) = 0;
439 439
 	/*------------------------------------------------------
440
-	 * Pre  : 
441
-	 * Post : 
440
+	 * Pre  :
441
+	 * Post :
442 442
 	 *
443 443
 	 *-- History ------------------------------------------
444 444
 	 *
445
-	 * 2002.08.09?: 
445
+	 * 2002.08.09?:
446 446
 	 * Mongoose - Created
447 447
 	 ------------------------------------------------------*/
448 448
 
449 449
 	virtual void swapBuffersGL() = 0;
450 450
 	/*------------------------------------------------------
451
-	 * Pre  : 
452
-	 * Post : 
451
+	 * Pre  :
452
+	 * Post :
453 453
 	 *
454 454
 	 *-- History ------------------------------------------
455 455
 	 *
456
-	 * 2002.08.09?: 
456
+	 * 2002.08.09?:
457 457
 	 * Mongoose - Created
458 458
 	 ------------------------------------------------------*/
459 459
 
460 460
 	virtual void toggleFullscreen() = 0;
461 461
 	/*------------------------------------------------------
462
-	 * Pre  : 
463
-	 * Post : 
462
+	 * Pre  :
463
+	 * Post :
464 464
 	 *
465 465
 	 *-- History ------------------------------------------
466 466
 	 *
467
-	 * 2002.08.09?: 
467
+	 * 2002.08.09?:
468 468
 	 * Mongoose - Created
469 469
 	 ------------------------------------------------------*/
470 470
 
@@ -511,7 +511,7 @@ public:
511 511
 
512 512
 	bool rc_command(char *symbol, char *command);
513 513
 	/*------------------------------------------------------
514
-	 * Pre  : 
514
+	 * Pre  :
515 515
 	 * Post : Returns true if <Command> matches <Symbol>
516 516
 	 *        command string
517 517
 	 *
@@ -520,7 +520,7 @@ public:
520 520
 	 *
521 521
 	 *-- History ------------------------------------------
522 522
 	 *
523
-	 * 2002.03.23: 
523
+	 * 2002.03.23:
524 524
 	 * Mongoose - Created
525 525
 	 ------------------------------------------------------*/
526 526
 
@@ -528,7 +528,7 @@ public:
528 528
 	/*------------------------------------------------------
529 529
 	 * Pre  : Buffer is "true" or "false"
530 530
 	 *
531
-	 * Post : Returns 0 if <Buffer> is "true" or "false" 
531
+	 * Post : Returns 0 if <Buffer> is "true" or "false"
532 532
 	 *        and sets <Val> accordingly
533 533
 	 *
534 534
 	 *        Returns -1 for null string
@@ -536,7 +536,7 @@ public:
536 536
 	 *
537 537
 	 *-- History ------------------------------------------
538 538
 	 *
539
-	 * 2002.03.23: 
539
+	 * 2002.03.23:
540 540
 	 * Mongoose - Created
541 541
 	 ------------------------------------------------------*/
542 542
 
@@ -547,7 +547,7 @@ public:
547 547
 	 *
548 548
 	 *-- History ------------------------------------------
549 549
 	 *
550
-	 * 2002.06.06: 
550
+	 * 2002.06.06:
551 551
 	 * Mongoose - Created
552 552
 	 ------------------------------------------------------*/
553 553
 #endif

+ 97
- 92
src/Texture.cpp Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*==========================================================================
3
- * 
3
+ *
4 4
  * Project : MTK, Freyja, OpenRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440
@@ -10,13 +10,13 @@
10 10
  *
11 11
  *           See file COPYING for license details.
12 12
  *
13
- * 
14
- *-- History ---------------------------------------------------------- 
15 13
  *
16
- * 2003.06.30, 
14
+ *-- History ----------------------------------------------------------
15
+ *
16
+ * 2003.06.30,
17 17
  * Mongoose - API update, SDL_TTF support moved here, misc features
18 18
  *            SDL_TTF support based on Sam Lantinga's public domain
19
- *            SDL_TTF demo functions and algorithms 
19
+ *            SDL_TTF demo functions and algorithms
20 20
  *
21 21
  * 2001.05.29:
22 22
  * Mongoose - Removed legacy code and done clean up
@@ -49,8 +49,13 @@
49 49
 #   include <SDL/SDL_ttf.h>
50 50
 #endif
51 51
 
52
+#ifdef __APPLE__
53
+#include <OpenGL/gl.h>
54
+#include <OpenGL/glu.h>
55
+#else
52 56
 #include <GL/gl.h>
53 57
 #include <GL/glu.h>
58
+#endif
54 59
 
55 60
 #include "Texture.h"
56 61
 
@@ -95,7 +100,7 @@ Texture::~Texture()
95 100
 ////////////////////////////////////////////////////////////
96 101
 
97 102
 unsigned char *Texture::generateColorTexture(unsigned char rgba[4],
98
-															unsigned int width, 
103
+															unsigned int width,
99 104
 															unsigned int height)
100 105
 {
101 106
 	unsigned char *image;
@@ -166,7 +171,7 @@ void bufferedPrintf(char *string, unsigned int len, char *s, ...)
166 171
 	if (s && s[0])
167 172
 	{
168 173
 		va_start(args, s);
169
-		vsnprintf(string, len-1, s, args);	
174
+		vsnprintf(string, len-1, s, args);
170 175
 		string[len-1] = 0;
171 176
 		va_end(args);
172 177
 	}
@@ -190,8 +195,8 @@ void glPrint2d(float x, float y, float scale, char *string)
190 195
 	glBindTexture(GL_TEXTURE_2D, font->textureId);
191 196
 	glTranslatef(x, y, 0);
192 197
 	glScalef(scale, scale, 1);
193
-	
194
-	/* FIXME: 
198
+
199
+	/* FIXME:
195 200
 	 * Add utf-8 dencoding of char* string
196 201
 	 *
197 202
 	 *	Also this string must be preprocessed to have glyph offsets
@@ -202,8 +207,8 @@ void glPrint2d(float x, float y, float scale, char *string)
202 207
 }
203 208
 
204 209
 
205
-void glPrint3d(float x, float y, float z, 
206
-					float pitch, float yaw, float roll, 
210
+void glPrint3d(float x, float y, float z,
211
+					float pitch, float yaw, float roll,
207 212
 					float scale,
208 213
 					char *string)
209 214
 {
@@ -225,8 +230,8 @@ void glPrint3d(float x, float y, float z,
225 230
 	glRotatef(yaw,   0, 1, 0);
226 231
 	glRotatef(pitch, 0, 0, 1);
227 232
 	glScalef(scale, scale, scale);
228
-	
229
-	/* FIXME: 
233
+
234
+	/* FIXME:
230 235
 	 * Add utf-8 dencoding of char* string
231 236
 	 *
232 237
 	 *	Also this string must be preprocessed to have glyph offsets
@@ -237,7 +242,7 @@ void glPrint3d(float x, float y, float z,
237 242
 }
238 243
 
239 244
 
240
-int Texture::loadFontTTF(char *filename, 
245
+int Texture::loadFontTTF(char *filename,
241 246
 								 unsigned int utf8Offset, unsigned int count)
242 247
 {
243 248
 	ttf_texture_t *texture;
@@ -273,7 +278,7 @@ int Texture::loadFontTTF(char *filename,
273 278
 
274 279
 		gFontTest = generateFont(texture);
275 280
 
276
-		/* FIXME: Until UTF8 decoder is working, we map from 
281
+		/* FIXME: Until UTF8 decoder is working, we map from
277 282
 			ASCII when rendering */
278 283
 		gFontTest->utf8Offset = 32; // hack to use ASCII strings to test unicode
279 284
 
@@ -328,7 +333,7 @@ gl_font_t *Texture::generateFont(ttf_texture_t *texture)
328 333
 #ifdef DEBUG_TTF_OFFSET
329 334
 		if (i+texture->utf8Offset == 'y' || i+texture->utf8Offset == 'x')
330 335
 		{
331
-			printf("%c: %i %i %i\n", 
336
+			printf("%c: %i %i %i\n",
332 337
 					 i+texture->utf8Offset,
333 338
 					 texture->fontDescent,
334 339
 					 texture->glyphs[i].miny, texture->glyphs[i].maxy);
@@ -352,17 +357,17 @@ gl_font_t *Texture::generateFont(ttf_texture_t *texture)
352 357
 		glBegin(GL_QUADS);
353 358
 		 glTexCoord2f(u2, v);	/* Top, right */
354 359
 		 glVertex3i(texture->glyphs[i].w, h, 0);
355
-		
360
+
356 361
 		 glTexCoord2f(u, v);	/* Top, left */
357 362
 		 glVertex3i(0, h, 0);
358 363
 
359 364
 		 glTexCoord2f(u, v2);	/* Bottom, left */
360 365
 		 glVertex3i(0, h+texture->glyphs[i].h, 0);
361
-		
366
+
362 367
 		 glTexCoord2f(u2, v2);	/* Bottom, right */
363 368
 		 glVertex3i(texture->glyphs[i].w, h+texture->glyphs[i].h, 0);
364 369
 		glEnd();
365
-		
370
+
366 371
 		/* Move To The Left Of The Character */
367 372
 		glTranslated(texture->glyphs[i].w + spacing, 0, 0);
368 373
 		glEndList();
@@ -375,7 +380,7 @@ gl_font_t *Texture::generateFont(ttf_texture_t *texture)
375 380
 }
376 381
 
377 382
 
378
-ttf_texture_t *Texture::generateFontTexture(char *filename, int pointSize, 
383
+ttf_texture_t *Texture::generateFontTexture(char *filename, int pointSize,
379 384
 														  unsigned int textureWidth,
380 385
 														  unsigned char color[3],
381 386
 														  unsigned int utf8Offset,
@@ -442,13 +447,13 @@ ttf_texture_t *Texture::generateFontTexture(char *filename, int pointSize,
442 447
 	texture->glyphs = new ttf_glyph_t[count];
443 448
 	texture->texture = new unsigned char[textureWidth*textureWidth*4];
444 449
 	memset(texture->texture, 0, textureWidth*textureWidth*4);
445
-		
450
+
446 451
 	texture->fontHeight = TTF_FontHeight(font);
447 452
 	texture->fontAscent = TTF_FontAscent(font);
448 453
 	texture->fontDescent = TTF_FontDescent(font);
449 454
 	texture->fontSpacing = TTF_FontLineSkip(font);
450 455
 
451
-	for (i = 0; i < count; ++i) 
456
+	for (i = 0; i < count; ++i)
452 457
 	{
453 458
 		glyph = TTF_RenderGlyph_Blended(font, i + utf8Offset, sdlColor);
454 459
 
@@ -457,13 +462,13 @@ ttf_texture_t *Texture::generateFontTexture(char *filename, int pointSize,
457 462
 	      image = (unsigned char*)glyph->pixels;
458 463
 
459 464
 			TTF_GlyphMetrics(font, i + utf8Offset,
460
-								  &texture->glyphs[i].minx, &texture->glyphs[i].maxx, 
465
+								  &texture->glyphs[i].minx, &texture->glyphs[i].maxx,
461 466
 								  &texture->glyphs[i].miny, &texture->glyphs[i].maxy,
462 467
 								  &texture->glyphs[i].advance);
463 468
 
464 469
 	      texture->glyphs[i].w = glyph->w;
465 470
 	      texture->glyphs[i].h = glyph->h;
466
-			
471
+
467 472
 	      if (xx + texture->glyphs[i].w > ((int)textureWidth - 1))
468 473
 	      {
469 474
 				yy += hh;
@@ -478,13 +483,13 @@ ttf_texture_t *Texture::generateFontTexture(char *filename, int pointSize,
478 483
 				texture->glyphs[i].x = xx;
479 484
 				texture->glyphs[i].y = yy;
480 485
 	      }
481
-			
486
+
482 487
 	      xx += glyph->w;
483
-			
488
+
484 489
 			if (verbose)
485 490
 			{
486 491
 				printf("0x%x : %ix%i @ %i, %i\n", i + utf8Offset,
487
-						 texture->glyphs[i].w, texture->glyphs[i].h, 
492
+						 texture->glyphs[i].w, texture->glyphs[i].h,
488 493
 						 texture->glyphs[i].x, texture->glyphs[i].y);
489 494
 			}
490 495
 
@@ -494,13 +499,13 @@ ttf_texture_t *Texture::generateFontTexture(char *filename, int pointSize,
494 499
 				w = texture->glyphs[i].x + k%glyph->w;
495 500
 				h = texture->glyphs[i].y + k/glyph->w;
496 501
 				offset = (w + h*textureWidth);
497
-				
502
+
498 503
 				if (verbose)
499 504
 				{
500
-					printf("Offset: %i; Pixel: %i,%i; Data: 0x%08x\n", 
505
+					printf("Offset: %i; Pixel: %i,%i; Data: 0x%08x\n",
501 506
 							 offset, w, h, *((unsigned int *)&image[k*4]));
502 507
 				}
503
-				
508
+
504 509
 				/* 32-bit ARGB to RGBA */
505 510
 				b = image[k*4+3];
506 511
 				texture->texture[offset*4]   = image[k*4]   = image[k*4+1];
@@ -549,7 +554,7 @@ void Texture::initSDL_TTF()
549 554
 		fprintf(stderr, "initSDL_TTF> Error is [%s].\n", SDL_GetError());
550 555
 	}
551 556
 	else
552
-	{	
557
+	{
553 558
 		mFlags |= fUseSDL_TTF;
554 559
 
555 560
 		printf("@ Started SDL_TTF subsystem...\n");
@@ -620,7 +625,7 @@ void Texture::useMultiTexture(float u, float v)
620 625
 void Texture::bindMultiTexture(int texture0, int texture1)
621 626
 {
622 627
 	if (//(int)a == mTextureId && (int)b == mTextureId2 ||
623
-		 !mTextureIds || 
628
+		 !mTextureIds ||
624 629
 		 texture0 < 0 || texture0 > (int)mTextureCount ||
625 630
 		 texture1 < 0 || texture1 > (int)mTextureCount)
626 631
    {
@@ -658,7 +663,7 @@ int Texture::getTextureCount()
658 663
 
659 664
 
660 665
 
661
-int Texture::loadBuffer(unsigned char *image, 
666
+int Texture::loadBuffer(unsigned char *image,
662 667
 								unsigned int width, unsigned int height,
663 668
 								ColorMode mode, unsigned int bpp)
664 669
 {
@@ -676,7 +681,7 @@ int Texture::loadBuffer(unsigned char *image,
676 681
 }
677 682
 
678 683
 
679
-void convertARGB32bppToRGBA32bpp(unsigned char *image, 
684
+void convertARGB32bppToRGBA32bpp(unsigned char *image,
680 685
 											unsigned int w, unsigned int h)
681 686
 {
682 687
 	unsigned int i, size = w*h;
@@ -695,7 +700,7 @@ void convertARGB32bppToRGBA32bpp(unsigned char *image,
695 700
 }
696 701
 
697 702
 
698
-int Texture::loadBufferSlot(unsigned char *image, 
703
+int Texture::loadBufferSlot(unsigned char *image,
699 704
 									 unsigned int width, unsigned int height,
700 705
 									 ColorMode mode, unsigned int bpp,
701 706
 									 unsigned int slot)
@@ -724,7 +729,7 @@ int Texture::loadBufferSlot(unsigned char *image,
724 729
 			printf("Texture::Load> ERROR Unsupported GREYSCALE, %i bpp\n", bpp);
725 730
 			return -2;
726 731
 		}
727
-		
732
+
728 733
 		bytes = 1;
729 734
 		glcMode = GL_LUMINANCE;
730 735
 		break;
@@ -734,7 +739,7 @@ int Texture::loadBufferSlot(unsigned char *image,
734 739
 			printf("Texture::Load> ERROR Unsupported RGBA, %i bpp\n", bpp);
735 740
 			return -2;
736 741
 		}
737
-		
742
+
738 743
 		bytes = 3;
739 744
 		glcMode = GL_RGB;
740 745
 		break;
@@ -749,7 +754,7 @@ int Texture::loadBufferSlot(unsigned char *image,
749 754
 			printf("Texture::Load> ERROR Unsupported RGBA/ARGB, %i bpp\n", bpp);
750 755
 			return -2;
751 756
 		}
752
-		
757
+
753 758
 		bytes = 4;
754 759
 		glcMode = GL_RGBA;
755 760
 		break;
@@ -761,7 +766,7 @@ int Texture::loadBufferSlot(unsigned char *image,
761 766
 	glClearColor(0.0, 0.0, 0.0, 0.0);
762 767
 	glEnable(GL_DEPTH_TEST);
763 768
 	glShadeModel(GL_SMOOTH);
764
-  
769
+
765 770
 	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
766 771
 
767 772
 	glBindTexture(GL_TEXTURE_2D, mTextureIds[slot]);
@@ -772,19 +777,19 @@ int Texture::loadBufferSlot(unsigned char *image,
772 777
 
773 778
 	if (mFlags & fUseMipmaps)
774 779
 	{
775
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
780
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
776 781
 							 GL_NEAREST_MIPMAP_LINEAR);
777 782
 		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
778
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
783
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
779 784
 							 GL_LINEAR_MIPMAP_LINEAR);
780
-		
785
+
781 786
 		gluBuild2DMipmaps(GL_TEXTURE_2D, bytes, width, height,
782 787
 								glcMode, GL_UNSIGNED_BYTE, image);
783 788
 	}
784 789
 	else
785 790
 	{
786 791
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
787
-		
792
+
788 793
 		glTexImage2D(GL_TEXTURE_2D, 0, glcMode, width, height, 0,
789 794
 						 glcMode, GL_UNSIGNED_BYTE, image);
790 795
 	}
@@ -831,7 +836,7 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
831 836
   while (!done)
832 837
   {
833 838
     snprintf(filename, 1024, "%s-%03i.png", base, count++);
834
-    
839
+
835 840
     f = fopen(filename, "rb");
836 841
 
837 842
     if (f)
@@ -854,7 +859,7 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
854 859
 
855 860
   mtk_image__png_save(f, image, width, height, 3);
856 861
   fclose(f);
857
-	
862
+
858 863
   delete [] image;
859 864
 
860 865
   printf("glScreenShot> Took screenshot '%s'.\n", filename);
@@ -868,15 +873,15 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
868 873
   bool done = false;
869 874
   int i, j, size;
870 875
   unsigned char comment_lenght;
871
-  unsigned char colormap_type; 
872
-  unsigned char image_type;    
873
-  unsigned short colormap_index;      
874
-  unsigned short colormap_lenght;     
875
-  unsigned char colormap_bbp;         
876
+  unsigned char colormap_type;
877
+  unsigned char image_type;
878
+  unsigned short colormap_index;
879
+  unsigned short colormap_lenght;
880
+  unsigned char colormap_bbp;
876 881
   unsigned short origin_x;
877 882
   unsigned short origin_y;
878
-  unsigned short swidth;   
879
-  unsigned short sheight;  
883
+  unsigned short swidth;
884
+  unsigned short sheight;
880 885
   char comment[32] = "Mongoose TGA 0.0.1\0";
881 886
   unsigned char tmp, bpp, desc_flags;
882 887
 
@@ -896,7 +901,7 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
896 901
   while (!done)
897 902
   {
898 903
     snprintf(filename, 1024, "%s-%04i.tga", base, count++);
899
-    
904
+
900 905
     f = fopen(filename, "rb");
901 906
 
902 907
     if (f)
@@ -941,7 +946,7 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
941 946
 
942 947
   // Write TGA header
943 948
   fwrite(&comment_lenght, 1, 1, f);
944
-  fwrite(&colormap_type, 1, 1, f); 
949
+  fwrite(&colormap_type, 1, 1, f);
945 950
   fwrite(&image_type, 1, 1, f);
946 951
   fwrite(&colormap_index, 2, 1, f);
947 952
   fwrite(&colormap_lenght, 2, 1, f);
@@ -957,7 +962,7 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
957 962
   fwrite(&comment, 1, comment_lenght, f);
958 963
 
959 964
   size = width * height * 3;
960
- 
965
+
961 966
   for (i = 0; i < size; i += 3)
962 967
   {
963 968
     tmp = image[i];
@@ -994,7 +999,7 @@ int Texture::loadPNG(char *filename)
994 999
 
995 1000
 
996 1001
 	f = fopen(filename, "rb");
997
-  
1002
+
998 1003
 	if (!f)
999 1004
 	{
1000 1005
 		perror("Couldn't load file");
@@ -1012,7 +1017,7 @@ int Texture::loadPNG(char *filename)
1012 1017
 			image = image2;
1013 1018
 			w = h = 256;
1014 1019
 		}
1015
-		
1020
+
1016 1021
 		if (image)
1017 1022
 		{
1018 1023
 			id = loadBuffer(image, w, h,
@@ -1056,7 +1061,7 @@ int Texture::loadTGA(char *filename)
1056 1061
 
1057 1062
 
1058 1063
 	f = fopen(filename, "rb");
1059
-  
1064
+
1060 1065
 	if (!f)
1061 1066
 	{
1062 1067
 		perror("Couldn't load file");
@@ -1077,10 +1082,10 @@ int Texture::loadTGA(char *filename)
1077 1082
 
1078 1083
 		if (image)
1079 1084
 		{
1080
-			id = loadBuffer(image, w, h, 
1085
+			id = loadBuffer(image, w, h,
1081 1086
 								 (type == 4) ? RGBA : RGB,
1082 1087
 								 (type == 4) ? 32 : 24);
1083
-			
1088
+
1084 1089
 			printf("%c", (id == -1) ? 'x' : 'o');
1085 1090
 			fflush(stdout);
1086 1091
 
@@ -1111,7 +1116,7 @@ int Texture::nextPower(int seed)
1111 1116
 {
1112 1117
   int i;
1113 1118
 
1114
-  for(i = 1; i < seed; i *= 2) 
1119
+  for(i = 1; i < seed; i *= 2)
1115 1120
     ;
1116 1121
 
1117 1122
   return i;
@@ -1119,8 +1124,8 @@ int Texture::nextPower(int seed)
1119 1124
 
1120 1125
 
1121 1126
 /* This code based off on gluScaleImage()  */
1122
-unsigned char *Texture::scaleBuffer(unsigned char *image, 
1123
-												int width,  int height,	
1127
+unsigned char *Texture::scaleBuffer(unsigned char *image,
1128
+												int width,  int height,
1124 1129
 												int components)
1125 1130
 {
1126 1131
    int i, j, k;
@@ -1141,14 +1146,14 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1141 1146
    height = nextPower(height);
1142 1147
    width = nextPower(width);
1143 1148
 
1144
-   if (height > 256) 
1149
+   if (height > 256)
1145 1150
      height = 256;
1146
-    
1147
-   if (width > 256) 
1151
+
1152
+   if (width > 256)
1148 1153
      width = 256;
1149 1154
 
1150 1155
    // Check to see if scaling is needed
1151
-   if (height == original_height && width == original_width) 
1156
+   if (height == original_height && width == original_width)
1152 1157
 		return NULL;
1153 1158
 
1154 1159
 	//printf("%i\n", components);
@@ -1170,17 +1175,17 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1170 1175
    }
1171 1176
 
1172 1177
    // Copy user data to float format.
1173
-   for (i = 0; i < original_height * original_width * components; ++i) 
1178
+   for (i = 0; i < original_height * original_width * components; ++i)
1174 1179
    {
1175 1180
      tempin[i] = (float)image[i];
1176 1181
    }
1177 1182
 
1178 1183
    // Determine which filter to use by checking ratios.
1179
-   if (width > 1) 
1184
+   if (width > 1)
1180 1185
    {
1181 1186
      sx = (float)(original_width - 1) / (float)(width - 1);
1182
-   } 
1183
-   else 
1187
+   }
1188
+   else
1184 1189
    {
1185 1190
      sx = (float)(original_width - 1);
1186 1191
    }
@@ -1188,13 +1193,13 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1188 1193
    if (height > 1)
1189 1194
    {
1190 1195
      sy = (float)(original_height - 1) / (float) (height - 1);
1191
-   } 
1192
-   else 
1196
+   }
1197
+   else
1193 1198
    {
1194 1199
      sy = (float)(original_height - 1);
1195 1200
    }
1196 1201
 
1197
-   if (sx < 1.0 && sy < 1.0) 
1202
+   if (sx < 1.0 && sy < 1.0)
1198 1203
    {
1199 1204
      /* Magnify both width and height:  use weighted sample of 4 pixels */
1200 1205
      int i0, i1, j0, j1;
@@ -1206,24 +1211,24 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1206 1211
      float s1, s2;
1207 1212
      float* dst;
1208 1213
 
1209
-     for(i = 0; i < height; ++i) 
1214
+     for(i = 0; i < height; ++i)
1210 1215
      {
1211 1216
        i0 = (int)(i * sy);
1212 1217
        i1 = i0 + 1;
1213 1218
 
1214
-       if (i1 >= original_height) 
1219
+       if (i1 >= original_height)
1215 1220
        {
1216 1221
 			 i1 = original_height - 1;
1217 1222
        }
1218 1223
 
1219 1224
        alpha = i * sy - i0;
1220 1225
 
1221
-       for (j = 0; j < width; ++j) 
1226
+       for (j = 0; j < width; ++j)
1222 1227
        {
1223 1228
 			 j0 = (int) (j * sx);
1224 1229
 			 j1 = j0 + 1;
1225 1230
 
1226
-			 if (j1 >= original_width) 
1231
+			 if (j1 >= original_width)
1227 1232
 			 {
1228 1233
 				 j1 = original_width - 1;
1229 1234
 			 }
@@ -1238,16 +1243,16 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1238 1243
 
1239 1244
 			 dst = tempout + (i * width + j) * components;
1240 1245
 
1241
-			 for (k = 0; k < components; ++k) 
1246
+			 for (k = 0; k < components; ++k)
1242 1247
 			 {
1243 1248
 				 s1 = *src00++ * (1.0 - beta) + *src01++ * beta;
1244 1249
 				 s2 = *src10++ * (1.0 - beta) + *src11++ * beta;
1245 1250
 				 *dst++ = s1 * (1.0 - alpha) + s2 * alpha;
1246
-			 } 
1251
+			 }
1247 1252
        }
1248
-     }     
1253
+     }
1249 1254
    }
1250
-   else 
1255
+   else
1251 1256
    {
1252 1257
      /* Shrink width and/or height:  use an unweighted box filter */
1253 1258
      int i0, i1;
@@ -1256,22 +1261,22 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1256 1261
      float sum;
1257 1262
      float* dst;
1258 1263
 
1259
-     for (i = 0; i < height; ++i) 
1264
+     for (i = 0; i < height; ++i)
1260 1265
      {
1261 1266
        i0 = (int) (i * sy);
1262 1267
        i1 = i0 + 1;
1263 1268
 
1264
-       if (i1 >= original_height) 
1269
+       if (i1 >= original_height)
1265 1270
        {
1266 1271
 			 i1 = original_height - 1;
1267 1272
        }
1268 1273
 
1269
-       for (j = 0; j < width; ++j) 
1274
+       for (j = 0; j < width; ++j)
1270 1275
        {
1271 1276
 			 j0 = (int) (j * sx);
1272 1277
 			 j1 = j0 + 1;
1273 1278
 
1274
-			 if (j1 >= original_width) 
1279
+			 if (j1 >= original_width)
1275 1280
 			 {
1276 1281
 				 j1 = original_width - 1;
1277 1282
 			 }
@@ -1279,15 +1284,15 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1279 1284
 			 dst = tempout + (i * width + j) * components;
1280 1285
 
1281 1286
 			 /* Compute average of pixels in the rectangle (i0,j0)-(i1,j1) */
1282
-			 for (k = 0; k < components; ++k) 
1287
+			 for (k = 0; k < components; ++k)
1283 1288
 			 {
1284 1289
 				 sum = 0.0;
1285 1290
 
1286
-				 for (ii = i0; ii <= i1; ++ii) 
1291
+				 for (ii = i0; ii <= i1; ++ii)
1287 1292
 				 {
1288
-					 for (jj = j0; jj <= j1; ++jj) 
1293
+					 for (jj = j0; jj <= j1; ++jj)
1289 1294
 					 {
1290
-						 sum += *(tempin + (ii * original_width + jj) 
1295
+						 sum += *(tempin + (ii * original_width + jj)
1291 1296
 									 * components + k);
1292 1297
 					 }
1293 1298
 				 }
@@ -1295,12 +1300,12 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1295 1300
 				 sum /= ( j1 - j0 + 1 ) * ( i1 - i0 + 1 );
1296 1301
 				 *dst++ = sum;
1297 1302
 			 }
1298
-       } 
1303
+       }
1299 1304
      }
1300 1305
    }
1301 1306
 
1302 1307
    // Copy to our results.
1303
-   for( i = 0; i < height * width * components; ++i) 
1308
+   for( i = 0; i < height * width * components; ++i)
1304 1309
    {
1305 1310
      timage[i] = (unsigned char)tempout[i];
1306 1311
    }

+ 730
- 730
src/TombRaider.cpp
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 47
- 47
src/World.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : OpenRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,14 +10,14 @@
10 10
  * Comments: The game world ( model )
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
15
+ *
16 16
  *-- Test Defines -----------------------------------------------
17
- *           
18
- * UNIT_TEST_WORLD - Builds World class as a console unit test 
19 17
  *
20
- *-- History ------------------------------------------------ 
18
+ * UNIT_TEST_WORLD - Builds World class as a console unit test
19
+ *
20
+ *-- History ------------------------------------------------
21 21
  *
22 22
  * 2002.12.16:
23 23
  * Mongoose - Created
@@ -33,10 +33,10 @@
33 33
 #   include "SkeletalModel.h"
34 34
 #endif
35 35
 
36
-#include <mstl/List.h>
37
-#include <mstl/Vector.h>
38
-#include <hel/math.h>
39
-#include <hel/Mass.h>
36
+#include "mstl/List.h"
37
+#include "mstl/Vector.h"
38
+#include "hel/math.h"
39
+#include "hel/Mass.h"
40 40
 
41 41
 
42 42
 // Mirrors TombRaider class' room flags really
@@ -86,12 +86,12 @@ typedef struct color_s
86 86
 
87 87
 typedef struct sprite_s
88 88
 {
89
-	int num_verts; // 4 == Quad, 3 == Triangle, renderered as triangles 
89
+	int num_verts; // 4 == Quad, 3 == Triangle, renderered as triangles
90 90
 	vertex_t vertex[4];
91 91
 	texel_t texel[4];
92 92
 	float pos[3];
93 93
 	float radius; // yeah, I know
94
-	int texture;	
94
+	int texture;
95 95
 
96 96
 } sprite_t;
97 97
 
@@ -177,7 +177,7 @@ typedef struct static_model_s
177 177
 	int index;     // model_mesh index
178 178
 	float yaw;     // angle of rotation on Y
179 179
 	float pos[3];  // position
180
-	
180
+
181 181
 	//vec3_t bboxMax;
182 182
 	//vec3_t bboxMin;
183 183
 
@@ -234,7 +234,7 @@ typedef struct room_mesh_s
234 234
 
235 235
 
236 236
 // Workout generic entity and a client class from these entities
237
-typedef struct world_entity_s 
237
+typedef struct world_entity_s
238 238
 {
239 239
 	vec3_t pos;
240 240
 	vec3_t lastPos;
@@ -249,7 +249,7 @@ typedef struct world_entity_s
249 249
 } world_entity_t;
250 250
 
251 251
 
252
-typedef struct actor_entity_s 
252
+typedef struct actor_entity_s
253 253
 {
254 254
 	vec3_t pos;
255 255
 	vec3_t lastPos;
@@ -305,12 +305,12 @@ class World
305 305
 
306 306
 	World();
307 307
 	/*------------------------------------------------------
308
-	 * Pre  : 
308
+	 * Pre  :
309 309
 	 * Post : Constructs an object of World
310 310
 	 *
311 311
 	 *-- History ------------------------------------------
312 312
 	 *
313
-	 * 2002.12.16: 
313
+	 * 2002.12.16:
314 314
 	 * Mongoose - Created
315 315
 	 ------------------------------------------------------*/
316 316
 
@@ -321,7 +321,7 @@ class World
321 321
 	 *
322 322
 	 *-- History ------------------------------------------
323 323
 	 *
324
-	 * 2002.12.16: 
324
+	 * 2002.12.16:
325 325
 	 * Mongoose - Created
326 326
 	 ------------------------------------------------------*/
327 327
 
@@ -341,28 +341,28 @@ class World
341 341
 	 *-- History ------------------------------------------
342 342
 	 *
343 343
 	 * 2002.12.20:
344
-	 * Mongoose - Created, factored out of Render class 
344
+	 * Mongoose - Created, factored out of Render class
345 345
 	 ------------------------------------------------------*/
346 346
 
347 347
 	int getRoomByLocation(float x, float y, float z);
348 348
 	/*------------------------------------------------------
349
-	 * Pre  : 
349
+	 * Pre  :
350 350
 	 * Post : Returns correct room index or -1 for unknown
351 351
 	 *
352
-	 *        NOTE: If it fails to be in a room it gives 
352
+	 *        NOTE: If it fails to be in a room it gives
353 353
 	 *        closest overlapping room
354 354
 	 *
355 355
 	 *-- History ------------------------------------------
356 356
 	 *
357 357
 	 * 2002.12.20:
358
-	 * Mongoose - Created, factored out of Render class 
358
+	 * Mongoose - Created, factored out of Render class
359 359
 	 ------------------------------------------------------*/
360 360
 
361
-	int getAdjoiningRoom(int index, 
361
+	int getAdjoiningRoom(int index,
362 362
 								float x, float y, float z,
363 363
 								float x2, float y2, float z2);
364 364
 	/*------------------------------------------------------
365
-	 * Pre  : 
365
+	 * Pre  :
366 366
 	 * Post : Looks for portal crossings from xyz to xyz2 segment
367 367
 	 *        from room[index] returns index of adjoined room or -1
368 368
 	 *
@@ -381,13 +381,13 @@ class World
381 381
 	 *-- History ------------------------------------------
382 382
 	 *
383 383
 	 * 2002.12.20:
384
-	 * Mongoose - Created, factored out of Render class 
384
+	 * Mongoose - Created, factored out of Render class
385 385
 	 ------------------------------------------------------*/
386 386
 
387 387
 	unsigned int getRoomInfo(int room);
388 388
 	/*------------------------------------------------------
389
-	 * Pre  : 
390
-	 * Post : 
389
+	 * Pre  :
390
+	 * Post :
391 391
 	 *
392 392
 	 *-- History ------------------------------------------
393 393
 	 *
@@ -404,7 +404,7 @@ class World
404 404
 	 *-- History ------------------------------------------
405 405
 	 *
406 406
 	 * 2002.12.20:
407
-	 * Mongoose - Created, factored out of Render class 
407
+	 * Mongoose - Created, factored out of Render class
408 408
 	 ------------------------------------------------------*/
409 409
 
410 410
 	bool getHeightAtPosition(int index, float x, float *y, float z);
@@ -416,7 +416,7 @@ class World
416 416
 	 *-- History ------------------------------------------
417 417
 	 *
418 418
 	 * 2002.12.20:
419
-	 * Mongoose - Created, factored out of Render class 
419
+	 * Mongoose - Created, factored out of Render class
420 420
 	 ------------------------------------------------------*/
421 421
 
422 422
 	// Temp methods for rendering use until more refactoring is done
@@ -432,32 +432,32 @@ class World
432 432
 	////////////////////////////////////////////////////////////
433 433
 	// Public Mutators
434 434
 	////////////////////////////////////////////////////////////
435
-	
435
+
436 436
 	void setFlag(WorldFlag flag);
437 437
 	/*------------------------------------------------------
438
-	 * Pre  : 
438
+	 * Pre  :
439 439
 	 * Post : Sets option flag
440 440
 	 *
441 441
 	 *-- History ------------------------------------------
442 442
 	 *
443 443
 	 * 2002.12.20:
444
-	 * Mongoose - Created, factored out of Render class 
444
+	 * Mongoose - Created, factored out of Render class
445 445
 	 ------------------------------------------------------*/
446 446
 
447 447
 	void clearFlag(WorldFlag flag);
448 448
 	/*------------------------------------------------------
449
-	 * Pre  : 
449
+	 * Pre  :
450 450
 	 * Post : Clears option flag
451 451
 	 *
452 452
 	 *-- History ------------------------------------------
453 453
 	 *
454 454
 	 * 2002.12.20:
455
-	 * Mongoose - Created, factored out of Render class 
455
+	 * Mongoose - Created, factored out of Render class
456 456
 	 ------------------------------------------------------*/
457 457
 
458 458
 	void destroy();
459 459
 	/*------------------------------------------------------
460
-	 * Pre  : 
460
+	 * Pre  :
461 461
 	 * Post : Clears all data in world, in future will check
462 462
 	 *        if data is in use before clearing
463 463
 	 *
@@ -469,58 +469,58 @@ class World
469 469
 
470 470
 	void addRoom(room_mesh_t *room);
471 471
 	/*------------------------------------------------------
472
-	 * Pre  : 
472
+	 * Pre  :
473 473
 	 * Post : Adds object to world
474 474
 	 *
475 475
 	 *-- History ------------------------------------------
476 476
 	 *
477 477
 	 * 2002.12.20:
478
-	 * Mongoose - Created, factored out of Render class 
478
+	 * Mongoose - Created, factored out of Render class
479 479
 	 ------------------------------------------------------*/
480
-	
480
+
481 481
 	void addMesh(model_mesh_t *model);
482 482
 	/*------------------------------------------------------
483
-	 * Pre  : 
483
+	 * Pre  :
484 484
 	 * Post : Adds object to world
485 485
 	 *
486 486
 	 *-- History ------------------------------------------
487 487
 	 *
488 488
 	 * 2002.12.20:
489
-	 * Mongoose - Created, factored out of Render class 
489
+	 * Mongoose - Created, factored out of Render class
490 490
 	 ------------------------------------------------------*/
491 491
 
492 492
 	void addEntity(entity_t *e);
493 493
 	/*------------------------------------------------------
494
-	 * Pre  : 
494
+	 * Pre  :
495 495
 	 * Post : Adds object to world
496 496
 	 *
497 497
 	 *-- History ------------------------------------------
498 498
 	 *
499 499
 	 * 2002.12.20:
500
-	 * Mongoose - Created, factored out of Render class 
500
+	 * Mongoose - Created, factored out of Render class
501 501
 	 ------------------------------------------------------*/
502 502
 
503 503
 	int addModel(skeletal_model_t *model);
504 504
 	/*------------------------------------------------------
505
-	 * Pre  : 
505
+	 * Pre  :
506 506
 	 * Post : Adds object to world, returns next model Id
507 507
 	 *        or -1 if failed to add model to world
508 508
 	 *
509 509
 	 *-- History ------------------------------------------
510 510
 	 *
511 511
 	 * 2002.12.20:
512
-	 * Mongoose - Created, factored out of Render class 
512
+	 * Mongoose - Created, factored out of Render class
513 513
 	 ------------------------------------------------------*/
514 514
 
515 515
 	void addSprite(sprite_seq_t *sprite);
516 516
 	/*------------------------------------------------------
517
-	 * Pre  : 
517
+	 * Pre  :
518 518
 	 * Post : Adds object to world
519 519
 	 *
520 520
 	 *-- History ------------------------------------------
521 521
 	 *
522 522
 	 * 2002.12.20:
523
-	 * Mongoose - Created, factored out of Render class 
523
+	 * Mongoose - Created, factored out of Render class
524 524
 	 ------------------------------------------------------*/
525 525
 
526 526
 	void moveEntity(entity_t *e, char movement);
@@ -556,7 +556,7 @@ class World
556 556
 
557 557
 	void clear();
558 558
 	/*------------------------------------------------------
559
-	 * Pre  : 
559
+	 * Pre  :
560 560
 	 * Post : Clears all data in world
561 561
 	 *
562 562
 	 *-- History ------------------------------------------

+ 84
- 0
src/hel/CollisionObject.cpp Zobrazit soubor

@@ -0,0 +1,84 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ *
4
+ * Project : libHel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : CollisionObject
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Bounding volume class for world/vis
11
+ *           culling/clipping/collision stuff
12
+ *
13
+ *
14
+ *           This file was generated using Mongoose's C++
15
+ *           template generator script.  <stu7440@westga.edu>
16
+ *
17
+ *-- History -------------------------------------------------
18
+ *
19
+ * 2002.11.27:
20
+ * Mongoose - Created
21
+ =================================================================*/
22
+
23
+#include "CollisionObject.h"
24
+
25
+
26
+////////////////////////////////////////////////////////////
27
+// Constructors
28
+////////////////////////////////////////////////////////////
29
+
30
+CollisionObject::CollisionObject()
31
+{
32
+}
33
+
34
+
35
+CollisionObject::~CollisionObject()
36
+{
37
+}
38
+
39
+
40
+////////////////////////////////////////////////////////////
41
+// Public Accessors
42
+////////////////////////////////////////////////////////////
43
+
44
+bool CollisionObject::intersectPoint(Vector3d p) {
45
+    return 0;
46
+}
47
+
48
+////////////////////////////////////////////////////////////
49
+// Public Mutators
50
+////////////////////////////////////////////////////////////
51
+
52
+
53
+////////////////////////////////////////////////////////////
54
+// Private Accessors
55
+////////////////////////////////////////////////////////////
56
+
57
+
58
+////////////////////////////////////////////////////////////
59
+// Private Mutators
60
+////////////////////////////////////////////////////////////
61
+
62
+
63
+////////////////////////////////////////////////////////////
64
+// Unit Test code
65
+////////////////////////////////////////////////////////////
66
+
67
+#ifdef UNIT_TEST_CollisionObject
68
+int runCollisionObjectUnitTest()
69
+{
70
+	CollisionObject col;
71
+
72
+	return 0;
73
+}
74
+
75
+
76
+int main(int argc, char *argv[])
77
+{
78
+	printf("[CollisionObject class test]\n");
79
+
80
+	runCollisionObjectUnitTest();
81
+
82
+	return 0;
83
+}
84
+#endif

+ 92
- 0
src/hel/CollisionObject.h Zobrazit soubor

@@ -0,0 +1,92 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ *
4
+ * Project : libHel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : CollisionObject
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Bounding volume class for world/vis
11
+ *           culling/clipping/collision stuff
12
+ *
13
+ *
14
+ *           This file was generated using Mongoose's C++
15
+ *           template generator script.  <stu7440@westga.edu>
16
+ *
17
+ *-- Test Defines -----------------------------------------------
18
+ *
19
+ * UNIT_TEST_BOUNDINGVOLUME - Builds BoundingVolume class unit test
20
+ *
21
+ *-- History ------------------------------------------------
22
+ *
23
+ * 2002.11.27:
24
+ * Mongoose - Created
25
+ ================================================================*/
26
+
27
+
28
+#ifndef GUARD__LIBHEL_MONGOOSE_COLLISIONOBJECT_H_
29
+#define GUARD__LIBHEL_MONGOOSE_COLLISIONOBJECT_H_
30
+
31
+#include <hel/Vector3d.h>
32
+
33
+class CollisionObject
34
+{
35
+ public:
36
+
37
+	////////////////////////////////////////////////////////////
38
+	// Constructors
39
+	////////////////////////////////////////////////////////////
40
+
41
+	CollisionObject();
42
+	/*------------------------------------------------------
43
+	 * Pre  :
44
+	 * Post : Constructs an object of CollisionObject
45
+	 *
46
+	 *-- History ------------------------------------------
47
+	 *
48
+	 * 2002.11.27:
49
+	 * Mongoose - Created
50
+	 ------------------------------------------------------*/
51
+
52
+	~CollisionObject();
53
+	/*------------------------------------------------------
54
+	 * Pre  : CollisionObject object is allocated
55
+	 * Post : Deconstructs an object of CollisionObject
56
+	 *
57
+	 *-- History ------------------------------------------
58
+	 *
59
+	 * 2002.11.27:
60
+	 * Mongoose - Created
61
+	 ------------------------------------------------------*/
62
+
63
+
64
+	////////////////////////////////////////////////////////////
65
+	// Public Accessors
66
+	////////////////////////////////////////////////////////////
67
+
68
+    bool intersectPoint(Vector3d p);
69
+
70
+	////////////////////////////////////////////////////////////
71
+	// Public Mutators
72
+	////////////////////////////////////////////////////////////
73
+
74
+    Vector3d mIntersection;
75
+
76
+
77
+ private:
78
+
79
+	////////////////////////////////////////////////////////////
80
+	// Private Accessors
81
+	////////////////////////////////////////////////////////////
82
+
83
+
84
+	////////////////////////////////////////////////////////////
85
+	// Private Mutators
86
+	////////////////////////////////////////////////////////////
87
+
88
+
89
+	/* */
90
+};
91
+
92
+#endif

+ 29
- 29
src/hel/Simulation.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Hel
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,14 +10,14 @@
10 10
  * Comments: This class simulates mass physics
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
15
+ *
16 16
  *-- Test Defines -----------------------------------------------
17
- *           
18
- * UNIT_TEST_SIMULATION - Builds Simulation class as a console unit test 
19 17
  *
20
- *-- History ------------------------------------------------ 
18
+ * UNIT_TEST_SIMULATION - Builds Simulation class as a console unit test
19
+ *
20
+ *-- History ------------------------------------------------
21 21
  *
22 22
  * 2003.06.08:
23 23
  * Mongoose - Generic collision and basic resolution w/o generic
@@ -47,12 +47,12 @@ class Simulation
47 47
 
48 48
 	Simulation();
49 49
 	/*------------------------------------------------------
50
-	 * Pre  : 
50
+	 * Pre  :
51 51
 	 * Post : Constructs an object of Simulation
52 52
 	 *
53 53
 	 *-- History ------------------------------------------
54 54
 	 *
55
-	 * 2003.06.02: 
55
+	 * 2003.06.02:
56 56
 	 * Mongoose - Created
57 57
 	 ------------------------------------------------------*/
58 58
 
@@ -63,7 +63,7 @@ class Simulation
63 63
 	 *
64 64
 	 *-- History ------------------------------------------
65 65
 	 *
66
-	 * 2003.06.02: 
66
+	 * 2003.06.02:
67 67
 	 * Mongoose - Created
68 68
 	 ------------------------------------------------------*/
69 69
 
@@ -74,7 +74,7 @@ class Simulation
74 74
 
75 75
 	Mass *getMass(unsigned int i);
76 76
 	/*------------------------------------------------------
77
-	 * Pre  : 
77
+	 * Pre  :
78 78
 	 * Post : Get <i>th Mass element of this simulation
79 79
 	 *
80 80
 	 *-- History ------------------------------------------
@@ -90,7 +90,7 @@ class Simulation
90 90
 
91 91
 	virtual void attachCollisionObject(CollisionObject *obj);
92 92
 	/*------------------------------------------------------
93
-	 * Pre  : 
93
+	 * Pre  :
94 94
 	 * Post : Adds <Obj> to the collision list for this simulation
95 95
 	 *
96 96
 	 * TODO : Allow multiple types of collision to be excluded?
@@ -103,7 +103,7 @@ class Simulation
103 103
 
104 104
 	virtual void clear();
105 105
 	/*------------------------------------------------------
106
-	 * Pre  : 
106
+	 * Pre  :
107 107
 	 * Post : Removes all masses from this simulation
108 108
 	 *
109 109
 	 *-- History ------------------------------------------
@@ -114,7 +114,7 @@ class Simulation
114 114
 
115 115
 	virtual bool collisionDetected(Mass *mass);
116 116
 	/*------------------------------------------------------
117
-	 * Pre  : 
117
+	 * Pre  :
118 118
 	 * Post : Returns true if <Mass> collided with object
119 119
 	 *
120 120
 	 *-- History ------------------------------------------
@@ -125,7 +125,7 @@ class Simulation
125 125
 
126 126
 	virtual void generateMasses(unsigned int count, vec_t mass);
127 127
 	/*------------------------------------------------------
128
-	 * Pre  : 
128
+	 * Pre  :
129 129
 	 * Post : <Count> number of masses with <mass> value are added
130 130
 	 *
131 131
 	 *-- History ------------------------------------------
@@ -135,11 +135,11 @@ class Simulation
135 135
 	 ------------------------------------------------------*/
136 136
 
137 137
 	virtual void generateMasses(unsigned int count, vec_t mass,
138
-										 const Vector3d &position, 
138
+										 const Vector3d &position,
139 139
 										 const Vector3d &velocity);
140 140
 	/*------------------------------------------------------
141
-	 * Pre  : 
142
-	 * Post : <Count> number of masses with 
141
+	 * Pre  :
142
+	 * Post : <Count> number of masses with
143 143
 	 *        <mass>, <position>, and <velocity> are added
144 144
 	 *
145 145
 	 *-- History ------------------------------------------
@@ -150,7 +150,7 @@ class Simulation
150 150
 
151 151
 	virtual void init();
152 152
 	/*------------------------------------------------------
153
-	 * Pre  : 
153
+	 * Pre  :
154 154
 	 * Post : Reset forces acting on masses
155 155
 	 *
156 156
 	 *-- History ------------------------------------------
@@ -161,7 +161,7 @@ class Simulation
161 161
 
162 162
 	virtual void resolveCollision(Mass *mass, CollisionObject *obj);
163 163
 	/*------------------------------------------------------
164
-	 * Pre  : 
164
+	 * Pre  :
165 165
 	 * Post : Resolves a collision of <Obj> and <Mass>
166 166
 	 *
167 167
 	 *        The default resolution here is to set mass pos
@@ -176,7 +176,7 @@ class Simulation
176 176
 
177 177
 	virtual void run(vec_t timeDelta);
178 178
 	/*------------------------------------------------------
179
-	 * Pre  : 
179
+	 * Pre  :
180 180
 	 * Post : Does full init, solve, simulate cycle
181 181
 	 *
182 182
 	 *-- History ------------------------------------------
@@ -187,7 +187,7 @@ class Simulation
187 187
 
188 188
 	virtual void simulate(vec_t timeDelta);
189 189
 	/*------------------------------------------------------
190
-	 * Pre  : 
190
+	 * Pre  :
191 191
 	 * Post : Update change in time for each mass
192 192
 	 *
193 193
 	 *-- History ------------------------------------------
@@ -199,7 +199,7 @@ class Simulation
199 199
 	virtual void solve ();
200 200
 	/*------------------------------------------------------
201 201
 	 * Pre  :
202
-	 * Post : Have forces act on masses  
202
+	 * Post : Have forces act on masses
203 203
 	 *
204 204
 	 *-- History ------------------------------------------
205 205
 	 *
@@ -231,13 +231,13 @@ class GravitySimulation : public Simulation
231 231
 {
232 232
 public:
233 233
 
234
-	GravitySimulation() : Simulation()      
234
+	GravitySimulation() : Simulation()
235 235
 	{
236 236
 		gravitation = Vector3d(0.0f, -9.81f, 0.0f);
237 237
 	}
238 238
 
239 239
 
240
-	virtual void solve()                                                    
240
+	virtual void solve()
241 241
 	{
242 242
 		Mass *m;
243 243
 
@@ -248,7 +248,7 @@ public:
248 248
 
249 249
 			// Gravitational force, Force = (Mass)(Gravity)
250 250
 			m->applyForce(gravitation * m->mMass);
251
-			
251
+
252 252
 			if (collisionDetected(m))
253 253
 			{
254 254
 				m->mVelocity = Vector3d(0, 0, 0);
@@ -269,12 +269,12 @@ public:
269 269
 	{
270 270
 	}
271 271
 
272
-	
272
+
273 273
 	virtual void generateMasses(unsigned int count, vec_t mass,
274
-										 const Vector3d &position, 
274
+										 const Vector3d &position,
275 275
 										 const Vector3d &velocity)
276 276
 	{
277
-		Simulation::generateMasses(count, mass, 
277
+		Simulation::generateMasses(count, mass,
278 278
 											connectionPos + position, velocity);
279 279
 	}
280 280
 
@@ -290,7 +290,7 @@ public:
290 290
 
291 291
 			// Vector from mass to spring connection
292 292
 			Vector3d springVector = m->mPos - connectionPos;
293
-			
293
+
294 294
 			// Apply spring force, spring force formulation
295 295
 			m->applyForce(-springVector * springConstant);
296 296
 

+ 53
- 53
src/mstl/Tree.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Mongoose
6 6
  * Website : http://gooseegg.sourceforge.net/
@@ -17,22 +17,22 @@
17 17
  *           2. The root node must be black.
18 18
  *           3. Every leaf node is black. (null pointers)
19 19
  *           4. If a node is red, then both its children are black.
20
- *           5. Every simple path from a node to a descendant 
20
+ *           5. Every simple path from a node to a descendant
21 21
  *              leaf contains the same number of black nodes.
22 22
  *           6. Any path from the root to a leaf must not have
23 23
  *              adjacent red nodes.
24 24
  *
25 25
  *
26
- *           This file was generated using Mongoose's C++ 
26
+ *           This file was generated using Mongoose's C++
27 27
  *           template generator script.  <stu7440@westga.edu>
28
- * 
29
- *-- History ------------------------------------------------ 
28
+ *
29
+ *-- History ------------------------------------------------
30 30
  *
31 31
  * 2002.02.17:
32 32
  * Mongoose - Rewritten as a Red-Black tree
33 33
  *
34 34
  * 2002.02.16:
35
- * Mongoose - Dug out of cobwebs and fixed up 
35
+ * Mongoose - Dug out of cobwebs and fixed up
36 36
  *            Yes, I believe in code reuse!  =)
37 37
  *
38 38
  * 2000.10.26:
@@ -59,7 +59,7 @@ typedef enum
59 59
 {
60 60
 	_tree_h_black,
61 61
 	_tree_h_red
62
-	
62
+
63 63
 }  _tree_h_color_t;
64 64
 
65 65
 
@@ -80,7 +80,7 @@ public:
80 80
 
81 81
 
82 82
 	~TreeNode()
83
-	{		
83
+	{
84 84
 		TreeNode<Key, Data> *left;
85 85
 		TreeNode<Key, Data> *right;
86 86
 
@@ -97,7 +97,7 @@ public:
97 97
 			left->SetParent(NULL);
98 98
 			delete left;
99 99
 		}
100
-			
100
+
101 101
 		if (right)
102 102
 		{
103 103
 			right->SetParent(NULL);
@@ -121,26 +121,26 @@ public:
121 121
 
122 122
 	/// Left, child ///////////////////////////////
123 123
 
124
-	TreeNode<Key, Data> *GetChild() 
124
+	TreeNode<Key, Data> *GetChild()
125 125
 	{
126
-		return Left();
126
+		return GetLeft();
127 127
 	}
128 128
 
129
-	
130
-	void SetChild(TreeNode<Key, Data> *tree) 
129
+
130
+	void SetChild(TreeNode<Key, Data> *tree)
131 131
 	{
132 132
 		Left(tree);
133 133
 	}
134 134
 
135 135
 
136
-	TreeNode<Key, Data> *GetLeft() 
136
+	TreeNode<Key, Data> *GetLeft()
137 137
 	{
138 138
 		return _left;
139 139
 	}
140 140
 
141 141
 
142 142
 	void SetLeft(TreeNode<Key, Data> *tree)
143
-	{	
143
+	{
144 144
 		if (tree == this)
145 145
 		{
146 146
 			return;
@@ -152,30 +152,30 @@ public:
152 152
 		{
153 153
 			tree->SetParent(this);
154 154
 		}
155
-	} 
155
+	}
156 156
 
157 157
 	/// Right, sibling ///////////////////////////
158 158
 
159
-	TreeNode<Key, Data> *GetSibling() 
159
+	TreeNode<Key, Data> *GetSibling()
160 160
 	{
161
-		return Right();
161
+		return GetRight();
162 162
 	}
163 163
 
164 164
 
165
-	void SetSibling(TreeNode<Key, Data> *tree) 
165
+	void SetSibling(TreeNode<Key, Data> *tree)
166 166
 	{
167
-		Right(tree);
167
+		SetRight(tree);
168 168
 	}
169 169
 
170 170
 
171
-	TreeNode<Key, Data> *GetRight() 
171
+	TreeNode<Key, Data> *GetRight()
172 172
 	{
173 173
 		return _right;
174 174
 	}
175 175
 
176 176
 
177 177
 	void SetRight(TreeNode<Key, Data> *tree)
178
-	{		
178
+	{
179 179
 		if (tree == this)
180 180
 		{
181 181
 			return;
@@ -240,7 +240,7 @@ public:
240 240
 	}
241 241
 
242 242
 
243
-	void PrintInorder() 
243
+	void PrintInorder()
244 244
 	{
245 245
 		if (_left)
246 246
 		{
@@ -250,7 +250,7 @@ public:
250 250
 		}
251 251
 
252 252
 		PrintNode();
253
-    
253
+
254 254
 		if (_right)
255 255
 		{
256 256
 			//cout << ", ";
@@ -373,7 +373,7 @@ public:
373 373
 			}
374 374
 			else
375 375
 			{
376
-				_right->Insert(tree);     
376
+				_right->Insert(tree);
377 377
 			}
378 378
 		}
379 379
 	}
@@ -403,7 +403,7 @@ private:
403 403
 template <class Key, class Data> class Tree
404 404
 {
405 405
 public:
406
-	
406
+
407 407
 	Tree()
408 408
 	{
409 409
 		_error = false;
@@ -416,7 +416,7 @@ public:
416 416
 	{
417 417
 		Clear();
418 418
 	}
419
-  
419
+
420 420
 
421 421
 	unsigned int NumElements()
422 422
 	{
@@ -438,7 +438,7 @@ public:
438 438
 		}
439 439
 
440 440
 		seeking = _root->SearchByKey(key, error);
441
-		
441
+
442 442
 		if (seeking)
443 443
 		{
444 444
 			return seeking->GetData();
@@ -462,7 +462,7 @@ public:
462 462
 		}
463 463
 
464 464
 		seeking = _root->SearchByData(data, error);
465
-		
465
+
466 466
 		if (seeking)
467 467
 		{
468 468
 			return seeking->GetKey();
@@ -515,7 +515,7 @@ public:
515 515
 		if (_root)
516 516
 		{
517 517
 #ifdef OBSOLETE
518
-			// Mongoose 2002.02.18, To remove duplicates 
518
+			// Mongoose 2002.02.18, To remove duplicates
519 519
 			erorr = false;
520 520
 
521 521
 			while (!error)
@@ -528,7 +528,7 @@ public:
528 528
 		}
529 529
 
530 530
 		return error;
531
-	}  
531
+	}
532 532
 
533 533
 
534 534
 	void Erase()
@@ -600,7 +600,7 @@ public:
600 600
 				}
601 601
 			}
602 602
 
603
-			cout << "(" << tree->GetKey() << ", " 
603
+			cout << "(" << tree->GetKey() << ", "
604 604
 				  << ((tree->GetColor() == _tree_h_red) ? "red" : "blk")
605 605
 				  << ")";
606 606
 
@@ -618,7 +618,7 @@ public:
618 618
 			return;
619 619
 		}
620 620
 		else if (seek < height)
621
-		{			
621
+		{
622 622
 			return;
623 623
 		}
624 624
 
@@ -634,7 +634,7 @@ public:
634 634
 		{
635 635
 			cout << "(-, blk) ";
636 636
 		}
637
-		
637
+
638 638
 		if (right)
639 639
 		{
640 640
 			PrintTree(right, height, seek, rightmost);
@@ -659,11 +659,11 @@ public:
659 659
 		PrintTree(_root, 0, 0, true);
660 660
 		cout << endl << "Nodes marked with * are in error" << endl;
661 661
 	}
662
-  
662
+
663 663
 
664 664
 	void Print()
665 665
 	{
666
-		cout << "Tree: " << _num_elements <<" elements {" << endl;    
666
+		cout << "Tree: " << _num_elements <<" elements {" << endl;
667 667
 
668 668
 		if (_root)
669 669
 		{
@@ -785,7 +785,7 @@ private:
785 785
 			}
786 786
 
787 787
 			return predecessor;
788
-		}		
788
+		}
789 789
 	}
790 790
 
791 791
 
@@ -886,7 +886,7 @@ private:
886 886
 			}
887 887
 			else
888 888
 			{
889
-				parent->SetRight(right);				
889
+				parent->SetRight(right);
890 890
 			}
891 891
 		}
892 892
 		else // TreeNode 'tree' was root, so now right is root
@@ -935,7 +935,7 @@ private:
935 935
 
936 936
 		if (left)
937 937
 		{
938
-        left->SetParent(tree->GetParent());  
938
+        left->SetParent(tree->GetParent());
939 939
 		}
940 940
 
941 941
 		parent = tree->GetParent();
@@ -967,7 +967,7 @@ private:
967 967
 	}
968 968
 
969 969
 
970
-	void TreeNodeShallowCopy(TreeNode<Key, Data> *src, 
970
+	void TreeNodeShallowCopy(TreeNode<Key, Data> *src,
971 971
 									 TreeNode<Key, Data> *dest, bool no_links)
972 972
 	{
973 973
 		if (!src || !dest)
@@ -1019,7 +1019,7 @@ private:
1019 1019
 		}
1020 1020
 		else
1021 1021
 		{
1022
-			cur = prev->GetRight();  
1022
+			cur = prev->GetRight();
1023 1023
 		}
1024 1024
 
1025 1025
 		if (cur)
@@ -1048,7 +1048,7 @@ private:
1048 1048
 		if (prev != tree)
1049 1049
 		{
1050 1050
 			TreeNodeShallowCopy(prev, tree, true);
1051
-			
1051
+
1052 1052
 			if (prev->GetParent())
1053 1053
 			{
1054 1054
 				if (prev == (prev->GetParent())->GetLeft())
@@ -1066,7 +1066,7 @@ private:
1066 1066
 			prev->SetParent(NULL);
1067 1067
 			prev->SetLeft(NULL);
1068 1068
 
1069
-			delete prev;     
1069
+			delete prev;
1070 1070
 		}
1071 1071
 
1072 1072
 		if (tree->GetColor() == _tree_h_black)
@@ -1088,13 +1088,13 @@ private:
1088 1088
 
1089 1089
 		parent = tree->GetParent();
1090 1090
 
1091
-		while ((tree != _root) && (parent->GetColor() == _tree_h_black)) 
1091
+		while ((tree != _root) && (parent->GetColor() == _tree_h_black))
1092 1092
 		{
1093
-			if (tree == parent->GetLeft()) 
1093
+			if (tree == parent->GetLeft())
1094 1094
 			{
1095 1095
 				sibling = parent->GetRight();
1096 1096
 
1097
-				if (sibling && sibling->GetColor() == _tree_h_red) 
1097
+				if (sibling && sibling->GetColor() == _tree_h_red)
1098 1098
 				{
1099 1099
 					sibling->SetColor(_tree_h_black);
1100 1100
 					parent->SetColor(_tree_h_red);
@@ -1199,18 +1199,18 @@ private:
1199 1199
 		}
1200 1200
 
1201 1201
 		tree->SetColor(_tree_h_red);
1202
-		
1202
+
1203 1203
 		parent = tree->GetParent();
1204 1204
 
1205
-		while ((tree != _root) && (parent->GetColor() == _tree_h_red)) 
1205
+		while ((tree != _root) && (parent->GetColor() == _tree_h_red))
1206 1206
 		{
1207 1207
 			grandparent = parent->GetParent();
1208
-			
1209
-			if (parent == grandparent->GetLeft()) 
1208
+
1209
+			if (parent == grandparent->GetLeft())
1210 1210
 			{
1211 1211
 				uncle = grandparent->GetRight();
1212 1212
 
1213
-				if (uncle && uncle->GetColor() == _tree_h_red) 
1213
+				if (uncle && uncle->GetColor() == _tree_h_red)
1214 1214
 				{
1215 1215
                // Case 1 - Change the colors
1216 1216
                parent->SetColor(_tree_h_black);
@@ -1240,8 +1240,8 @@ private:
1240 1240
 			else // TreeNode 'tree' is in right subtree
1241 1241
 			{
1242 1242
 				uncle = grandparent->GetLeft();
1243
-								
1244
-				if (uncle && uncle->GetColor() == _tree_h_red) 
1243
+
1244
+				if (uncle && uncle->GetColor() == _tree_h_red)
1245 1245
 				{
1246 1246
                // Case 1 - Change the colors
1247 1247
                parent->SetColor(_tree_h_black);

+ 22
- 22
src/mstl/Vector.h Zobrazit soubor

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Mongoose
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,11 +10,11 @@
10 10
  * Comments: mtk template vector
11 11
  *
12 12
  *           UINT_MAX is an error condition, used in place of -1
13
- * 
14
- *           This file was generated using Mongoose's C++ 
13
+ *
14
+ *           This file was generated using Mongoose's C++
15 15
  *           template generator script.  <stu7440@westga.edu>
16
- * 
17
- *-- History ------------------------------------------------ 
16
+ *
17
+ *-- History ------------------------------------------------
18 18
  *
19 19
  * 2002.08.31:
20 20
  * Mongoose - Created
@@ -84,7 +84,7 @@ public:
84 84
 			delete [] mData;
85 85
 		}
86 86
 
87
-		clear();		
87
+		clear();
88 88
 		mReserve = 0;
89 89
 	}
90 90
 
@@ -116,7 +116,7 @@ public:
116 116
 	{
117 117
 		unsigned int i;
118 118
 		Object *swap = 0x0;
119
-		
119
+
120 120
 
121 121
 		if (count > mReserve)
122 122
 		{
@@ -131,7 +131,7 @@ public:
131 131
 			{
132 132
 				mData[i] = swap[i];
133 133
 			}
134
-			
134
+
135 135
 			delete [] swap;
136 136
 		}
137 137
 	}
@@ -157,7 +157,7 @@ public:
157 157
 				mData[i] = object;
158 158
 			}
159 159
 		}
160
-		
160
+
161 161
 		mEnd = count;
162 162
 	}
163 163
 
@@ -166,7 +166,7 @@ public:
166 166
 	{
167 167
 		pushBack(0x0);
168 168
 	}
169
-	
169
+
170 170
 
171 171
 	void pushBack(Object object)
172 172
 	{
@@ -185,13 +185,13 @@ public:
185 185
 	{
186 186
 		return mReserve;
187 187
 	}
188
-	
188
+
189 189
 
190 190
 	unsigned int begin()
191 191
 	{
192 192
 		return mStart;
193 193
 	}
194
-	
194
+
195 195
 
196 196
 	unsigned int end()
197 197
 	{
@@ -203,7 +203,7 @@ public:
203 203
 	{
204 204
 		return mEnd;
205 205
 	}
206
-	
206
+
207 207
 
208 208
 	void copy(Vector<Object> &vector)
209 209
 	{
@@ -221,7 +221,7 @@ public:
221 221
 		for (i = vector.begin(); i < vector.end(); ++i)
222 222
 		{
223 223
 			mData[i] = vector[i];
224
-			Add(list->Current());
224
+			//Add(list->Current()); // WTFBBQ?
225 225
 		}
226 226
 	}
227 227
 
@@ -230,13 +230,13 @@ public:
230 230
 	{
231 231
 		qsort(mData, end(), sizeof(Object), compareFunc);
232 232
 	}
233
-	
233
+
234 234
 
235 235
 	void swap(unsigned int index, unsigned int index2)
236 236
 	{
237 237
 		if (index < begin() || index > end())
238 238
 			return;
239
-		
239
+
240 240
 		if (index2 < begin() || index2 > end())
241 241
 			return;
242 242
 
@@ -245,7 +245,7 @@ public:
245 245
 		mData[index2] = swap;
246 246
 	}
247 247
 
248
-	
248
+
249 249
 	void assign(unsigned int index, Object object)
250 250
 	{
251 251
 		mData[index] = object;
@@ -254,7 +254,7 @@ public:
254 254
 
255 255
 	Object operator [] (unsigned int index)
256 256
 	{
257
-		if (mData == 0x0 || index < begin() || index > end() || 
257
+		if (mData == 0x0 || index < begin() || index > end() ||
258 258
 			 index >= size() || empty())
259 259
 			return mError;
260 260
 
@@ -276,8 +276,8 @@ public:
276 276
 
277 277
 			fflush(stdout);
278 278
 		}
279
-		
280
-		printf("\n");    
279
+
280
+		printf("\n");
281 281
 	}
282 282
 
283 283
 
@@ -285,7 +285,7 @@ public:
285 285
 
286 286
 	void start(unsigned int index)
287 287
 	{
288
-		if (mData == 0x0 || index < begin() || index > end() || 
288
+		if (mData == 0x0 || index < begin() || index > end() ||
289 289
 			 index >= size() || empty())
290 290
 			return;
291 291
 
@@ -354,7 +354,7 @@ public:
354 354
 		return mData[mIndex];
355 355
 	}
356 356
 
357
-	
357
+
358 358
 	/* Requires objects to support '=='  */
359 359
 	bool find(Object object)
360 360
 	{

+ 31
- 31
src/mtk_tga.cpp Zobrazit soubor

@@ -1,10 +1,10 @@
1 1
 /*================================================================
2
- * 
2
+ *
3 3
  * Project : Freyja
4 4
  * Author  : Mongoose
5 5
  * Website : http://www.westga.edu/~stu7440/
6 6
  * Email   : stu7440@westga.edu
7
- * Object  : 
7
+ * Object  :
8 8
  * License : GPL See file COPYING, also (C) 2000 Mongoose
9 9
  * Comments: TGA plug-in
10 10
  *
@@ -12,10 +12,10 @@
12 12
  *                 2 bits for RGBA | RGB | GREY
13 13
  *                 val for depth
14 14
  *
15
- *           This file was generated using Mongoose's C++ 
15
+ *           This file was generated using Mongoose's C++
16 16
  *           template generator script.  <stu7440@westga.edu>
17
- * 
18
- *-- History ------------------------------------------------ 
17
+ *
18
+ *-- History ------------------------------------------------
19 19
  *
20 20
  * 2001-10-25:
21 21
  * Mongoose - support for screen origin bit
@@ -62,7 +62,7 @@ int mtk_image__tga_check(FILE *f)
62 62
 }
63 63
 
64 64
 
65
-int mtk_image__tga_load(FILE *f, unsigned char **image, 
65
+int mtk_image__tga_load(FILE *f, unsigned char **image,
66 66
 			unsigned int *width, unsigned int *height, char *type)
67 67
 {
68 68
   mtk_image_tga_t header;
@@ -85,7 +85,7 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
85 85
 
86 86
   // Read TGA header
87 87
   fread(&header.comment_lenght, 1, 1, f);
88
-  fread(&header.colormap_type, 1, 1, f); 
88
+  fread(&header.colormap_type, 1, 1, f);
89 89
   fread(&header.image_type, 1, 1, f);
90 90
   fread(&header.colormap_index, 2, 1, f);
91 91
   fread(&header.colormap_lenght, 2, 1, f);
@@ -133,17 +133,17 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
133 133
   }
134 134
 
135 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,  
136
+  printf("TGA [%ix%i@%ibpp, %it, %ix, %iy, %uf]\n",
137
+	 header.width, header.height, header.bpp, header.image_type,
138 138
 	 header.origin_x, header.origin_y,
139 139
 	 header.desc_flags);
140 140
 #endif
141 141
 
142 142
   // Comments can be 0 - 255
143
-  if (header.comment_lenght) 
143
+  if (header.comment_lenght)
144 144
   {
145 145
     fread(&comment, 1, header.comment_lenght, f);
146
-    
146
+
147 147
     for (i = 0; i < 255; ++i)
148 148
     {
149 149
       if (comment[i] > 32 && comment[i] < 127)
@@ -162,7 +162,7 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
162 162
 
163 163
   size = header.width * header.height;
164 164
 
165
-  if (!size || (!(header.colormap_type == 0 && 
165
+  if (!size || (!(header.colormap_type == 0 &&
166 166
 		  (header.image_type == 2 || header.image_type == 10))))
167 167
   {
168 168
     fprintf(stderr, "mtk_image__tga_load> Unknown image format.\n");
@@ -189,7 +189,7 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
189 189
       for (i = 0; i < size;)
190 190
       {
191 191
 	fread(&packet, 1, 1, f);
192
-	
192
+
193 193
 	if (packet & 0x80)  // Run Lenght
194 194
 	{
195 195
 	  packet = (packet &0x7F) + 1;
@@ -207,7 +207,7 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
207 207
 	else // RAW
208 208
 	{
209 209
 	  packet = (packet &0x7F) + 1;
210
-	  
210
+
211 211
 	  for (j = 0; j < packet; j++)
212 212
 	  {
213 213
 	    fread(&pixel, 4, 1, f);
@@ -229,7 +229,7 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
229 229
       }
230 230
 
231 231
       for (i = 0; i < size; i += 4)
232
-      { 
232
+      {
233 233
 	tmp = (*image)[i];
234 234
 	(*image)[i] = (*image)[i + 2];
235 235
 	(*image)[i + 2] = tmp;
@@ -242,15 +242,15 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
242 242
     if (must_flip)
243 243
     {
244 244
       swap_row = new unsigned char [header.width * 4];
245
-      
246
-      for (i = 0, (int)j = header.height-1; (int)i < header.height/2; i++, j--)
245
+
246
+      for (i = 0, j = header.height-1; (int)i < header.height/2; i++, j--)
247 247
       {
248 248
 	memcpy(swap_row, &(*image)[i*header.width*4], header.width*4);
249
-	memcpy(&(*image)[i*header.width*4], &(*image)[j*header.width*4], 
249
+	memcpy(&(*image)[i*header.width*4], &(*image)[j*header.width*4],
250 250
 	       header.width*4);
251 251
 	memcpy(&(*image)[j*header.width*4], swap_row, header.width*4);
252 252
       }
253
-			
253
+
254 254
       delete [] swap_row;
255 255
     }
256 256
     break;
@@ -315,11 +315,11 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
315 315
     if (must_flip)
316 316
     {
317 317
       swap_row = new unsigned char [header.width * 3];
318
-      
318
+
319 319
       for (i = 0, j = header.height - 1; (int)i < header.height / 2; i++, j--)
320 320
       {
321 321
 	memcpy(swap_row, &(*image)[i*header.width*3], header.width*3);
322
-	memcpy(&(*image)[i*header.width*3], &(*image)[j*header.width*3], 
322
+	memcpy(&(*image)[i*header.width*3], &(*image)[j*header.width*3],
323 323
 	       header.width*3);
324 324
 	memcpy(&(*image)[j*header.width*3], swap_row, header.width*3);
325 325
       }
@@ -328,13 +328,13 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
328 328
     }
329 329
 
330 330
     break;
331
-  case 8: 
331
+  case 8:
332 332
     printf("tga_load> 8bpp Not implemented\n");
333 333
     break;
334 334
   default:
335 335
     ;
336 336
   }
337
-    
337
+
338 338
 #ifdef DEBUG_TGA
339 339
   char c;
340 340
 
@@ -348,7 +348,7 @@ int mtk_image__tga_load(FILE *f, unsigned char **image,
348 348
   printf("\n");
349 349
 #endif
350 350
 
351
-  return 0; 
351
+  return 0;
352 352
 }
353 353
 
354 354
 
@@ -356,7 +356,7 @@ int mtk_image__tga_save(FILE *f, unsigned char *image,
356 356
 			unsigned int width, unsigned int height, char type)
357 357
 {
358 358
   mtk_image_tga_t header;
359
-  unsigned int size; 
359
+  unsigned int size;
360 360
   //  unsigned int i;
361 361
   //  unsigned char tmp;
362 362
   char comment[64];
@@ -374,7 +374,7 @@ int mtk_image__tga_save(FILE *f, unsigned char *image,
374 374
 
375 375
   header.comment_lenght = strlen(comment);
376 376
   header.colormap_type = 0;
377
-  
377
+
378 378
   // No colormaps
379 379
   header.colormap_index = 0;
380 380
   header.colormap_lenght = 0;
@@ -405,7 +405,7 @@ int mtk_image__tga_save(FILE *f, unsigned char *image,
405 405
 
406 406
   // Write TGA header
407 407
   fwrite(&header.comment_lenght, 1, 1, f);
408
-  fwrite(&header.colormap_type, 1, 1, f); 
408
+  fwrite(&header.colormap_type, 1, 1, f);
409 409
   fwrite(&header.image_type, 1, 1, f);
410 410
   fwrite(&header.colormap_index, 2, 1, f);
411 411
   fwrite(&header.colormap_lenght, 2, 1, f);
@@ -426,7 +426,7 @@ int mtk_image__tga_save(FILE *f, unsigned char *image,
426 426
   {
427 427
   case 32:
428 428
     size = header.width * header.height * 4;
429
- 
429
+
430 430
     //for (i = 0; i < size; i += 4)
431 431
     //{
432 432
     //  tmp = image[i];
@@ -436,7 +436,7 @@ int mtk_image__tga_save(FILE *f, unsigned char *image,
436 436
     break;
437 437
   case 24:
438 438
     size = header.width * header.height * 3;
439
- 
439
+
440 440
     //for (i = 0; i < size; i += 3)
441 441
     //{
442 442
     //  tmp = image[i];
@@ -474,7 +474,7 @@ int mtk_image__tga_save_filename(unsigned char *image,
474 474
   va_start(args, s);
475 475
   vsnprintf(buffer, 1023, s, args);
476 476
   va_end(args);
477
-  
477
+
478 478
   f = fopen(buffer, "wb");
479 479
 
480 480
   if (!f)
@@ -496,7 +496,7 @@ int main(int argc, char *argv[])
496 496
   FILE *f;
497 497
   unsigned char *image;
498 498
   unsigned int width;
499
-  unsigned int height; 
499
+  unsigned int height;
500 500
   char type;
501 501
 
502 502
   if (argc > 1)

Loading…
Zrušit
Uložit