Browse Source

Removed files

Thomas Buck 11 years ago
parent
commit
71b0e8d94b
7 changed files with 15 additions and 1012 deletions
  1. 6
    0
      ChangeLog
  2. 9
    91
      Makefile
  3. 0
    47
      src/hel/CollisionObject.cpp
  4. 0
    62
      src/hel/CollisionObject.h
  5. 0
    453
      src/hel/Simulation.cpp
  6. 0
    308
      src/hel/Simulation.h
  7. 0
    51
      src/mstl/Vector.cpp

+ 6
- 0
ChangeLog View File

@@ -5,6 +5,12 @@
5 5
 
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8
+	[ 20140107 ]
9
+	* Removed even more unused files (mstl/Vector.cpp)
10
+	* Removed hel/Simulation, as it depends on missing files
11
+	  (hel/CollisionObject)
12
+	* Improved Makefile portability
13
+
8 14
 	[ 20140106 ]
9 15
 	* Hel Simulation Test builds, but doesn't work!
10 16
 

+ 9
- 91
Makefile View File

@@ -46,18 +46,20 @@ AUDIO_LIBS += -lalut
46 46
 AUDIO_LIBS += -framework OpenAL
47 47
 AUDIO_LIBS += -L/usr/local/lib
48 48
 AUDIO_DEFS += -I/usr/local/include
49
-BASE_LIBS += -L/opt/local/lib
50
-BASE_DEFS += -I/opt/local/include
51
-BASE_LIBS += -framework OpenGL
52
-BASE_LIBS += -framework GLUT
49
+GL_LIBS += -framework OpenGL
50
+GL_LIBS += -L/opt/local/lib
51
+GL_DEFS += -I/opt/local/include
53 52
 else
54 53
 AUDIO_LIBS += -lopenal
55
-BASE_LIBS += -L/usr/local/lib
56
-BASE_DEFS += -I/usr/local/include
54
+GL_LIBS += -lGL -lGLU
55
+GL_LIBS += -L/usr/local/lib
56
+GL_DEFS += -I/usr/local/include
57 57
 endif
58 58
 
59 59
 BASE_LIBS += $(AUDIO_LIBS)
60
+BASE_LIBS += $(GL_LIBS)
60 61
 BASE_DEFS += $(AUDIO_DEFS)
62
+BASE_DEFS += $(GL_DEFS)
61 63
 
62 64
 # libferit, File transfer via HTTP/FTP/etc support
63 65
 LIBFERIT_LIB=/usr/local/lib/libferit.so
@@ -97,10 +99,6 @@ BASE_CFLAGS=-Wall $(BASE_DEFS) \
97 99
 LD_FLAGS=-L/usr/X11/lib -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi \
98 100
 	 -lm $(BASE_LIBS)
99 101
 
100
-ifneq ($(UNAME),Darwin)
101
-LD_FLAGS+=-lGL -lGLU
102
-endif
103
-
104 102
 RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
105 103
 	-fomit-frame-pointer -O2
106 104
 
@@ -180,16 +178,13 @@ depend:
180 178
 # Later hel will become a seperate library once it matures
181 179
 HEL_OBJ = \
182 180
 	$(BUILDDIR)/Mass.o \
183
-	$(BUILDDIR)/Simulation.o \
184 181
 	$(BUILDDIR)/Vector3d.o \
185 182
 	$(BUILDDIR)/Matrix.o \
186 183
 	$(BUILDDIR)/ViewVolume.o \
187
-	$(BUILDDIR)/CollisionObject.o \
188 184
 	$(BUILDDIR)/BoundingVolume.o \
189 185
 	$(BUILDDIR)/Quaternion.o \
190 186
 	$(BUILDDIR)/math.o \
191 187
 	$(BUILDDIR)/Entity.o
192
-	#$(BUILDDIR)/Spring.o
193 188
 
194 189
 OBJS = \
195 190
 	$(DEBUG_OBJ) \
@@ -309,90 +304,13 @@ TombRaider.test:
309 304
 
310 305
 #################################################################
311 306
 
312
-ifeq ($(UNAME),Darwin)
313 307
 GLString.test:
314 308
 	mkdir -p $(BUILD_TEST_DIR)
