Browse Source

Simulation builds

Thomas Buck 11 years ago
parent
commit
6e04a4163f
9 changed files with 48 additions and 43 deletions
  1. 3
    0
      ChangeLog
  2. 9
    0
      Makefile
  3. 1
    1
      README.md
  4. 2
    0
      src/SDLUnitTest.cpp
  5. 2
    0
      src/Sound.cpp
  6. 2
    0
      src/TombRaider.cpp
  7. 1
    20
      src/hel/CollisionObject.cpp
  8. 5
    0
      src/hel/CollisionObject.h
  9. 23
    22
      src/hel/Simulation.cpp

+ 3
- 0
ChangeLog View File

@@ -5,6 +5,9 @@
5 5
 
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8
+	[ 20140106 ]
9
+	* Hel Simulation Test builds, but doesn't work!
10
+
8 11
 	[ 20140105 ]
9 12
 	* Fixed the TR2 & TR3 SFX file loading to read the original MAIN.SFX
10 13
 	* Fixed strange Mouse Y-Axis Overflow bug

+ 9
- 0
Makefile View File

@@ -350,12 +350,21 @@ SIMULATION_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
350 350
 		$(BUILD_TEST_DIR)/Quaternion.o \
351 351
 		$(BUILD_TEST_DIR)/math.o
352 352
 
353
+ifeq ($(UNAME),Darwin)
354
+Simulation.test:
355
+	mkdir -p $(BUILD_TEST_DIR)
356
+	$(MAKE) targets NAME=Simulation.test BUILDDIR=$(BUILD_TEST_DIR) \
357
+		OBJS="$(SIMULATION_OBJS)" \
358
+		CFLAGS="$(SIMULATION_CFLAGS)" \
359
+		LD_FLAGS="-lm -lstdc++ -lSDL_ttf -lSDL -framework OpenGL -framework GLUT $(shell sdl-config --libs)"
360
+else
353 361
 Simulation.test:
354 362
 	mkdir -p $(BUILD_TEST_DIR)
355 363
 	$(MAKE) targets NAME=Simulation.test BUILDDIR=$(BUILD_TEST_DIR) \
356 364
 		OBJS="$(SIMULATION_OBJS)" \
357 365
 		CFLAGS="$(SIMULATION_CFLAGS)" \
358 366
 		LD_FLAGS="-lm -lstdc++ -lSDL_ttf -lSDL -lGL -lGLU $(shell sdl-config --libs)"
367
+endif
359 368
 
360 369
 #################################################################
361 370
 

+ 1
- 1
README.md View File

@@ -72,4 +72,4 @@ OpenRaider is based on code, specs, and alogrithms from:
72 72
 
73 73
 All code should be GPLed, unless otherwise noted.
74 74
 
75
-2013 improvements & clean-up by xythobuz.
75
+2013, 2014 improvements & clean-up by xythobuz.

+ 2
- 0
src/SDLUnitTest.cpp View File

@@ -455,6 +455,7 @@ int main_gl(int argc, char *argv[])
455 455
   SDL_Init(SDL_INIT_VIDEO);
456 456
   printf("\n@Created OpenGL Context...\n");
457 457
 
458
+#ifndef __APPLE__
458 459
   if (!driver || !driver[0] || SDL_GL_LoadLibrary(driver) < 0)
459 460
   {
460 461
 	  SDL_ClearError();
@@ -473,6 +474,7 @@ int main_gl(int argc, char *argv[])
473 474
 		  }
474 475
 	  }
475 476
   }
477
+#endif
476 478
 
477 479
   flags = SDL_OPENGL;
478 480
 

+ 2
- 0
src/Sound.cpp View File

@@ -18,6 +18,8 @@
18 18
 #include <AL/alc.h>
19 19
 #include <AL/alut.h>
20 20
 #endif
21
+#else
22
+#warning "No OpenAL support. Won't play sound!"
21 23
 #endif
22 24
 
23 25
 #include <time.h>

+ 2
- 0
src/TombRaider.cpp View File

@@ -53,6 +53,8 @@
53 53
 
54 54
 #ifdef ZLIB_SUPPORT
