Index: trunk/src/lib/graphics/importer/material.cc
===================================================================
--- trunk/src/lib/graphics/importer/material.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/material.cc	(revision 8619)
@@ -22,4 +22,7 @@
 #include "debug.h"
 #include "compiler.h"
+
+#include "loading/load_param.h"
+
 #include "util/loading/resource_manager.h"
 
@@ -47,4 +50,37 @@
 }
 
+Material& Material::operator=(const Material& material)
+{
+  this->illumModel = material.illumModel;
+  this->diffuse = material.diffuse;
+  this->specular = material.specular;
+  this->ambient = material.ambient;
+  this->shininess = material.shininess;
+
+  this->textures = material.textures;
+  this->sFactor = material.sFactor;
+  this->tFactor = material.tFactor;
+  this->setName(material.getName());
+
+  return *this;
+}
+
+
+
+void Material::loadParams(const TiXmlElement* root)
+{
+  LoadParam(root, "illum", this, Material, setIllum);
+
+  LoadParam(root, "diffuse-color", this, Material , setDiffuse);
+  LoadParam(root, "ambient-color", this, Material , setAmbient);
+  LoadParam(root, "specular-color", this, Material , setSpecular);
+  LoadParam(root, "transparency", this, Material , setTransparency);
+
+  LoadParam(root, "tex", this, Material, setDiffuseMap);
+  LoadParam(root, "blendfunc", this, Material, setBlendFuncS)
+      .defaultValues("ZERO", "ZERO");
+}
+
+
 /**
  * @brief deletes a Material
@@ -65,16 +101,4 @@
 
 const Material* Material::selectedMaterial = NULL;
-
-const GLenum Material::glTextureArbs[] =
-{
-  GL_TEXTURE0,
-  GL_TEXTURE1,
-  GL_TEXTURE2,
-  GL_TEXTURE3,
-  GL_TEXTURE4,
-  GL_TEXTURE5,
-  GL_TEXTURE6,
-  GL_TEXTURE7
-};
 
 
@@ -104,19 +128,19 @@
  * @brief sets the material with which the following Faces will be painted
  */
-  bool Material::select() const
+bool Material::select() const
 {
   if (unlikely(this == Material::selectedMaterial))
-      return true;
-
-/// !!  HACK !!! FIX THIS IN MODEL ///
+    return true;
+
+  /// !!  HACK !!! FIX THIS IN MODEL ///
   else if (likely(Material::selectedMaterial != NULL))
   {
-  Material::unselect();
-//     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
-//     {
-//         glActiveTexture(Material::glTextureArbs[i]);
-//         glBindTexture(GL_TEXTURE_2D, 0);
-//         glDisable(GL_TEXTURE_2D);
-//     }
+    Material::unselect();
+    //     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
+    //     {
+    //         glActiveTexture(Material::glTextureArbs[i]);
+    //         glBindTexture(GL_TEXTURE_2D, 0);
+    //         glDisable(GL_TEXTURE_2D);
+    //     }
   }
 
@@ -125,11 +149,11 @@
     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
     {
-        glActiveTexture(Material::glTextureArbs[i]);
-        //glBindTexture(GL_TEXTURE_2D, 0);
-        glDisable(GL_TEXTURE_2D);
+      glActiveTexture(Material::glTextureArbs[i]);
+      //glBindTexture(GL_TEXTURE_2D, 0);
+      glDisable(GL_TEXTURE_2D);
     }
   }
 
-    // setting diffuse color
+  // setting diffuse color
   glColor4f (diffuse.r(), diffuse.g(), diffuse.b(), diffuse.a());
   // setting ambient color
@@ -161,11 +185,11 @@
   for(unsigned int i = 0; i < this->textures.size(); ++i)
   {
-      glActiveTexture(Material::glTextureArbs[i]);
-      glEnable(GL_TEXTURE_2D);
-      if(this->textures[i].hasAlpha())
-      {
-        glEnable(GL_BLEND);
-      }
-      glBindTexture(GL_TEXTURE_2D, this->textures[i].getTexture());
+    glActiveTexture(Material::glTextureArbs[i]);
+    glEnable(GL_TEXTURE_2D);
+    if(this->textures[i].hasAlpha())
+    {
+      glEnable(GL_BLEND);
+    }
+    glBindTexture(GL_TEXTURE_2D, this->textures[i].getTexture());
   }
   Material::selectedMaterial = this;
