Index: trunk/src/lib/graphics/Makefile.am
===================================================================
--- trunk/src/lib/graphics/Makefile.am	(revision 6812)
+++ trunk/src/lib/graphics/Makefile.am	(revision 6815)
@@ -9,9 +9,12 @@
 			   render2D/render_2d.cc \
 			   render2D/element_2d.cc \
+			   render2D/billboard.cc \
 			   text_engine/text_engine.cc \
 			   text_engine/text.cc \
 			   text_engine/font.cc \
 			   effects/graphics_effect.cc \
-			   effects/fog_effect.cc
+			   effects/fog_effect.cc \
+			   effects/lense_flare.cc
+
 
 noinst_HEADERS = graphics_engine.h \
@@ -20,9 +23,11 @@
 		 render2D/render_2d.h \
 		 render2D/element_2d.h \
+		 render2D/billboard.h \
 		 text_engine/text_engine.h \
 		 text_engine/text.h \
 		 text_engine/font.h \
 		 effects/graphics_effect.h \
-		 effects/fog_effect.h
+		 effects/fog_effect.h \
+		 effects/lense_flare.h
 
 
Index: trunk/src/lib/graphics/effects/fog_effect.cc
===================================================================
--- trunk/src/lib/graphics/effects/fog_effect.cc	(revision 6812)
+++ trunk/src/lib/graphics/effects/fog_effect.cc	(revision 6815)
@@ -62,7 +62,8 @@
 void FogEffect::loadParams(const TiXmlElement* root)
 {
+  printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.loadParms\n\n");
   GraphicsEffect::loadParams(root);
 
-   LoadParam(root, "fog-effect", this, FogEffect, setFogMode)
+   LoadParam(root, "fog-mode", this, FogEffect, setFogMode)
        .describe("sets the the fog mode {GL_LINEAR, GL_EXP, GL_EXP2}");
 
@@ -87,4 +88,5 @@
 bool FogEffect::activate()
 {
+  printf("fog==============================================>>>>>>>>>>>>>>>>>>>>>>>>...\n\n");
   PRINTF(4)( "Enabling Fog Effect, mode: %i, density: %f, start: %f, end: %f\n", this->fogMode, this->fogDensity,
              this->fogStart, this->fogEnd);
@@ -92,5 +94,5 @@
   glEnable(GL_FOG);
   {
-    GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1.0};
+    GLfloat fogColor[4] = {0.6, 0.6, 0.6, 1.0};
 
     glFogi(GL_FOG_MODE, this->fogMode);
Index: trunk/src/lib/graphics/effects/graphics_effect.cc
===================================================================
--- trunk/src/lib/graphics/effects/graphics_effect.cc	(revision 6812)
+++ trunk/src/lib/graphics/effects/graphics_effect.cc	(revision 6815)
@@ -72,2 +72,18 @@
 bool GraphicsEffect::init()
 {}
+
+
+
+/**
+ * draws the effect, if needed
+ */
+void GraphicsEffect::draw() const
+{}
+
+
+
+/**
+ * ticks the effect if there is any time dependancy
+ */
+void GraphicsEffect::tick(float dt)
+{}
Index: trunk/src/lib/graphics/effects/graphics_effect.h
===================================================================
--- trunk/src/lib/graphics/effects/graphics_effect.h	(revision 6812)
+++ trunk/src/lib/graphics/effects/graphics_effect.h	(revision 6815)
@@ -25,5 +25,8 @@
     virtual bool deactivate() = 0;
 
-    inline bool isActivated() { return this->bActivated; }
+    virtual void draw() const;
+    virtual void tick(float dt);
+
+    inline bool isActivated() const { return this->bActivated; }
 
 
Index: trunk/src/lib/graphics/effects/lense_flare.cc
===================================================================
--- trunk/src/lib/graphics/effects/lense_flare.cc	(revision 6815)
+++ trunk/src/lib/graphics/effects/lense_flare.cc	(revision 6815)
@@ -0,0 +1,188 @@
+
+
+/*
+   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: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
+
+#include "lense_flare.h"
+
+#include "load_param.h"
+#include "factory.h"
+
+#include "glincl.h"
+#include "texture.h"
+
+#include "light.h"
+#include "state.h"
+
+#include "render2D/billboard.h"
+
+using namespace std;
+
+CREATE_FACTORY(LenseFlare, CL_LENSE_FLARE);
+
+
+
+/**
+ *  default constructor
+ * @param root The XML-element to load the LenseFlare from
+ */
+ LenseFlare::LenseFlare(const TiXmlElement* root)
+{
+  if (root != NULL)
+    this->loadParams(root);
+
+  this->flareMatrix = new float[14];
+  /*          length                      image scale */
+  this->flareMatrix[0] = 1.0f; this->flareMatrix[1] = 1.0f;
+  this->flareMatrix[2] = 0.5f; this->flareMatrix[3] = 0.5f;
+  this->flareMatrix[4] = 0.33f; this->flareMatrix[5] = 0.25f;
+  this->flareMatrix[6] = 0.125f; this->flareMatrix[7] = 1.0f;
+  this->flareMatrix[8] = -0.5f; this->flareMatrix[9] = 0.5f;
+  this->flareMatrix[10] = -0.25f; this->flareMatrix[11] = 0.25f;
+  this->flareMatrix[12] = 1.82f; this->flareMatrix[13] = 0.25f;
+}
+
+
+/**
+ *  destroys a LenseFlare
+ */
+LenseFlare::~LenseFlare()
+{
+  std::vector<Billboard*>::iterator it;
+  for( it = flares.begin(); it != flares.end(); it++)
+    delete (*it);
+}
+
+
+/**
+ * @param root The XML-element to load the LenseFlare from
+ */
+void LenseFlare::loadParams(const TiXmlElement* root)
+{
+  GraphicsEffect::loadParams(root);
+
+    LoadParam(root, "add-flare-texture", this, LenseFlare, addFlare)
+        .describe("adds a lensflare texture to the engine");
+}
+
+
+/**
+ * initializes the fog effect
+ */
+bool LenseFlare::init()
+{}
+
+
+/**
+ * activates the fog effect
+ */
+bool LenseFlare::activate()
+{
+  this->bActivated = true;
+}
+
+
+/**
+ * deactivates the fog effect
+ */
+bool LenseFlare::deactivate()
+{
+  this->bActivated = false;
+}
+
+
+/**
+ * converts a gl mode char to a GLint
+ * @param mode the mode character
+ */
+GLint LenseFlare::charToFogMode(const char* mode)
+{}
+
+
+/**
+ * adds a texture flare
+ * @param textureName the name of the flare texture
+ *
+ *  1st: Texture of the Sun/Light source itself
+ *  2nd: Texture of the fist halo
+ *  3rd: Texture of small burst
+ *  4th: Texture of the second halo
+ *  5th: Texutre of the second burst
+ *  6th: Texture of the third halo
+ *  7th: Texture of the third burst
+ */
+void LenseFlare::addFlare(const char* textureName)
+{
+  if( this->flares.size() < LF_MAX_FLARES)
+  {
+    PRINTF(2)("You tried to add more than %i lense flares, ignoring\n", LF_MAX_FLARES);
+    return;
+  }
+
+  Billboard* bb = new Billboard(NULL);
+  bb->setTexture(textureName);
+  this->flares.push_back(bb);
+  PRINTF(0)("Added a Lenseflare Billboard with texture %s\n", textureName);
+
+  // the first flare belongs to the light source
+  if( this->flares.size() == 1 && this->lightSource != NULL)
+  {
+    bb->setBindNode(static_cast<PNode*>(this->lightSource));
+  }
+}
+
+
+
+/**
+ * tick the effect
+ */
+void LenseFlare::tick(float dt)
+{
+  if( unlikely(!this->bActivated || this->flares.size() == 0))
+    return;
+  // always update the screen center, it could be, that the window is resized
+  this->screenCenter = Vector(State::getResX()/2.0f, State::getResY()/2.0f, 0.0f);
+  // flare vector is the direction from the center to the light source
+  this->flareVector = this->flares[0]->getAbsCoor2D();
+  this->distance = this->flareVector.len();
+  this->flareVector.normalize();
+
+  // now calculate the new coordinates of the billboards
+  std::vector<Billboard*>::iterator it;
+  int i;
+  for( it = flares.begin(), i = 0; it != flares.end(); it++, i++)
+  {
+    // set the new position
+    (*it)->setAbsCoor2D(this->flareVector * this->flareMatrix[i * 2]);
+    PRINTF(0)("Drawing flare %i @ (%f, %f)\n", i, (this->flareVector * this->flareMatrix[i * 2]).x, (this->flareVector * this->flareMatrix[i * 2]).y);
+    // tick them
+    (*it)->tick(dt);
+  }
+}
+
+
+/**
+ * draws the LenseFlares
+ */
+void LenseFlare::draw() const
+{
+  if( !this->bActivated)
+    return;
+
+  std::vector<Billboard*>::const_iterator it;
+  for( it = flares.begin(); it != flares.end(); it++)
+    (*it)->draw();
+}
Index: trunk/src/lib/graphics/effects/lense_flare.h
===================================================================
--- trunk/src/lib/graphics/effects/lense_flare.h	(revision 6815)
+++ trunk/src/lib/graphics/effects/lense_flare.h	(revision 6815)
@@ -0,0 +1,59 @@
+/**
+ * @file lense_flare.h
+ *  lense flare effect
+ */
+
+#ifndef _LENSE_FLARE
+#define _LENSE_FLARE
+
+#include "graphics_effect.h"
+
+#include <vector>
+
+#include "vector.h"
+
+
+#define LF_MAX_FLARES 7
+
+
+class TiXmlElement;
+class Light;
+class Billboard;
+
+//! A class that handles LenseFlares. The LenseFlareManager operates on this.
+class LenseFlare : public GraphicsEffect
+{
+  public:
+    LenseFlare(const TiXmlElement* root = NULL);
+    virtual ~LenseFlare();
+
+    virtual void loadParams(const TiXmlElement* root);
+
+    virtual bool init();
+
+    virtual bool activate();
+    virtual bool deactivate();
+
+    virtual void draw() const;
+    virtual void tick(float dt);
+
+    void addFlare(const char* textureName);
+
+
+  private:
+    GLint charToFogMode(const char* mode);
+
+
+  private:
+    Light*                   lightSource;        //!< reference to the sun (or primary light source)
+    std::vector<Billboard*>  flares;             //!< the flares array
+
+    Vector                   flareVector;        //!< the axis to draw the flares on
+    float                    distance;           //!< distance from center to source
+    Vector                   screenCenter;       //!< the vector marking the center of the screen
+
+    float*                   flareMatrix;
+};
+
+
+#endif /* _LENSE_FLARE */
Index: trunk/src/lib/graphics/graphics_engine.cc
===================================================================
--- trunk/src/lib/graphics/graphics_engine.cc	(revision 6812)
+++ trunk/src/lib/graphics/graphics_engine.cc	(revision 6815)
@@ -41,4 +41,9 @@
 #include "shell_command.h"
 
+
+#include "parser/tinyxml/tinyxml.h"
+#include "load_param.h"
+#include "factory.h"
+
 #ifdef __WIN32__
  #include "class_list.h"
@@ -113,4 +118,16 @@
   GraphicsEngine::singletonRef = NULL;
 }
+
+
+/**
+ * loads the GraphicsEngine Specific Parameters.
+ * @param root: the XML-Element to load the Data From
+ */
+void GraphicsEngine::loadParams(const TiXmlElement* root)
+{
+  LoadParamXML(root, "load-effect", this, GraphicsEngine, loadGraphicsEffectXML)
+      .describe("loads a graphics effect");
+}
+
 
 /**
@@ -150,8 +167,8 @@
   this->initVideo(atoi(resolution.getString(0)), atoi(resolution.getString(1)), 16);
 
-  GraphicsEffect* fe = new FogEffect(NULL);
-  this->loadGraphicsEffect(fe);
-  fe->activate();
-  PRINTF(0)("--------------------------------------------------------------\n");
+//   GraphicsEffect* fe = new FogEffect(NULL);
+//   this->loadGraphicsEffect(fe);
+//   fe->activate();
+//   PRINTF(0)("--------------------------------------------------------------\n");
 }
 
@@ -571,7 +588,12 @@
 #endif /* NO_TEXT */
 
-
-  }
+  }
+
   Render2D::getInstance()->tick(dt);
