Index: trunk/src/lib/particles/model_particles.cc
===================================================================
--- trunk/src/lib/particles/sprite_particles.cc	(revision 6628)
+++ trunk/src/lib/particles/model_particles.cc	(revision 6629)
@@ -16,5 +16,5 @@
 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
 
-#include "sprite_particles.h"
+#include "model_particles.h"
 
 #include "load_param.h"
@@ -28,8 +28,8 @@
 
 
-CREATE_FACTORY(SpriteParticles, CL_SPRITE_PARTICLES);
+CREATE_FACTORY(ModelParticles, CL_MODEL_PARTICLES);
 
-SHELL_COMMAND(texture, SpriteParticles, setMaterialTexture)
-    ->defaultValues(1, "maps/evil-flower.png");
+SHELL_COMMAND(texture, ModelParticles, setMaterialTexture)
+->defaultValues(1, "maps/evil-flower.png");
 
 using namespace std;
@@ -38,8 +38,8 @@
  *  standard constructor
  * @param maxCount the Count of particles in the System
- * @param type The Type of the SpriteParticles
+ * @param type The Type of the ModelParticles
 */
-SpriteParticles::SpriteParticles (unsigned int maxCount)
-  : ParticleSystem(maxCount)
+ModelParticles::ModelParticles (unsigned int maxCount)
+    : ParticleSystem(maxCount)
 {
   this->init();
@@ -50,5 +50,5 @@
  * @param root: the XML-element to load from
  */
-SpriteParticles::SpriteParticles(const TiXmlElement* root)
+ModelParticles::ModelParticles(const TiXmlElement* root)
 {
   this->init();
@@ -60,5 +60,5 @@
  *  standard deconstructor
 */
-SpriteParticles::~SpriteParticles()
+ModelParticles::~ModelParticles()
 {
   // deleting all the living Particles
@@ -80,9 +80,9 @@
 
 /**
- * @brief initializes the SpriteParticles with default values
+ * @brief initializes the ModelParticles with default values
 */
-void SpriteParticles::init()
+void ModelParticles::init()
 {
-  this->setClassID(CL_SPRITE_PARTICLES, "SpriteParticles");
+  this->setClassID(CL_MODEL_PARTICLES, "ModelParticles");
 
   this->material.setDiffuseMap("maps/radial-trans-noise.png");
@@ -94,16 +94,16 @@
  * @param root the XML-element to load from.
  */
-void SpriteParticles::loadParams(const TiXmlElement* root)
+void ModelParticles::loadParams(const TiXmlElement* root)
 {
   ParticleSystem::loadParams(root);
 
-  LoadParam(root, "texture", this, SpriteParticles, setMaterialTexture);
+  LoadParam(root, "texture", this, ModelParticles, setMaterialTexture);
 }
 
 /**
  * @brief sets the Texutre that is placed onto the particles
- * @param textureFile the Texture to load onto these SpriteParticles
+ * @param textureFile the Texture to load onto these ModelParticles
  */
-void SpriteParticles::setMaterialTexture(const char* textureFile)
+void ModelParticles::setMaterialTexture(const char* textureFile)
 {
   this->material.setDiffuseMap(textureFile);
@@ -117,8 +117,7 @@
  * This is just the fastest Way to do this, but will most likely be changed in the future.
  */
-void SpriteParticles::draw() const
+void ModelParticles::draw() const
 {
   glPushAttrib(GL_ENABLE_BIT);
-
   Particle* drawPart = particles;
 
@@ -128,53 +127,30 @@
     glDisable(GL_LIGHTING);
   glMatrixMode(GL_MODELVIEW);
-  glDepthMask(GL_FALSE);
 
-  material.select();
+  this->material.select();
   glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
 
-  //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
+  if (likely(this->getModel() != NULL))
+    while (likely(drawPart != NULL))
+    {
+      glPushMatrix();
+      glMatrixMode(GL_MODELVIEW);
+      /* move */
+      glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z);
+      /* scale */
+      glScalef(drawPart->radius, drawPart->radius, drawPart->radius);
+      /* rotate */
+      Vector tmpRot = drawPart->orientation.getSpacialAxis();
+      glRotatef (drawPart->orientation.getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
 
-  while (likely(drawPart != NULL))
-  {
-    glColor4fv(drawPart->color);
-    //! @todo implement a faster code for the look-at Camera algorithm.
+      this->getModel()->draw();
 
-    const PNode* camera = State::getCamera();  //!< @todo MUST be different
-    Vector cameraPos = camera->getAbsCoor();
-    Vector cameraTargetPos = State::getCameraTarget()->getAbsCoor();
-    Vector view = cameraTargetPos - cameraPos;
-    Vector up = Vector(0, 1, 0);
-    up = camera->getAbsDir().apply(up);
-    Vector h = up.cross(view);
-    Vector v = h.cross(view);
-    h.normalize();
-    v.normalize();
-    v *= .5 * drawPart->radius;
-    h *= .5 * drawPart->radius;
-
-    glBegin(GL_TRIANGLE_STRIP);
-    glTexCoord2i(1, 1);
-    glVertex3f(drawPart->position.x - h.x - v.x,
-               drawPart->position.y - h.y - v.y,
-               drawPart->position.z - h.z - v.z);
-    glTexCoord2i(0, 1);
-    glVertex3f(drawPart->position.x - h.x + v.x,
-               drawPart->position.y - h.y + v.y,
-               drawPart->position.z - h.z + v.z);
-    glTexCoord2i(1, 0);
-    glVertex3f(drawPart->position.x + h.x - v.x,
-               drawPart->position.y + h.y - v.y,
-               drawPart->position.z + h.z - v.z);
-    glTexCoord2i(0, 0);
-    glVertex3f(drawPart->position.x + h.x + v.x,
-               drawPart->position.y + h.y + v.y,
-               drawPart->position.z + h.z + v.z);
-
-    glEnd();
-
-    drawPart = drawPart->next;
-  }
-  glDepthMask(GL_TRUE);
+      glPopMatrix();
+      drawPart = drawPart->next;
+    }
+  else
+    PRINTF(2)("no model loaded onto ParticleSystem-%s\n", this->getName());
   glPopAttrib();
 }
