Browse Source

fix user alpha

georges 25 years ago
parent
commit
0acafa7712

+ 10 - 9
panda/src/particlesystem/geomParticleRenderer.cxx

@@ -148,17 +148,18 @@ render(vector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
       PT(ColorTransition) alpha;
       PT(ColorTransition) alpha;
       xform = new TransformTransition(LMatrix4f::translate_mat(pos));
       xform = new TransformTransition(LMatrix4f::translate_mat(pos));
 
 
-      if ((_alpha_mode != PR_ALPHA_NONE) && (_alpha_mode != PR_ALPHA_USER)) {
-
-        float alpha_scalar = cur_particle->get_parameterized_age();
-
-        if (_alpha_mode == PR_ALPHA_IN) {
-          alpha = new ColorTransition(1.0f, 1.0f, 1.0f, alpha_scalar);
-        }
-        else if (_alpha_mode == PR_ALPHA_OUT) {
-          alpha = new ColorTransition(1.0f, 1.0f, 1.0f, 1.0f - alpha_scalar);
+      if ((_alpha_mode != PR_ALPHA_NONE)) {
+        float alpha_scalar;
+
+	    if(_alpha_mode == PR_ALPHA_USER) {
+			alpha_scalar=get_user_alpha();
+		} else {
+			alpha_scalar = cur_particle->get_parameterized_age();
+			if (_alpha_mode == PR_ALPHA_OUT) 
+				alpha_scalar = 1.0f - alpha_scalar;
         }
         }
 
 
+        alpha = new ColorTransition(1.0f, 1.0f, 1.0f, alpha_scalar);
         cur_arc->set_transition(alpha);
         cur_arc->set_transition(alpha);
       }
       }
 
 

+ 9 - 3
panda/src/particlesystem/lineParticleRenderer.cxx

@@ -189,10 +189,16 @@ render(vector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
     // handle alpha
     // handle alpha
 
 
     if (_alpha_mode != PR_ALPHA_NONE) {
     if (_alpha_mode != PR_ALPHA_NONE) {
-      float alpha = cur_particle->get_parameterized_age();
 
 
-      if (_alpha_mode == PR_ALPHA_OUT)
-        alpha = 1.0f - alpha;
+	  float alpha;
+
+      if (_alpha_mode == PR_ALPHA_USER) {
+		  alpha = get_user_alpha();
+	  } else {
+		  alpha = cur_particle->get_parameterized_age();
+		  if (_alpha_mode == PR_ALPHA_OUT)
+			  alpha = 1.0f - alpha;
+	  }
 
 
       head_color[3] = alpha;
       head_color[3] = alpha;
       tail_color[3] = alpha;
       tail_color[3] = alpha;

+ 15 - 5
panda/src/particlesystem/pointParticleRenderer.cxx

@@ -175,14 +175,24 @@ create_color(const BaseParticle *p) {
 
 
   // handle alpha channel
   // handle alpha channel
 
 
-  if (!((_alpha_mode == PR_ALPHA_NONE) || (_alpha_mode == PR_ALPHA_USER))) {
+  if(_alpha_mode != PR_ALPHA_NONE) {
+
     if (have_alpha_t == false)
     if (have_alpha_t == false)
       alpha_linear_t = p->get_parameterized_age();
       alpha_linear_t = p->get_parameterized_age();
 
 
-    if (_alpha_mode == PR_ALPHA_OUT)
-      color[3] = 1.0f - alpha_linear_t;
-    else
-      color[3] = alpha_linear_t;
+	switch(_alpha_mode) {
+	    case PR_ALPHA_OUT:
+			color[3] = 1.0f - alpha_linear_t;        
+			break;
+
+	    case PR_ALPHA_IN:
+			color[3] = alpha_linear_t;        
+			break;
+
+	    case PR_ALPHA_USER:
+			color[3] = get_user_alpha();
+			break;
+	}
   }
   }
 
 
   return color;
   return color;

+ 8 - 4
panda/src/particlesystem/sparkleParticleRenderer.cxx

@@ -200,10 +200,14 @@ render(vector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
     // handle alpha
     // handle alpha
 
 
     if (_alpha_mode != PR_ALPHA_NONE) {
     if (_alpha_mode != PR_ALPHA_NONE) {
-      alpha = cur_particle->get_parameterized_age();
-
-      if (_alpha_mode == PR_ALPHA_OUT)
-	alpha = 1.0f - alpha;
+	  if(_alpha_mode == PR_ALPHA_USER) {
+		  alpha=get_user_alpha();
+	  } else {
+		  alpha = cur_particle->get_parameterized_age();
+
+		  if (_alpha_mode == PR_ALPHA_OUT)
+			  alpha = 1.0f - alpha;
+	  }
 
 
       center_color[3] = alpha;
       center_color[3] = alpha;
       edge_color[3] = alpha;
       edge_color[3] = alpha;