Browse Source

Added spread value for ring and alpha in out mode for particles

Mark Mine 21 years ago
parent
commit
acf25fe6ad

+ 4 - 0
panda/src/particlesystem/baseParticleRenderer.I

@@ -79,6 +79,10 @@ get_cur_alpha(BaseParticle* bp) {
   case PR_ALPHA_IN:
     return bp->get_parameterized_age();
 
+  case PR_ALPHA_IN_OUT:
+    return 2.0 * min(bp->get_parameterized_age(),
+                     1.0f - bp->get_parameterized_age());
+
   case PR_ALPHA_USER:
     return _user_alpha;
 

+ 1 - 0
panda/src/particlesystem/baseParticleRenderer.h

@@ -40,6 +40,7 @@ PUBLISHED:
     PR_ALPHA_NONE,
     PR_ALPHA_OUT,
     PR_ALPHA_IN,
+    PR_ALPHA_IN_OUT,
     PR_ALPHA_USER,
     PR_NOT_INITIALIZED_YET
   };

+ 2 - 0
panda/src/particlesystem/geomParticleRenderer.cxx

@@ -191,6 +191,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
           alpha_scalar = cur_particle->get_parameterized_age();
           if (_alpha_mode == PR_ALPHA_OUT)
             alpha_scalar = 1.0f - alpha_scalar;
+          else if (_alpha_mode == PR_ALPHA_IN_OUT)
+            alpha_scalar = 2.0f * min(alpha_scalar, 1.0f - alpha_scalar);
           alpha_scalar *= get_user_alpha();
         }
         

+ 2 - 0
panda/src/particlesystem/lineParticleRenderer.cxx

@@ -212,6 +212,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
                   alpha = cur_particle->get_parameterized_age();
                   if (_alpha_mode == PR_ALPHA_OUT)
                           alpha = 1.0f - alpha;
+                  else if (_alpha_mode == PR_ALPHA_IN_OUT)
+                    alpha = 2.0f * min(alpha, 1.0f - alpha);
           }
 
       head_color[3] = alpha;

+ 3 - 0
panda/src/particlesystem/pointParticleRenderer.cxx

@@ -201,6 +201,9 @@ create_color(const BaseParticle *p) {
 
       if(_alpha_mode==PR_ALPHA_OUT) {
         parameterized_age = 1.0f - parameterized_age;
+      } else if(_alpha_mode==PR_ALPHA_IN_OUT) {
+        parameterized_age = 2.0f * min(parameterized_age, 
+                                      1.0f - parameterized_age);
       }
     }
     color[3] = parameterized_age * get_user_alpha();

+ 23 - 0
panda/src/particlesystem/ringEmitter.I

@@ -38,6 +38,17 @@ set_angle(float angle) {
   _aoe = angle;
 }
 
+////////////////////////////////////////////////////////////////////
+//    Function : set_radius_spread
+//      Access : public
+// Description : radius_spread set
+////////////////////////////////////////////////////////////////////
+
+INLINE void RingEmitter::
+set_radius_spread(float spread) {
+  _radius_spread = spread;
+}
+
 ////////////////////////////////////////////////////////////////////
 //    Function : get_radius
 //      Access : public
@@ -59,3 +70,15 @@ INLINE float RingEmitter::
 get_angle() const {
   return _aoe;
 }
+
+////////////////////////////////////////////////////////////////////
+//    Function : get_radius_spread
+//      Access : public
+// Description : radius_spread get
+////////////////////////////////////////////////////////////////////
+
+INLINE float RingEmitter::
+get_radius_spread() const {
+  return _radius_spread;
+}
+

+ 6 - 3
panda/src/particlesystem/ringEmitter.cxx

@@ -25,7 +25,7 @@
 ////////////////////////////////////////////////////////////////////
 RingEmitter::
 RingEmitter() :
