Index: orxonox/trunk/src/lib/coord/null_parent.cc
===================================================================
--- orxonox/trunk/src/lib/coord/null_parent.cc	(revision 3917)
+++ orxonox/trunk/src/lib/coord/null_parent.cc	(revision 3966)
@@ -54,5 +54,5 @@
   this->parent = this;
   this->mode = PNODE_ALL;
-  *this->absCoordinate = absCoordinate;
+  this->absCoordinate = absCoordinate;
   this->setName("NullParent");
 }
@@ -80,7 +80,7 @@
 {
 
-  PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z);
-  *this->absCoordinate = *this->relCoordinate;
-  *this->absDirection = parent->getAbsDir () * *this->relDirection;
+  PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
+  this->absCoordinate = this->relCoordinate;
+  this->absDirection = parent->getAbsDir () * this->relDirection;
 
   tIterator<PNode>* iterator = this->children->getIterator();
Index: orxonox/trunk/src/lib/coord/p_node.cc
===================================================================
--- orxonox/trunk/src/lib/coord/p_node.cc	(revision 3917)
+++ orxonox/trunk/src/lib/coord/p_node.cc	(revision 3966)
@@ -60,13 +60,11 @@
   this->init(parent);
 
-  *this->absCoordinate = absCoordinate;
+  this->absCoordinate = absCoordinate;
 
   if (likely(parent != NULL))
   {
-    *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
+    this->relCoordinate = this->absCoordinate - parent->getAbsCoor();
     parent->addChild (this);
   }
-  else 
-    this->relCoordinate = new Vector();
 }
 
@@ -89,10 +87,4 @@
   delete []this->objectName;
 
-  delete this->relCoordinate;
-  delete this->absCoordinate;
-  delete this->relDirection;
-  delete this->absDirection;
-  delete this->lastAbsCoordinate;
-  delete this->diffCoordinate;
 }
 
@@ -108,11 +100,4 @@
   this->objectName = NULL;
   this->time = 1.0; /* set time to 1 to make divisions by zero impossible */
-
-  this->absCoordinate = new Vector();
-  this->relCoordinate = new Vector();
-  this->absDirection = new Quaternion();
-  this->relDirection = new Quaternion();
-  this->lastAbsCoordinate = new Vector();
-  this->diffCoordinate = new Vector();
 }
 
@@ -158,5 +143,5 @@
 {
   this->bRelCoorChanged = true;
-  *this->relCoordinate = relCoord;
+  this->relCoordinate = relCoord;
 }
 
@@ -182,5 +167,5 @@
 {
   this->bAbsCoorChanged = true;
-  *this->absCoordinate = absCoord;
+  this->absCoordinate = absCoord;
 }
 
@@ -211,9 +196,9 @@
   if( unlikely(this->bAbsCoorChanged))
     {
-      *this->absCoordinate = *this->absCoordinate + shift;
+      this->absCoordinate += shift;
     }
   else 
     {
-      *this->relCoordinate = *this->relCoordinate + shift;
+      this->relCoordinate += shift;
       this->bRelCoorChanged = true;
     }
@@ -241,5 +226,5 @@
 {
   this->bRelCoorChanged = true;
-  *this->relDirection = relDir;
+  this->relDirection = relDir;
 }
 
@@ -264,5 +249,5 @@
 {
   this->bAbsDirChanged = true;
-  *this->absDirection = absDir;
+  this->absDirection = absDir;
 }
 
@@ -293,5 +278,5 @@
 {
   this->bRelDirChanged = true;
-  *this->relDirection = *this->relDirection * shift;
+  this->relDirection = this->relDirection * shift;
 }
 
@@ -303,8 +288,14 @@
 float PNode::getSpeed() const
 {
-  *this->diffCoordinate = *this->absCoordinate - *this->lastAbsCoordinate;
-  return this->diffCoordinate->len() / this->time;
-}
-
+  return (this->absCoordinate - this->lastAbsCoordinate).len() / this->time;
+}
+
+/**
+   \returns the Velocity of the PNode
+*/
+Vector PNode::getVelocity() const
+{
+  return (this->absCoordinate - this->lastAbsCoordinate) / this->time;
+}
 
 /**
@@ -432,7 +423,7 @@
 void PNode::update (float dt)
 {
-  *this->lastAbsCoordinate = *this->absCoordinate;
+  this->lastAbsCoordinate = this->absCoordinate;
   this->time = dt;
-  PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z);
+  PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
 
 
@@ -442,5 +433,5 @@
 	{
 	  /* if you have set the absolute coordinates this overrides all other changes */
-	  *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
+	  this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
 	}
       if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
@@ -455,5 +446,5 @@
 	    }
 	    else */
-	  *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate;	      /* update the current absCoordinate */
+	  this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;	      /* update the current absCoordinate */
 	}
     }
@@ -464,10 +455,10 @@
 	{
 	  /* if you have set the absolute coordinates this overrides all other changes */
-	  *this->relDirection = *this->absDirection - parent->getAbsDir();
+	  this->relDirection = this->absDirection - parent->getAbsDir();
 	}
       else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
 	{
 	  /* update the current absDirection - remember * means rotation around sth.*/
-	  *this->absDirection = parent->getAbsDir() * *this->relDirection;
+	  this->absDirection = parent->getAbsDir() * this->relDirection;
 	}
     }
@@ -478,5 +469,5 @@
 	{
 	  /* if you have set the absolute coordinates this overrides all other changes */
-	  *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
+	  this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
 	}
       else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
@@ -486,5 +477,5 @@
 	    *this->absCoordinate = *this->relCoordinate;
 	    else*/
-	  *this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(*this->relCoordinate);	      /* update the current absCoordinate */
+	  this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);	      /* update the current absCoordinate */
 	}
     }
@@ -540,7 +531,7 @@
 {
   PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n", 
-	 this->absCoordinate->x, 
-	 this->absCoordinate->y,
-	 this->absCoordinate->z);
+	 this->absCoordinate.x, 
+	 this->absCoordinate.y,
+	 this->absCoordinate.z);
 }
 
@@ -551,5 +542,5 @@
   for debug purposes realy usefull, not used to work properly
 */
-void PNode::setName (char* newName)
+void PNode::setName (const char* newName)
 {
   this->objectName = new char[strlen(newName)+1];
@@ -561,5 +552,5 @@
   \brief gets the name of the node
 */
-char* PNode::getName ()
+const char* PNode::getName ()
 {
   return this->objectName;
Index: orxonox/trunk/src/lib/coord/p_node.h
===================================================================
--- orxonox/trunk/src/lib/coord/p_node.h	(revision 3917)
+++ orxonox/trunk/src/lib/coord/p_node.h	(revision 3966)
@@ -57,17 +57,18 @@
 
 
-  inline Vector* getRelCoor () const { return this->relCoordinate; }
+  inline const Vector& getRelCoor () const { return this->relCoordinate; }
   void setRelCoor (const Vector& relCoord);
-  inline Vector getAbsCoor () const { return *this->absCoordinate; }
+  inline const Vector& getAbsCoor () const { return this->absCoordinate; }
   void setAbsCoor (const Vector& absCoord);
   void shiftCoor (const Vector& shift);
 
-  inline Quaternion getRelDir () const { return *this->relDirection; }
+  inline const Quaternion& getRelDir () const { return this->relDirection; }
   void setRelDir (const Quaternion& relDir);
-  inline Quaternion getAbsDir () const { return *this->absDirection; }
+  inline const Quaternion& getAbsDir () const { return this->absDirection; }
   void setAbsDir (const Quaternion& absDir);
   void shiftDir (const Quaternion& shift);
 
   float getSpeed() const;
+  Vector getVelocity() const;
 
   void addChild (PNode* pNode, int parentingMode = DEFAULT_MODE);
@@ -85,6 +86,6 @@
   void processTick (float dt);
 
-  void setName (char* newName);
-  char* getName ();
+  void setName (const char* newName);
+  const char* getName ();
 
 
@@ -99,8 +100,8 @@
   bool bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
 
-  Vector* relCoordinate;    //!< coordinates relative to the parent
-  Vector* absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) )
-  Quaternion* relDirection; //!< direction relative to the parent
-  Quaternion* absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
+  Vector relCoordinate;    //!< coordinates relative to the parent
+  Vector absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) )
+  Quaternion relDirection; //!< direction relative to the parent
+  Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
 
   int mode;                //!< the mode of the binding
@@ -109,6 +110,6 @@
   void init(PNode* parent);
 