+
+  // tick the graphics effects
+  list<GraphicsEffect*>::iterator it;
+  for (it = this->graphicsEffects.begin(); it != this->graphicsEffects.end(); it++)
+    (*it)->tick(dt);
 }
 
@@ -587,4 +609,9 @@
   Render2D::getInstance()->draw(E2D_LAYER_ALL);
   Shader::restoreShader();
+
+  //draw the graphics
+  list<GraphicsEffect*>::const_iterator it;
+  for (it = this->graphicsEffects.begin(); it != this->graphicsEffects.end(); it++)
+    (*it)->draw();
 }
 
@@ -661,4 +688,20 @@
 
 /**
+ * @param root The XML-element to load GraphicsEffects from
+ */
+void GraphicsEngine::loadGraphicsEffectXML(const TiXmlElement* root)
+{
+  const TiXmlElement* element = root->FirstChildElement();
+
+  while (element != NULL)
+  {
+    Factory::fabricate(element);
+
+    element = element->NextSiblingElement();
+  }
+}
+
+
+/**
  * loads a GraphicsEffect into the engine
  * @param effect the GraphicsEffect to add
Index: trunk/src/lib/graphics/graphics_engine.h
===================================================================
--- trunk/src/lib/graphics/graphics_engine.h	(revision 6812)
+++ trunk/src/lib/graphics/graphics_engine.h	(revision 6815)
@@ -23,4 +23,5 @@
 class WorldEntity;
 class GraphicsEffect;
+class TiXmlElement;
 
 //! class to handle graphics
@@ -34,4 +35,6 @@
     /** @returns a Pointer to the only object of this Class */
     inline static GraphicsEngine* getInstance() { if (!GraphicsEngine::singletonRef) GraphicsEngine::singletonRef = new GraphicsEngine();  return GraphicsEngine::singletonRef; };