-  _radius(1.0f), _aoe(0.0f) {
+  _radius(1.0f), _aoe(0.0f), _radius_spread(0.0f) {
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -38,6 +38,7 @@ RingEmitter(const RingEmitter &copy) :
   BaseParticleEmitter(copy) {
   _radius = copy._radius;
   _aoe = copy._aoe;
+  _radius_spread = copy._radius_spread;
 
   _sin_theta = copy._sin_theta;
   _cos_theta = copy._cos_theta;
@@ -73,8 +74,9 @@ assign_initial_position(LPoint3f& pos) {
   _cos_theta = cosf(theta);
   _sin_theta = sinf(theta);
 
-  float new_x = _cos_theta * _radius;
-  float new_y = _sin_theta * _radius;
+  float new_radius_spread = SPREAD(_radius_spread);
+  float new_x = _cos_theta * (_radius + new_radius_spread);
+  float new_y = _sin_theta * (_radius + new_radius_spread);
 
   pos.set(new_x, new_y, 0.0f);
 }
@@ -127,6 +129,7 @@ write(ostream &out, int indent) const {
   #ifndef NDEBUG //[
   out.width(indent); out<<""; out<<"RingEmitter:\n";
   out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n";
+  out.width(indent+2); out<<""; out<<"_radius_spread "<<_radius_spread<<"\n";
   out.width(indent+2); out<<""; out<<"_aoe "<<_aoe<<"\n";
   out.width(indent+2); out<<""; out<<"_sin_theta "<<_sin_theta<<"\n";
   out.width(indent+2); out<<""; out<<"_cos_theta "<<_cos_theta<<"\n";

+ 3 - 0
panda/src/particlesystem/ringEmitter.h

@@ -36,15 +36,18 @@ PUBLISHED:
 
   INLINE void set_radius(float r);
   INLINE void set_angle(float angle);
+  INLINE void set_radius_spread(float spread);
 
   INLINE float get_radius() const;
   INLINE float get_angle() const;
+  INLINE float get_radius_spread() const;
 
   virtual void output(ostream &out) const;
   virtual void write(ostream &out, int indent=0) const;
 
 private:
   float _radius;
+  float _radius_spread;
 
   // CUSTOM EMISSION PARAMETERS
   float _aoe;  // angle of elevation

+ 2 - 0
panda/src/particlesystem/sparkleParticleRenderer.cxx

@@ -211,6 +211,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
         alpha = cur_particle->get_parameterized_age();
         if (_alpha_mode == PR_ALPHA_OUT)
           alpha = 1.0f - alpha;
+        else if (_alpha_mode == PR_ALPHA_IN_OUT)
+          alpha = 2.0f * min(alpha, 1.0f - alpha);
 
         alpha *= get_user_alpha();
       }

+ 3 - 0
panda/src/particlesystem/spriteParticleRenderer.cxx

@@ -330,6 +330,9 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
         c[3] = (1.0f - t) * get_user_alpha();
       else if (alphamode == PR_ALPHA_IN)
         c[3] = t * get_user_alpha();
+      else if (alphamode == PR_ALPHA_IN_OUT) {
+        c[3] = 2.0f * min(t, 1.0f - t) * get_user_alpha();
+      }
       else {
         assert(alphamode == PR_ALPHA_USER);
         c[3] = get_user_alpha();

+ 18 - 0
panda/src/particlesystem/tangentRingEmitter.I

@@ -25,6 +25,15 @@ set_radius(float r) {
   _radius = r;
 }
 
+////////////////////////////////////////////////////////////////////
+//  Function : set_radius_spread
+//    Access : public
+////////////////////////////////////////////////////////////////////
+INLINE void TangentRingEmitter::
+set_radius_spread(float spread) {
+  _radius_spread = spread;
+}
+
 ////////////////////////////////////////////////////////////////////
 //  Function : get_radius
 //    Access : public
@@ -33,3 +42,12 @@ INLINE float TangentRingEmitter::
 get_radius(void) const {
   return _radius;
 }
+
+////////////////////////////////////////////////////////////////////
+//  Function : get_radius_spread
+//    Access : public
+////////////////////////////////////////////////////////////////////
+INLINE float TangentRingEmitter::
+get_radius_spread(void) const {
+  return _radius_spread;
+}

+ 5 - 1
panda/src/particlesystem/tangentRingEmitter.cxx

@@ -26,6 +26,7 @@
 TangentRingEmitter::
 TangentRingEmitter() {
   _radius = 1.0f;
+  _radius_spread = 0.0f;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -37,6 +38,7 @@ TangentRingEmitter::
 TangentRingEmitter(const TangentRingEmitter &copy) :
   BaseParticleEmitter(copy) {
   _radius = copy._radius;
+  _radius_spread = copy._radius_spread;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -70,7 +72,8 @@ assign_initial_position(LPoint3f& pos) {
   _x = cosf(theta);
   _y = sinf(theta);
 
-  pos.set(_radius * _x, _radius * _y, 0.0f);
+  float new_radius = _radius + SPREAD(_radius_spread);
+  pos.set(new_radius * _x, new_radius * _y, 0.0f);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -107,6 +110,7 @@ write(ostream &out, int indent) const {
   #ifndef NDEBUG //[
   out.width(indent); out<<""; out<<"TangentRingEmitter:\n";
   out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n";
+  out.width(indent+2); out<<""; out<<"_radius_spread "<<_radius_spread<<"\n";
   out.width(indent+2); out<<""; out<<"_x "<<_x<<"\n";
   out.width(indent+2); out<<""; out<<"_y "<<_y<<"\n";
   BaseParticleEmitter::write(out, indent+2);

+ 4 - 0
panda/src/particlesystem/tangentRingEmitter.h

@@ -36,13 +36,17 @@ PUBLISHED:
   virtual BaseParticleEmitter *make_copy();
 
   INLINE void set_radius(float r);
+  INLINE void set_radius_spread(float spread);
+
   INLINE float get_radius() const;
+  INLINE float get_radius_spread() const;
 
   virtual void output(ostream &out) const;
   virtual void write(ostream &out, int indent=0) const;
 
 private:
   float _radius;
+  float _radius_spread;
 
   // CUSTOM EMISSION PARAMETERS
   // none