Index: orxonox/branches/shadows/src/orxonox.cc
===================================================================
--- orxonox/branches/shadows/src/orxonox.cc	(revision 3705)
+++ orxonox/branches/shadows/src/orxonox.cc	(revision 3706)
@@ -133,6 +133,6 @@
 
   int bpp = 16;
-  int width = 640;
-  int height = 480;
+  int width = 1024;
+  int height = 768;
   //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/
   //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER;
@@ -177,13 +177,18 @@
   GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
   GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0};
-  GLfloat lightPosition[] = {10.0, 10, 19.0, 0.0};
-
+  GLfloat lightPosition[] = {0.0, 10, 19.0, 0.0};
+  GLfloat lightPosition2[] ={50,10,0,0};
+  
   glLightfv (GL_LIGHT0, GL_DIFFUSE, whiteLight);
   glLightfv (GL_LIGHT0, GL_SPECULAR, whiteLight);
+  glLightfv(GL_LIGHT1,GL_SPECULAR,whiteLight);
   glEnable (GL_LIGHTING);
   glEnable (GL_LIGHT0);
+  glEnable (GL_LIGHT1);
   glEnable (GL_DEPTH_TEST);
   glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
+  glLightfv (GL_LIGHT1, GL_POSITION, lightPosition2);
   glLightfv (GL_LIGHT0, GL_DIFFUSE, whiteLight);
+  glLightfv (GL_LIGHT1, GL_DIFFUSE, whiteLight);
    
   //glEnable (GL_TEXTURE_2D); 
Index: orxonox/branches/shadows/src/player.h
===================================================================
--- orxonox/branches/shadows/src/player.h	(revision 3705)
+++ orxonox/branches/shadows/src/player.h	(revision 3706)
@@ -31,5 +31,5 @@
   
   virtual void leftWorld();
-  
+  float angle;
   
  private:
@@ -42,5 +42,5 @@
   float travelSpeed;
   float acceleration;
-  float angle;
+  
   GLuint objectList;
   
Index: orxonox/branches/shadows/src/shadow.cc
===================================================================
--- orxonox/branches/shadows/src/shadow.cc	(revision 3705)
+++ orxonox/branches/shadows/src/shadow.cc	(revision 3706)
@@ -39,7 +39,8 @@
 */
 
-Shadow::Shadow(Model* player,float* groundVertexes)
+Shadow::Shadow(OBJModel* player,Player* playerangle,float groundVertexes[])
 {
     this->player=player;
+    this->playerangle=playerangle;
 }
 
@@ -88,5 +89,5 @@
     glNewList(this->player_id,GL_COMPILE);
     
-    //blabla
+    this->player->draw();
     
     glEndList();    
@@ -94,9 +95,5 @@
     this->image=(unsigned char*)malloc(SIZE*SIZE*4);
     
-    //this->player_id=newList {glNormalefv;glVertex3fv}
-    //this->ground_id=newList {glTexCoord2fv;glNormal3fv;glVertex3fv}
-    
-    
-    //lightPos[] blabla
+
 }
 
@@ -117,8 +114,11 @@
     glLoadIdentity();
     
-    //gluLookAt(light0,light1,light2,player0,player1,player2,0,0,1);
+    gluLookAt(this->lightPos[0],this->lightPos[1],this->lightPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1);
     
     glColor3f(.4,.4,.4);
-    //glTranslatef(player0,player1,player2);
+    glTranslatef(this->playerPos[0],this->playerPos[1],this->playerPos[2]);
+    glRotatef(this->playerangle->angle,1.0,0.0,0.0);
+    
+    
     glCallList(this->player_id);
     glColor3f(1,1,1);
@@ -134,8 +134,37 @@
 }
 
