mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:03:11 +02:00
clean up of particle system
This commit is contained in:
parent
4389389f17
commit
be5612711b
3 changed files with 15 additions and 27 deletions
|
@ -73,7 +73,7 @@ using namespace std;
|
||||||
static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
|
static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
|
||||||
static char STAR_CACHE_FILE[] = "cachedStars.txt";
|
static char STAR_CACHE_FILE[] = "cachedStars.txt";
|
||||||
|
|
||||||
static const bool TESTING_PARTICLE_SYSTEM = false;
|
static const bool TESTING_PARTICLE_SYSTEM = true;
|
||||||
|
|
||||||
static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
|
static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
|
||||||
|
|
||||||
|
@ -3514,19 +3514,11 @@ void Application::updateParticleSystem(float deltaTime) {
|
||||||
glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f);
|
glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
glm::vec3 velocity(0.0f, 0.1f, 0.0f);
|
glm::vec3 velocity(0.0f, 0.1f, 0.0f);
|
||||||
float lifespan = 100000.0f;
|
float lifespan = 100000.0f;
|
||||||
|
|
||||||
// determine a collision sphere
|
|
||||||
glm::vec3 collisionSpherePosition = glm::vec3( 5.0f, 0.5f, 5.0f );
|
|
||||||
float collisionSphereRadius = 0.5f;
|
|
||||||
_particleSystem.setCollisionSphere(_coolDemoParticleEmitter, collisionSpherePosition, collisionSphereRadius);
|
|
||||||
_particleSystem.emitParticlesNow(_coolDemoParticleEmitter, 1500, radius, color, velocity, lifespan);
|
_particleSystem.emitParticlesNow(_coolDemoParticleEmitter, 1500, radius, color, velocity, lifespan);
|
||||||
}
|
}
|
||||||
|
|
||||||
// signal that the particle system has been initialized
|
// signal that the particle system has been initialized
|
||||||
_particleSystemInitialized = true;
|
_particleSystemInitialized = true;
|
||||||
|
|
||||||
// apply a preset color palette
|
|
||||||
_particleSystem.setOrangeBlueColorPalette();
|
|
||||||
} else {
|
} else {
|
||||||
// update the particle system
|
// update the particle system
|
||||||
|
|
||||||
|
@ -3547,6 +3539,7 @@ void Application::updateParticleSystem(float deltaTime) {
|
||||||
ParticleSystem::ParticleAttributes attributes;
|
ParticleSystem::ParticleAttributes attributes;
|
||||||
|
|
||||||
attributes.radius = 0.01f;
|
attributes.radius = 0.01f;
|
||||||
|
attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
attributes.gravity = 0.0f + 0.05f * sinf( t * 0.52f );
|
attributes.gravity = 0.0f + 0.05f * sinf( t * 0.52f );
|
||||||
attributes.airFriction = 2.5 + 2.0f * sinf( t * 0.32f );
|
attributes.airFriction = 2.5 + 2.0f * sinf( t * 0.32f );
|
||||||
attributes.jitter = 0.05f + 0.05f * sinf( t * 0.42f );
|
attributes.jitter = 0.05f + 0.05f * sinf( t * 0.42f );
|
||||||
|
@ -3563,7 +3556,7 @@ void Application::updateParticleSystem(float deltaTime) {
|
||||||
attributes.gravity = 0.0f;
|
attributes.gravity = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
_particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes);
|
_particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
_particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f));
|
_particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
|
@ -147,7 +147,7 @@ void ParticleSystem::killParticle(int p) {
|
||||||
_numParticles --;
|
_numParticles --;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void ParticleSystem::setOrangeBlueColorPalette() {
|
void ParticleSystem::setOrangeBlueColorPalette() {
|
||||||
|
|
||||||
for (unsigned int p = 0; p < _numParticles; p++) {
|
for (unsigned int p = 0; p < _numParticles; p++) {
|
||||||
|
@ -163,6 +163,7 @@ void ParticleSystem::setOrangeBlueColorPalette() {
|
||||||
_particle[p].color = glm::vec4(red, green, blue, alpha);
|
_particle[p].color = glm::vec4(red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
void ParticleSystem::setParticleAttributes(int emitterIndex, ParticleAttributes attributes) {
|
void ParticleSystem::setParticleAttributes(int emitterIndex, ParticleAttributes attributes) {
|
||||||
|
@ -201,13 +202,7 @@ void ParticleSystem::updateParticle(int p, float deltaTime) {
|
||||||
int lifeStage = (int)( ageFraction * (NUM_PARTICLE_LIFE_STAGES-1) );
|
int lifeStage = (int)( ageFraction * (NUM_PARTICLE_LIFE_STAGES-1) );
|
||||||
|
|
||||||
float lifeStageFraction = ageFraction * ( NUM_PARTICLE_LIFE_STAGES - 1 ) - lifeStage;
|
float lifeStageFraction = ageFraction * ( NUM_PARTICLE_LIFE_STAGES - 1 ) - lifeStage;
|
||||||
|
|
||||||
/*
|
|
||||||
if ( p == 0 ) {
|
|
||||||
printf( "lifespan = %f ageFraction = %f lifeStage = %d lifeStageFraction = %f\n", _particle[p].lifespan, ageFraction, lifeStage, lifeStageFraction );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
_particle[p].radius
|
_particle[p].radius
|
||||||
= _emitter[_particle[p].emitterIndex].particleAttributes[lifeStage ].radius * (1.0f - lifeStageFraction)
|
= _emitter[_particle[p].emitterIndex].particleAttributes[lifeStage ].radius * (1.0f - lifeStageFraction)
|
||||||
+ _emitter[_particle[p].emitterIndex].particleAttributes[lifeStage+1].radius * lifeStageFraction;
|
+ _emitter[_particle[p].emitterIndex].particleAttributes[lifeStage+1].radius * lifeStageFraction;
|
||||||
|
@ -294,6 +289,7 @@ void ParticleSystem::updateParticle(int p, float deltaTime) {
|
||||||
_particle[p].age += deltaTime;
|
_particle[p].age += deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void ParticleSystem::setCollisionSphere(int e, glm::vec3 position, float radius) {
|
void ParticleSystem::setCollisionSphere(int e, glm::vec3 position, float radius) {
|
||||||
|
|
||||||
int lifeStage = 0;
|
int lifeStage = 0;
|
||||||
|
@ -302,6 +298,7 @@ void ParticleSystem::setCollisionSphere(int e, glm::vec3 position, float radius)
|
||||||
_emitter[e].particleAttributes[lifeStage].collisionSpherePosition = position;
|
_emitter[e].particleAttributes[lifeStage].collisionSpherePosition = position;
|
||||||
_emitter[e].particleAttributes[lifeStage].collisionSphereRadius = radius;
|
_emitter[e].particleAttributes[lifeStage].collisionSphereRadius = radius;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void ParticleSystem::setEmitterBaseParticle(int emitterIndex, bool showing ) {
|
void ParticleSystem::setEmitterBaseParticle(int emitterIndex, bool showing ) {
|
||||||
|
|
||||||
|
|
|
@ -42,17 +42,15 @@ public:
|
||||||
void emitParticlesNow(int emitterIndex, int numParticles, float radius, glm::vec4 color, glm::vec3 velocity, float lifespan);
|
void emitParticlesNow(int emitterIndex, int numParticles, float radius, glm::vec4 color, glm::vec3 velocity, float lifespan);
|
||||||
void simulate(float deltaTime);
|
void simulate(float deltaTime);
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up
|
||||||
void setEmitterBaseParticle(int emitterIndex, bool showing );
|
void setEmitterBaseParticle(int emitterIndex, bool showing );
|
||||||
void setEmitterBaseParticle(int emitterIndex, bool showing, float radius, glm::vec4 color );
|
void setEmitterBaseParticle(int emitterIndex, bool showing, float radius, glm::vec4 color );
|
||||||
|
void setParticleAttributes (int emitterIndex, ParticleAttributes attributes);
|
||||||
void setOrangeBlueColorPalette(); // apply a nice preset color palette to the particles
|
void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes);
|
||||||
void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up
|
void setEmitterPosition (int emitterIndex, glm::vec3 position) { _emitter[emitterIndex].position = position; } // set position of emitter
|
||||||
void setParticleAttributes(int emitterIndex, ParticleAttributes attributes);
|
void setEmitterRotation (int emitterIndex, glm::quat rotation) { _emitter[emitterIndex].rotation = rotation; } // set rotation of emitter
|
||||||
void setParticleAttributes(int emitterIndex, int lifeStage, ParticleAttributes attributes);
|
void setShowingEmitter (int emitterIndex, bool showing ) { _emitter[emitterIndex].visible = showing; } // set its visibiity
|
||||||
void setCollisionSphere (int emitterIndex, glm::vec3 position, float radius); // specify a sphere for the particles to collide with
|
|
||||||
void setEmitterPosition (int emitterIndex, glm::vec3 position) { _emitter[emitterIndex].position = position; } // set position of emitter
|
|
||||||
void setEmitterRotation (int emitterIndex, glm::quat rotation) { _emitter[emitterIndex].rotation = rotation; } // set rotation of emitter
|
|
||||||
void setShowingEmitter (int emitterIndex, bool showing ) { _emitter[emitterIndex].visible = showing; } // set its visibiity
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue