Browse Source

Added stub for missing hel/CollisionObject.

Now compiles on OS X, but segfaults at launch...
Thomas Buck 10 years ago
parent
commit
3f365336f9
33 changed files with 2380 additions and 2142 deletions
  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 View File

1
+.DS_Store

+ 10
- 10
Makefile View File

29
 # -DMULTITEXTURE		Add OpenGL multitexturing
29
 # -DMULTITEXTURE		Add OpenGL multitexturing
30
 # -DUNICODE_SUPPORT		Add unicode/internation keyboard support
30
 # -DUNICODE_SUPPORT		Add unicode/internation keyboard support
31
 # -DUSING_EMITTER_IN_GAME	Run particle test in game
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
 	-DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
33
 	-DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
34
 	-DUSING_OPENAL -DUSING_MTK_TGA -DUSING_PTHREADS \
34
 	-DUSING_OPENAL -DUSING_MTK_TGA -DUSING_PTHREADS \
35
 	-DUSING_HEL -DHAVE_SDL_TTF -DHAVE_OPENGL
35
 	-DUSING_HEL -DHAVE_SDL_TTF -DHAVE_OPENGL
36
 
36
 
37
 BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
37
 BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
38
-	-lopenal -lpthread -lSDL_ttf
38
+	-lpthread -lSDL_ttf
39
 
39
 
40
 # -DDEBUG_GL
40
 # -DDEBUG_GL
41
 DEBUG_DEFS=-DDEBUG -DEXPERIMENTAL
41
 DEBUG_DEFS=-DDEBUG -DEXPERIMENTAL
43
 
43
 
44
 ###############################################################
44
 ###############################################################
45
 # OpenAL, Sound support
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
 # libferit, File transfer via HTTP/FTP/etc support
49
 # libferit, File transfer via HTTP/FTP/etc support
50
 LIBFERIT_LIB=/usr/local/lib/libferit.so
50
 LIBFERIT_LIB=/usr/local/lib/libferit.so
77
 ###############################################################
77
 ###############################################################
78
 CC=gcc
78
 CC=gcc
79
 
79
 
80
-BASE_CFLAGS=-Wall -Isrc $(BASE_DEFS) \
80
+BASE_CFLAGS=-Wall $(BASE_DEFS) \
81
 	-DVERSION=\"\\\"$(NAME)-$(VERSION)-$(BUILD_ID)\\\"\" \
81
 	-DVERSION=\"\\\"$(NAME)-$(VERSION)-$(BUILD_ID)\\\"\" \
82
 	-DBUILD_HOST=\"\\\"$(BUILD_HOST)\\\"\"
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
 	-lGL -lGLU -lm $(BASE_LIBS)
85
 	-lGL -lGLU -lm $(BASE_LIBS)
86
 
86
 
87
 RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
87
 RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
160
 	$(BUILDDIR)/Vector3d.o \
160
 	$(BUILDDIR)/Vector3d.o \
161
 	$(BUILDDIR)/Matrix.o \
161
 	$(BUILDDIR)/Matrix.o \
162
 	$(BUILDDIR)/ViewVolume.o \
162
 	$(BUILDDIR)/ViewVolume.o \
163
-	$(BUILDDIR)/Spring.o \
164
 	$(BUILDDIR)/CollisionObject.o \
163
 	$(BUILDDIR)/CollisionObject.o \
165
 	$(BUILDDIR)/BoundingVolume.o \
164
 	$(BUILDDIR)/BoundingVolume.o \
166
 	$(BUILDDIR)/Quaternion.o \
165
 	$(BUILDDIR)/Quaternion.o \
167
-	$(BUILDDIR)/math.o
168
-
166
+	$(BUILDDIR)/math.o \
167
+	$(BUILDDIR)/Entity.o
168
+	#$(BUILDDIR)/Spring.o
169
 
169
 
170
 OBJS = \
170
 OBJS = \
171
 	$(DEBUG_OBJ) \
171
 	$(DEBUG_OBJ) \
