|
@@ -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
|
|