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

+ 9
- 0
Makefile View File

350
 		$(BUILD_TEST_DIR)/Quaternion.o \
350
 		$(BUILD_TEST_DIR)/Quaternion.o \
351
 		$(BUILD_TEST_DIR)/math.o
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
 Simulation.test:
361
 Simulation.test:
354
 	mkdir -p $(BUILD_TEST_DIR)
362
 	mkdir -p $(BUILD_TEST_DIR)
355
 	$(MAKE) targets NAME=Simulation.test BUILDDIR=$(BUILD_TEST_DIR) \
363
 	$(MAKE) targets NAME=Simulation.test BUILDDIR=$(BUILD_TEST_DIR) \
356
 		OBJS="$(SIMULATION_OBJS)" \
364
 		OBJS="$(SIMULATION_OBJS)" \
357
 		CFLAGS="$(SIMULATION_CFLAGS)" \
365
 		CFLAGS="$(SIMULATION_CFLAGS)" \
358
 		LD_FLAGS="-lm -lstdc++ -lSDL_ttf -lSDL -lGL -lGLU $(shell sdl-config --libs)"
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
 
72
 
73
 All code should be GPLed, unless otherwise noted.
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
   SDL_Init(SDL_INIT_VIDEO);
455
   SDL_Init(SDL_INIT_VIDEO);
456
   printf("\n@Created OpenGL Context...\n");
456
   printf("\n@Created OpenGL Context...\n");
457
 
457
 
458
+#ifndef __APPLE__
458
   if (!driver || !driver[0] || SDL_GL_LoadLibrary(driver) < 0)
459
   if (!driver || !driver[0] || SDL_GL_LoadLibrary(driver) < 0)
459
   {
460
   {
460
 	  SDL_ClearError();
461
 	  SDL_ClearError();
473
 		  }
474
 		  }
474
 	  }
475
 	  }
475
   }
476
   }
477
+#endif
476
 
478
 
477
   flags = SDL_OPENGL;
479
   flags = SDL_OPENGL;
478
 
480
 

+ 2
- 0
src/Sound.cpp View File

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

+ 2
- 0
src/TombRaider.cpp View File

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

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

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
 	/* */
54
 	/* */
55
 };
55
 };
56
 
56
 
57
+class HeightCollisionObject : public CollisionObject {
58
+public:
59
+    HeightCollisionObject(int a, int b);
60
+};
61
+
57
 #endif
62
 #endif

+ 23
- 22
src/hel/Simulation.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 : 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
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17
  *
17
  *
18
  * 2003.06.02:
18
  * 2003.06.02:
19
  * Mongoose - Created, based on algorithms from Erkin Tunca
19
  * Mongoose - Created, based on algorithms from Erkin Tunca
20
  =================================================================*/
20
  =================================================================*/
21
 
21
 
22
+#include <math.h>
22
 #include "Simulation.h"
23
 #include "Simulation.h"
23
 
24
 
24
 
25
 
72
 	{
73
 	{
73
 		if ((mObjects.current())->intersectPoint(mass->mPos))
74
 		if ((mObjects.current())->intersectPoint(mass->mPos))
74
 		{
75
 		{
75
-			detected = true; 
76
+			detected = true;
76
 			resolveCollision(mass, mObjects.current());
77
 			resolveCollision(mass, mObjects.current());
77
 		}
78
 		}
78
 	}
79
 	}
88
 
89
 
89
 
90
 
90
 void Simulation::generateMasses(unsigned int count, vec_t mass,
91
 void Simulation::generateMasses(unsigned int count, vec_t mass,
91
-										  const Vector3d &position, 
92
+										  const Vector3d &position,
92
 										  const Vector3d &velocity)
93
 										  const Vector3d &velocity)
93
 {
94
 {
94
 	unsigned int i;
95
 	unsigned int i;
205
 	//glColor4f(mColor, g, b, life);
206
 	//glColor4f(mColor, g, b, life);
206
 
207
 
207
 	// Render tristrip quad
208
 	// Render tristrip quad
208
-	for (gEmitter->mMasses.start(); gEmitter->mMasses.forward(); 
209
+	for (gEmitter->mMasses.start(); gEmitter->mMasses.forward();
209
 		  gEmitter->mMasses.next())
210
 		  gEmitter->mMasses.next())
210
 	{
211
 	{
211
 		m = gEmitter->mMasses.current();
212
 		m = gEmitter->mMasses.current();
241
 			z = m->mPos.mVec[2];
242
 			z = m->mPos.mVec[2];
242
 
243
 
243
 			glBegin(GL_TRIANGLE_STRIP);
244
 			glBegin(GL_TRIANGLE_STRIP);
244
-			
245
+
245
 			glTexCoord2d(1.0, 1.0);
246
 			glTexCoord2d(1.0, 1.0);
246
 			glVertex3f(x + 25, y + 25, z);
247
 			glVertex3f(x + 25, y + 25, z);
247
-			
248
+
248
 			glTexCoord2d(0.0, 1.0);
249
 			glTexCoord2d(0.0, 1.0);
249
 			glVertex3f(x - 25, y + 25, z);
250
 			glVertex3f(x - 25, y + 25, z);
250
-			
251
+
251
 			glTexCoord2d(1.0, 0.0);
252
 			glTexCoord2d(1.0, 0.0);
252
 			glVertex3f(x + 25, y - 25, z);
253
 			glVertex3f(x + 25, y - 25, z);
253
-			
254
+
254
 			glTexCoord2d(0.0, 0.0);
255
 			glTexCoord2d(0.0, 0.0);
255
 			glVertex3f(x - 25, y - 25, z);
256
 			glVertex3f(x - 25, y - 25, z);
256
-			
257
+
257
 			glEnd();
258
 			glEnd();
258
 		}
259
 		}
259
 	}
260
 	}
