Index: trunk/src/lib/particles/Makefile.am
===================================================================
--- trunk/src/lib/particles/Makefile.am	(revision 6628)
+++ trunk/src/lib/particles/Makefile.am	(revision 6629)
@@ -10,4 +10,5 @@
 			sprite_particles.cc \
 			spark_particles.cc \
+			model_particles.cc \
 			\
 			quick_animation.cc
@@ -20,4 +21,5 @@
 			sprite_particles.h \
 			spark_particles.h \
+			model_particles.h \
 			\
 			quick_animation.h
Index: trunk/src/lib/particles/model_particles.cc
===================================================================
--- trunk/src/lib/particles/model_particles.cc	(revision 6629)
+++ trunk/src/lib/particles/model_particles.cc	(revision 6629)
@@ -0,0 +1,156 @@
+/*
+   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_GRAPHICS
+
+#include "model_particles.h"
+
+#include "load_param.h"
+#include "factory.h"
+#include "material.h"
+#include "state.h"
+#include "shell_command.h"
+
+#include "parser/tinyxml/tinyxml.h"
+#include <algorithm>
+
+
+CREATE_FACTORY(ModelParticles, CL_MODEL_PARTICLES);
+
+SHELL_COMMAND(texture, ModelParticles, setMaterialTexture)
+->defaultValues(1, "maps/evil-flower.png");
+
+using namespace std;
+
+/**
+ *  standard constructor
+ * @param maxCount the Count of particles in the System
+ * @param type The Type of the ModelParticles
+*/
+ModelParticles::ModelParticles (unsigned int maxCount)
+    : ParticleSystem(maxCount)
+{
+  this->init();
+}
+
+/**
+ * @brief creates a Particle System out of a XML-element
+ * @param root: the XML-element to load from
+ */
+ModelParticles::ModelParticles(const TiXmlElement* root)
+{
+  this->init();
+  if (root != NULL)
+    this->loadParams(root);
+}
+
+/**
+ *  standard deconstructor
+*/
+ModelParticles::~ModelParticles()
+{
+  // deleting all the living Particles
+  while (this->particles)
+  {
+    Particle* tmpDelPart = this->particles;
+    this->particles = this->particles->next;
+    delete tmpDelPart;
+  }
+
+  // deleting all the dead particles
+  while (this->deadList)
+  {
+    Particle* tmpDelPart = this->deadList;
+    this->deadList = this->deadList->next;
+    delete tmpDelPart;
+  }
+}
+
+/**
+ * @brief initializes the ModelParticles with default values
+*/
+void ModelParticles::init()
+{
+  this->setClassID(CL_MODEL_PARTICLES, "ModelParticles");
+
+  this->material.setDiffuseMap("maps/radial-trans-noise.png");
+}
+
+
+/**
+ * loads Parameters from a TiXmlElement
+ * @param root the XML-element to load from.
+ */
+void ModelParticles::loadParams(const TiXmlElement* root)
+{
+  ParticleSystem::loadParams(root);
+
+  LoadParam(root, "texture", this, ModelParticles, setMaterialTexture);
+}
+
+/**
+ * @brief sets the Texutre that is placed onto the particles
+ * @param textureFile the Texture to load onto these ModelParticles
+ */
+void ModelParticles::setMaterialTexture(const char* textureFile)
+{
+  this->material.setDiffuseMap(textureFile);
+}
+
+/**
+ * @brief draws all the Particles of this System
+ *
+ * The Cases in this Function all do the same:
+ * Drawing all the particles with the appropriate Type.
+ * This is just the fastest Way to do this, but will most likely be changed in the future.
+ */
+void ModelParticles::draw() const
+{
+  glPushAttrib(GL_ENABLE_BIT);
+  Particle* drawPart = particles;
+
+  GLboolean checkLight = false;
+  glGetBooleanv(GL_LIGHTING, &checkLight);
+  if (checkLight == GL_TRUE)
+    glDisable(GL_LIGHTING);
+  glMatrixMode(GL_MODELVIEW);
+
+  this->material.select();
+  glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
+
+  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 );
+
+      this->getModel()->draw();
+
+      glPopMatrix();
+      drawPart = drawPart->next;
+    }
+  else
+    PRINTF(2)("no model loaded onto ParticleSystem-%s\n", this->getName());
+  glPopAttrib();
+}
Index: trunk/src/lib/particles/model_particles.h
===================================================================
--- trunk/src/lib/particles/model_particles.h	(revision 6629)
+++ trunk/src/lib/particles/model_particles.h	(revision 6629)
@@ -0,0 +1,36 @@
+/*!
+ * @file model_particles.h
+
+*/
+
+#ifndef _MODEL_PARTICLE_SYSTEM_H
+#define _MODEL_PARTICLE_SYSTEM_H
+
+#include "particle_system.h"
+#include "material.h"
+
+//! A class to handle ParticleSystems
+class ModelParticles : public ParticleSystem
+{
+public:
+  ModelParticles(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT);
+  ModelParticles(const TiXmlElement* root);
+  virtual ~ModelParticles();
+
+  virtual void loadParams(const TiXmlElement* root);
+
+  void setMaterialTexture(const char* textureFile);
+
+  /** @returns the Material that lies on this particles */
+  inline const Material* getMaterial() const { return &this->material; };
+
+  virtual void draw() const;
+
+private:
+  void init();
+
+private:
+  Material          material;            //!< A Material for all the Particles.
+};
+
+#endif /* _MODEL_PARTICLE_SYSTEM_H */
Index: trunk/src/lib/particles/particle_system.cc
===================================================================
--- trunk/src/lib/particles/particle_system.cc	(revision 6628)
+++ trunk/src/lib/particles/particle_system.cc	(revision 6629)
@@ -74,6 +74,6 @@
 
 /**
-  \brief initializes the ParticleSystem with default values
-*/
+ * @brief initializes the ParticleSystem with default values
+ */
 void ParticleSystem::init()
 {
@@ -125,4 +125,8 @@
   }
   LOAD_PARAM_END_CYCLE(element);
