Showing the changes to interface/src/ParticleSystem.cpp (1 of 5 files). Show all
Unified · Split
| @@ -22,9 +22,9 @@ ParticleSystem::ParticleSystem() { · 21 unmodified lines | ||
| 22 | 22 | _upDirection = glm::vec3(0.0f, 1.0f, 0.0f); // default |
| 23 | 23 | |
| 24 | 24 | for (unsigned int emitterIndex = 0; emitterIndex < MAX_EMITTERS; emitterIndex++) { |
| 25 | − _emitter[emitterIndex].position = glm::vec3(0.0f, 0.0f, 0.0f); | |
| 26 | − _emitter[emitterIndex].rotation = glm::quat(); | |
| 27 | − _emitter[emitterIndex].visible = false; | |
| 25 | + _emitter[emitterIndex].position = glm::vec3(0.0f, 0.0f, 0.0f); | |
| 26 | + _emitter[emitterIndex].direction = glm::vec3(0.0f, 1.0f, 0.0f); | |
| 27 | + _emitter[emitterIndex].visible = false; | |
| 28 | 28 | _emitter[emitterIndex].baseParticle.alive = false; |
| 29 | 29 | _emitter[emitterIndex].baseParticle.age = 0.0f; |
| 30 | 30 | _emitter[emitterIndex].baseParticle.lifespan = 0.0f; |
| @@ -90,10 +90,10 @@ void ParticleSystem::simulate(float deltaTime) { · 59 unmodified lines | ||
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | −void ParticleSystem::emitParticlesNow(int e, int num, glm::vec3 velocity, float lifespan) { | |
| 93 | +void ParticleSystem::emitParticlesNow(int e, int num, float thrust, float lifespan) { | |
| 94 | 94 | |
| 95 | 95 | for (unsigned int p = 0; p < num; p++) { |
| 96 | − createParticle(e, velocity, lifespan); | |
| 96 | + createParticle(e, _emitter[e].direction * thrust, lifespan); | |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| @@ -212,9 +212,9 @@ void ParticleSystem::updateParticle(int p, float deltaTime) { · 112 unmodified lines | ||
| 212 | 212 | // apply tornado force |
| 213 | 213 | |
| 214 | 214 | |
| 215 | − glm::vec3 emitterUp = myEmitter.rotation * IDENTITY_UP; | |
| 215 | + //glm::vec3 emitterUp = myEmitter.rotation * IDENTITY_UP; | |
| 216 | 216 | |
| 217 | − glm::vec3 tornadoDirection = glm::cross(vectorToHome, emitterUp); | |
| 217 | + glm::vec3 tornadoDirection = glm::cross(vectorToHome, myEmitter.direction); | |
| 218 | 218 | _particle[p].velocity += tornadoDirection * myEmitter.particleAttributes[lifeStage].tornadoForce * deltaTime; |
| 219 | 219 | |
| 220 | 220 | // apply air friction |
| @@ -351,12 +351,19 @@ void ParticleSystem::renderParticle(int p) { · 130 unmodified lines | ||
| 351 | 351 | |
| 352 | 352 | void ParticleSystem::renderEmitter(int e, float size) { |
| 353 | 353 | |
| 354 | + /* | |
| 354 | 355 | glm::vec3 r = _emitter[e].rotation * IDENTITY_FRONT * size; |
| 355 | 356 | glm::vec3 u = _emitter[e].rotation * IDENTITY_RIGHT * size; |
| 356 | 357 | glm::vec3 f = _emitter[e].rotation * IDENTITY_UP * size; |
| 358 | + */ | |
| 357 | 359 | |
| 360 | + glm::vec3 f = _emitter[e].direction; | |
| 361 | + //glm::vec3 r = glm::vec3(_emitter[e].direction.y, _emitter[e].direction.z, _emitter[e].direction.x); | |
| 362 | + //glm::vec3 u = glm::vec3(_emitter[e].direction.z, _emitter[e].direction.x, _emitter[e].direction.y); | |
| 363 | + | |
| 358 | 364 | glLineWidth(2.0f); |
| 359 | 365 | |
| 366 | +/* | |
| 360 | 367 | glColor3f(0.8f, 0.4, 0.4); |
| 361 | 368 | glBegin(GL_LINES); |
| 362 | 369 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); |
| @@ -368,7 +375,7 @@ void ParticleSystem::renderEmitter(int e, float size) { · 5 unmodified lines | ||
| 368 | 375 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); |
| 369 | 376 | glVertex3f(_emitter[e].position.x + u.x, _emitter[e].position.y + u.y, _emitter[e].position.z + u.z); |
| 370 | 377 | glEnd(); |
| 371 | − | |
| 378 | +*/ | |
| 372 | 379 | glColor3f(0.4f, 0.4, 0.8); |
| 373 | 380 | glBegin(GL_LINES); |
| 374 | 381 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); |