261
 #else
262
 #else
262
 	glBegin(GL_POINTS);
263
 	glBegin(GL_POINTS);
263
 
264
 
264
-	for (gEmitter.mMasses.start(); gEmitter.mMasses.forward(); 
265
+	for (gEmitter.mMasses.start(); gEmitter.mMasses.forward();
265
 		  gEmitter.mMasses.next())
266
 		  gEmitter.mMasses.next())
266
 	{
267
 	{
267
 		m = gEmitter.mMasses.current();
268
 		m = gEmitter.mMasses.current();
295
 	case 'r':
296
 	case 'r':
296
 		gGravityEmitter.clear();
297
 		gGravityEmitter.clear();
297
 
298
 
298
-		gGravityEmitter.generateMasses(1, 1.0f, 
299
+		gGravityEmitter.generateMasses(1, 1.0f,
299
 												 Vector3d(0.0f, 0.0f, 0.0f),
300
 												 Vector3d(0.0f, 0.0f, 0.0f),
300
 												 Vector3d(0.0f, 96.0f, -64.0f));
301
 												 Vector3d(0.0f, 96.0f, -64.0f));
301
-		gGravityEmitter.generateMasses(1, 1.0f, 
302
+		gGravityEmitter.generateMasses(1, 1.0f,
302
 												 Vector3d(-128.0f, 0.0f, 0.0f),
303
 												 Vector3d(-128.0f, 0.0f, 0.0f),
303
 												 Vector3d(32.0f, 96.0f, 0.0f));
304
 												 Vector3d(32.0f, 96.0f, 0.0f));
304
 		gGravityEmitter.generateMasses(1, 1.0f,
305
 		gGravityEmitter.generateMasses(1, 1.0f,
402
 
403
 
403
 	// Masses created above the origin, traveling down on Y axis
404
 	// Masses created above the origin, traveling down on Y axis
404
 	// as if it where in a vacuum pulled by gravity
405
 	// as if it where in a vacuum pulled by gravity
405
-	gGravityEmitter.generateMasses(1, 1.0f, 
406
+	gGravityEmitter.generateMasses(1, 1.0f,
406
 											 Vector3d(0.0f, 0.0f, 0.0f),
407
 											 Vector3d(0.0f, 0.0f, 0.0f),
407
 											 Vector3d(0.0f, 96.0f, 0.0f));
408
 											 Vector3d(0.0f, 96.0f, 0.0f));
408
-	gGravityEmitter.generateMasses(1, 1.0f, 
409
+	gGravityEmitter.generateMasses(1, 1.0f,
409
 											 Vector3d(-64.0f, 1424.0f, 0.0f),
410
 											 Vector3d(-64.0f, 1424.0f, 0.0f),
410
 											 Vector3d(-9.8f, 0.0f, 0.0f));
411
 											 Vector3d(-9.8f, 0.0f, 0.0f));
411
 	gGravityEmitter.generateMasses(1, 1.0f,
412
 	gGravityEmitter.generateMasses(1, 1.0f,
412
 											 Vector3d(64.0f, 1424.0f, 0.0f),
413
 											 Vector3d(64.0f, 1424.0f, 0.0f),
413
 											 Vector3d(9.8f, 0.0f, 0.0f));
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
 	//										 9999, 9999, 9999);
418
 	//										 9999, 9999, 9999);
418
 
419
 
419
 	HeightCollisionObject *obj = new HeightCollisionObject(0, 9999);
420
 	HeightCollisionObject *obj = new HeightCollisionObject(0, 9999);
425
 	// Spring
426
 	// Spring
426
 	gSpringEmitter.connectionPos = Vector3d(0.0f, 200.0f, 0.0f);
427
 	gSpringEmitter.connectionPos = Vector3d(0.0f, 200.0f, 0.0f);
427
 	gSpringEmitter.springConstant = 0.3f;
428
 	gSpringEmitter.springConstant = 0.3f;
428
-	gSpringEmitter.generateMasses(1, 0.5f, 
429
+	gSpringEmitter.generateMasses(1, 0.5f,
429
 											Vector3d(0.0f, -512.0f, 0.0f),
430
 											Vector3d(0.0f, -512.0f, 0.0f),
430
 											Vector3d(3.0f, 0.0f, 0.0f));
431
 											Vector3d(3.0f, 0.0f, 0.0f));
431
-	gSpringEmitter.generateMasses(1, 0.5f, 
432
+	gSpringEmitter.generateMasses(1, 0.5f,
432
 											Vector3d(-512.0f, -128.0f, 0.0f),
433
 											Vector3d(-512.0f, -128.0f, 0.0f),
433
 											Vector3d(0.0f, 3.0f, 0.0f));
434
 											Vector3d(0.0f, 3.0f, 0.0f));
434
-	gSpringEmitter.generateMasses(1, 0.5f, 
435
+	gSpringEmitter.generateMasses(1, 0.5f,
435
 											Vector3d(512.0f, -128.0f, 0.0f),
436
 											Vector3d(512.0f, -128.0f, 0.0f),
436
 											Vector3d(0.0f, 0.0f, 0.3f));
437
 											Vector3d(0.0f, 0.0f, 0.3f));
437
 
438
 

Loading…
Cancel
Save