-  Vector* lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate
-  Vector* diffCoordinate;    //!< this is stored here for performance reasons, difference to the last vector
+  Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate
+  Vector diffCoordinate;    //!< this is stored here for performance reasons, difference to the last vector
   float time;                //!< time since last update
 };
Index: orxonox/trunk/src/lib/graphics/importer/material.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/importer/material.cc	(revision 3917)
+++ orxonox/trunk/src/lib/graphics/importer/material.cc	(revision 3966)
@@ -88,9 +88,5 @@
   
   // setting the transparency
-  if (this->transparency == 1.0)
-    {
-      glDisable(GL_BLEND);
-    }
-  else
+  if (this->transparency < 1.0)
     {
       glEnable(GL_BLEND);
@@ -98,4 +94,10 @@
       glBlendFunc(GL_SRC_ALPHA, GL_ONE);
     }
+  else
+    {
+      glDisable(GL_BLEND);
+      glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    }
+
 
   // setting illumination Model 
@@ -109,4 +111,11 @@
       glEnable(GL_TEXTURE_2D);
       glBindTexture(GL_TEXTURE_2D, this->diffuseTexture->getTexture());
+
+      /* This allows alpha blending of 2D textures with the scene */
+      if (this->diffuseTexture->hasAlpha())
+	{
+	  glEnable(GL_BLEND);
+	  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	}
     }
   else
Index: orxonox/trunk/src/lib/graphics/importer/texture.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/importer/texture.cc	(revision 3917)
+++ orxonox/trunk/src/lib/graphics/importer/texture.cc	(revision 3966)
@@ -25,4 +25,5 @@
 Texture::Texture(const char* imageName)
 {
+  bAlpha = false;
   this->texture = 0;
   if (imageName)
@@ -112,4 +113,5 @@
       if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
 	SDL_SetAlpha(surface, saved_flags | SDL_OPENGL, saved_alpha);
+	this->bAlpha = true;
       }
       
@@ -119,5 +121,6 @@
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-      /*      glTexImage2D(GL_TEXTURE_2D,
+      // build the Texture
+      glTexImage2D(GL_TEXTURE_2D,
 		   0,
 		   GL_RGBA,
@@ -127,7 +130,7 @@
 		   GL_UNSIGNED_BYTE,
 		   image->pixels);
-      */
+      // build the MipMaps
       gluBuild2DMipmaps(GL_TEXTURE_2D,
-			3,
+			GL_RGBA,
 			w,
 			h,
@@ -135,5 +138,5 @@
 			GL_UNSIGNED_BYTE,
 			image->pixels);
-
+      
       SDL_FreeSurface(image); /* No longer needed */
       
Index: orxonox/trunk/src/lib/graphics/importer/texture.h
===================================================================
--- orxonox/trunk/src/lib/graphics/importer/texture.h	(revision 3917)
+++ orxonox/trunk/src/lib/graphics/importer/texture.h	(revision 3966)
@@ -23,4 +23,6 @@
   char* searchTextureInPaths(const char* texName) const;
   void swap(unsigned char &a, unsigned char &b);
+
+  bool bAlpha;           //!< if the texture has an alpha channel.
  public:
   Texture(const char* imageName = NULL);
@@ -30,4 +32,5 @@
   inline GLuint getTexture(void) {return this->texture;} 
   GLuint loadTexToGL (SDL_Surface* surface);
+  inline bool hasAlpha(void) {return bAlpha;}
 
   bool loadImage(const char* imageName);