@@ -179,10 +203,10 @@
 {
   Material::selectedMaterial = NULL;
-    for(unsigned int i = 0; i < 8; ++i)
-    {
-        glActiveTexture(Material::glTextureArbs[i]);
-        glBindTexture(GL_TEXTURE_2D, 0);
-        glDisable(GL_TEXTURE_2D);
-    }
+  for(unsigned int i = 0; i < 8; ++i)
+  {
+    glActiveTexture(Material::glTextureArbs[i]);
+    glBindTexture(GL_TEXTURE_2D, 0);
+    glDisable(GL_TEXTURE_2D);
+  }
 }
 
@@ -252,4 +276,16 @@
   this->diffuse.a() = trans;
 }
+
+/**
+ * @brief sets the Blend-Function Parameters
+ * @param sFactor the Source Parameter.
+ * @param tFactor the Desitnation Parameter.
+ */
+void Material::setBlendFuncS(const std::string& sFactor, const std::string& tFactor)
+{
+  this->setBlendFunc(Material::stringToBlendFunc(sFactor), Material::stringToBlendFunc(tFactor));
+}
+
+
 
 /**
@@ -354,6 +390,6 @@
   // HACK
   glActiveTexture(textureNumber);
-   glEnable(GL_TEXTURE_2D);
-   glBindTexture(GL_TEXTURE_2D, this->textures[textureNumber].getTexture());
+  glEnable(GL_TEXTURE_2D);
+  glBindTexture(GL_TEXTURE_2D, this->textures[textureNumber].getTexture());
   glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
 
@@ -387,6 +423,5 @@
  */
 void Material::setBump(const std::string& bump)
-{
-}
+{}
 
 
@@ -400,2 +435,69 @@
   return maxTexUnits;
 }