+
+/** 
+    brief updatePosition is used in the same kind as for skysphere, because
+    the light has got a static orientation(parallel light), we have to always 
+    add the same relative coordinates being 0,10,19 to the players position
+    in order to receive the lightPosition. This is needed to calculate the Shadow!!
+
+*/
+
+void Shadow::updatePosition(float x,float y,float z)
+{
+    this->playerPos[0]=x;
+    this->playerPos[1]=y;
+    this->playerPos[2]=z;
+    
+    this->lightPos[0]=this->playerPos[0];
+    this->lightPos[1]=this->playerPos[1]+10;
+    this->lightPos[2]=this->playerPos[2]+19;
+
+    
+}
+/**
+
+    brief m_inverse simply inverses the *m matrix and stores the result back
+    to *out. This is needed further down in the draw() method
+
+
+*/
+
 void Shadow::m_inverse(const float *m,float *out)
 {
     float det;
-    det=m[0]*m[5]*m[10];
+    det=  m[0]*m[5]*m[10];
     det+= m[4]*m[9]*m[2];
     det+= m[8]*m[1]*m[6];
@@ -143,6 +172,30 @@
     det-= m[4]*m[1]*m[10];
     det-= m[0]*m[9]*m[6];
-}
-
+    
+    if(det!= 0.0)
+	det=1.0/det;
+    out[0]=  (m[5]*m[10]-m[9]*m[6])*det;
+    out[1]= -(m[1]*m[10]-m[9]*m[2])*det;
+    out[2]=  (m[1]*m[6]-m[5]*m[2])*det;
+    out[3]= 0.0;
+    out[4]= -(m[4]*m[10]-m[8]*m[6])*det;
+    out[5]=  (m[0]*m[10]-m[8]*m[2])*det;
+    out[6]= -(m[0]*m[6]-m[4]*m[2])*det;
+    out[7]= 0.0;
+    out[8]=  (m[4]*m[9]-m[8]*m[5])*det;
+    out[9]= -(m[0]*m[9]-m[8]*m[1])*det;
+    out[10]= (m[0]*m[5]-m[4]*m[1])*det;
+    out[11]= 0.0;
+    out[12]=- (m[12]*out[0]+m[13]*out[4]+m[14]*out[8]);
+    out[13]=- (m[12]*out[1]+m[13]*out[5]+m[14]*out[9]);
+    out[14]=- (m[12]*out[2]+m[13]*out[6]+m[14]*out[10]);
+    out[15]= 1.0;
+
+
+}
+
+/**
+    brief Method draw() is called after each tick() from the world.cc class
+*/
 
 void Shadow::draw()
@@ -151,5 +204,5 @@
     createShadow();
     
-    glClearColor(0,0,0,0);
+    /*glClearColor(0,0,0,0);
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glMatrixMode(GL_PROJECTION);
@@ -159,6 +212,6 @@
     glLoadIdentity();
     
-    //gluLookAt(camera0,camera1,camera2,player0,player1,player2,0,0,1);
-    
+    gluLookAt(this->cameraPos[0],this->cameraPos[1],this->cameraPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1);
+    */
     glEnable(GL_TEXTURE_GEN_S);
     glEnable(GL_TEXTURE_GEN_T);
@@ -166,4 +219,28 @@
     glEnable(GL_TEXTURE_GEN_Q);
     glGetFloatv(GL_MODELVIEW_MATRIX,m);
+    m_inverse(m,im);
+    glMatrixMode(GL_TEXTURE);
+    glLoadIdentity();
+    glTranslatef(0.5,0.5,1.0);
+    glOrtho(-1,1,-1,1,-1,1);
+    
+    gluLookAt(this->lightPos[0],this->lightPos[1],this->lightPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1);
+    
+    glMultMatrixf(im);
+    glEnable(GL_TEXTURE_2D),
+    glBindTexture(GL_TEXTURE_2D,this->shadow_id);
+    glEnable(GL_BLEND);
+    glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
+    glCallList(ground_id);
+    glDisable(GL_BLEND);
+    
+    glLoadIdentity();
+    glMatrixMode(GL_MODELVIEW);
+    glDisable(GL_TEXTURE_GEN_S);
+    glDisable(GL_TEXTURE_GEN_T);
+    glDisable(GL_TEXTURE_GEN_R);
+    glDisable(GL_TEXTURE_GEN_Q);
+    
+    
     
 }
Index: orxonox/branches/shadows/src/shadow.h
===================================================================
--- orxonox/branches/shadows/src/shadow.h	(revision 3705)
+++ orxonox/branches/shadows/src/shadow.h	(revision 3706)
@@ -19,7 +19,8 @@
 
 #include "importer/material.h"
-#include "importer/model.h"
+#include "importer/objModel.h"
 #include "p_node.h"
 #include "world_entity.h"
+#include "player.h"
 
 //! A Class to handle the Shadow
@@ -29,8 +30,12 @@
 	int player_id,ground_id; //These are for the glLists!
 	int shadow_id;  //this is for the empty shadow texture
-	int lightPos[3];
+	float lightPos[3];
+	float playerPos[3];
+
 	
 	unsigned char *image;
-	Model* player;
+	OBJModel* player;
+	//playerangle used to obtain information about the angle of the player
+	Player* playerangle;
 	
 	void blur(unsigned char *in,int size);
@@ -40,8 +45,9 @@
     
     public:
-	Shadow(Model* player,float* groundVertexes);
+	Shadow(OBJModel* player,Player* playerangle,float groundVertexes[]);
 	~Shadow();
 	void init();
 	void draw();
+	void updatePosition(float x,float y,float z);
 
 
Index: orxonox/branches/shadows/src/skysphere.cc
===================================================================
--- orxonox/branches/shadows/src/skysphere.cc	(revision 3705)
+++ orxonox/branches/shadows/src/skysphere.cc	(revision 3706)
@@ -80,5 +80,6 @@
    
 void Skysphere::draw()
-{
+{   
+    glEnable(GL_COLOR_MATERIAL);
     sky->select();
     glPushMatrix();
@@ -91,4 +92,5 @@
     gluSphere(sphereObj,200.0f,20,20);
     glPopMatrix();
+    glDisable(GL_COLOR_MATERIAL);
 
 
Index: orxonox/branches/shadows/src/world.cc
===================================================================
--- orxonox/branches/shadows/src/world.cc	(revision 3705)
+++ orxonox/branches/shadows/src/world.cc	(revision 3706)
@@ -28,5 +28,4 @@
 #include "helper_parent.h"
 #include "glmenu_imagescreen.h"
-#include "skysphere.h"
 #include "importer/material.h"
 
@@ -291,8 +290,13 @@
 	    
 	    
-	    // create skybox
+	    //create shadow
+	    float a[]={1.0,1.0,1.0,4.0};
+	    this->shadow =new Shadow(myPlayer->model,(Player*)myPlayer,a);	    
+	    shadow->init();	    	    
+	    
+	    //create skysphere
 	    this->skysphere =new Skysphere();
-	    	    
-	    	    
+	    
+	    
 	    // bind camera
 	    this->localCamera = new Camera(this);
@@ -583,6 +587,8 @@
   
   glEnable(GL_TEXTURE_2D);
-  
   skysphere->draw();
+  
+  shadow->draw();
+  
   
 }
@@ -668,5 +674,5 @@
   
   skysphere->updatePosition(localPlayer->absCoordinate.x,localPlayer->absCoordinate.y,localPlayer->absCoordinate.z);
-  
+  shadow->updatePosition(localPlayer->absCoordinate.x,localPlayer->absCoordinate.y,localPlayer->absCoordinate.z);
   //for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
 }
Index: orxonox/branches/shadows/src/world.h
===================================================================
--- orxonox/branches/shadows/src/world.h	(revision 3705)
+++ orxonox/branches/shadows/src/world.h	(revision 3706)
@@ -11,4 +11,5 @@
 #include "story_entity.h"
 #include "skysphere.h"
+#include "shadow.h"
 class Material;
 
@@ -87,4 +88,5 @@
   WorldEntity* localPlayer;
   Skysphere* skysphere;
+  Shadow* shadow;
   PNode* nullParent;
  
