Index: trunk/src/world_entities/effects/trail.cc
===================================================================
--- trunk/src/world_entities/effects/trail.cc	(revision 10368)
+++ trunk/src/world_entities/effects/trail.cc	(revision 10368)
@@ -0,0 +1,312 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2006 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+
+   Trail system for engine output trails.
+   uses a catmull rom spline to interpolate the curve which is subdivided
+   into sections parts.
+   main-programmer: Marc Schaerer
+*/
+
+#include "trail.h"
+
+#include "util/loading/load_param.h"
+#include "util/loading/factory.h"
+
+#include "quaternion.h"
+#include "vector.h"
+
+#include "graphics_engine.h"
+#include "material.h"
+#include "glincl.h"
+#include "state.h"
+#include "debug.h"
+
+
+
+#define trailAlphaMax 1.0f
+#define trailAlphaMin 0.2f
+
+ObjectListDefinition(Trail);
+CREATE_FACTORY(Trail);
+
+/**
+ * standart constructor
+ * @param maxLength maximum length of the trail. You will later need to set the actual length used.
+ * @param sections number of sections into which the trail polygon shall be splited. Higher number for more smooth curves
+ * @param radius radius of the trail cross.
+ * 
+ */
+Trail::Trail (float maxLength, int sections, float radius, PNode* parent)
+{
+  this->maxLength = maxLength;
+  this->length    = 1.0;
+  this->sections  = sections;
+  this->radius    = radius;
+  this->setParent( parent);
+
+  this->nodeList  = new Vector[sections];
+
+
+  this->init();
+}
+
+Trail::Trail (const TiXmlElement* root)
+{
+  this->init();
+
+  if( root)
+    this->loadParams(root);
+}
+
+/**
+ * destroys a Trail
+ */
+Trail::~Trail ()
+{
+  if (this->material)
+    delete this->material;
+  delete this->nodeList;
+}
+
+
+/**
+ * initializes the Trail
+ */
+void Trail::init()
+{
+  this->registerObject(this, Trail::_objectList);
+  this->setName("Trail");
+
+  this->material = new Material();
+  this->material->setIllum(3);
+  this->material->setDiffuse(1.0,1.0,1.0);
+  this->material->setSpecular(0.0,0.0,0.0);
+  this->material->setAmbient(1.0, 1.0, 1.0);
+
+  this->setAbsCoor(0, 0, 0);
+  this->setVisibiliy(true);
+
+  this->nodeList[0] = (this->getAbsCoor());
+  //PRINTF(0)("Trail data: N%i (%f,%f,%f)",0,this->getAbsCoor().x,this->getAbsCoor().y,this->getAbsCoor().z);
+  for( int i = 1; i < sections; i++)
+  {
+    this->nodeList[i] = (this->getAbsCoor());// - (((this->getParent()->getAbsDir().apply(Vector(1,1,1))).getNormalized() * (i * this->maxLength / sections))));
+    //PRINTF(0)(" N%i (%f,%f,%f)",i,this->nodeList[i].x,this->nodeList[i].y,this->nodeList[i].z);
+  }
+  //PRINTF(0)("\n");
+}
+
+
+/**
+ *  load params
+ * @param root TiXmlElement object
+ */
+void Trail::loadParams(const TiXmlElement* root)
+{
+  WorldEntity::loadParams( root);
+}
+
+/**
+ * sets the material to load
+ * @param textureFile The texture-file to load
+ */
+void Trail::setTexture(const std::string& textureFile)
+{
+  this->material->setDiffuseMap(textureFile);
+}
+
+
+/**
+ * ticks the Trail
+ * @param dt the time to ticks
+ */
+void Trail::tick(float dt)
+{
+  // Update node positions
+  float len = 0;
+  float secLen  = this->maxLength / this->sections;
+  this->nodeList[0] = this->getAbsCoor();
+  this->nodeList[1] = this->getAbsCoor() - ((this->getParent()->getAbsDir().apply(Vector(1,0,0))).getNormalized() *  this->maxLength / sections);
+  for(int i = 2; i < this->sections; i++)
+  {
+    len = (this->nodeList[i-1] - this->nodeList[i]).len();
+    if( secLen < len) len = secLen;
+    this->nodeList[i] = this->nodeList[i-1] - (this->nodeList[i-1] - this->nodeList[i]).getNormalized()*len;
+  }
+}
+
+
+/**
+ * draws the trail
+ * the trail has a cone shape
+ */
+void Trail::draw() const
+{
+  if(!this->isVisible())
+    return;
+
+  Vector* Q = new Vector[4];
+  Vector targ;
+  Vector now, later;
+  float fact  = 1.0/this->sections;
+  float radzero, radone;
+
+  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();
+
+  //float alphaStep = 1.0 / 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 + 0.2 * (float)rand()/(float)RAND_MAX);
+    radzero  = this->radius * (1.0-(i+1)*fact + 0.2 * (float)rand()/(float)RAND_MAX);
+
+    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)
+    {
+      
+      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);
+    }
+
+
+  }
+  glEnd();
+  glBegin(GL_TRIANGLE_STRIP);
+  for( int i = this->sections-1; i > 0; i--)
+  {
+    radone  = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX);
+    radzero  = this->radius * (1.0-(i-1)*fact + 0.2 * (float)rand()/(float)RAND_MAX);
+
+    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); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.01f);
+	glTexCoord2f(0.0f, 0.0f); 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); glVertex3f(Q[2].x,Q[2].y,Q[2].z+0.01f);
+		glTexCoord2f(0.0f, 1.0f); 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 + 0.2 * (float)rand()/(float)RAND_MAX);
+    radzero  = this->radius * (1.0-(i+1)*fact + 0.2 * (float)rand()/(float)RAND_MAX);
+
+    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 + 0.2 * (float)rand()/(float)RAND_MAX);
+    radzero  = this->radius * (1.0-(i-1)*fact + 0.2 * (float)rand()/(float)RAND_MAX);
+
+    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.01f,Q[0].y,Q[0].z);
+	glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x+0.01f,Q[3].y,Q[3].z);
+
+    if( i == 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+0.01f,Q[1].y,Q[1].z);
+		glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x+0.01f,Q[2].y,Q[2].z);
+	}
+
+  }
+  glEnd();
+  this->material->unselect();
+
+  glPopMatrix();
+  glPopAttrib();
+}
Index: trunk/src/world_entities/effects/trail.h
===================================================================
--- trunk/src/world_entities/effects/trail.h	(revision 10368)
+++ trunk/src/world_entities/effects/trail.h	(revision 10368)
@@ -0,0 +1,62 @@
+/*!
+ * @file trail.h
+ */
+
+#ifndef _TRAIL_H_
+#define _TRAIL_H_
+
+#include "world_entity.h"
+
+class Material;
+
+
+
+class Trail : public WorldEntity
+{
+  ObjectListDeclaration(Trail);
+  public:
+    Trail(float maxLength, int sections, float radius, PNode* parent);
+    Trail(const TiXmlElement* root = NULL);
+    virtual ~Trail();
+
+    virtual void loadParams(const TiXmlElement* root);
+
+    void setTexture(const std::string& textureFile);
+
+    virtual void tick(float dt);
+    virtual void draw() const;
+
+    /**
+     *  length of the trail.
+     */
+    inline void setLength(float length) { this->length = length;};
+    inline float getLength() { return this->length;};
+
+    /**
+     *  Amount of sections (parts) of the trail. The more, the rounder it will look
+     */
+    inline void setSections(int sections) { this->sections = sections;};
+    inline int getSections() { return this->sections;};
+
+    /**
+     *  Radius of the trail object
+     */
+    inline void setRadius(float radius) { this->radius = radius;};
+    inline float getRadius() { return this->radius;};
+
+  private:
+    void init();
+    inline Vector catmull(Vector P0, Vector P1, Vector P2, Vector P3, float t) const {return (P1*2 + (P2 - P0)*t + (P0*2 - P1*5- P2*4 - P3)*t*t + (P1*3 -P0 - P2*3 + P3)*t*t*t); };
+
+
+    Material*              material;
+
+    float maxLength;
+    float length;
+    float radius;
+    int   sections;
+
+    Vector*  nodeList;
+};
+
+#endif /* _TRAIL_H_ */
Index: trunk/src/world_entities/effects/wobblegrid.cc
===================================================================
--- trunk/src/world_entities/effects/wobblegrid.cc	(revision 10368)
+++ trunk/src/world_entities/effects/wobblegrid.cc	(revision 10368)
@@ -0,0 +1,215 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2006 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: David Hasenfratz
+*/
+
+#include "wobblegrid.h"
+
+#include "util/loading/load_param.h"
+#include "util/loading/factory.h"
+
+#include "graphics_engine.h"
+#include "material.h"
+#include "glincl.h"
+#include "state.h"
+#include "grid.h"
+
+#include <assert.h>
+#include "debug.h"
+
+
+
+ObjectListDefinition(Wobblegrid);
+CREATE_FACTORY(Wobblegrid);
+
+/**
+ * Wobble Grids are grids which "wobble"
+ * Wobbling is realized through fixed center and sin wave outwards
+ * For the beginning the grid will be a 5x5
+ */
+
+/**
+ * standart constructor
+ */
+Wobblegrid::Wobblegrid (const TiXmlElement* root)
+{
+  this->size  = 5;
+
+  this->init();
+
+  if( root)
+    this->loadParams(root);
+}
+
+Wobblegrid::Wobblegrid (int size, const TiXmlElement* root)
+{
+  this->size  = size;
+
+  this->init();
+
+  if( root)
+    this->loadParams(root);
+}
+
+
+/**
+ * destroys a Wobblegrid
+ */
+Wobblegrid::~Wobblegrid ()
+{
+  if (this->material)
+    delete this->material;
+}
+
+
+/**
+ * initializes the Wobblegrid
+ */
+void Wobblegrid::init()
+{
+  this->registerObject(this, Wobblegrid::_objectList);
+  this->setName("Wobblegrid");
+
+  this->material = new Material();
+  this->material->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  this->setAbsCoor(0, 0, 0);
+  //this->setVisibiliy(true);
+  
+  this->subdivision = 5;
+
+  this->grid  = new Grid( this->size, this->size, this->subdivision, this->subdivision);
+  this->angularSpeed = M_PI; //180;
+  this->setModel(this->grid);
+
+  this->setUpdateFunction((*sinf));
+}
+
+
+/**
+ *  load params
+ * @param root TiXmlElement object
+ */
+void Wobblegrid::loadParams(const TiXmlElement* root)
+{
+  /*LoadParam(root, "texture", this->material, Material, setDiffuseMap)
+      .describe("the texture-file to load onto the Wobblegrid");
+
+  LoadParam(root, "size", this, Wobblegrid, setSize)
+  .describe("the size of the Wobblegrid in Pixels");*/
+}
+
+
+
+/**
+ * sets the material to load
+ * @param textureFile The texture-file to load
+ */
+void Wobblegrid::setTexture(const std::string& textureFile)
+{
+  this->material->setBlendFunc(GL_SRC_ALPHA,GL_ONE);
+  this->material->setDiffuseMap(textureFile);
+}
+
+
+/**
+ * ticks the Wobblegrid
+ * @param dt the time to ticks
+ */
+void Wobblegrid::tick(float dt)
+{
+  angle += dt * angularSpeed;
+  if (angle > 2 * M_PI)
+    angle -= 2 * M_PI;
+
+  //Vector vec;
+  float fac = 1.0 / (this->subdivision - 1);
+  for( int z=1; z < 4; z++)
+  {
+    for( int x=1; x < 4; x++)
+    {
+      //if(x==2 && z == 2)
+      //  continue;
+
+      Vector2D& vec = this->grid->texCoord(z*this->subdivision + x);
+      vec.y  = (x * fac + sgn(x-2)*updateWobble(angle)*fac/2.0);
+      vec.x  = (z * fac + sgn(z-2)*updateWobble(angle)*fac/2.0);
+    }
+  }
+  //this->grid->finalize();
+  this->orient();
+}
+
+
+/**
+ * draws the billboard
+ */
+void Wobblegrid::draw() const
+{
+
+//   this->material->select();
+//   WorldEntity::draw();
+//   return;
+
+
+  if( !this->isVisible())
+    return;
+
+  glPushAttrib(GL_ENABLE_BIT);
+  glDisable(GL_LIGHTING);
+  glDisable(GL_FOG);
+
+  glMatrixMode(GL_MODELVIEW);
+  glPushMatrix();
+
+  //glTranslatef(this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z);
+  //glTranslatef(0,0,0);
+  this->material->select();
+
+  glDisable(GL_BLEND);
+  glEnable( GL_ALPHA_TEST);
+  glAlphaFunc( GL_GEQUAL, .5);
+
+  glTranslatef (this->getAbsCoor ().x,
+                  this->getAbsCoor ().y,
+                  this->getAbsCoor ().z);
+
+  Vector tmpRot = this->getAbsDir().getSpacialAxis();
+  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
+
+  //Quaternion  dir = Quaternion(this->getAbsDir().getSpacialAxisAngle(),view);
+  //this->setAbsDir(dir);
+  //glRotatef(this->angle, 0.0, 0.0, 1.0);
+  this->grid->draw();
+
+  glPopMatrix();
+
+  glPopAttrib();
+}
+
+void Wobblegrid::orient()
+{
+
+  Vector view = this->getAbsCoor() - State::getCameraNode()->getAbsCoor();
+//   view.normalize();
+
+  Vector up = Vector(0, 1, 0);
+//   if ( up.dot(view) == 0 )
+//     up = Vector(1, 0, 0);
+//   if ( up.dot(view) == 0 )
+//     up = Vector (0, 0, 1);
+
+  Vector h = up.cross(view.getNormalized());
+  up = h.cross(view.getNormalized());
+  Quaternion dir = Quaternion::lookAt( this->getAbsCoor(), this->getAbsCoor() + up, view);
+//   Quaternion dir = Quaternion::lookAt( Vector(), view, up);
+  this->setAbsDir(dir);
+}
Index: trunk/src/world_entities/effects/wobblegrid.h
===================================================================
--- trunk/src/world_entities/effects/wobblegrid.h	(revision 10368)
+++ trunk/src/world_entities/effects/wobblegrid.h	(revision 10368)
@@ -0,0 +1,49 @@
+/*!
+ * @file wobblegrid.h
+ */
+
+#ifndef _WOBBLEGRID_H
+#define _WOBBLEGRID_H
+
+#include "world_entity.h"
+
+class Material;
+class TiXmlElement;
+class Grid;
+
+class Wobblegrid : public WorldEntity
+{
+  ObjectListDeclaration(Wobblegrid);
+  public:
+    Wobblegrid(int size, const TiXmlElement* root = NULL);
+    Wobblegrid( const TiXmlElement* root = NULL);
+    virtual ~Wobblegrid();
+
+    void init();
+    void loadParams(const TiXmlElement* root);
+
+    void setTexture(const std::string& textureFile);
+
+    inline float sgn(float x) { if(likely(x==0)) return 0.0f; else return x / fabsf(x);};
+    virtual void tick(float dt);
+    virtual void draw() const;
+
+    inline void setUpdateFunction(float (*updateFct)(float value)) { if( updateFct)  this->updateWobble = updateFct;};
+
+  private:
+    float (*updateWobble)(float value);
+
+    void orient();
+
+    Material*        material;
+    Grid*            grid;	//!< current projected positions transformed into billboard state
+
+    int subdivision;
+
+    int size;
+
+    float angle;
+    float angularSpeed;
+};
+
+#endif /* _WOBBLEGRID_H */