315 309
 	$(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
316 310
 	$(shell sdl-config --cflags) $(shell sdl-config --libs) \
317
-	-I/opt/local/include -I/usr/local/include \
318
-	-framework OpenGL \
319
-	-framework GLUT \
320
-	-lm -lstdc++ \
311
+	$(GL_LIBS) $(GL_DEFS) -lm -lstdc++ \
321 312
 	src/Texture.cpp src/mtk_tga.cpp \
322 313
 	src/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
323
-else
324
-GLString.test:
325
-	mkdir -p $(BUILD_TEST_DIR)
326
-	$(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
327
-	$(shell sdl-config --cflags) $(shell sdl-config --libs) \
328
-	-lGL -lGLU -lm \
329
-	src/Texture.cpp src/mtk_tga.cpp \
330
-	src/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
331
-endif
332
-
333
-#################################################################
334
-
335
-# CollisionObject and HeightCollisionObject seem to be missing?
336
-# -- xythobuz, 2014-01-04
337
-
338
-SIMULATION_CFLAGS=-Wall -O0 -g -Isrc $(shell sdl-config --cflags) \
339
-		-I/opt/local/include \
340
-		-DUSING_OPENGL -DUSING_HEL -DUSING_MTK_TGA \
341
-		-DUNIT_TEST_SIMULATION
342
-SIMULATION_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
343
-		$(BUILD_TEST_DIR)/Mass.o \
344
-		$(BUILD_TEST_DIR)/CollisionObject.o \
345
-		$(BUILD_TEST_DIR)/Simulation.o \
346
-		$(BUILD_TEST_DIR)/Vector3d.o \
347
-		$(BUILD_TEST_DIR)/Matrix.o \
348
-		$(BUILD_TEST_DIR)/ViewVolume.o \
349
-		$(BUILD_TEST_DIR)/BoundingVolume.o \
350
-		$(BUILD_TEST_DIR)/Quaternion.o \
351
-		$(BUILD_TEST_DIR)/math.o
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
361
-Simulation.test:
362
-	mkdir -p $(BUILD_TEST_DIR)
363
-	$(MAKE) targets NAME=Simulation.test BUILDDIR=$(BUILD_TEST_DIR) \
364
-		OBJS="$(SIMULATION_OBJS)" \
365
-		CFLAGS="$(SIMULATION_CFLAGS)" \
366
-		LD_FLAGS="-lm -lstdc++ -lSDL_ttf -lSDL -lGL -lGLU $(shell sdl-config --libs)"
367
-endif
368
-
369
-#################################################################
370
-
371
-# Spring files seem to be missing?
372
-# -- xythobuz, 2014-01-04
373
-
374
-HEL_PARTICLE_CFLAGS=-Wall -O0 -g -Isrc $(shell sdl-config --cflags) \
375
-		-I/opt/local/include \
376
-		-DUSING_OPENGL -DUSING_HEL -DUSING_MTK_TGA \
377
-		-DUNIT_TEST_SPRING -DHAVE_SDL_TTF
378
-HEL_PARTICLE_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
379
-		$(BUILD_TEST_DIR)/Mass.o \
380
-		$(BUILD_TEST_DIR)/Spring.o \
381
-		$(BUILD_TEST_DIR)/CollisionObject.o \
382
-		$(BUILD_TEST_DIR)/Simulation.o \
383
-		$(BUILD_TEST_DIR)/Vector3d.o \
384
-		$(BUILD_TEST_DIR)/Matrix.o \
385
-		$(BUILD_TEST_DIR)/ViewVolume.o \
386
-		$(BUILD_TEST_DIR)/BoundingVolume.o \
387
-		$(BUILD_TEST_DIR)/Quaternion.o \
388
-		$(BUILD_TEST_DIR)/math.o
389
-
390
-Spring.test:
391
-	mkdir -p $(BUILD_TEST_DIR)
392
-	$(MAKE) targets NAME=Spring.test BUILDDIR=$(BUILD_TEST_DIR) \
393
-		OBJS="$(HEL_PARTICLE_OBJS)" \
394
-		CFLAGS="$(HEL_PARTICLE_CFLAGS)" \
395
-		LD_FLAGS="-lm -lstdc++ -lSDL_ttf-lGL -lGLU $(shell sdl-config --libs)"
396 314
 
397 315
 #################################################################
398 316
 

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

@@ -1,47 +0,0 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
3
- *
4
- * Project : libHel
5
- * Object  : CollisionObject
6
- * Comments: Was missing from SourceForge!
7
- *
8
- *-- History ------------------------------------------------
9
- *
10
- * 2013.12.27:
11
- * xythobuz - Created as stub, was missing
12
- ================================================================*/
13
-
14
-#include "CollisionObject.h"
15
-
16
-
17
-////////////////////////////////////////////////////////////
18
-// Constructors
19
-////////////////////////////////////////////////////////////
20
-
21
-
22
-////////////////////////////////////////////////////////////
23
-// Public Accessors
24
-////////////////////////////////////////////////////////////
25
-
26
-bool CollisionObject::intersectPoint(Vector3d p) {
27
-    return 0;
28
-}
29
-
30
-////////////////////////////////////////////////////////////
31
-// Public Mutators
32
-////////////////////////////////////////////////////////////
33
-
34
-
35
-////////////////////////////////////////////////////////////
36
-// Private Accessors
37
-////////////////////////////////////////////////////////////
38
-
39
-
40
-////////////////////////////////////////////////////////////
41
-// Private Mutators
42
-////////////////////////////////////////////////////////////
43
-
44
-
45
-HeightCollisionObject::HeightCollisionObject(int a, int b) {
46
-
47
-}

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

@@ -1,62 +0,0 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
3
- *
4
- * Project : libHel
5
- * Object  : CollisionObject
6
- * Comments: Was missing from SourceForge!
7
- *
8
- *-- History ------------------------------------------------
9
- *
10
- * 2013.12.27:
11
- * xythobuz - Created as stub, was missing
12
- ================================================================*/
13
-
14
-
15
-#ifndef GUARD__LIBHEL_MONGOOSE_COLLISIONOBJECT_H_
16
-#define GUARD__LIBHEL_MONGOOSE_COLLISIONOBJECT_H_
17
-
18
-#include <hel/Vector3d.h>
19
-
20
-class CollisionObject
21
-{
22
- public:
23
-
24
-	////////////////////////////////////////////////////////////
25
-	// Constructors
26
-	////////////////////////////////////////////////////////////
27
-
28
-
29
-	////////////////////////////////////////////////////////////
30
-	// Public Accessors
31
-	////////////////////////////////////////////////////////////
32
-
33
-    bool intersectPoint(Vector3d p);
34
-
35
-	////////////////////////////////////////////////////////////
36
-	// Public Mutators
37
-	////////////////////////////////////////////////////////////
38
-
39
-    Vector3d mIntersection;
40
-
41
-
42
- private:
43
-
44
-	////////////////////////////////////////////////////////////
45
-	// Private Accessors
46
-	////////////////////////////////////////////////////////////
47
-
48
-
49
-	////////////////////////////////////////////////////////////
50
-	// Private Mutators
51
-	////////////////////////////////////////////////////////////
52
-
53
-
54
-	/* */
55
-};
56
-
57
-class HeightCollisionObject : public CollisionObject {
58
-public:
59
-    HeightCollisionObject(int a, int b);
60
-};
61
-
62
-#endif

+ 0
- 453
src/hel/Simulation.cpp View File

@@ -1,453 +0,0 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
3
- *
4
- * Project : Hel
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Simulation
9
- * License : No use w/o permission (C) 2003 Mongoose
10
- * Comments: This class simulates mass physics
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History -------------------------------------------------
17
- *
18
- * 2003.06.02:
19
- * Mongoose - Created, based on algorithms from Erkin Tunca
20
- =================================================================*/
21
-
22
-#include <math.h>
23
-#include "Simulation.h"
24
-
25
-
26
-////////////////////////////////////////////////////////////
27
-// Constructors
28
-////////////////////////////////////////////////////////////
29
-
30
-Simulation::Simulation()
31
-{
32
-	mMassCount = 0;
33
-}
34
-
35
-
36
-Simulation::~Simulation()
37
-{
38
-	clear();
39
-}
40
-
41
-
42
-////////////////////////////////////////////////////////////
43
-// Public Accessors
44
-////////////////////////////////////////////////////////////
45
-
46
-Mass *Simulation::getMass(unsigned int i)
47
-{
48
-	return mMasses[i];
49
-}
50
-
51
-
52
-////////////////////////////////////////////////////////////
53
-// Public Mutators
54
-////////////////////////////////////////////////////////////
55
-
56
-void Simulation::attachCollisionObject(CollisionObject *obj)
57
-{
58
-	mObjects.pushBack(obj);
59
-}
60
-
61
-
62
-void Simulation::clear()
63
-{
64
-	mMasses.erase();
65
-}
66
-
67
-
68
-bool Simulation::collisionDetected(Mass *mass)
69
-{
70
-	bool detected = false;
71
-
72
-	for (mObjects.start(); mObjects.forward(); mObjects.next())
73
-	{
74
-		if ((mObjects.current())->intersectPoint(mass->mPos))
75
-		{
76
-			detected = true;
77
-			resolveCollision(mass, mObjects.current());
78
-		}
79
-	}
80
-
81
-	return detected;
82
-}
83
-
84
-
85
-void Simulation::generateMasses(unsigned int count, vec_t mass)
86
-{
87
-	generateMasses(count, mass, Vector3d(0, 0, 0), Vector3d(0, 0, 0));
88
-}
89
-
90
-
91
-void Simulation::generateMasses(unsigned int count, vec_t mass,
92
-										  const Vector3d &position,
93
-										  const Vector3d &velocity)
94
-{
95
-	unsigned int i;
96
-
97
-
98
-	mMassCount = count;
99
-	//mMasses.reserve(mMasses.size() + count);
100
-
101
-	for (i = 0; i < count; ++i)
102
-	{
103
-		mMasses.pushBack(new Mass(mass, position, velocity));
104
-	}
105
-}
106
-
107
-
108
-void Simulation::init()
109
-{
110
-	Mass *m;
111
-
112
-	for (mMasses.start(); mMasses.forward(); mMasses.next())
113
-	{
114
-		m = mMasses.current();
115
-
116
-		if (!m)
117
-			continue;
118
-
119
-		m->rest();
120
-	}
121
-}
122
-
123
-
124
-void Simulation::resolveCollision(Mass *mass, CollisionObject *obj)
125
-{
126
-	mass->mPos = obj->mIntersection;
127
-}
128
-
129
-
130
-void Simulation::run(vec_t timeDelta)
131
-{
132
-	// Reset forces
133
-	init();
134
-
135
-	// Apply external forces
136
-	solve();
137
-
138
-	// Update change in time
139
-	simulate(timeDelta);
140
-}
141
-
142
-
143
-void Simulation::simulate(vec_t timeDelta)
144
-{
145
-	Mass *m;
146
-
147
-	for (mMasses.start(); mMasses.forward(); mMasses.next())
148
-	{
149
-		m = mMasses.current();
150
-
151
-		if (!m)
152
-			continue;
153
-
154
-		m->simulate(timeDelta);
155
-	}
156
-}
157
-
158
-
159
-void Simulation::solve()
160
-{
161
-}
162
-
163
-
164
-////////////////////////////////////////////////////////////
165
-// Private Accessors
166
-////////////////////////////////////////////////////////////
167
-
168
-
169
-////////////////////////////////////////////////////////////
170
-// Private Mutators
171
-////////////////////////////////////////////////////////////
172
-
173
-
174
-////////////////////////////////////////////////////////////
175
-// Unit Test code
176
-////////////////////////////////////////////////////////////
177
-
178
-#ifdef UNIT_TEST_SIMULATION
179
-
180
-#define SDL_UNIT_TEST
181
-#include "SDLUnitTest.cpp"
182
-
183
-Simulation *gEmitter;
184
-GravitySimulation gGravityEmitter;
185
-SpringSimulation gSpringEmitter;
186
-SpringSimulation gSpringEmitter2;
187
-bool gOn = false;
188
-float gSpeed = 0.1f;
189
-
190
-
191
-// Draw particles
192
-#define ENABLE_TEX_PARTICLES
193
-void renderScene(float time, float lastTime)
194
-{
195
-	Mass *m;
196
-	Vector3d last;
197
-	vec_t x, y, z;
198
-
199
-	glBindTexture(GL_TEXTURE_2D, 1);
200
-
201
-	if (gOn)
202
-		gEmitter->run((time - lastTime) * 0.1 * gSpeed); // slow it down
203
-
204
-#ifdef ENABLE_TEX_PARTICLES
205
-	// Alpha is determined by life, which is affected by blend amount
206
-	//glColor4f(mColor, g, b, life);
207
-
208
-	// Render tristrip quad
209
-	for (gEmitter->mMasses.start(); gEmitter->mMasses.forward();
210
-		  gEmitter->mMasses.next())
211
-	{
212
-		m = gEmitter->mMasses.current();
213
-
214
-		if (!m)
215
-			continue;
216
-
217
-		if (gEmitter == &gSpringEmitter)
218
-		{
219
-			if (gEmitter->mMasses.getCurrentIndex() == 0)
220
-			{
221
-				glDisable(GL_TEXTURE_2D);
222
-
223
-				glColor4f(0.0, 1.0, 0.0, 1.0);
224
-				glBegin(GL_POINTS);
225
-				glVertex3fv(gSpringEmitter.connectionPos.mVec);
226
-				glEnd();
227
-			}
228
-
229
-			glColor4f(gEmitter->mMasses.getCurrentIndex()*0.33, 0.0, 1.0, 1.0);
230
-			glBegin(GL_POINTS);
231
-			glVertex3fv(m->mPos.mVec);
232
-			glEnd();
233
-			glBegin(GL_LINES);
234
-			glVertex3fv(m->mPos.mVec);
235
-			glVertex3fv(gSpringEmitter.connectionPos.mVec);
236
-			glEnd();
237
-		}
238
-		else
239
-		{
240
-			x = m->mPos.mVec[0];
241
-			y = m->mPos.mVec[1];
242
-			z = m->mPos.mVec[2];
243
-
244
-			glBegin(GL_TRIANGLE_STRIP);
245
-
246
-			glTexCoord2d(1.0, 1.0);
247
-			glVertex3f(x + 25, y + 25, z);
248
-
249
-			glTexCoord2d(0.0, 1.0);
250
-			glVertex3f(x - 25, y + 25, z);
251
-
252
-			glTexCoord2d(1.0, 0.0);
253
-			glVertex3f(x + 25, y - 25, z);
254
-
255
-			glTexCoord2d(0.0, 0.0);
256
-			glVertex3f(x - 25, y - 25, z);
257
-
258
-			glEnd();
259
-		}
260
-	}
261
-
262
-#else
263
-	glBegin(GL_POINTS);
264
-
265
-	for (gEmitter.mMasses.start(); gEmitter.mMasses.forward();
266
-		  gEmitter.mMasses.next())
267
-	{
268
-		m = gEmitter.mMasses.current();
269
-
270
-		if (!m)
271
-			continue;
272
-
273
-		glColor4f(0.0, 1.0, 1.0, 1.0);
274
-		glVertex3fv(m->mPos.mVec);
275
-	}
276
-
277
-	glEnd();
278
-#endif
279
-}
280
-
281
-
282
-void handleKey(int key)
283
-{
284
-	Mass *m;
285
-
286
-	switch (key)
287
-	{
288
-	case ' ':
289
-		m = gGravityEmitter.getMass(0);
290
-
291
-		if (m)
292
-		{
293
-			m->mVelocity = Vector3d(0.0f, 120.0f, 0.0f);
294
-		}
295
-		break;
296
-	case 'r':
297
-		gGravityEmitter.clear();
298
-
299
-		gGravityEmitter.generateMasses(1, 1.0f,
300
-												 Vector3d(0.0f, 0.0f, 0.0f),
301
-												 Vector3d(0.0f, 96.0f, -64.0f));
302
-		gGravityEmitter.generateMasses(1, 1.0f,
303
-												 Vector3d(-128.0f, 0.0f, 0.0f),
304
-												 Vector3d(32.0f, 96.0f, 0.0f));
305
-		gGravityEmitter.generateMasses(1, 1.0f,
306
-												 Vector3d(128.0f, 0.0f, 0.0f),
307
-												 Vector3d(-32.0f, 96.0f, 0.0f));
308
-		break;
309
-	case 't':
310
-		if (gEmitter == &gGravityEmitter)
311
-		{
312
-			gEmitter = &gSpringEmitter;
313
-		}
314
-		else
315
-		{
316
-			gEmitter = &gGravityEmitter;
317
-		}
318
-		break;
319
-	case 'f':
320
-		gGravityEmitter.gravitation *= 10.0;
321
-		printf("G is now %f\n", gGravityEmitter.gravitation.mVec[1]);
322
-		break;
323
-	case 'g':
324
-		if (fabs(gGravityEmitter.gravitation.mVec[1] * 0.1) > 0.0000001)
325
-			gGravityEmitter.gravitation *= 0.1;
326
-
327
-		printf("G is now %f\n", gGravityEmitter.gravitation.mVec[1]);
328
-		break;
329
-	case 's':
330
-		gOn = !gOn;
331
-		break;
332
-	case '[':
333
-		gSpringEmitter.springConstant += 0.5f;
334
-		printf("Spring constant = %f\n", gSpringEmitter.springConstant);
335
-		break;
336
-	case ']':
337
-		if (gSpringEmitter.springConstant - 0.5 > 0.0f)
338
-			gSpringEmitter.springConstant -= 0.5f;
339
-		printf("Spring constant = %f\n", gSpringEmitter.springConstant);
340
-		break;
341
-	case '.':
342
-		gSpeed *= 10.0;
343
-		printf("Time is at %f speed\n", gSpeed);
344
-		break;
345
-	case ',':
346
-		if (gSpeed * 0.1 > 0.0000001)
347
-			gSpeed *= 0.1;
348
-		printf("Time is at %f speed\n", gSpeed);
349
-		break;
350
-	case 'h':
351
-		printf("\n");
352
-		printf("----------------------------------\n");
353
-		printf("t -       Toggle emitter\n");
354
-		printf("r -       Reset gravity emitter test\n");
355
-		printf("[ ] -     Adjust spring stiffness\n");
356
-		printf(", . -     Adjust time delta\n");
357
-		printf("g -       Scale gravity down\n");
358
-		printf("f -       Scale gravity up\n");
359
-		printf("s -       Start/stop simulation\n");
360
-		break;
361
-	}
362
-}
363
-
364
-
365
-void handleArgKey(char key)
366
-{
367
-	switch (key)
368
-	{
369
-	default:
370
-		;
371
-	}
372
-}
373
-
374
-
375
-void initScene(int argc, char *argv[])
376
-{
377
-	//glEnable(GL_CULL_FACE);
378
-	//glCullFace(GL_FRONT);    // Q3A uses front face culling
379
-	glEnable(GL_TEXTURE_2D);
380
-	glEnable(GL_DEPTH_TEST);
381
-	glDepthFunc(GL_LESS);
382
-	glShadeModel(GL_SMOOTH);
383
-	glDisable(GL_LIGHTING);
384
-
385
-	glPointSize(5.0f);
386
-	gYawOn = false;
387
-	gScale = 0.3f;
388
-
389
-	// Texture setup
390
-	gTexture.reset();
391
-	gTexture.setFlag(Texture::fUseMipmaps);
392
-	gTexture.setMaxTextureCount(64);
393
-	printf("Loading textures: ");
394
-	gTexture.loadTGA("data/snow.tga");
395
-	gTexture.loadTGA("data/snow2.tga");
396
-	printf(" done\n\n");
397
-}
398
-
399
-
400
-int runSimulationUnitTest(int argc, char *argv[])
401
-{
402
-	gEmitter = &gGravityEmitter;
403
-
404
-	// Masses created above the origin, traveling down on Y axis
405
-	// as if it where in a vacuum pulled by gravity
406
-	gGravityEmitter.generateMasses(1, 1.0f,
407
-											 Vector3d(0.0f, 0.0f, 0.0f),
408
-											 Vector3d(0.0f, 96.0f, 0.0f));
409
-	gGravityEmitter.generateMasses(1, 1.0f,
410
-											 Vector3d(-64.0f, 1424.0f, 0.0f),
411
-											 Vector3d(-9.8f, 0.0f, 0.0f));
412
-	gGravityEmitter.generateMasses(1, 1.0f,
413
-											 Vector3d(64.0f, 1424.0f, 0.0f),
414
-											 Vector3d(9.8f, 0.0f, 0.0f));
415
-
416
-	//InternalBBoxCollisionObject *obj =
417
-	//new InternalBBoxCollisionObject(-9999, 0, -9999,
418
-	//										 9999, 9999, 9999);
419
-
420
-	HeightCollisionObject *obj = new HeightCollisionObject(0, 9999);
421
-
422
-	/* Don't fall out ot the box world  =) */
423
-	gGravityEmitter.attachCollisionObject(obj);
424
-	gSpringEmitter.attachCollisionObject(obj);
425
-
426
-	// Spring
427
-	gSpringEmitter.connectionPos = Vector3d(0.0f, 200.0f, 0.0f);
428
-	gSpringEmitter.springConstant = 0.3f;
429
-	gSpringEmitter.generateMasses(1, 0.5f,
430
-											Vector3d(0.0f, -512.0f, 0.0f),
431
-											Vector3d(3.0f, 0.0f, 0.0f));
432
-	gSpringEmitter.generateMasses(1, 0.5f,
433
-											Vector3d(-512.0f, -128.0f, 0.0f),
434
-											Vector3d(0.0f, 3.0f, 0.0f));
435
-	gSpringEmitter.generateMasses(1, 0.5f,
436
-											Vector3d(512.0f, -128.0f, 0.0f),
437
-											Vector3d(0.0f, 0.0f, 0.3f));
438
-
439
-	updateWindowTitle("[Simulation particle class test]");
440
-	runSDLUnitTest(argc, argv);
441
-
442
-	return 0;
443
-}
444
-
445
-
446
-int main(int argc, char *argv[])
447
-{
448
-	printf("[Simulation class test]\n");
449
-	runSimulationUnitTest(argc, argv);
450
-
451
-	return 0;
452
-}
453
-#endif

+ 0
- 308
src/hel/Simulation.h View File

@@ -1,308 +0,0 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
3
- *
4
- * Project : Hel
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Simulation
9
- * License : No use w/o permission (C) 2003 Mongoose
10
- * Comments: This class simulates mass physics
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- Test Defines -----------------------------------------------
17
- *
18
- * UNIT_TEST_SIMULATION - Builds Simulation class as a console unit test
19
- *
20
- *-- History ------------------------------------------------
21
- *
22
- * 2003.06.08:
23
- * Mongoose - Generic collision and basic resolution w/o generic
24
- *            Hel Resolvers
25
- *
26
- * 2003.06.02:
27
- * Mongoose - Created, based on algorithms from Erkin Tunca
28
- ================================================================*/
29
-
30
-
31
-#ifndef GUARD__HEL_MONGOOSE_SIMULATION_H_
32
-#define GUARD__HEL_MONGOOSE_SIMULATION_H_
33
-
34
-#include <mstl/Vector.h>
35
-#include <hel/CollisionObject.h>
36
-#include <hel/Mass.h>
37
-#include <hel/math.h>
38
-
39
-
40
-class Simulation
41
-{
42
- public:
43
-
44
-	////////////////////////////////////////////////////////////
45
-	// Constructors
46
-	////////////////////////////////////////////////////////////
47
-
48
-	Simulation();
49
-	/*------------------------------------------------------
50
-	 * Pre  :
51
-	 * Post : Constructs an object of Simulation
52
-	 *
53
-	 *-- History ------------------------------------------
54
-	 *
55
-	 * 2003.06.02:
56
-	 * Mongoose - Created
57
-	 ------------------------------------------------------*/
58
-
59
-	virtual ~Simulation();
60
-	/*------------------------------------------------------
61
-	 * Pre  : Simulation object is allocated
62
-	 * Post : Deconstructs an object of Simulation
63
-	 *
64
-	 *-- History ------------------------------------------
65
-	 *
66
-	 * 2003.06.02:
67
-	 * Mongoose - Created
68
-	 ------------------------------------------------------*/
69
-
70
-
71
-	////////////////////////////////////////////////////////////
72
-	// Public Accessors
73
-	////////////////////////////////////////////////////////////
74
-
75
-	Mass *getMass(unsigned int i);
76
-	/*------------------------------------------------------
77
-	 * Pre  :
78
-	 * Post : Get <i>th Mass element of this simulation
79
-	 *
80
-	 *-- History ------------------------------------------
81
-	 *
82
-	 * 2003.06.02:
83
-	 * Mongoose - Created
84
-	 ------------------------------------------------------*/
85
-
86
-
87
-	////////////////////////////////////////////////////////////
88
-	// Public Mutators
89
-	////////////////////////////////////////////////////////////
90
-
91
-	virtual void attachCollisionObject(CollisionObject *obj);
92
-	/*------------------------------------------------------
93
-	 * Pre  :
94
-	 * Post : Adds <Obj> to the collision list for this simulation
95
-	 *
96
-	 * TODO : Allow multiple types of collision to be excluded?
97
-	 *
98
-	 *-- History ------------------------------------------
99
-	 *
100
-	 * 2003.06.08:
101
-	 * Mongoose - Created
102
-	 ------------------------------------------------------*/
103
-
104
-	virtual void clear();
105
-	/*------------------------------------------------------
106
-	 * Pre  :
107
-	 * Post : Removes all masses from this simulation
108
-	 *
109
-	 *-- History ------------------------------------------
110
-	 *
111
-	 * 2003.06.02:
112
-	 * Mongoose - Created
113
-	 ------------------------------------------------------*/
114
-
115
-	virtual bool collisionDetected(Mass *mass);
116
-	/*------------------------------------------------------
117
-	 * Pre  :
118
-	 * Post : Returns true if <Mass> collided with object
119
-	 *
120
-	 *-- History ------------------------------------------
121
-	 *
122
-	 * 2003.06.08:
123
-	 * Mongoose - Created
124
-	 ------------------------------------------------------*/
125
-
126
-	virtual void generateMasses(unsigned int count, vec_t mass);
127
-	/*------------------------------------------------------
128
-	 * Pre  :
129
-	 * Post : <Count> number of masses with <mass> value are added
130
-	 *
131
-	 *-- History ------------------------------------------
132
-	 *
133
-	 * 2003.06.02:
134
-	 * Mongoose - Created
135
-	 ------------------------------------------------------*/
136
-
137
-	virtual void generateMasses(unsigned int count, vec_t mass,
138
-										 const Vector3d &position,
139
-										 const Vector3d &velocity);
140
-	/*------------------------------------------------------
141
-	 * Pre  :
142
-	 * Post : <Count> number of masses with
143
-	 *        <mass>, <position>, and <velocity> are added
144
-	 *
145
-	 *-- History ------------------------------------------
146
-	 *
147
-	 * 2003.06.02:
148
-	 * Mongoose - Created
149
-	 ------------------------------------------------------*/
150
-
151
-	virtual void init();
152
-	/*------------------------------------------------------
153
-	 * Pre  :
154
-	 * Post : Reset forces acting on masses
155
-	 *
156
-	 *-- History ------------------------------------------
157
-	 *
158
-	 * 2003.06.02:
159
-	 * Mongoose - Created
160
-	 ------------------------------------------------------*/
161
-
162
-	virtual void resolveCollision(Mass *mass, CollisionObject *obj);
163
-	/*------------------------------------------------------
164
-	 * Pre  :
165
-	 * Post : Resolves a collision of <Obj> and <Mass>
166
-	 *
167
-	 *        The default resolution here is to set mass pos
168
-	 *        to intersection point with the object, there
169
-	 *        is no affect on velocity
170
-	 *
171
-	 *-- History ------------------------------------------
172
-	 *
173
-	 * 2003.06.08:
174
-	 * Mongoose - Created
175
-	 ------------------------------------------------------*/
176
-
177
-	virtual void run(vec_t timeDelta);
178
-	/*------------------------------------------------------
179
-	 * Pre  :
180
-	 * Post : Does full init, solve, simulate cycle
181
-	 *
182
-	 *-- History ------------------------------------------
183
-	 *
184
-	 * 2003.06.02:
185
-	 * Mongoose - Created
186
-	 ------------------------------------------------------*/
187
-
188
-	virtual void simulate(vec_t timeDelta);
189
-	/*------------------------------------------------------
190
-	 * Pre  :
191
-	 * Post : Update change in time for each mass
192
-	 *
193
-	 *-- History ------------------------------------------
194
-	 *
195
-	 * 2003.06.02:
196
-	 * Mongoose - Created
197
-	 ------------------------------------------------------*/
198
-
199
-	virtual void solve ();
200
-	/*------------------------------------------------------
201
-	 * Pre  :
202
-	 * Post : Have forces act on masses
203
-	 *
204
-	 *-- History ------------------------------------------
205
-	 *
206
-	 * 2003.06.02:
207
-	 * Mongoose - Created
208
-	 ------------------------------------------------------*/
209
-
210
-	Vector<Mass *> mMasses;			/* It's a collection of masses, silly */
211
-
212
-	Vector<CollisionObject *> mObjects;	/* Object(s) to test collision with */
213
-
214
-	unsigned int mMassCount;		/* Cache of number of masses in collection  */
215
-
216
-
217
- private:
218
-
219
-	////////////////////////////////////////////////////////////
220
-	// Private Accessors
221
-	////////////////////////////////////////////////////////////
222
-
223
-
224
-	////////////////////////////////////////////////////////////
225
-	// Private Mutators
226
-	////////////////////////////////////////////////////////////
227
-};
228
-
229
-
230
-class GravitySimulation : public Simulation
231
-{
232
-public:
233
-
234
-	GravitySimulation() : Simulation()
235
-	{
236
-		gravitation = Vector3d(0.0f, -9.81f, 0.0f);
237
-	}
238
-
239
-
240
-	virtual void solve()
241
-	{
242
-		Mass *m;
243
-
244
-		// Apply gravitational force to each mass
245
-		for (mMasses.start(); mMasses.forward(); mMasses.next())
246
-		{
247
-			m = mMasses.current();
248
-
249
-			// Gravitational force, Force = (Mass)(Gravity)
250
-			m->applyForce(gravitation * m->mMass);
251
-
252
-			if (collisionDetected(m))
253
-			{
254
-				m->mVelocity = Vector3d(0, 0, 0);
255
-			}
256
-		}
257
-	}
258
-
259
-
260
-	Vector3d gravitation;     /* Gravitational acceleration */
261
-};
262
-
263
-
264
-class SpringSimulation : public Simulation
265
-{
266
-public:
267
-
268
-	SpringSimulation() : Simulation()
269
-	{
270
-	}
271
-
272
-
273
-	virtual void generateMasses(unsigned int count, vec_t mass,
274
-										 const Vector3d &position,
275
-										 const Vector3d &velocity)
276
-	{
277
-		Simulation::generateMasses(count, mass,
278
-											connectionPos + position, velocity);
279
-	}
280
-
281
-
282
-	virtual void solve()
283
-	{
284
-		Mass *m;
285
-
286
-		// Apply spring force to each mass
287
-		for (mMasses.start(); mMasses.forward(); mMasses.next())
288
-		{
289
-			m = mMasses.current();
290
-
291
-			// Vector from mass to spring connection
292
-			Vector3d springVector = m->mPos - connectionPos;
293
-
294
-			// Apply spring force, spring force formulation
295
-			m->applyForce(-springVector * springConstant);
296
-
297
-			if (collisionDetected(m))
298
-			{
299
-				//m->mVelocity = Vector3d(0, 0, 0);
300
-			}
301
-		}
302
-	}
303
-
304
-	vec_t springConstant;     /* Stiffness, higher values more spring force */
305
-
306
-	Vector3d connectionPos;   /* Location where mass is connected to spring */
307
-};
308
-#endif

+ 0
- 51
src/mstl/Vector.cpp View File

@@ -1,51 +0,0 @@
1
-#include "Vector.h"
2
-
3
-
4
-int main()
5
-{
6
-   Vector<int> numbers;
7
-   int num[8];
8
-   int fill = 32;
9
-   unsigned int i;
10
-
11
-
12
-   num[0] = 14;
13
-   num[1] = 311;   
14
-
15
-   for (i = 2; i < 8; ++i)
16
-   {
17
-     num[i] = fill;
18
-   }
19
-
20
-   numbers.pushBack(num[0]);
21
-   numbers.pushBack(num[1]);
22
-   numbers.resize(8, fill);
23
-
24
-   for (numbers.mIndex = numbers.begin(); numbers.mIndex < numbers.end(); 
25
-	++numbers.mIndex)
26
-   {
27
-     printf("numbers[%i] = %3i   |   numbers[%i] = %3i\n",  
28
-	    numbers.mIndex, num[numbers.mIndex],
29
-	    numbers.mIndex, numbers[numbers.mIndex]);
30
-   }
31
-
32
-   printf("\n");
33
-
34
-   for (numbers.start(); numbers.forward(); numbers.next())
35
-   {
36
-     printf("numbers[%i] = %3i   |   numbers[%i] = %3i\n",  
37
-	    numbers.mIndex, num[numbers.mIndex],
38
-	    numbers.mIndex, numbers[numbers.mIndex]);
39
-   }
40
-
41
-   printf("\n");
42
-
43
-   for (numbers.finish(); numbers.backward(); numbers.prev())
44
-   {
45
-     printf("numbers[%i] = %3i   |   numbers[%i] = %3i\n",  
46
-	    numbers.mIndex, num[numbers.mIndex],
47
-	    numbers.mIndex, numbers[numbers.mIndex]);
48
-   }
49
-
50
-   return 0;
51
-}

Loading…
Cancel
Save