+
+const GLenum Material::glTextureArbs[] =
+{
+  GL_TEXTURE0,
+  GL_TEXTURE1,
+  GL_TEXTURE2,
+  GL_TEXTURE3,
+  GL_TEXTURE4,
+  GL_TEXTURE5,
+  GL_TEXTURE6,
+  GL_TEXTURE7
+};
+
+
+/**
+ * @param blendFunc the Enumerator to convert to a String.
+ * @returns the matching String if found
+ */
+const std::string& Material::blendFuncToString(GLenum blendFunc)
+{
+  for (unsigned int i = 0; i < 9; ++i)
+    if (blendFunc == Material::glBlendFuncParams[i])
+      return Material::blendFuncNames[i];
+  PRINTF(2)("Supplied an Invalid Enumerator to blendfunc %d\n", blendFunc);
+  return Material::blendFuncNames[0];
+}
+
+/**
+ * @param blendFuncString the String to convert into a gl-enumeration
+ * @returns the matching GL-enumeration if found.
+ */
+GLenum Material::stringToBlendFunc(const std::string& blendFuncString)
+{
+  for (unsigned int i = 0; i < 9; ++i)
+    if (blendFuncString == Material::blendFuncNames[i])
+      return Material::glBlendFuncParams[i];
+  PRINTF(2)("BlendFunction %s not recognized using %s\n", blendFuncString.c_str(), Material::blendFuncNames[0].c_str());
+  return Material::glBlendFuncParams[0];
+}
+
+
+const GLenum Material::glBlendFuncParams[] =
+  {
+    GL_ZERO,
+    GL_ONE,
+    GL_DST_COLOR,
+    GL_ONE_MINUS_DST_COLOR,
+    GL_SRC_ALPHA,
+    GL_ONE_MINUS_SRC_ALPHA,
+    GL_DST_ALPHA,
+    GL_ONE_MINUS_DST_ALPHA,
+    GL_SRC_ALPHA_SATURATE
+  };
+
+const std::string Material::blendFuncNames[] =
+  {
+    "ZERO",
+    "ONE",
+    "DST_COLOR",
+    "ONE_MINUS_DST_COLOR",
+    "SRC_ALPHA",
+    "ONE_MINUS_SRC_ALPHA",
+    "DST_ALPHA",
+    "ONE_MINUS_DST_ALPHA",
+    "SRC_ALPHA_SATURATE"
+
+  };
Index: trunk/src/lib/graphics/importer/material.h
===================================================================
--- trunk/src/lib/graphics/importer/material.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/material.h	(revision 8619)
@@ -24,60 +24,74 @@
 class Material : public BaseObject
 {
-  public:
-    Material (const std::string& mtlName = "");
-    virtual ~Material ();
+public:
+  Material (const std::string& mtlName = "");
+  virtual ~Material ();
 
-    Material& operator=(const Material& material);
+  void loadParams(const TiXmlElement* root);
 
-    bool select () const;
-    bool activateTextureUnit(unsigned int textureNumber);
-    static void unselect();
+  Material& operator=(const Material& material);
 
-    void setIllum (int illum);
-    int getIllumModel() const { return this->illumModel; };
+  bool select () const;
+  bool activateTextureUnit(unsigned int textureNumber);
+  static void unselect();
 
-    void setDiffuse (float r, float g, float b);
-    void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
-    void setAmbient (float r, float g, float b);
-    void setSpecular (float r, float g, float b);
-    void setShininess (float shini);
-    void setTransparency (float trans);
-    void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
+  void setIllum (int illum);
+  int getIllumModel() const { return this->illumModel; };
 
-    const Color& getDiffuseColor() const { return diffuse; };
+  void setDiffuse (float r, float g, float b);
+  void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
+  void setAmbient (float r, float g, float b);
+  void setSpecular (float r, float g, float b);
+  void setShininess (float shini);
+  void setTransparency (float trans);
+  void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
+  void setBlendFuncS(const std::string& sFactor, const std::string& tFactor);
 
-    // MAPPING //
-    void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
-    void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
-    void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
-    void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+  Color& diffuseColor() { return diffuse; };
+  const Color& diffuseColor() const { return diffuse; };
 
-    void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
-    void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
-    void setBump(const std::string& bump);
-    GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
+  // MAPPING //
+  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
+  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
+  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
+  void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
 
-    static void addTexturePath(const std::string& pathName);
+  void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
+  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
+  void setBump(const std::string& bump);
 
-  public:
-    static const GLenum glTextureArbs[];  //!< The Texture ARB's
+  GLuint diffuseTextureID(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
 
-    static unsigned int getMaxTextureUnits();
+  const Texture& diffuseTexture(unsigned int i = 0) const { return this->textures[i]; };
 
-  private:
-    static const Material* selectedMaterial; //!< The currently selected material.
+  static void addTexturePath(const std::string& pathName);
 
-    int              illumModel;       //!< The IlluminationModel is either flat or smooth.
-    Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
-    Color            ambient;          //!< The ambient color of the Material.
-    Color            specular;         //!< The specular color of the Material.
-    float            shininess;        //!< The shininess of the Material.
-    GLenum           sFactor;          //!< The Blending Factor for the Source.
-    GLenum           tFactor;          //!< The Blending Factor for the Destination.
+  const std::string& blendFuncToString(GLenum blendFunc);
+  GLenum stringToBlendFunc(const std::string& blendFuncString);
 
-    std::vector<Texture> textures;     //!< An Array of Textures.
 
-    Texture*         ambientTexture;   //!< The ambient texture of the Material.
-    Texture*         specularTexture;  //!< The specular texture of the Material.
+public:
+  static const GLenum glTextureArbs[];  //!< The Texture ARB's
+
+  static const GLenum glBlendFuncParams[];
+  static const std::string blendFuncNames[];
+
+  static unsigned int getMaxTextureUnits();
+
+private:
+  static const Material* selectedMaterial; //!< The currently selected material.
+
+  int              illumModel;       //!< The IlluminationModel is either flat or smooth.
+  Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
+  Color            ambient;          //!< The ambient color of the Material.
+  Color            specular;         //!< The specular color of the Material.
+  float            shininess;        //!< The shininess of the Material.
+  GLenum           sFactor;          //!< The Blending Factor for the Source.
+  GLenum           tFactor;          //!< The Blending Factor for the Destination.
+
+  std::vector<Texture> textures;     //!< An Array of Textures.
+
+  Texture*         ambientTexture;   //!< The ambient texture of the Material.
+  Texture*         specularTexture;  //!< The specular texture of the Material.
 };
 
Index: trunk/src/lib/graphics/importer/texture_sequence.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture_sequence.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/texture_sequence.cc	(revision 8619)
@@ -180,5 +180,5 @@
   }
   bool success = this->addFrame(addSurface);
-  delete addSurface;
+  SDL_FreeSurface(addSurface);
 
   return success;
