diff --git a/interface/src/ParticleSystem.cpp b/interface/src/ParticleSystem.cpp index c40d692166..c61bc41764 100644 --- a/interface/src/ParticleSystem.cpp +++ b/interface/src/ParticleSystem.cpp @@ -69,13 +69,12 @@ ParticleSystem::ParticleSystem() { int ParticleSystem::addEmitter() { - _numEmitters ++; - - if (_numEmitters > MAX_EMITTERS) { - return -1; + if (_numEmitters < MAX_EMITTERS) { + _numEmitters ++; + return _numEmitters - 1; } - return _numEmitters - 1; + return -1; } @@ -95,12 +94,16 @@ void ParticleSystem::simulate(float deltaTime) { void ParticleSystem::emitNow(int e) { - for (unsigned int p = 0; p < _emitter[e].rate; p++) { - createParticle(e, _emitter[e].direction); + assert( e >= 0 ); + assert( e <= MAX_EMITTERS ); + assert( _emitter[e].rate >= 0 ); + + for (int p = 0; p < _emitter[e].rate; p++) { + createParticle(e); } } -void ParticleSystem::createParticle(int e, glm::vec3 velocity) { +void ParticleSystem::createParticle(int e) { for (unsigned int p = 0; p < MAX_PARTICLES; p++) { if (!_particle[p].alive) { diff --git a/interface/src/ParticleSystem.h b/interface/src/ParticleSystem.h index 9ba8d8ed35..34089941bd 100644 --- a/interface/src/ParticleSystem.h +++ b/interface/src/ParticleSystem.h @@ -11,7 +11,7 @@ #include const int MAX_PARTICLES = 5000; -const int MAX_EMITTERS = 1000; +const int MAX_EMITTERS = 100; const int NUM_PARTICLE_LIFE_STAGES = 4; // each equal time-division of the particle's life can have different attributes const bool SHOW_VELOCITY_TAILS = false; @@ -99,7 +99,7 @@ private: // private methods void updateParticle(int index, float deltaTime); - void createParticle(int e, glm::vec3 velocity); + void createParticle(int e); void killParticle(int p); void renderEmitter(int emitterIndex, float size); void renderParticle(int p); diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 8a4f04ad78..96993b2bc9 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -15,7 +15,7 @@ #include "renderer/ProgramObject.h" const bool SHOW_LEAP_HAND = false; -const int NUM_TEST_RAVE_GLOVE_MODES = 5; +const int NUM_TEST_RAVE_GLOVE_MODES = 6; const float TEST_RAVE_GLOVE_MODE_DURATION = 7.0f; using namespace std; @@ -342,14 +342,14 @@ void Hand::updateFingerParticles(float deltaTime) { FingerData& finger = palm.getFingers()[f]; if (finger.isActive()) { if (_fingerParticleEmitter[0] != -1) { - _particleSystem.emitNow(_fingerParticleEmitter[fingerIndex]); + _particleSystem.emitNow(_fingerParticleEmitter[fingerIndex]); fingerIndex ++; } } } } } - + _particleSystem.simulate(deltaTime); } } @@ -530,6 +530,43 @@ void Hand::setRaveGloveMode(int mode) { attributes.radius = 0.0f; attributes.color = glm::vec4( 0.0f, 0.0f, 0.0f, 1.0f); _particleSystem.setParticleAttributes(_fingerParticleEmitter[f], 3, attributes); + + //----------------------------------------- + // flashy trails + //----------------------------------------- + } else if (mode == 5) { + + _particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_RIBBON ); + _particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], false ); + _particleSystem.setEmitterParticleLifespan (_fingerParticleEmitter[f], 0.2 ); + _particleSystem.setEmitterThrust (_fingerParticleEmitter[f], 0.002f ); + _particleSystem.setEmitterRate (_fingerParticleEmitter[f], 6.0 ); + _particleSystem.setEmitterParticleResolution (_fingerParticleEmitter[f], 12 ); + + attributes.radius = 0.0f; + attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); + attributes.gravity = 0.0f; + attributes.airFriction = 0.0f; + attributes.jitter = 0.01f; + attributes.emitterAttraction = 0.0f; + attributes.tornadoForce = 0.0f; + attributes.neighborAttraction = 0.0f; + attributes.neighborRepulsion = 0.0f; + attributes.bounce = 1.0f; + attributes.usingCollisionSphere = false; + _particleSystem.setParticleAttributes(_fingerParticleEmitter[f], 0, attributes); + + attributes.radius = 0.01f; + attributes.color = glm::vec4( 1.0f, 1.0f, 0.0f, 1.0f); + _particleSystem.setParticleAttributes(_fingerParticleEmitter[f], 1, attributes); + + attributes.radius = 0.01f; + attributes.color = glm::vec4( 1.0f, 0.0f, .0f, 1.0f); + _particleSystem.setParticleAttributes(_fingerParticleEmitter[f], 2, attributes); + + attributes.radius = 0.0f; + attributes.color = glm::vec4( 0.0f, 0.0f, 1.0f, 0.0f); + _particleSystem.setParticleAttributes(_fingerParticleEmitter[f], 3, attributes); } } } diff --git a/interface/src/avatar/Hand.h b/interface/src/avatar/Hand.h index d0782138da..8152a4b271 100755 --- a/interface/src/avatar/Hand.h +++ b/interface/src/avatar/Hand.h @@ -19,8 +19,6 @@ #include #include -//const int MAX_TRAIL_PARTICLES = 20; - class Avatar; class ProgramObject; @@ -63,7 +61,6 @@ private: int _testRaveGloveMode; bool _particleSystemInitialized; int _fingerParticleEmitter[NUM_FINGERS]; - //int _fingerTrailParticleEmitter[NUM_FINGERS][MAX_TRAIL_PARTICLES]; Avatar* _owningAvatar; float _renderAlpha; bool _lookingInMirror;