498
 	CFLAGS="-Wall -O0 -g -Isrc -DUNIT_TEST_UTPACKAGE -DUSING_MTK_TGA" \
498
 	CFLAGS="-Wall -O0 -g -Isrc -DUNIT_TEST_UTPACKAGE -DUSING_MTK_TGA" \
499
 	LD_FLAGS="-lm -lstdc++"
499
 	LD_FLAGS="-lm -lstdc++"
500
 
500
 
501
-#################################################################
501
+#################################################################

+ 7
- 8
deps.sh View File

3
 # Call it passing CFLAGS and a source filename
3
 # Call it passing CFLAGS and a source filename
4
 # to generate a dep line
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 View File

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

+ 55
- 55
src/Camera.h View File

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

+ 28
- 23
src/Emitter.cpp View File

1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
 /*================================================================
2
 /*================================================================
3
- * 
3
+ *
4
  * Project : Freyja
4
  * Project : Freyja
5
  * Author  : Terry 'Mongoose' Hendrix II
5
  * Author  : Terry 'Mongoose' Hendrix II
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
10
  * Comments: Particle emitter for freyja
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
  *           template generator script.  <stu7440@westga.edu>
14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17
  *
17
  *
18
  * 2001.06.30:
18
  * 2001.06.30:
19
  * Mongoose - Created
19
  * Mongoose - Created
22
 #include <stdlib.h>
22
 #include <stdlib.h>
23
 #include <string.h>
23
 #include <string.h>
24
 #include <stdio.h>
24
 #include <stdio.h>
25
+#ifdef __APPLE__
26
+#include <OpenGL/gl.h>
27
+#include <OpenGL/glu.h>
28
+#else
25
 #include <GL/gl.h>
29
 #include <GL/gl.h>
26
 #include <GL/glu.h>
30
 #include <GL/glu.h>
31
+#endif
27
 #include "Emitter.h"
32
 #include "Emitter.h"
28
 
33
 
29
 #ifdef DEBUG_MEMEORY
34
 #ifdef DEBUG_MEMEORY
42
 		return -1; // error really
47
 		return -1; // error really
43
 
48
 
44
 	a->Pos(&x, &y, &z);
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
 				Emitter::mFrustum[5][3]);
53
 				Emitter::mFrustum[5][3]);
49
 
54
 
50
 	b->Pos(&x, &y, &z);
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
 				Emitter::mFrustum[5][3]);
59
 				Emitter::mFrustum[5][3]);
55
 
60
 
56
 	// reverse less/greater than
61
 	// reverse less/greater than
193
 {
198
 {
194
 	unsigned int i;
199
 	unsigned int i;
195
 
200
 
196
-	
201
+
197
 	for (i = 0; i < _count; i++)
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
 								unsigned int particle_end, int id)
208
 								unsigned int particle_end, int id)
204
 {
209
 {
205
 	unsigned int i;
210
 	unsigned int i;
210
 		 (particle_start < particle_end))
215
 		 (particle_start < particle_end))
211
 	{
216
 	{
212
 		for (i = particle_start; i < particle_end; i++)
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
 						  float r, float g, float b)
224
 						  float r, float g, float b)
220
 {
225
 {
221
 	unsigned int i;
226
 	unsigned int i;
226
 		 (particle_start < particle_end))
231
 		 (particle_start < particle_end))
227
 	{
232
 	{
228
 		for (i = particle_start; i < particle_end; i++)
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
 						  float x, float y, float z)
240
 						  float x, float y, float z)
236
 {
241
 {
237
 	unsigned int i;
242
 	unsigned int i;
242
 		 (particle_start < particle_end))
247
 		 (particle_start < particle_end))
243
 	{
248
 	{
244
 		for (i = particle_start; i < particle_end; i++)
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
 						  float x, float y, float z)
256
 						  float x, float y, float z)
252
 {
257
 {
253
 	unsigned int i;
258
 	unsigned int i;
258
 		 (particle_start < particle_end))
263
 		 (particle_start < particle_end))
259
 	{
264
 	{
260
 		for (i = particle_start; i < particle_end; i++)
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
 			{
304
 			{
300
 				for (p = 0; p < 6; ++p)
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
 						 mFrustum[p][3] < 0)
310
 						 mFrustum[p][3] < 0)
306
 					{
311
 					{
307
 						_particle[i].setActive(false);
312
 						_particle[i].setActive(false);

+ 40
- 36
src/GLString.cpp View File

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

+ 14
- 8
src/GLUTSystem.cpp View File

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

+ 10
- 10
src/Light.h View File

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

+ 90
- 86
src/Md3.cpp View File

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

+ 120
- 116
src/Md3AnimModel.cpp View File

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

+ 45
- 41
src/OpenGLMesh.cpp View File

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

+ 60
- 60
src/OpenGLMesh.h View File

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

+ 59
- 59
src/OpenRaider.h View File

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

+ 162
- 157
src/PSKModel.cpp View File

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

+ 31
- 31
src/Particle.h View File

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

+ 159
- 154
src/Render.cpp
File diff suppressed because it is too large
View File


+ 73
- 73
src/Render.h View File

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

+ 31
- 26
src/SDLSystem.cpp View File

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

+ 24
- 19
src/SDLUnitTest.cpp View File

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

+ 12
- 12
src/SkeletalModel.h View File

1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
 /*================================================================
2
 /*================================================================
3
- * 
3
+ *
4
  * Project : OpenRaider
4
  * Project : OpenRaider
5
  * Author  : Terry 'Mongoose' Hendrix II
5
  * Author  : Terry 'Mongoose' Hendrix II
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
10
  * Comments: This is the factored out skeletal model class
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
  *           template generator script.  <stu7440@westga.edu>
14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
15
+ *
16
  *-- Test Defines -----------------------------------------------
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
  * 2003.05.19:
22
  * 2003.05.19:
23
  * Mongoose - Created
23
  * Mongoose - Created
24
  ================================================================*/
24
  ================================================================*/
25
 
25
 
26
-// TODO 
26
+// TODO
27
 // Start cutting off old hacks by simple force use of method interface
27
 // Start cutting off old hacks by simple force use of method interface
28
 // Also move the publicly exposed attributes out  =)
28
 // Also move the publicly exposed attributes out  =)
29
 // Better animation system in general - this is memory wasteful
29
 // Better animation system in general - this is memory wasteful
31
 #ifndef GUARD__OPENRAIDER_MONGOOSE_SKELETALMODEL_H_
31
 #ifndef GUARD__OPENRAIDER_MONGOOSE_SKELETALMODEL_H_
32
 #define GUARD__OPENRAIDER_MONGOOSE_SKELETALMODEL_H_
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
 typedef struct bone_tag_s
38
 typedef struct bone_tag_s
90
 
90
 
91
 	SkeletalModel();
91
 	SkeletalModel();
92
 	/*------------------------------------------------------
92
 	/*------------------------------------------------------
93
-	 * Pre  : 
93
+	 * Pre  :
94
 	 * Post : Constructs an object of SkeletalModel
94
 	 * Post : Constructs an object of SkeletalModel
95
 	 *
95
 	 *
96
 	 *-- History ------------------------------------------
96
 	 *-- History ------------------------------------------
97
 	 *
97
 	 *
98
-	 * 2003.05.19: 
98
+	 * 2003.05.19:
99
 	 * Mongoose - Created
99
 	 * Mongoose - Created
100
 	 ------------------------------------------------------*/
100
 	 ------------------------------------------------------*/
101
 
101
 
106
 	 *
106
 	 *
107
 	 *-- History ------------------------------------------
107
 	 *-- History ------------------------------------------
108
 	 *
108
 	 *
109
-	 * 2003.05.19: 
109
+	 * 2003.05.19:
110
 	 * Mongoose - Created
110
 	 * Mongoose - Created
111
 	 ------------------------------------------------------*/