Index: orxonox/trunk/src/lib/graphics/particles/particle_emitter.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/particles/particle_emitter.cc	(revision 3966)
+++ orxonox/trunk/src/lib/graphics/particles/particle_emitter.cc	(revision 3966)
@@ -0,0 +1,149 @@
+/* 
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 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: Benjamin Grauer
+   co-programmer: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PARTICLE
+
+#include "particle_emitter.h"
+
+#include "particle_system.h"
+#include "particle_engine.h"
+
+using namespace std;
+
+
+/**
+   \brief standard constructor
+*/
+ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate, 
+		  float velocity)
+{
+   this->setClassName ("ParticleEmitter");
+   this->direction = direction;
+   this->setSpread(angle);
+   this->setEmissionRate(emissionRate);
+   this->setVelocity(velocity);
+
+   this->saveTime = 0.0;
+
+   ParticleEngine::getInstance()->addEmitter(this);
+}
+
+
+
+/**
+   \brief standard destructor
+
+*/
+ParticleEmitter::~ParticleEmitter () 
+{
+  ParticleEngine::getInstance()->removeEmitter(this);
+  
+}
+
+
+/**
+   \brief this start the emitter
+*/
+void ParticleEmitter::start() {}
+
+
+/**
+   \brief this stops the emitter
+*/
+void ParticleEmitter::stop() {}
+
+
+
+
+/* these are Animation interfaces: so you can change spec values as you want */
+
+/**
+   \brief set the emission rate
+   \param sets the number of particles emitted per second
+
+   if you want to change the value of this variable during emission time (to make it more dynamic)
+   you may want to use the animation class
+*/
+void ParticleEmitter::setEmissionRate(float emissionRate)
+{
+  this->emissionRate = emissionRate;
+}
+
+/**
+   \brief set the angle of the emitter
+   \param angle around the direction in which there are particles to be emitted
+   \param randomAngle A random spread-angle, the +- randomness of this option
+
+   if you want to change the value of this variable during emission time (to make it more dynamic)
+   you may want to use the animation class
+*/
+void ParticleEmitter::setSpread(float angle, float randomAngle)
+{
+  this->angle = angle;
+  this->randomAngle = randomAngle;
+}
+
+/**
+   \brief sets the velocity of all particles emitted
+   \param velocity The starting velocity of the emitted particles
+   \param random A random starting velocity, the +- randomness of this option
+
+   if you want to change the value of this variable during emission time (to make it more dynamic)
+   you may want to use the animation class
+*/
+void ParticleEmitter::setVelocity(float velocity, float randomVelocity)
+{
+  this->velocity = velocity;
+  this->randomVelocity = randomVelocity;
+}
+
+/**
+   \brief this set the time to life of a particle, after which it will die
+   \param the time to live in seconds
+
+   if you want to change the value of this variable during emission time (to make it more dynamic)
+   you may want to use the animation class
+*/
+
+void ParticleEmitter::tick(float dt, ParticleSystem* system)
+{
+  if (likely(dt > 0.0 && this->emissionRate > 0.0))
+  {
+    // saving the time
+    float count = (dt+this->saveTime) * this->emissionRate;
+    this->saveTime = modff(count, &count);
+    this->saveTime /= this->emissionRate;
+    PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime); 
+    
+    for (int i = 0; i < count; i++)
+      // emmits from EMITTER_DOT,
+      {
+	Vector randDir = Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2);
+	randDir.normalize();
+	randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)random()/RAND_MAX -.5), randDir)).apply(this->direction);
+	randDir = randDir.getNormalized()*velocity + (this->getVelocity() * system->inheritSpeed);
+
+	system->addParticle(this->getAbsCoor(), randDir);
+      }
+  }
+}
+
+/**
+   \brief outputs some nice debug information
+*/
+void ParticleEmitter::debug(void)
+{
+
+}
Index: orxonox/trunk/src/lib/graphics/particles/particle_emitter.h
===================================================================
--- orxonox/trunk/src/lib/graphics/particles/particle_emitter.h	(revision 3966)
+++ orxonox/trunk/src/lib/graphics/particles/particle_emitter.h	(revision 3966)
@@ -0,0 +1,51 @@
+/*! 
+    \file particle_e,otter.h
+    \brief Definition of a ParticleEmitter
+*/
+
+#ifndef _PARTICLE_EMITTER_H
+#define _PARTICLE_EMITTER_H
+
+#include "p_node.h"
+
+// FORWARD DEFINITION 
+struct Particle;
+class ParticleSystem;
+
+typedef enum EMITTER_TYPE {EMITTER_DOT,
+			   EMITTER_PLANE,
+			   EMITTER_SPHERE,
+			   EMITTER_CUBE};
+
+//! A default singleton class.
+class ParticleEmitter : public PNode {
+
+ public:
+  ParticleEmitter(const Vector& direction, float angle = .5, float emissionRate = 1.0,
+		  float velocity = 1.0);
+  virtual ~ParticleEmitter(void);
+
+  /* controlling the emitter: interface */
+  void start();
+  void stop();
+  void tick(float dt, ParticleSystem* system);
+
+  /* controlling the behavour: these can be used as Animation interfaces */
+  void setEmissionRate(float emissionRate);
+  void setSpread(float angle, float randomAngle = 0.0);
+  void setVelocity(float velocity, float randomVelocity = 0.0);
+
+  void debug(void);
+
+ private:
+  Vector direction;     //!< emition direction
+  float angle;          //!< max angle from the direction of the emitter
+  float randomAngle;    //!< random emission angle (angle +- angleRandom is the emitted angle.
+  float emissionRate;   //!< amount of particles per seconds emitted by emitter.
+  float velocity;       //!< the initial speed of a Particles.
+  float randomVelocity; //!< the random variation from the initial Speed.
+
+  float saveTime;       //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).
+};
+
+#endif /* _PARTICLE_EMITTER_H */
Index: orxonox/trunk/src/lib/graphics/particles/particle_engine.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/particles/particle_engine.cc	(revision 3966)
+++ orxonox/trunk/src/lib/graphics/particles/particle_engine.cc	(revision 3966)
@@ -0,0 +1,307 @@
+/* 
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 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: ...
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PARTICLE
+
+#include "particle_engine.h"
+
+#include "particle_system.h"
+#include "particle_emitter.h"
+
+#include "list.h"
+
+using namespace std;
+
+/**
+   \brief standard constructor
+*/
+ParticleEngine::ParticleEngine () 
+{
+   this->setClassName ("ParticleEngine");
+
+   this->systemList = new tList<ParticleSystem>;
+   this->emitterList = new tList<ParticleEmitter>;
+   this->connectionList = new tList<ParticleConnection>;
+}
+
+/**
+   \brief the singleton reference to this class
+*/
+ParticleEngine* ParticleEngine::singletonRef = NULL;
+
+/**
+   \returns a Pointer to this Class
+*/
+ParticleEngine* ParticleEngine::getInstance(void)
+{
+  if (!ParticleEngine::singletonRef)
+    ParticleEngine::singletonRef = new ParticleEngine();
+  return ParticleEngine::singletonRef;
+}
+
+/**
+   \brief deletes all the system, emitters, connections and Lists
+*/
+ParticleEngine::~ParticleEngine () 
+{
+  // delete all remaining systems
+  tIterator<ParticleSystem>* sysIt = this->systemList->getIterator();
+  ParticleSystem* tmpSys = sysIt->nextElement();
+  while(tmpSys)
+    {
+      delete tmpSys;
+      tmpSys = sysIt->nextElement();
+    }
+  delete sysIt;
+  delete this->systemList;
+
+  // delete all remaining emitters
+  tIterator<ParticleEmitter>* emitIt = this->emitterList->getIterator();
+  ParticleEmitter* tmpEmit = emitIt->nextElement();
+  while(tmpEmit)
+    {
+      delete tmpEmit;
+      tmpEmit = emitIt->nextElement();
+    }
+  delete emitIt;
+  delete this->emitterList;
+
+  // there should be no more Connections
+  if (this->connectionList->getSize() == 0)
+    delete this->connectionList;
+  else
+    PRINTF(2)("The Connection List is not empty. This should not happen.\n");
+
+  ParticleEngine::singletonRef = NULL;
+}
+
+/**
+   \brief Adds a System to the System list.
+
+   this is done automatically when creating a ParticleSystem
+*/
+void ParticleEngine::addSystem(ParticleSystem* system)
+{
+  this->systemList->add(system);
+}
+
+/**
+   \brief Adds an emitter to the emitterList
+
+   this is done automatically when creating a ParticleEmitter
+*/
+void ParticleEngine::addEmitter(ParticleEmitter* emitter)
+{
+  this->emitterList->add(emitter);
+}
+
+/**
+   \brief Connects a ParticleSystem to a ParticleSystem thus emitting Particles.
+   \param emitter the Emitter to connect to the System
+   \param system the System to connect to the Emitter
+*/
+void ParticleEngine::addConnection(ParticleEmitter* emitter, ParticleSystem* system)
+{
+  // look, if we have already added this connection
+  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
+  ParticleConnection* tmpConnection = tmpConIt->nextElement();
+  while(tmpConnection)
+    {
+      if (tmpConnection->emitter == emitter && tmpConnection->system == system)
+	{
+	  PRINTF(2)("Connection between Emitter and System already added\n");
+	  delete tmpConIt;
+	  return;
+	}
+      
+      tmpConnection = tmpConIt->nextElement();
+    }
+  delete tmpConIt;
+  
+
+
+  ParticleConnection* tmpCon = new ParticleConnection;
+  tmpCon->emitter = emitter;
+  tmpCon->system = system;
+
+  this->connectionList->add(tmpCon);
+}
+
+/**
+   \brief Removes a system from the systemList and also removes all Connections to the System
+   \param system The ParticleSystem to delete
+*/
+bool ParticleEngine::removeSystem(ParticleSystem* system)
+{
+  // remove any connections, that have this system within
+  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
+  ParticleConnection* tmpConnection = tmpConIt->nextElement();
+  while(tmpConnection)
+    {
+      if (tmpConnection->system == system)
+	this->breakConnection(tmpConnection);
+      tmpConnection = tmpConIt->nextElement();
+    }
+  delete tmpConIt;
+
+  // remove the System from the systemList.
+  this->systemList->remove(system);
+}
+
+/**
+   \brief removes an emitter from the emitterList and also from all Connections it is attached to.
+   \param emitter the ParticleEmitter to remove.
+*/
+bool ParticleEngine::removeEmitter(ParticleEmitter* emitter)
+{
+  // remove any connections, that have this emitter within
+  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
+  ParticleConnection* tmpConnection = tmpConIt->nextElement();
+  while(tmpConnection)
+    {
+      if (tmpConnection->emitter == emitter)
+	this->breakConnection(tmpConnection);
+      tmpConnection = tmpConIt->nextElement();
+    }
+  delete tmpConIt;
+
+  // remove the emitter from the emitterList
+  this->emitterList->remove(emitter);
+}
+
+/**
+   \brief removes a Connection between an Emitter and a System
+   \param emitter The emitter of the connection to remove
+   \param system The system of the connection to remove
+   \returns true, if the connection was broken, false if the conntection was not found
+
+   only if both system and emitter are in the connection the Connection will be broken
+*/
+bool ParticleEngine::breakConnection(ParticleEmitter* emitter, ParticleSystem* system)
+{
+  // look, if we have already added this connection
+  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
+  ParticleConnection* tmpConnection = tmpConIt->nextElement();
+  while(tmpConnection)
+    {
+    if (tmpConnection->emitter == emitter && tmpConnection->system == system)
+      {
+	this->breakConnection(tmpConnection);
+	delete tmpConIt;
+	return true;
+      }
+    tmpConnection = tmpConIt->nextElement();
+    }
+  delete tmpConIt;
+  return false;
+}
+
+/**
+   \brief removes a Connection between an Emitter and a System
+   \param connection the connection to remove
+
+   \see bool ParticleEngine::breakConnection(ParticleEmitter* emitter, ParticleSystem* system)
+*/
+bool ParticleEngine::breakConnection(ParticleConnection* connection)
+{
+  this->connectionList->remove(connection);
+  return true;
+}
+
+
+/**
+   \brief this function ticks all the ParticleSystems, so an animation will flow
+   \param dt passed since last tick
+*/
+void ParticleEngine::tick(float dt)
+{
+  // add new Particles to each System connected to an Emitter.
+  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
+  ParticleConnection* tmpConnection = tmpConIt->nextElement();
+  while(tmpConnection)
+    {
+      tmpConnection->emitter->tick(dt, tmpConnection->system);
+      tmpConnection = tmpConIt->nextElement();
+    }
+  delete tmpConIt;
+  
+
+  // ticks all the ParticleSystems
+  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
+  ParticleSystem* tmpSys = tmpIt->nextElement();
+  while(tmpSys)
+    {
+      tmpSys->tick(dt);
+      tmpSys = tmpIt->nextElement();
+    }
+  delete tmpIt;
+}
+
+/**
+   \brief draws all the systems and their Particles.
+*/
+void ParticleEngine::draw(void)
+{
+  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
+  ParticleSystem* tmpSys = tmpIt->nextElement();
+  while(tmpSys)
+    {
+      tmpSys->draw();
+      tmpSys = tmpIt->nextElement();
+    }
+  delete tmpIt;
+
+}
+
+/**
+   \brief outputs some nice debug information
+*/
+void ParticleEngine::debug(void)
+{
+  PRINT(0)("+-----------------------------------+\n");
+  PRINT(0)("+ PARTICLE-ENGINE DEBUG INFORMATION +\n");
+  PRINT(0)("+-----------------------------------+\n");
+  PRINT(0)(" Reference: %p\n", ParticleEngine::singletonRef);
+  PRINT(0)(" Count: Emitters: %d; Systems: %d, Connections: %d\n",
+	    this->emitterList->getSize(), this->systemList->getSize(), this->connectionList->getSize());
+  if (this->connectionList->getSize() > 0)
+    {
+      PRINT(0)(" Connections:\n");
+      PRINT(0)(" -----------------------------------\n");
+
+      tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
+      ParticleConnection* tmpConnection = tmpConIt->nextElement();
+      while(tmpConnection)
+	{
+	  PRINT(0)(" Emitter '%s' emitts into System '%s'\n", tmpConnection->emitter->getName(), tmpConnection->system->getName());
+	  tmpConnection = tmpConIt->nextElement();
+	}
+      delete tmpConIt;
+    }
+  if (this->systemList->getSize() > 0)
+    {
+      tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
+      ParticleSystem* tmpSys = tmpIt->nextElement();
+      while(tmpSys)
+	{
+	  tmpSys->debug();
+	  tmpSys = tmpIt->nextElement();
+	}
+      delete tmpIt;
+    }
+
+  PRINT(0)("+--------------------------------PE-+\n");
+
+}
Index: orxonox/trunk/src/lib/graphics/particles/particle_engine.h
===================================================================
--- orxonox/trunk/src/lib/graphics/particles/particle_engine.h	(revision 3966)
+++ orxonox/trunk/src/lib/graphics/particles/particle_engine.h	(revision 3966)
@@ -0,0 +1,53 @@
+/*! 
+    \file particle_engine.h
+    \brief Definition of the ParticleEngine
+*/
+
+#ifndef _PARTICLE_ENGINE_H
+#define _PARTICLE_ENGINE_H
+
+#include "base_object.h"
+
+// FORWARD DEFINITION 
+template<class T> class tList;
+class ParticleSystem;
+class ParticleEmitter;
+
+struct ParticleConnection
+{
+  ParticleEmitter* emitter;    //!< The emitter to emit system from.
+  ParticleSystem* system;      //!< The Particles emitted from emitter.
+};
+
+//! A default singleton class.
+class ParticleEngine : public BaseObject {
+
+ public:
+  static ParticleEngine* getInstance(void);
+  virtual ~ParticleEngine(void);
+
+  void tick(float dt);
+  void draw(void);
+
+  void addSystem(ParticleSystem* system);
+  void addEmitter(ParticleEmitter* emitter);
+  void addConnection(ParticleEmitter* emitter, ParticleSystem* system);
+
+  bool removeSystem(ParticleSystem* system);
+  bool removeEmitter(ParticleEmitter* emitter);
+  bool breakConnection(ParticleEmitter* emitter, ParticleSystem* system);
+  bool breakConnection(ParticleConnection* connection);
+
+  void debug();
+
+ private:
+  ParticleEngine(void);
+  static ParticleEngine* singletonRef;
+
+  tList<ParticleSystem>* systemList;
+  tList<ParticleEmitter>* emitterList;
+
+  tList<ParticleConnection>* connectionList;
+};
+
+#endif /* _PARTICLE_ENGINE_H */
Index: orxonox/trunk/src/lib/graphics/particles/particle_system.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/particles/particle_system.cc	(revision 3966)
+++ orxonox/trunk/src/lib/graphics/particles/particle_system.cc	(revision 3966)
@@ -0,0 +1,300 @@
+/* 
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 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: Benjamin Grauer
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PARTICLE
+
+#include "particle_system.h"
+
+#include "particle_emitter.h"
+#include "particle_engine.h"
+#include "compiler.h"
+#include "material.h"
+
+using namespace std;
+
+/**
+   \brief standard constructor
+   \param count the Count of particles in the System
+   \param type The Type of the ParticleSystem
+
+   \todo this constructor is not jet implemented - do it
+*/
+ParticleSystem::ParticleSystem (unsigned int maxCount, PARTICLE_TYPE type)
+{
+   this->setClassName ("ParticleSystem");
+   this->name = NULL;
+   this->maxCount = maxCount;
+   this->count = 0;
+   this->particleType = type;
+   this->particles = NULL;
+   this->setConserve(.8);
+   this->setLifeSpan(.1);
+   this->setInheritSpeed(0);
+   this->glID = NULL;
+   this->setRadius(1.0, 1.0, 0.0);
+   this->setType(PARTICLE_SPRITE, 1);
+   ParticleEngine::getInstance()->addSystem(this);
+}
+
+
+/**
+   \brief standard deconstructor
+*/
+ParticleSystem::~ParticleSystem() 
+{
+  // delete what has to be deleted here
+   ParticleEngine::getInstance()->removeSystem(this);
+}
+
+/**
+   \brief sets the Name of the Particle System
+   \param name the Name of the System
+*/
+void ParticleSystem::setName(const char* name)
+{
+  if (this->name)
+    delete this->name;
+  this->name = new char[strlen(name)+1];
+  strcpy(this->name, name);
+}
+
+/**
+   \returns the Name of the ParticleSystem
+*/
+const char* ParticleSystem::getName(void) const
+{
+  return this->name;
+}
+
+/**
+   \todo this will be different
+*/
+void ParticleSystem::setType(PARTICLE_TYPE particleType, int count)
+{
+  this->particleType = particleType;
+  this->dialectCount = count;
+  if (glID != NULL)
+    delete glID;
+
+  glID = new GLuint[count];
+  for (int i = 0; i< count; i++)
+    glID[i] = 0;
+
+  glID[0] = glGenLists(count);
+  
+  material = new Material("transperencyMap");
+  material->setDiffuseMap("pictures/radialTransparency.png");
+  //  material->setTransparency(.5);
+
+  glNewList(glID[0], GL_COMPILE);
+  glBegin(GL_TRIANGLE_STRIP);
+  glTexCoord2f(1, 1);
+  glVertex3f(0.0, .5, .5);
+  glTexCoord2f(1, 0);
+  glVertex3f(0.0, -.5, .5);
+  glTexCoord2f(0, 1);
+  glVertex3f(0.0, .5, -.5);
+  glTexCoord2f(0, 0);
+  glVertex3f(0.0, -.5, -.5);
+  glEnd();
+  glEndList();
+}
+
+// setting properties
+void ParticleSystem::setMaterial(Material* material)
+{
+  this->material = material;
+}
+
+
+
+/**
+   \brief how much of the speed from the ParticleEmitter should flow onto the ParticleSystem
+   \param value a Value between zero and one
+
+   
+   if you want to change the value of this variable during emission time (to make it more dynamic)
+   you may want to use the animation class
+*/
+void ParticleSystem::setInheritSpeed(float value)
+{
+  if (unlikely(value > 1.0))
+    this->inheritSpeed = 1;
+  else if (unlikely(value < 0.0))
+    this->inheritSpeed = 0;
+  else
+    this->inheritSpeed = value;
+}
+
+/**
+   \brief Sets the lifespan of newly created particles
+*/   
+void ParticleSystem::setLifeSpan(float lifeSpan, float randomLifeSpan)
+{
+  this->lifeSpan = lifeSpan;
+  this->randomLifeSpan = randomLifeSpan;
+}
+
+/**
+   \brief sets the radius of newly created particles
+*/
+void ParticleSystem::setRadius(float startRadius, float endRadius, float randomStartRadius, float randomEndRadius)
+{
+  this->startRadius = startRadius;
+  this->endRadius = endRadius;
+  this->randomStartRadius = randomStartRadius;
+  this->randomEndRadius = randomEndRadius;
+}
+
+/**
+   \brief sets the conserve Factor of newly created particles
+*/
+void ParticleSystem::setConserve(float conserve)
+{
+  if (conserve > 1.0)
+    this->conserve = 1.0;
+  else if (conserve < 0.0)
+    this->conserve = 0.0;
+  else
+    this->conserve = conserve;
+}
+
+/**
+   \brief ticks the system.
+   \param dt the time to tick all the Particles of the System
+
+   this is used to get all the particles some motion
+*/
+void ParticleSystem::tick(float dt)
+{
+  Particle* tickPart = particles;  // the particle to Tick
+  Particle* prevPart = NULL;       // 
+  while (likely(tickPart != NULL))
+    {
+      tickPart->position = tickPart->position + tickPart->velocity;
+      tickPart->radius += tickPart->radiusIt * dt;
+
+      // many more to come
+
+
+      if (this->conserve < 1.0)
+	tickPart->velocity = tickPart->velocity * this->conserve;
+      // find out if we have to delete tickPart
+      if ((tickPart->timeToLive -= dt) <= 0)
+	{
+	  // remove the particle from the list
+	  if (likely(prevPart != NULL))
+	    {
+	      prevPart->next = tickPart->next;
+	      delete tickPart;
+	      tickPart = prevPart->next;
+	    }
+	  else
+	    {
+	      prevPart = NULL;
+	      this->particles = tickPart->next;
+	      delete tickPart;
+	      tickPart = this->particles;
+	    }
+	  --this->count;
+	}
+      else
+	{      
+	  prevPart = tickPart;
+	  tickPart = tickPart->next;
+	}
+    }
+}
+
+/**
+   \brief draws all the Particles of this System
+*/
+void ParticleSystem::draw(void)
+{
+  //  material->select();
+
+
+  glMatrixMode(GL_MODELVIEW);
+  //  glDisable(GL_LIGHTING);
+  material->select();
+
+  Particle* drawPart = particles;
+  if (likely(drawPart != NULL))
+    {
+      glBegin(GL_POINTS);
+      while (likely(drawPart != NULL))
+	{
+	  // draw in DOT mode
+	  glPushMatrix();
+	  glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z);
+	  glScalef(drawPart->radius, drawPart->radius, drawPart->radius);
+	  glCallList(*this->glID);
+	  
+	  //	  	  glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
+	  drawPart = drawPart->next;
+	  glPopMatrix();
+	}
+      glEnd();
+    }
+}
+
+/**
+   \brief adds a new Particle to the System
+   \param position the position where the particle gets emitted.
+   \param velocity the Starting velocity of the particle.
+   \param data some more data given by the emitter
+*/
+void ParticleSystem::addParticle(const Vector& position, const Vector& velocity, unsigned int data)
+{
+  if (this->count <= this->maxCount)
+    {
+      // if it is the first Particle
+      if (unlikely(particles == NULL))
+	{
+	  this->particles = new Particle;
+	  this->particles->next = NULL;
+	}
+      // filling the List from the beginning
+      else
+	{
+	  Particle* tmpPart = new Particle;
+	  tmpPart->next = this->particles;
+	  this->particles = tmpPart;
+	}
+      
+      particles->timeToLive = this->lifeSpan + (float)(random()/RAND_MAX)* this->randomLifeSpan;
+      particles->position = position;
+      particles->velocity = velocity;
+
+      //  particle->rotation = ; //! \todo rotation is once again something to be done.
+      particles->mass = this->initialMass + (random()/RAND_MAX -.5)* this->randomInitialMass;
+      particles->radius = this->startRadius + (random()/RAND_MAX-.5)*this->randomStartRadius;
+      
+      particles->radiusIt = (this->endRadius + (random()/RAND_MAX-.5)*this->randomEndRadius - particles->radius) / particles->timeToLive;
+
+      ++this->count;
+    }
+  else
+    PRINTF(4)("maximum count of particles reached not adding any more\n");
+}
+
+/**
+   \brief outputs some nice debug information
+*/
+void ParticleSystem::debug(void)
+{
+  PRINT(0)("  ParticleSystem %s\n", this->name);
+  PRINT(0)("  ParticleCount: %d, maximumCount: %d :: filled %d%%\n", this->count, this->maxCount, 100*this->count/this->maxCount);
+}
Index: orxonox/trunk/src/lib/graphics/particles/particle_system.h
===================================================================
--- orxonox/trunk/src/lib/graphics/particles/particle_system.h	(revision 3966)
+++ orxonox/trunk/src/lib/graphics/particles/particle_system.h	(revision 3966)
@@ -0,0 +1,98 @@
+/*! 
+    \file particle_system.h
+
+*/
+
+#ifndef _PARTICLE_SYSTEM_H
+#define _PARTICLE_SYSTEM_H
+
+#include "base_object.h"
+#include "vector.h"
+
+#define PARTICLE_DOT_MASK           0x00001
+#define PARTICLE_SPRITE_MASK        0x00010
+#define PARTICLE_MODEL_MASK         0x00100
+#define PARTICLE_WORDL_ENTITY_MASK  0x01000
+#define PARTICLE_MULTI_MASK         0x10000
+
+//! An enumerator for the different types of particles.
+typedef enum PARTICLE_TYPE {PARTICLE_DOT = PARTICLE_DOT_MASK,
+			    PARTICLE_SPRITE = PARTICLE_SPRITE_MASK,
+			    PARTICLE_MULTI_SPRITE = PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK,
+			    PARTICLE_MODEL = PARTICLE_MODEL_MASK,
+			    PARTICLE_MULTI_MODE = PARTICLE_MODEL_MASK | PARTICLE_MULTI_MASK};
+
+#define PARTICLE_DEFAULT_MAX_COUNT    200               //!< a default count of particles in the system.
+#define PARTICLE_DEFAULT_TYPE         PARTICLE_SPRITE   //!< A default type of the system.
+
+// FORWARD DEFINITION
+class Material;
+class ParticleEmitter;
+
+
+//! A struct for one Particle
+typedef struct Particle
+{
+  float timeToLive;           //!< The time this particle lives from NOW on.
+  Vector position;            //!< The current position of this particle.
+  Vector velocity;            //!< The current velocity of this particle.
+  Quaternion rotation;        //!< The current rotation of this particle.
+  float mass;                 //!< The mass of this particle.
+  float radius;               //!< The current size of this particle.
+  float radiusIt;             //!< The difference of the Size per second.
+
+  Particle* next;             //!< pointer to the next particle in the List. (NULL if no preceding one)
+};
+
+//! A class to handle particle Systems
+class ParticleSystem : public BaseObject {
+  friend class ParticleEmitter;
+
+ public:
+  ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT, PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
+  virtual ~ParticleSystem();
+  void setName(const char* name);
+  const char* getName(void) const;
+
+  void setType(PARTICLE_TYPE particleType, int count = 0);
+  void setMaterial(Material* material);
+  void setInheritSpeed(float value);
+  void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0);
+  void setRadius(float startRadius, float endRadius, float randomStartRadius = 0.0, float randomEndRadius = 0.0);
+  void setConserve(float conserve);
+  void setMass(float mass, float randomMass);
+
+  void tick(float dt);
+  void draw(void);
+
+  void debug(void);
+
+ private:
+  char* name;                // the Name of the Particle System
+
+  float conserve;            //!< How much energy gets conserved to the next Tick.
+  float lifeSpan;            //!< Initial lifetime of a Particle.
+  float randomLifeSpan;
+  float startRadius;
+  float endRadius;
+  float randomStartRadius;
+  float randomEndRadius;
+  float initialMass;
+  float randomInitialMass;
+  float inheritSpeed;
+
+  // particles
+  int maxCount;              //!< The maximum count of Particles.
+  int count;                 //!< The current count of Particles.
+  PARTICLE_TYPE particleType;//!< A type for all the Particles
+  Material* material;        //!< A Material for all the Particles.
+  Particle* particles;       //!< A list of particles of this System.
+
+  GLuint* glID;              //!< A List of different gl-List-ID's
+  GLuint dialectCount;       //!< How many different types of particles are there in the Particle System
+
+  void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0);
+  
+};
+
+#endif /* _PARTICLE_SYSTEM_H */
Index: orxonox/trunk/src/lib/math/quaternion.h
===================================================================
--- orxonox/trunk/src/lib/math/quaternion.h	(revision 3917)
+++ 	(revision )
@@ -1,413 +1,0 @@
-/*! 
-    \file vector.h
-    \brief A basic 3D math framework
-    
-    Contains classes to handle vectors, lines, rotations and planes
-*/ 
-
-#ifndef _QUATERNION_H
-#define _QUATERNION_H
-
-#include <math.h>
-//! PI the circle-constant
-
-//! Quaternion
-/**
-	Class to handle 3-dimensional rotation efficiently
-*/
-class Quaternion
-{
- public:
-  Vector v;	//!< Imaginary Vector
-  float w;        //!< Real part of the number
-  
-  Quaternion ();
-  Quaternion (float m[4][4]);
-  Quaternion (float angle, const Vector& axis);
-  Quaternion (const Vector& dir, const Vector& up);
-  Quaternion (float roll, float pitch, float yaw);
-  
-  Quaternion operator/ (const float& f) const;
-  Quaternion operator* (const float& f) const;
-  Quaternion operator* (const Quaternion& q) const;
-  Quaternion operator+ (const Quaternion& q) const;
-  Quaternion operator- (const Quaternion& q) const;
-  Quaternion conjugate () const;
-  Quaternion inverse () const;
-  Vector apply (Vector& f) const;
-  float norm () const;
-  void matrix (float m[4][4]) const;
-  void quatSlerp(const Quaternion* from, const Quaternion* to, const float t, Quaternion* res);
-  
-  void debug();
- private:
-  float DELTA;      //!< resolution of calculation
-
-};
-
-
-/**
-	\brief creates a multiplicational identity Quaternion
-*/
-Quaternion::Quaternion ()
-{
-	w = 1;
-	v = Vector(0,0,0);
-}
-
-/**
-	\brief turns a rotation along an axis into a Quaternion
-	\param angle: the amount of radians to rotate
-	\param axis: the axis to rotate around
-*/
-Quaternion::Quaternion (float angle, const Vector& axis)
-{
-	w = cos(angle/2);
-	v = axis * sin(angle/2);
-}
-
-/**
-   \brief calculates a lookAt rotation
-   \param dir: the direction you want to look
-   \param up: specify what direction up should be
-   
-   Mathematically this determines the rotation a (0,0,1)-Vector has to undergo to point
-   the same way as dir. If you want to use this with cameras, you'll have to reverse the
-   dir Vector (Vector(0,0,0) - your viewing direction) or you'll point the wrong way. You
-   can use this for meshes as well (then you do not have to reverse the vector), but keep 
-   in mind that if you do that, the model's front has to point in +z direction, and left 
-   and right should be -x or +x respectively or the mesh wont rotate correctly.
-*/
-Quaternion::Quaternion (const Vector& dir, const Vector& up)
-{
-  Vector z = dir;
-  z.normalize(); 
-  Vector x = up.cross(z);
-  x.normalize(); 
-  Vector y = z.cross(x);
-  
-  float m[4][4];
-  m[0][0] = x.x;
-  m[0][1] = x.y;
-  m[0][2] = x.z;
-  m[0][3] = 0;
-  m[1][0] = y.x;
-  m[1][1] = y.y;
-  m[1][2] = y.z;
-  m[1][3] = 0;
-  m[2][0] = z.x;
-  m[2][1] = z.y;
-  m[2][2] = z.z;
-  m[2][3] = 0;
-  m[3][0] = 0;
-  m[3][1] = 0;
-  m[3][2] = 0;
-  m[3][3] = 1;
-  
-  *this = Quaternion (m);
-}
-
-/**
-	\brief calculates a rotation from euler angles
-	\param roll: the roll in radians
-	\param pitch: the pitch in radians
-	\param yaw: the yaw in radians
-	
-	I DO HONESTLY NOT EXACTLY KNOW WHICH ANGLE REPRESENTS WHICH ROTATION. And I do not know 
-	in what order they are applied,	I just copy-pasted the code.
-*/
-Quaternion::Quaternion (float roll, float pitch, float yaw)
-{
-	float cr, cp, cy, sr, sp, sy, cpcy, spsy;
-	
-	// calculate trig identities
-	cr = cos(roll/2);
-	cp = cos(pitch/2);
-	cy = cos(yaw/2);
-	
-	sr = sin(roll/2);
-	sp = sin(pitch/2);
-	sy = sin(yaw/2);
-	
-	cpcy = cp * cy;
-	spsy = sp * sy;
-	
-	w = cr * cpcy + sr * spsy;
-	v.x = sr * cpcy - cr * spsy;
-	v.y = cr * sp * cy + sr * cp * sy;
-	v.z = cr * cp * sy - sr * sp * cy;
-}
-
-/**
-	\brief rotates one Quaternion by another
-	\param q: another Quaternion to rotate this by
-	\return a quaternion that represents the first one rotated by the second one (WARUNING: this operation is not commutative! e.g. (A*B) != (B*A))
-*/
-Quaternion Quaternion::operator*(const Quaternion& q) const
-{
-	float A, B, C, D, E, F, G, H;
-	Quaternion r;
-	
-	A = (w   + v.x)*(q.w   + q.v.x);
-	B = (v.z - v.y)*(q.v.y - q.v.z);
-	C = (w   - v.x)*(q.v.y + q.v.z); 
-	D = (v.y + v.z)*(q.w   - q.v.x);
-	E = (v.x + v.z)*(q.v.x + q.v.y);
-	F = (v.x - v.z)*(q.v.x - q.v.y);
-	G = (w   + v.y)*(q.w   - q.v.z);
-	H = (w   - v.y)*(q.w   + q.v.z);
-	
-	r.w = B +  (-E - F + G + H)/2;
-	r.v.x = A - (E + F + G + H)/2; 
-	r.v.y = C + (E - F + G - H)/2; 
-	r.v.z = D + (E - F - G + H)/2;
-	
-	return r;
-}
-
-/**
-	\brief add two Quaternions
-	\param q: another Quaternion
-	\return the sum of both Quaternions
-*/
-Quaternion Quaternion::operator+(const Quaternion& q) const
-{
-	Quaternion r(*this);
-	r.w = r.w + q.w;
-	r.v = r.v + q.v;
-	return r;
-}
-
-/**
-	\brief subtract two Quaternions
-	\param q: another Quaternion
-	\return the difference of both Quaternions
-*/
-Quaternion Quaternion::operator- (const Quaternion& q) const
-{
-	Quaternion r(*this);
-	r.w = r.w - q.w;
-	r.v = r.v - q.v;
-	return r;
-}
-
-/**
-	\brief rotate a Vector by a Quaternion
-	\param v: the Vector
-	\return a new Vector representing v rotated by the Quaternion
-*/
-Vector Quaternion::apply (Vector& v) const
-{
-	Quaternion q;
-	q.v = v;
-	q.w = 0;
-	q = *this * q * conjugate();
-	return q.v;
-}
-
-/**
-	\brief multiply a Quaternion with a real value
-	\param f: a real value
-	\return a new Quaternion containing the product
-*/
-Quaternion Quaternion::operator*(const float& f) const
-{
-	Quaternion r(*this);
-	r.w = r.w*f;
-	r.v = r.v*f;
-	return r;
-}
-
-/**
-	\brief divide a Quaternion by a real value
-	\param f: a real value
-	\return a new Quaternion containing the quotient
-*/
-Quaternion Quaternion::operator/(const float& f) const
-{
-	if( f == 0) return Quaternion();
-	Quaternion r(*this);
-	r.w = r.w/f;
-	r.v = r.v/f;
-	return r;
-}
-
-/**
-	\brief calculate the conjugate value of the Quaternion
-	\return the conjugate Quaternion
-*/
-Quaternion Quaternion::conjugate() const
-{
-	Quaternion r(*this);
-	r.v = Vector() - r.v;
-	return r;
-}
-
-/**
-	\brief calculate the norm of the Quaternion
-	\return the norm of The Quaternion
-*/
-float Quaternion::norm() const
-{
-	return w*w + v.x*v.x + v.y*v.y + v.z*v.z;
-}
-
-/**
-	\brief calculate the inverse value of the Quaternion
-	\return the inverse Quaternion
-	
-	Note that this is equal to conjugate() if the Quaternion's norm is 1
-*/
-Quaternion Quaternion::inverse() const
-{
-	float n = norm();
-	if (n != 0)
-	{
-		return conjugate() / norm();
-	}
-	else return Quaternion();
-}
-
-/**
-	\brief convert the Quaternion to a 4x4 rotational glMatrix
-	\param m: a buffer to store the Matrix in
-*/
-void Quaternion::matrix (float m[4][4]) const
-{
-  float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2; 
-  
-  // calculate coefficients
-  x2 = v.x + v.x;
-  y2 = v.y + v.y; 
-  z2 = v.z + v.z;
-  xx = v.x * x2; xy = v.x * y2; xz = v.x * z2;
-  yy = v.y * y2; yz = v.y * z2; zz = v.z * z2;
-  wx = w * x2; wy = w * y2; wz = w * z2;
-  
-  m[0][0] = 1.0 - (yy + zz); m[1][0] = xy - wz;
-  m[2][0] = xz + wy; m[3][0] = 0.0;
-	
-  m[0][1] = xy + wz; m[1][1] = 1.0 - (xx + zz);
-  m[2][1] = yz - wx; m[3][1] = 0.0;
-  
-  m[0][2] = xz - wy; m[1][2] = yz + wx;
-  m[2][2] = 1.0 - (xx + yy); m[3][2] = 0.0;
-  
-  m[0][3] = 0; m[1][3] = 0;
-  m[2][3] = 0; m[3][3] = 1;
-}
-
-/**
-   \brief performs a smooth move.
-   \param from from where
-   \param to to where
-   \param t the time this transformation should take
-   \param res The approximation-density
-*/
-void Quaternion::quatSlerp(const Quaternion* from, const Quaternion* to, float t, Quaternion* res)
-{
-  float tol[4];
-  double omega, cosom, sinom, scale0, scale1;
-  DELTA = 0.2;
-
-  cosom = from->v.x * to->v.x + from->v.y * to->v.y + from->v.z * to->v.z + from->w * to->w;
-
-  if( cosom < 0.0 ) 
-    { 
-      cosom = -cosom; 
-      tol[0] = -to->v.x;
-      tol[1] = -to->v.y;
-      tol[2] = -to->v.z;
-      tol[3] = -to->w;
-    }
-  else
-    {
-      tol[0] = to->v.x;
-      tol[1] = to->v.y;
-      tol[2] = to->v.z;
-      tol[3] = to->w;
-    }
-  
-  //if( (1.0 - cosom) > DELTA )
-  //{
-      omega = acos(cosom);
-      sinom = sin(omega);
-      scale0 = sin((1.0 - t) * omega) / sinom;
-      scale1 = sin(t * omega) / sinom;
-      //}
-      /*
-  else
-    {
-      scale0 = 1.0 - t;
-      scale1 = t;
-    }
-      */
-  res->v.x = scale0 * from->v.x + scale1 * tol[0];
-  res->v.y = scale0 * from->v.y + scale1 * tol[1];
-  res->v.z = scale0 * from->v.z + scale1 * tol[2];
-  res->w = scale0 * from->w + scale1 * tol[3];
-}
-
-
-/**
-   \brief convert a rotational 4x4 glMatrix into a Quaternion
-   \param m: a 4x4 matrix in glMatrix order
-*/
-Quaternion::Quaternion (float m[4][4])
-{
-	
-  float  tr, s, q[4];
-  int    i, j, k;
-
-  int nxt[3] = {1, 2, 0};
-
-  tr = m[0][0] + m[1][1] + m[2][2];
-
-  	// check the diagonal
-  if (tr > 0.0) 
-  {
-    s = sqrt (tr + 1.0);
-    w = s / 2.0;
-    s = 0.5 / s;
-    v.x = (m[1][2] - m[2][1]) * s;
-    v.y = (m[2][0] - m[0][2]) * s;
-    v.z = (m[0][1] - m[1][0]) * s;
-	} 
-	else 
-	{
- 		// diagonal is negative
-  	i = 0;
-  	if (m[1][1] > m[0][0]) i = 1;
-    if (m[2][2] > m[i][i]) i = 2;
-    j = nxt[i];
-    k = nxt[j];
-
-    s = sqrt ((m[i][i] - (m[j][j] + m[k][k])) + 1.0);
-      
-    q[i] = s * 0.5;
-            
-    if (s != 0.0) s = 0.5 / s;
-	
-	  q[3] = (m[j][k] - m[k][j]) * s;
-    q[j] = (m[i][j] + m[j][i]) * s;
-    q[k] = (m[i][k] + m[k][i]) * s;
-
-  	v.x = q[0];
-  	v.y = q[1];
-  	v.z = q[2];
-  	w = q[3];
-  }
-}
-
-/**
-   \brief outputs some nice formated debug information about this quaternion
-*/
-void Quaternion::debug(void)
-{
-  PRINT(0)("Quaternion Debug Information\n");
-  PRINT(0)("real a=%f; imag: x=%f y=%f z=%f\n", w, v.x, v.y, v.z);
-}
-
-
-
-#endif /* _QUATERNION_H */
Index: orxonox/trunk/src/lib/math/vector.cc
===================================================================
--- orxonox/trunk/src/lib/math/vector.cc	(revision 3917)
+++ orxonox/trunk/src/lib/math/vector.cc	(revision 3966)
@@ -100,17 +100,17 @@
 */
 