+
+  LoadParam(root, "precache", this, ParticleSystem, precache)
+      .describe("Precaches the ParticleSystem for %1 seconds, %2 times per Second")
+      .defaultValues(2, 1, 25);
 }
 
@@ -222,5 +226,8 @@
 }
 
-
+/**
+ * @brief adds an Emitter to this System.
+ * @param emitter the Emitter to add.
+ */
 void ParticleSystem::addEmitter(ParticleEmitter* emitter)
 {
@@ -232,5 +239,8 @@
 }
 
-
+/**
+ * @brief removes a ParticleEmitter from this System
+ * @param emitter the Emitter to remove
+ */
 void ParticleSystem::removeEmitter(ParticleEmitter* emitter)
 {
@@ -244,4 +254,18 @@
 
 /**
+ * @brief does a Precaching, meaning, that the ParticleSystem(and its emitters) will be ticked force
+ * @param seconds: seconds
+ * @param ticksPerSeconds times per Second.
+ */
+void ParticleSystem::precache(unsigned int seconds, unsigned int ticksPerSecond)
+{
+  PRINTF(4)("Precaching %s::%s %d seconds %d timesPerSecond\n", this->getClassName(), this->getName(), seconds, ticksPerSecond);
+  this->debug();
+  for (unsigned int i = 0; i < seconds*ticksPerSecond; i++)
+    this->tick(1.0/(float)ticksPerSecond);
+}
+
+
+/**
  *  ticks the system.
  * @param dt the time to tick all the Particles of the System
@@ -355,47 +379,7 @@
 //   switch (this->particleType)
 //   {
-//     case PARTICLE_SPARK:
-//       glDisable(GL_LIGHTING);
-//       glDepthMask(GL_FALSE);
-//       //glEnable(GL_LINE_SMOOTH);
-//       glEnable(GL_BLEND);
-//
-//       glBegin(GL_LINES);
-//       while (likely(drawPart != NULL))
-//       {
-//         glColor4fv(drawPart->color);
-//         glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
-//         glVertex3f(drawPart->position.x - drawPart->velocity.x * drawPart->radius,
-//                    drawPart->position.y - drawPart->velocity.y * drawPart->radius,
-//                    drawPart->position.z - drawPart->velocity.z * drawPart->radius);
-//         drawPart = drawPart->next;
-//       }
-//       glEnd();
-//       break;
 //
 //     case PARTICLE_MODEL:
 //       {
-//         GLfloat matrix[4][4];
-//
-//         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 */
-//           drawPart->orientation.matrix (matrix);
-//           glMultMatrixf((float*)matrix);
-//
-//           this->getModel()->draw();
-//
-//           glPopMatrix();
-//           drawPart = drawPart->next;
-//         }
-//         else
-//           PRINTF(2)("no model loaded onto ParticleSystem-%s\n", this->getName());
 //       }
 //       break;
@@ -488,5 +472,5 @@
 void ParticleSystem::debug() const
 {
-  PRINT(0)("  ParticleCount: %d, maximumCount: %d :: filled %d%%\n", this->count, this->maxCount, 100*this->count/this->maxCount);
+  PRINT(0)("  ParticleCount: %d emitters: %d, maximumCount: %d :: filled %d%%\n", this->count, this->emitters.size(), this->maxCount, 100*this->count/this->maxCount);
   if (deadList)
   {
Index: trunk/src/lib/particles/particle_system.h
===================================================================
--- trunk/src/lib/particles/particle_system.h	(revision 6628)
+++ trunk/src/lib/particles/particle_system.h	(revision 6629)
@@ -95,4 +95,6 @@
   void addParticle(const Vector& position, const Vector& velocity, const Quaternion& orientation, const Quaternion& momentum, unsigned int data = 0);
 
+  void precache(unsigned int seconds, unsigned int ticksPerSecond = 25);
+
   virtual void tick(float dt);
   virtual void draw() const = 0;
Index: trunk/src/lib/particles/spark_particles.cc
===================================================================
--- trunk/src/lib/particles/spark_particles.cc	(revision 6628)
+++ trunk/src/lib/particles/spark_particles.cc	(revision 6629)
@@ -107,5 +107,4 @@
 void SparkParticles::draw() const
 {
-  exit(-1);
   glPushAttrib(GL_ENABLE_BIT);
 