55 55
 #   include "zlib.h"
56
+#else
57
+#warning "No zlib. Won't support TR4+ files!"
56 58
 #endif
57 59
 
58 60
 #ifdef __TEST_TR5_DUMP_TGA

+ 1
- 20
src/hel/CollisionObject.cpp View File

@@ -42,25 +42,6 @@ bool CollisionObject::intersectPoint(Vector3d p) {
42 42
 ////////////////////////////////////////////////////////////
43 43
 
44 44
 
45
-////////////////////////////////////////////////////////////
46
-// Unit Test code
47
-////////////////////////////////////////////////////////////
48
-
49
-#ifdef UNIT_TEST_CollisionObject
50
-int runCollisionObjectUnitTest()
51
-{
52
-	CollisionObject col;
53
-
54
-	return 0;
55
-}
56
-
57
-
58
-int main(int argc, char *argv[])
59
-{
60
-	printf("[CollisionObject class test]\n");
61
-
62
-	runCollisionObjectUnitTest();
45
+HeightCollisionObject::HeightCollisionObject(int a, int b) {
63 46
 
64
-	return 0;
65 47
 }
66
-#endif

+ 5
- 0
src/hel/CollisionObject.h View File

@@ -54,4 +54,9 @@ class CollisionObject
54 54
 	/* */
55 55
 };
56 56
 
57
+class HeightCollisionObject : public CollisionObject {
58
+public:
59
+    HeightCollisionObject(int a, int b);
60
+};
61
+
57 62
 #endif

+ 23
- 22
src/hel/Simulation.cpp View File

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Hel
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,15 +10,16 @@
10 10
  * Comments: This class simulates mass physics
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2003.06.02:
19 19
  * Mongoose - Created, based on algorithms from Erkin Tunca
20 20
  =================================================================*/
21 21
 
22
+#include <math.h>
22 23
 #include "Simulation.h"
23 24
 
24 25
 
@@ -72,7 +73,7 @@ bool Simulation::collisionDetected(Mass *mass)
72 73
 	{
73 74
 		if ((mObjects.current())->intersectPoint(mass->mPos))
74 75
 		{
75
-			detected = true; 
76
+			detected = true;
76 77
 			resolveCollision(mass, mObjects.current());
77 78
 		}
78 79
 	}
@@ -88,7 +89,7 @@ void Simulation::generateMasses(unsigned int count, vec_t mass)
88 89
 
89 90
 
90 91
 void Simulation::generateMasses(unsigned int count, vec_t mass,
91
-										  const Vector3d &position, 
92
+										  const Vector3d &position,
92 93
 										  const Vector3d &velocity)
93 94
 {
94 95
 	unsigned int i;
@@ -205,7 +206,7 @@ void renderScene(float time, float lastTime)
205 206
 	//glColor4f(mColor, g, b, life);
206 207
 
207 208
 	// Render tristrip quad
208
-	for (gEmitter->mMasses.start(); gEmitter->mMasses.forward(); 
209
+	for (gEmitter->mMasses.start(); gEmitter->mMasses.forward();
209 210
 		  gEmitter->mMasses.next())
210 211
 	{
211 212
 		m = gEmitter->mMasses.current();
@@ -241,19 +242,19 @@ void renderScene(float time, float lastTime)
241 242
 			z = m->mPos.mVec[2];
242 243
 
243 244
 			glBegin(GL_TRIANGLE_STRIP);
244
-			
245
+
245 246
 			glTexCoord2d(1.0, 1.0);
246 247
 			glVertex3f(x + 25, y + 25, z);
247
-			
248
+
248 249
 			glTexCoord2d(0.0, 1.0);
249 250
 			glVertex3f(x - 25, y + 25, z);
250
-			
251
+
251 252
 			glTexCoord2d(1.0, 0.0);
252 253
 			glVertex3f(x + 25, y - 25, z);
253
-			
254
+
254 255
 			glTexCoord2d(0.0, 0.0);
255 256
 			glVertex3f(x - 25, y - 25, z);
256
-			
257
+
257 258
 			glEnd();
258 259
 		}
259 260
 	}
@@ -261,7 +262,7 @@ void renderScene(float time, float lastTime)
261 262
 #else
262 263
 	glBegin(GL_POINTS);
263 264
 
264
-	for (gEmitter.mMasses.start(); gEmitter.mMasses.forward(); 
265
+	for (gEmitter.mMasses.start(); gEmitter.mMasses.forward();
265 266
 		  gEmitter.mMasses.next())
266 267
 	{
267 268
 		m = gEmitter.mMasses.current();
@@ -295,10 +296,10 @@ void handleKey(int key)
295 296
 	case 'r':
296 297
 		gGravityEmitter.clear();
297 298
 
298
-		gGravityEmitter.generateMasses(1, 1.0f, 
299
+		gGravityEmitter.generateMasses(1, 1.0f,
299 300
 												 Vector3d(0.0f, 0.0f, 0.0f),
300 301
 												 Vector3d(0.0f, 96.0f, -64.0f));
301
-		gGravityEmitter.generateMasses(1, 1.0f, 
302
+		gGravityEmitter.generateMasses(1, 1.0f,
302 303
 												 Vector3d(-128.0f, 0.0f, 0.0f),
303 304
 												 Vector3d(32.0f, 96.0f, 0.0f));
304 305
 		gGravityEmitter.generateMasses(1, 1.0f,
@@ -402,18 +403,18 @@ int runSimulationUnitTest(int argc, char *argv[])
402 403
 
403 404
 	// Masses created above the origin, traveling down on Y axis
404 405
 	// as if it where in a vacuum pulled by gravity
405
-	gGravityEmitter.generateMasses(1, 1.0f, 
406
+	gGravityEmitter.generateMasses(1, 1.0f,
406 407
 											 Vector3d(0.0f, 0.0f, 0.0f),
407 408
 											 Vector3d(0.0f, 96.0f, 0.0f));
408
-	gGravityEmitter.generateMasses(1, 1.0f, 
409
+	gGravityEmitter.generateMasses(1, 1.0f,
409 410
 											 Vector3d(-64.0f, 1424.0f, 0.0f),
410 411
 											 Vector3d(-9.8f, 0.0f, 0.0f));
411 412
 	gGravityEmitter.generateMasses(1, 1.0f,
412 413
 											 Vector3d(64.0f, 1424.0f, 0.0f),
413 414
 											 Vector3d(9.8f, 0.0f, 0.0f));
414 415
 
415
-	//InternalBBoxCollisionObject *obj = 
416
-	//new InternalBBoxCollisionObject(-9999, 0, -9999, 
416
+	//InternalBBoxCollisionObject *obj =
417
+	//new InternalBBoxCollisionObject(-9999, 0, -9999,
417 418
 	//										 9999, 9999, 9999);
418 419
 
419 420
 	HeightCollisionObject *obj = new HeightCollisionObject(0, 9999);
@@ -425,13 +426,13 @@ int runSimulationUnitTest(int argc, char *argv[])
425 426
 	// Spring
426 427
 	gSpringEmitter.connectionPos = Vector3d(0.0f, 200.0f, 0.0f);
427 428
 	gSpringEmitter.springConstant = 0.3f;
428
-	gSpringEmitter.generateMasses(1, 0.5f, 
429
+	gSpringEmitter.generateMasses(1, 0.5f,
429 430
 											Vector3d(0.0f, -512.0f, 0.0f),
430 431
 											Vector3d(3.0f, 0.0f, 0.0f));
431
-	gSpringEmitter.generateMasses(1, 0.5f, 
432
+	gSpringEmitter.generateMasses(1, 0.5f,
432 433
 											Vector3d(-512.0f, -128.0f, 0.0f),
433 434
 											Vector3d(0.0f, 3.0f, 0.0f));
434
-	gSpringEmitter.generateMasses(1, 0.5f, 
435
+	gSpringEmitter.generateMasses(1, 0.5f,
435 436
 											Vector3d(512.0f, -128.0f, 0.0f),
436 437
 											Vector3d(0.0f, 0.0f, 0.3f));
437 438
 

Loading…
Cancel
Save