-Vector* Vector::getNormalized()
+Vector Vector::getNormalized()
 {
   float l = len();
   if(unlikely(l != 1.0))
     {
-      return this;
+      return *this;
     }
   else if(unlikely(l == 0.0))
     {
-      return 0;
+      return *this;
     }
 
-  return new Vector(x / l, y /l, z / l);
+  return *this / l;
 }
 
@@ -172,5 +172,5 @@
    \brief Outputs the values of the Vector
 */
-void Vector::debug(void)
+void Vector::debug(void) const
 {
   PRINT(0)("Vector Debug information\n");
@@ -438,7 +438,8 @@
    \param to to where
    \param t the time this transformation should take
-   \param res The approximation-density
-*/
-void Quaternion::quatSlerp(const Quaternion* from, const Quaternion* to, float t, Quaternion* res)
+
+   \returns the Result of the smooth move
+*/
+Quaternion Quaternion::quatSlerp(const Quaternion& from, const Quaternion& to, float t)
 {
   float tol[4];
@@ -446,40 +447,49 @@
   DELTA = 0.2;
 
-  cosom = from->v.x * to->v.x + from->v.y * to->v.y + from->v.z * to->v.z + from->w * to->w;
+  cosom = from.v.x * to.v.x + from.v.y * to.v.y + from.v.z * to.v.z + from.w * to.w;
 
   if( cosom < 0.0 ) 
     { 
       cosom = -cosom; 
-      tol[0] = -to->v.x;
-      tol[1] = -to->v.y;
-      tol[2] = -to->v.z;
-      tol[3] = -to->w;
+      tol[0] = -to.v.x;
+      tol[1] = -to.v.y;
+      tol[2] = -to.v.z;
+      tol[3] = -to.w;
     }
   else
     {
-      tol[0] = to->v.x;
-      tol[1] = to->v.y;
-      tol[2] = to->v.z;
-      tol[3] = to->w;
+      tol[0] = to.v.x;
+      tol[1] = to.v.y;
+      tol[2] = to.v.z;
+      tol[3] = to.w;
     }
   
   //if( (1.0 - cosom) > DELTA )
   //{
-      omega = acos(cosom);
-      sinom = sin(omega);
-      scale0 = sin((1.0 - t) * omega) / sinom;
-      scale1 = sin(t * omega) / sinom;
-      //}
-      /*
-  else
+  omega = acos(cosom);
+  sinom = sin(omega);
+  scale0 = sin((1.0 - t) * omega) / sinom;
+  scale1 = sin(t * omega) / sinom;
+  //}
+  /*
+    else
     {
-      scale0 = 1.0 - t;
-      scale1 = t;
+    scale0 = 1.0 - t;
+    scale1 = t;
     }
-      */
-  res->v.x = scale0 * from->v.x + scale1 * tol[0];
-  res->v.y = scale0 * from->v.y + scale1 * tol[1];
-  res->v.z = scale0 * from->v.z + scale1 * tol[2];
-  res->w = scale0 * from->w + scale1 * tol[3];
+  */
+
+
+  /*
+    Quaternion res;
+    res.v.x = scale0 * from.v.x + scale1 * tol[0];
+    res.v.y = scale0 * from.v.y + scale1 * tol[1];
+    res.v.z = scale0 * from.v.z + scale1 * tol[2];
+    res.w = scale0 * from.w + scale1 * tol[3];
+  */
+  return Quaternion(scale0 * from.w + scale1 * tol[3], 
+		    Vector(scale0 * from.v.x + scale1 * tol[0],
+			   scale0 * from.v.y + scale1 * tol[1],
+			   scale0 * from.v.z + scale1 * tol[2]));
 }
 
Index: orxonox/trunk/src/lib/math/vector.h
===================================================================
--- orxonox/trunk/src/lib/math/vector.h	(revision 3917)
+++ orxonox/trunk/src/lib/math/vector.h	(revision 3966)
@@ -31,10 +31,16 @@
 
   inline Vector operator+ (const Vector& v) const { return Vector(x + v.x, y + v.y, z + v.z); }
+  inline const Vector& operator+= (const Vector& v) {this->x += v.x; this->y += v.y; this->z += v.z; return *this;}
   inline Vector operator- (const Vector& v) const { return Vector(x - v.x, y - v.y, z - v.z); }
+  inline const Vector& operator-= (const Vector& v) {this->x -= v.x; this->y -= v.y; this->z -= v.z; return *this;}
   inline float operator* (const Vector& v) const { return x * v.x + y * v.y + z * v.z; }
+  inline const Vector& operator*= (const Vector& v) {this->x *= v.x; this->y *= v.y; this->z *= v.z; return *this;}
   inline Vector operator* (float f) const { return Vector(x * f, y * f, z * f); }
+  inline const Vector& operator*= (float f) {this->x *= f; this->y *= f; this->z *= f; return *this;}
   Vector operator/ (float f) const;
+  inline const Vector& operator/= (float f) {this->x /= f; this->y /= f; this->z /= f; return *this;}
+  inline const Vector& operator= (const Vector& v) {this->x = v.x; this->y = v.y; this->z = v.z; return *this;}
   float dot (const Vector& v) const;
-  inline Vector cross (const Vector& v) const {  return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); }
+  inline Vector cross (const Vector& v) const { return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); }
   void scale(const Vector& v);
   inline float len() const { return sqrt (x*x+y*y+z*z); }
