Index: branches/playability/src/world_entities/effects/trail.cc
===================================================================
--- branches/playability/src/world_entities/effects/trail.cc	(revision 10095)
+++ branches/playability/src/world_entities/effects/trail.cc	(revision 10102)
@@ -32,4 +32,7 @@
 
 #include "class_id_DEPRECATED.h"
+
+#define trailAlphaMax 1.0f
+#define trailAlphaMin 0.2f
 
 ObjectListDefinition(Trail);
@@ -166,18 +169,27 @@
   float radzero, radone;
 
-  //glPushAttrib(GL_ENABLE_BIT);
+  glPushAttrib(GL_ENABLE_BIT);
   
   glPushMatrix();
   //glMatrixMode(GL_MODELVIEW);
   //glLoadIdentity();
+
+  glEnable( GL_BLEND);
+  glBlendFunc(GL_SRC_ALPHA,GL_ONE)
+  glDisable( GL_ALPHA_TEST);
+
   glTranslatef(-this->getAbsCoor().x,-this->getAbsCoor().y,-this->getAbsCoor().z);
   glScalef(1,1,1);
   this->material->select();
-  /*
-  glBegin(GL_TRIANGLESTRIP);
-  for( int i = 0; i < this->sections-1; i++)
-  {
-    rad1  = this->radius * (1.0-i*fact);
-    rad0  = this->radius * (1.0-(i+1)*fact);
+
+  float alphaStep = (trailAlphaMax - trailAlphaMin)/this->sections;
+
+  glBegin(GL_TRIANGLE_STRIP);
+
+  // Alpha goes from 1.0 to 0.4 -> alphastep = .6 / this->sections
+  for( int i = 1; i < this->sections-1; i++)
+  {
+    radone  = this->radius * (1.0-i*fact);
+    radzero  = this->radius * (1.0-(i+1)*fact);
 
     now   =  this->nodeList[i];
@@ -188,23 +200,60 @@
       targ  = (this->getAbsCoor() - now).getNormalized();
 
-    // vertical polygon
-    Q[0]  = now + Vector(0,rad1,0) ;
-    Q[1]  = later + Vector(0,rad0,0) ;
-    Q[2]  = later + Vector(0,-rad0,0) ;
-    Q[3]  = now + Vector(0,-rad1,0) ;
-    //PRINTF(0)("Debug output: Q0 (%f,%f,%f) :: Q1 (%f,%f,%f) :: Q2 (%f,%f,%f) :: Q3 (%f,%f,%f)\n",Q[0].x,Q[0].y,Q[0].z,Q[1].x,Q[1].y,Q[1].z,Q[2].x,Q[2].y,Q[2].z,Q[3].x,Q[3].y,Q[3].z);
-
-      glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
-      glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
-      glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
-      glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
+    // horizontal polygon
+    Q[0]  = now + Vector(0,radone,0) ;
+    Q[3]  = now + Vector(0,-radone,0) ;
     
-  }
-  glEnd();
-  glBegin(GL_TRIANGLESTRIP);
-  for( int i = 0; i < this->sections-1; i++)
-  {
-    rad1  = this->radius * (1.0-i*fact);
-    rad0  = this->radius * (1.0-(i+1)*fact);
+    glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
+	glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
+
+    if( i == this->sections - 1)
+    {
+      
+      Q[1]  = later + Vector(0,radzero,0) ;
+      Q[2]  = later + Vector(0,-radzero,0) ;
+      glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
+      glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
+    }
+
+
+  }
+  glEnd();
+  glBegin(GL_TRIANGLE_STRIP);
+  for( int i = this->sections-1; i > 0; i--)
+  {
+    radone  = this->radius * (1.0-i*fact);
+    radzero  = this->radius * (1.0-(i-1)*fact);
+
+    now   =  this->nodeList[i];
+    later =  this->nodeList[i-1];
+    if( i == 0)
+      targ  = this->getAbsDir().apply(Vector(1,0,0)).getNormalized();
+    else
+      targ  = (this->getAbsCoor() - now).getNormalized();
+
+    // horizontal polygon
+    Q[0]  = now + Vector(0,radone,0) ;
+    Q[3]  = now + Vector(0,-radone,0) ;
+
+	glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.01f);
+	glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z+0.01f);
+
+    if( i == 1)
+    {
+        Q[1]  = later + Vector(0,radzero,0) ;
+        Q[2]  = later + Vector(0,-radzero,0) ;
+		glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z+0.01f);
+		glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z+0.01f);
+	}
+
+  }
+  glEnd();
+
+
+  glBegin(GL_TRIANGLE_STRIP);
+  for( int i = 1; i < this->sections-1; i++)
+  {
+    radone  = this->radius * (1.0-i*fact);
+    radzero  = this->radius * (1.0-(i+1)*fact);
 
     now   =  this->nodeList[i];
@@ -215,45 +264,17 @@
       targ  = (this->getAbsCoor() - now).getNormalized();
 
-    // vertical polygon
-    Q[0]  = now + Vector(0,rad1,0) ;
-    Q[1]  = later + Vector(0,rad0,0) ;
-    Q[2]  = later + Vector(0,-rad0,0) ;
-    Q[3]  = now + Vector(0,-rad1,0) ;
-    //PRINTF(0)("Debug output: Q0 (%f,%f,%f) :: Q1 (%f,%f,%f) :: Q2 (%f,%f,%f) :: Q3 (%f,%f,%f)\n",Q[0].x,Q[0].y,Q[0].z,Q[1].x,Q[1].y,Q[1].z,Q[2].x,Q[2].y,Q[2].z,Q[3].x,Q[3].y,Q[3].z);
-
-      glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
-      glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
-      glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
-      glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
+    // horizontal polygon
+    Q[0]  = now + targ.cross(Vector(0,radone,0)) ;
+    Q[3]  = now + targ.cross(Vector(0,-radone,0)) ;
     
-  }
-  glEnd();*/
-  glBegin(GL_TRIANGLE_STRIP);
-  for( int i = 1; i < this->sections-1; i++)
-  {
-    radone  = this->radius * (1.0-i*fact);
-    radzero  = this->radius * (1.0-(i+1)*fact);
-
-    now   =  this->nodeList[i];
-    later =  this->nodeList[i+1];
-    if( i == 0)
-      targ  = this->getAbsDir().apply(Vector(1,0,0)).getNormalized();
-    else
-      targ  = (this->getAbsCoor() - now).getNormalized();
-
-    // horizontal polygon
-    Q[0]  = now + Vector(0,radone,0) ;
-    Q[3]  = now + Vector(0,-radone,0) ;
-    
-    glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
-	glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
-
-    if( i == this->sections - 1)
+	glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
+	glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
+
+    if( i == this->sections-1)
     {
-      
-      Q[1]  = later + Vector(0,radzero,0) ;
-      Q[2]  = later + Vector(0,-radzero,0) ;
-      glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
-      glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
+      Q[1]  = later + targ.cross(Vector(0,radzero,0)) ;
+      Q[2]  = later + targ.cross(Vector(0,-radzero,0)) ;
+      glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
+      glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
     }
 
@@ -275,72 +296,9 @@
 
     // horizontal polygon
-    Q[0]  = now + Vector(0,radone,0) ;
-    Q[3]  = now + Vector(0,-radone,0) ;
-
-	glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.0001f);
-	glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z+0.0001f);
-
-    if( i == 1)
-    {
-        Q[1]  = later + Vector(0,radzero,0) ;
-        Q[2]  = later + Vector(0,-radzero,0) ;
-		glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z+0.0001f);
-		glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z+0.0001f);
-	}
-
-  }
-  glEnd();
-
-
-  glBegin(GL_TRIANGLE_STRIP);
-  for( int i = 1; i < this->sections-1; i++)
-  {
-    radone  = this->radius * (1.0-i*fact);
-    radzero  = this->radius * (1.0-(i+1)*fact);
-
-    now   =  this->nodeList[i];
-    later =  this->nodeList[i+1];
-    if( i == 0)
-      targ  = this->getAbsDir().apply(Vector(1,0,0)).getNormalized();
-    else
-      targ  = (this->getAbsCoor() - now).getNormalized();
-
-    // horizontal polygon
     Q[0]  = now + targ.cross(Vector(0,radone,0)) ;
     Q[3]  = now + targ.cross(Vector(0,-radone,0)) ;
-    
-	glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
-	glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
-
-    if( i == this->sections-1)
-    {
-      Q[1]  = later + targ.cross(Vector(0,radzero,0)) ;
-      Q[2]  = later + targ.cross(Vector(0,-radzero,0)) ;
-      glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
-      glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
-    }
-
-
-  }
-  glEnd();
-  glBegin(GL_TRIANGLE_STRIP);
-  for( int i = this->sections-1; i > 0; i--)
-  {
-    radone  = this->radius * (1.0-i*fact);
-    radzero  = this->radius * (1.0-(i-1)*fact);
-
-    now   =  this->nodeList[i];
-    later =  this->nodeList[i-1];
-    if( i == 0)
-      targ  = this->getAbsDir().apply(Vector(1,0,0)).getNormalized();
-    else
-      targ  = (this->getAbsCoor() - now).getNormalized();
-
-    // horizontal polygon
-    Q[0]  = now + targ.cross(Vector(0,radone,0)) ;
-    Q[3]  = now + targ.cross(Vector(0,-radone,0)) ;
-
-	glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x+0.0001f,Q[0].y,Q[0].z);
-	glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x+0.0001f,Q[3].y,Q[3].z);
+
+	glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x+0.01f,Q[0].y,Q[0].z);
+	glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x+0.01f,Q[3].y,Q[3].z);
 
     if( i == 1)
@@ -348,6 +306,6 @@
         Q[1]  = later + targ.cross(Vector(0,radzero,0)) ;
         Q[2]  = later + targ.cross(Vector(0,-radzero,0)) ;
-		glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x+0.0001f,Q[1].y,Q[1].z);
-		glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x+0.0001f,Q[2].y,Q[2].z);
+		glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x+0.01f,Q[1].y,Q[1].z);
+		glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x+0.01f,Q[2].y,Q[2].z);
 	}
 
@@ -357,5 +315,5 @@
 
   glPopMatrix();
-  //glPopAttrib();
+  glPopAttrib();
 /*
   //glTranslatef(this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z);