+
+    virtual void loadParams(const TiXmlElement* root);
 
     int init();
@@ -83,4 +86,5 @@
     void process(const Event  &event);
 
+    void loadGraphicsEffectXML(const TiXmlElement* root);
     bool loadGraphicsEffect(GraphicsEffect* effect);
     bool unloadGraphicsEffect(GraphicsEffect* effect);
Index: trunk/src/lib/graphics/render2D/billboard.cc
===================================================================
--- trunk/src/lib/graphics/render2D/billboard.cc	(revision 6815)
+++ trunk/src/lib/graphics/render2D/billboard.cc	(revision 6815)
@@ -0,0 +1,168 @@
+/*
+   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: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
+
+#include "billboard.h"
+
+#include "load_param.h"
+#include "factory.h"
+
+#include "graphics_engine.h"
+#include "material.h"
+#include "glincl.h"
+#include "state.h"
+#include "p_node.h"
+
+
+using namespace std;
+
+
+CREATE_FACTORY(Billboard, CL_IMAGE_ENTITY);
+
+
+/**
+ * standart constructor
+ */
+Billboard::Billboard (const TiXmlElement* root)
+{
+  this->init();
+
+  if( root)
+    this->loadParams(root);
+}
+
+
+/**
+ * destroys a Billboard
+ */
+Billboard::~Billboard ()
+{
+  if (this->material)
+    delete this->material;
+}
+
+
+/**
+ * initializes the Billboard
+ */
+void Billboard::init()
+{
+  this->setClassID(CL_BILLBOARD, "Billboard");
+  this->setName("Billboard");
+
+  this->setLayer(E2D_LAYER_TOP);
+  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0, GraphicsEngine::getInstance()->getResolutionY()/10.0);
+
+  //this->setBindNode(this);
+  this->material = new Material();
+  this->setTexture("pictures/error_texture.png");
+}
+
+
+/**
+ *  load params
+ * @param root TiXmlElement object
+ */
+void Billboard::loadParams(const TiXmlElement* root)
+{
+  LoadParam(root, "texture", this, Billboard, setTexture)
+      .describe("the texture-file to load onto the Billboard");
+
+  LoadParam(root, "size", this, Billboard, setSize)
+      .describe("the size of the Billboard in Pixels");
+}
+
+
+/**
+ * sets the size of the Billboard.
+ * @param size the size in pixels
+ */
+void Billboard::setSize(float sizeX, float sizeY)
+{
+  this->setSize2D(sizeX, sizeY);
+}
+
+
+/**
+ * sets the material to load
+ * @param textureFile The texture-file to load onto the crosshair
+ */
+void Billboard::setTexture(const char* textureFile)
+{
+  this->material->setDiffuseMap(textureFile);
+}
+
+
+/**
+ * attaches this billboard to a parent
+ * @param pNode node to attach to
+ */
+void Billboard::attachTo(PNode* pNode)
+{
+  this->source->setParent(pNode);
+}
+
+
+/**
+ * ticks the Billboard
+ * @param dt the time to ticks
+ */
+void Billboard::tick(float dt)
+{
+  float z = 0.0f;
+  glReadPixels ((int)this->getAbsCoor2D().x,
+                 GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,
+                 1,
+                 1,
+                 GL_DEPTH_COMPONENT,
+                 GL_FLOAT,
+                 &z);
+
+  GLdouble objX=.0, objY=.0, objZ=.0;
+  gluUnProject(this->getAbsCoor2D().x,
+               GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,
+               .99,  // z
+               GraphicsEngine::modMat,
+               GraphicsEngine::projMat,
+               GraphicsEngine::viewPort,
+               &objX,
+               &objY,
+               &objZ );
+}
+
+
+/**
+ * draws the billboard
+ */
+void Billboard::draw() const
+{
+  glPushMatrix();
+
+  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
+  this->material->select();
+
+  glBegin(GL_TRIANGLE_STRIP);
+  glTexCoord2f(0, 0);
+  glVertex2f(-this->getSizeX2D(), -this->getSizeY2D());
+  glTexCoord2f(1, 0);
+  glVertex2f(this->getSizeX2D(), -this->getSizeY2D());
+  glTexCoord2f(0, 1);
+  glVertex2f(-this->getSizeX2D(), this->getSizeY2D());
+  glTexCoord2f(1, 1);
+  glVertex2f(this->getSizeX2D(), this->getSizeY2D());
+  glEnd();
+
+  glPopMatrix();
+}
Index: trunk/src/lib/graphics/render2D/billboard.h
===================================================================
--- trunk/src/lib/graphics/render2D/billboard.h	(revision 6815)
+++ trunk/src/lib/graphics/render2D/billboard.h	(revision 6815)
@@ -0,0 +1,47 @@
+/*!
+ * @file billboard.h
+ *  Definition of a billboard
+ */
+
+#ifndef _BILLBOARD_H
+#define _BILLBOARD_H
+
+
+#include "element_2d.h"
+
+#include "vector.h"
+
+
+
+class Model;
+class Material;
+class TiXmlElement;
+
+//! A class that enables the
+class Billboard :  public Element2D
+{
+
+  public:
+    Billboard(const TiXmlElement* root = NULL);
+    virtual ~Billboard();
+
+    void init();
+    void loadParams(const TiXmlElement* root);
+
+    void setSize(float sizeX, float sizeY);
+    void setTexture(const char* textureFile);
+    void attachTo(PNode* pnode);
+
+    virtual void tick(float dt);
+    virtual void draw() const;
+
+
+  private:
+    Material*        material;             //!< a material for the Billboard
+    float            rotationSpeed;        //!< Speed of the Rotation.
+
+    PNode*           source;               //!< the source attached to it
+
+};
+
+#endif /* _BILLBOARD_H */