@@ -50,8 +56,8 @@
 		      z = z / l; 
                     }
-  Vector* getNormalized();
+  Vector getNormalized();
   Vector abs();
 
-  void debug();
+  void debug() const;
 };
 
@@ -76,8 +82,14 @@
   Quaternion (float roll, float pitch, float yaw);
   Quaternion operator/ (const float& f) const;
+  inline const Quaternion operator/= (const float& f) {*this = *this / f; return *this;}
   Quaternion operator* (const float& f) const;
+  inline const Quaternion operator*= (const float& f) {*this = *this * f; return *this;}
   Quaternion operator* (const Quaternion& q) const;
+  inline const Quaternion operator*= (const Quaternion& q) {*this = *this * q; return *this;}
   inline Quaternion operator+ (const Quaternion& q) const { return Quaternion(q.v + v, q.w + w); }
+  inline const Quaternion& operator+= (const Quaternion& q) {this->v += q.v; this->w += q.w; return *this;}
   inline Quaternion operator- (const Quaternion& q) const { return Quaternion(q.v - v, q.w - w); }
+  inline const Quaternion& operator-= (const Quaternion& q) {this->v -= q.v; this->w -= q.w; return *this;}
+  inline Quaternion operator= (const Quaternion& q) {this->v = q.v; this->w = q.w; return *this;}
   Quaternion conjugate () const {  Quaternion r(*this);
   r.v = Vector() - r.v;
@@ -87,5 +99,5 @@
   float norm () const;
   void matrix (float m[4][4]) const;
-  void quatSlerp(const Quaternion* from, const Quaternion* to, const float t, Quaternion* res);
+  Quaternion quatSlerp(const Quaternion& from, const Quaternion& to, float t);
   
   void debug();
Index: orxonox/trunk/src/lib/math/vector_new.h
===================================================================
--- orxonox/trunk/src/lib/math/vector_new.h	(revision 3917)
+++ 	(revision )
@@ -1,265 +1,0 @@
-/*! 
-    \file vector.h
-    \brief A basic 3D math framework
-    
-    Contains classes to handle vectors, lines, rotations and planes
-*/ 
-
-#ifndef _VECTOR_H
-#define _VECTOR_H
-
-#include <math.h>
-//! PI the circle-constant
-#define PI 3.14159265359f  /* this is not nice... make a math_def file or something */ 
-
-//! 3D Vector
-/**
-	Class to handle 3D Vectors
-*/
-class Vector {
-
-  public:
- 
-  float x; //!< The x Coordinate of the Vector.
-  float y; //!< The y Coordinate of the Vector.
-  float z; //!< The z Coordinate of the Vector.
-
-  Vector (float x, float y, float z) : x(x), y(y), z(z) {}  //!< assignment constructor
-  Vector () : x(0), y(0), z(0) {}
-  ~Vector () {}
-
-  Vector operator+ (const Vector& v) const;
-  Vector operator- (const Vector& v) const;
-  float operator* (const Vector& v) const;
-  Vector operator* (float f) const;
-  Vector operator/ (float f) const;
-  inline float dot (const Vector& v) const;
-  Vector cross (const Vector& v) const;
-  void scale(const Vector& v);
-  float len() const;
-  void normalize();
-  Vector* getNormalized();
-  Vector abs();
-
-  void debug();
-};
-
-//float angleDeg (const Vector& v1, const Vector& v2);
-//float angleRad (const Vector& v1, const Vector& v2);
-
-
-/**
-   \brief add two vectors
-   \param v: the other vector
-   \return the sum of both vectors
-*/
-Vector Vector::operator+ (const Vector& v) const
-{
-  Vector r;
-
-  r.x = x + v.x;
-  r.y = y + v.y;
-  r.z = z + v.z;
-  
-  return r;
-}
-
-/**
-   \brief subtract a vector from another
-   \param v: the other vector
-   \return the difference between the vectors
-*/
-Vector Vector::operator- (const Vector& v) const
-{
-  Vector r;
-  
-  r.x = x - v.x;
-  r.y = y - v.y;
-  r.z = z - v.z;
-  
-  return r;
-}
-
-/**
-   \brief calculate the dot product of two vectors
-   \param v: the other vector
-   \return the dot product of the vectors
-*/
-float Vector::operator* (const Vector& v) const
-{
-  return x * v.x + y * v.y + z * v.z;
-}
-
-/**
-   \brief multiply a vector with a float
-   \param f: the factor
-   \return the vector multipied by f
-*/
-Vector Vector::operator* (float f) const
-{  
-  Vector r;
-  
-  r.x = x * f;
-  r.y = y * f;
-  r.z = z * f;
-  
-  return r;
-}
-
-/**
-   \brief divide a vector with a float
-   \param f: the divisor
-   \return the vector divided by f   
-*/
-Vector Vector::operator/ (float f) const
-{
-  Vector r;
-  
-  if( f == 0.0)
-  {
-    // Prevent divide by zero
-    return Vector (0,0,0);
-  }
-  
-  r.x = x / f;
-  r.y = y / f;
-  r.z = z / f;
-  
-  return r;
-}
-
-/**
-   \brief calculate the dot product of two vectors
-   \param v: the other vector
-   \return the dot product of the vectors
-*/
-inline float Vector::dot (const Vector& v) const
-{
-  return x*v.x+y*v.y+z*v.z;
-}
-
-/**
-  \brief calculate the cross product of two vectors
-  \param v: the other vector
-	\return the cross product of the vectors
-*/
-Vector Vector::cross (const Vector& v) const
-{
-  Vector r;
-  
-  r.x = y * v.z - z * v.y;
-  r.y = z * v.x - x * v.z;
-  r.z = x * v.y - y * v.x;
-  
-  return r;
-}
-  
-/**
-   \brief normalizes the vector to lenght 1.0
-*/
-void Vector::normalize ()
-{
-  float l = len();
-  
-  if( l == 0.0)
-  {
-    // Prevent divide by zero
-    return;
-  }
-  
-  x = x / l;
-  y = y / l;
-  z = z / l;
-}
-
-
-/**
-   \brief returns the voctor normalized to length 1.0
-*/
-
-Vector* Vector::getNormalized()
-{
-  float l = len();
-  if(l != 1.0)
-    {
-      return this;
-    }
-  else if(l == 0.0)
-    {
-      return 0;
-    }
-  
-  Vector *normalizedVector = new Vector(x / l, y /l, z / l);
-  return normalizedVector;
-}
-
-/**
-   \brief scales this Vector with Vector v.
-   \param v the vector to scale this vector with
-*/
-void Vector::scale(const Vector& v)
-{
-  x *= v.x;
-  y *= v.y;
-  z *= v.z;
-}
-
- 
-/**
-   \brief calculates the lenght of the vector
-   \return the lenght of the vector
-*/
-float Vector::len () const
-{
-  return sqrt (x*x+y*y+z*z);
-}
-
-
-/**
-   \brief Vector is looking in the positive direction on all axes after this
-*/
-Vector Vector::abs() 
-{
-  Vector v(fabs(x), fabs(y), fabs(z));
-  return v;
-}
-
-/**
-   \brief calculate the angle between two vectors in radiances
-   \param v1: a vector
-   \param v2: another vector
-   \return the angle between the vectors in radians
-*/
-float angleRad (const Vector& v1, const Vector& v2)
-{
-  return acos( v1 * v2 / (v1.len() * v2.len()));
-}
-
-
-/**
-   \brief calculate the angle between two vectors in degrees
-   \param v1: a vector
-   \param v2: another vector
-   \return the angle between the vectors in degrees
-*/
-float angleDeg (const Vector& v1, const Vector& v2)
-{
-  float f;
-  f = acos( v1 * v2 / (v1.len() * v2.len()));
-  return f * 180 / PI;
-}
-
-
-/**
-   \brief Outputs the values of the Vector
-*/
-void Vector::debug(void)
-{
-  PRINT(0)("Vector Debug information\n");
-  PRINT(0)("x: %f; y: %f; z: %f", x, y, z);
-  PRINT(3)(" lenght: %f", len());
-  PRINT(0)("\n");
-}
-
-
-#endif /* _VECTOR_H */