111
 	 ------------------------------------------------------*/
112
 
112
 

+ 18
- 13
src/Sound.cpp View File

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

+ 54
- 49
src/System.cpp View File

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

+ 81
- 81
src/System.h View File

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

+ 97
- 92
src/Texture.cpp View File

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

+ 730
- 730
src/TombRaider.cpp
File diff suppressed because it is too large
View File


+ 47
- 47
src/World.h View File

1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
 /*================================================================
2
 /*================================================================
3
- * 
3
+ *
4
  * Project : OpenRaider
4
  * Project : OpenRaider
5
  * Author  : Terry 'Mongoose' Hendrix II
5
  * Author  : Terry 'Mongoose' Hendrix II
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
10
  * Comments: The game world ( model )
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
  *           template generator script.  <stu7440@westga.edu>
14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
15
+ *
16
  *-- Test Defines -----------------------------------------------
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
  * 2002.12.16:
22
  * 2002.12.16:
23
  * Mongoose - Created
23
  * Mongoose - Created
33
 #   include "SkeletalModel.h"
33
 #   include "SkeletalModel.h"
34
 #endif
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
 // Mirrors TombRaider class' room flags really
42
 // Mirrors TombRaider class' room flags really
86
 
86
 
87
 typedef struct sprite_s
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
 	vertex_t vertex[4];
90
 	vertex_t vertex[4];
91
 	texel_t texel[4];
91
 	texel_t texel[4];
92
 	float pos[3];
92
 	float pos[3];
93
 	float radius; // yeah, I know
93
 	float radius; // yeah, I know
94
-	int texture;	
94
+	int texture;
95
 
95
 
96
 } sprite_t;
96
 } sprite_t;
97
 
97
 
177
 	int index;     // model_mesh index
177
 	int index;     // model_mesh index
178
 	float yaw;     // angle of rotation on Y
178
 	float yaw;     // angle of rotation on Y
179
 	float pos[3];  // position
179
 	float pos[3];  // position
180
-	
180
+
181
 	//vec3_t bboxMax;
181
 	//vec3_t bboxMax;
182
 	//vec3_t bboxMin;
182
 	//vec3_t bboxMin;
183
 
183
 
234
 
234
 
235
 
235
 
236
 // Workout generic entity and a client class from these entities
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
 	vec3_t pos;
239
 	vec3_t pos;
240
 	vec3_t lastPos;
240
 	vec3_t lastPos;
249
 } world_entity_t;
249
 } world_entity_t;
250
 
250
 
251
 
251
 
252
-typedef struct actor_entity_s 
252
+typedef struct actor_entity_s
253
 {
253
 {
254
 	vec3_t pos;
254
 	vec3_t pos;
255
 	vec3_t lastPos;
255
 	vec3_t lastPos;
305
 
305
 
306
 	World();
306
 	World();
307
 	/*------------------------------------------------------
307
 	/*------------------------------------------------------
308
-	 * Pre  : 
308
+	 * Pre  :
309
 	 * Post : Constructs an object of World
309
 	 * Post : Constructs an object of World
310
 	 *
310
 	 *
311
 	 *-- History ------------------------------------------
311
 	 *-- History ------------------------------------------
312
 	 *
312
 	 *
313
-	 * 2002.12.16: 
313
+	 * 2002.12.16:
314
 	 * Mongoose - Created
314
 	 * Mongoose - Created
315
 	 ------------------------------------------------------*/
315
 	 ------------------------------------------------------*/
316
 
316
 
321
 	 *
321
 	 *
322
 	 *-- History ------------------------------------------
322
 	 *-- History ------------------------------------------
323
 	 *
323
 	 *
324
-	 * 2002.12.16: 
324
+	 * 2002.12.16:
325
 	 * Mongoose - Created
325
 	 * Mongoose - Created
326
 	 ------------------------------------------------------*/
326
 	 ------------------------------------------------------*/
327
 
327
 
341
 	 *-- History ------------------------------------------
341
 	 *-- History ------------------------------------------
342
 	 *
342
 	 *
343
 	 * 2002.12.20:
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
 	int getRoomByLocation(float x, float y, float z);
347
 	int getRoomByLocation(float x, float y, float z);
348
 	/*------------------------------------------------------
348
 	/*------------------------------------------------------
349
-	 * Pre  : 
349
+	 * Pre  :
350
 	 * Post : Returns correct room index or -1 for unknown
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
 	 *        closest overlapping room
353
 	 *        closest overlapping room
354
 	 *
354
 	 *
355
 	 *-- History ------------------------------------------
355
 	 *-- History ------------------------------------------
356
 	 *
356
 	 *
357
 	 * 2002.12.20:
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
 								float x, float y, float z,
362
 								float x, float y, float z,
363
 								float x2, float y2, float z2);
363
 								float x2, float y2, float z2);
364
 	/*------------------------------------------------------
364
 	/*------------------------------------------------------
365
-	 * Pre  : 
365
+	 * Pre  :
366
 	 * Post : Looks for portal crossings from xyz to xyz2 segment
366
 	 * Post : Looks for portal crossings from xyz to xyz2 segment
367
 	 *        from room[index] returns index of adjoined room or -1
367
 	 *        from room[index] returns index of adjoined room or -1
368
 	 *
368
 	 *
381
 	 *-- History ------------------------------------------
381
 	 *-- History ------------------------------------------
382
 	 *
382
 	 *
383
 	 * 2002.12.20:
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
 	unsigned int getRoomInfo(int room);
387
 	unsigned int getRoomInfo(int room);
388
 	/*------------------------------------------------------
388
 	/*------------------------------------------------------
389
-	 * Pre  : 
390
-	 * Post : 
389
+	 * Pre  :
390
+	 * Post :
391
 	 *
391
 	 *
392
 	 *-- History ------------------------------------------
392
 	 *-- History ------------------------------------------
393
 	 *
393
 	 *
404
 	 *-- History ------------------------------------------
404
 	 *-- History ------------------------------------------
405
 	 *
405
 	 *
406
 	 * 2002.12.20:
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
 	bool getHeightAtPosition(int index, float x, float *y, float z);
410
 	bool getHeightAtPosition(int index, float x, float *y, float z);
416
 	 *-- History ------------------------------------------
416
 	 *-- History ------------------------------------------
417
 	 *
417
 	 *
418
 	 * 2002.12.20:
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
 	// Temp methods for rendering use until more refactoring is done
422
 	// Temp methods for rendering use until more refactoring is done
432
 	////////////////////////////////////////////////////////////
432
 	////////////////////////////////////////////////////////////
433
 	// Public Mutators
433
 	// Public Mutators
434
 	////////////////////////////////////////////////////////////
434
 	////////////////////////////////////////////////////////////
435
-	
435
+
436
 	void setFlag(WorldFlag flag);
436
 	void setFlag(WorldFlag flag);
437
 	/*------------------------------------------------------
437
 	/*------------------------------------------------------
438
-	 * Pre  : 
438
+	 * Pre  :
439
 	 * Post : Sets option flag
439
 	 * Post : Sets option flag
440
 	 *
440
 	 *
441
 	 *-- History ------------------------------------------
441
 	 *-- History ------------------------------------------
442
 	 *
442
 	 *
443
 	 * 2002.12.20:
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
 	void clearFlag(WorldFlag flag);
447
 	void clearFlag(WorldFlag flag);
448
 	/*------------------------------------------------------
448
 	/*------------------------------------------------------
449
-	 * Pre  : 
449
+	 * Pre  :
450
 	 * Post : Clears option flag
450
 	 * Post : Clears option flag
451
 	 *
451
 	 *
452
 	 *-- History ------------------------------------------
452
 	 *-- History ------------------------------------------
453
 	 *
453
 	 *
454
 	 * 2002.12.20:
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
 	void destroy();
458
 	void destroy();
459
 	/*------------------------------------------------------
459
 	/*------------------------------------------------------
460
-	 * Pre  : 
460
+	 * Pre  :
461
 	 * Post : Clears all data in world, in future will check
461
 	 * Post : Clears all data in world, in future will check
462
 	 *        if data is in use before clearing
462
 	 *        if data is in use before clearing
463
 	 *
463
 	 *
469
 
469
 
470
 	void addRoom(room_mesh_t *room);
470
 	void addRoom(room_mesh_t *room);
471
 	/*------------------------------------------------------
471
 	/*------------------------------------------------------
472
-	 * Pre  : 
472
+	 * Pre  :
473
 	 * Post : Adds object to world
473
 	 * Post : Adds object to world
474
 	 *
474
 	 *
475
 	 *-- History ------------------------------------------
475
 	 *-- History ------------------------------------------
476
 	 *
476
 	 *
477
 	 * 2002.12.20:
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
 	void addMesh(model_mesh_t *model);
481
 	void addMesh(model_mesh_t *model);
482
 	/*------------------------------------------------------
482
 	/*------------------------------------------------------
483
-	 * Pre  : 
483
+	 * Pre  :
484
 	 * Post : Adds object to world
484
 	 * Post : Adds object to world
485
 	 *
485
 	 *
486
 	 *-- History ------------------------------------------
486
 	 *-- History ------------------------------------------
487
 	 *
487
 	 *
488
 	 * 2002.12.20:
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
 	void addEntity(entity_t *e);
492
 	void addEntity(entity_t *e);
493
 	/*------------------------------------------------------
493
 	/*------------------------------------------------------
494
-	 * Pre  : 
494
+	 * Pre  :
495
 	 * Post : Adds object to world
495
 	 * Post : Adds object to world
496
 	 *
496
 	 *
497
 	 *-- History ------------------------------------------
497
 	 *-- History ------------------------------------------
498
 	 *
498
 	 *
499
 	 * 2002.12.20:
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
 	int addModel(skeletal_model_t *model);
503
 	int addModel(skeletal_model_t *model);
504
 	/*------------------------------------------------------
504
 	/*------------------------------------------------------
505
-	 * Pre  : 
505
+	 * Pre  :
506
 	 * Post : Adds object to world, returns next model Id
506
 	 * Post : Adds object to world, returns next model Id
507
 	 *        or -1 if failed to add model to world
507
 	 *        or -1 if failed to add model to world
508
 	 *
508
 	 *
509
 	 *-- History ------------------------------------------
509
 	 *-- History ------------------------------------------
510
 	 *
510
 	 *
511
 	 * 2002.12.20:
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
 	void addSprite(sprite_seq_t *sprite);
515
 	void addSprite(sprite_seq_t *sprite);
516
 	/*------------------------------------------------------
516
 	/*------------------------------------------------------
517
-	 * Pre  : 
517
+	 * Pre  :
518
 	 * Post : Adds object to world
518
 	 * Post : Adds object to world
519
 	 *
519
 	 *
520
 	 *-- History ------------------------------------------
520
 	 *-- History ------------------------------------------
521
 	 *
521
 	 *
522
 	 * 2002.12.20:
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
 	void moveEntity(entity_t *e, char movement);
526
 	void moveEntity(entity_t *e, char movement);
556
 
556
 
557
 	void clear();
557
 	void clear();
558
 	/*------------------------------------------------------
558
 	/*------------------------------------------------------
559
-	 * Pre  : 
559
+	 * Pre  :
560
 	 * Post : Clears all data in world
560
 	 * Post : Clears all data in world
561
 	 *
561
 	 *
562
 	 *-- History ------------------------------------------
562
 	 *-- History ------------------------------------------

+ 84
- 0
src/hel/CollisionObject.cpp View File

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 View File

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 View File

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

+ 53
- 53
src/mstl/Tree.h View File

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

+ 22
- 22
src/mstl/Vector.h View File

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

+ 31
- 31
src/mtk_tga.cpp View File

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

Loading…
Cancel
Save