Index: branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.cc
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.cc	(revision 7759)
+++ branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.cc	(revision 7760)
@@ -18,4 +18,7 @@
 #include "util/loading/factory.h"
 
+#include "p_node.h"
+#include "state.h"
+
 #include "glincl.h"
 //#include "shell_command.h"
@@ -23,4 +26,5 @@
 #define GLX_GLXEXT_PROTOTYPES
 #include <GL/glx.h>
+#include <GL/glut.h>
 
 //#include <GL/glext.h> //OpenGL Extensions
@@ -78,21 +82,16 @@
 
 	// set fog mode
-	GLenum fogMode  = GL_EXP2;
+	GLenum fogMode  = GL_EXP;
 
 	// set fog density
-	float  fogDensity  = 0.03f;
+	float  fogDensity  = 0.001f;
 
 	// set fog near & far distance
-	float fogStart = 0.05f;
-	float fogEnd   = 100.0f;
+	float fogStart = 0.0f;
+	float fogEnd   = 1000.0f;
 
 	// Set fog color
-	float fogColor[4] = {0.0, 1.0, 0.0, 1.0};
+	float fogColor[4] = {0.6f,0.58f,0.79f,0.0f};
 	
-	glClearColor(fogColor[0],fogColor[1],fogColor[2],0.0f);
-	glShadeModel(GL_SMOOTH);
-	glEnable(GL_DEPTH_TEST);
-	glEnable(GL_CULL_FACE);
-	glCullFace(GL_BACK);
 
 	glFogCoordfEXT       = (PFNGLFOGCOORDFEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfEXT");
@@ -105,5 +104,5 @@
 	glFogf (GL_FOG_START,  fogStart);
 	glFogf (GL_FOG_END,    fogEnd);
-	glFogfv(GL_FOG_COLOR,  fogColor);      
+	glFogfv(GL_FOG_COLOR,  fogColor);
 	glFogi (GL_FOG_MODE,   fogMode);
 	glFogf (GL_FOG_DENSITY,fogDensity);
@@ -139,4 +138,6 @@
 {
 	PRINTF(0)("Deactivating VolFogEffect\n");
+
+	glDisable(GL_FOG);
 }
 
@@ -147,5 +148,11 @@
 void VolFogEffect::draw() const
 {
-	
+  glPushAttrib(GL_ENABLE_BIT);
+  glClearColor(fogColor[0],fogColor[1],fogColor[2],0.0f);
+	glShadeModel(GL_SMOOTH);
+	glEnable(GL_DEPTH_TEST);
+	glEnable(GL_CULL_FACE);
+	glCullFace(GL_BACK);
+
 	/* clear all pixels in colour buffer */
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -154,50 +161,47 @@
 	//glEnable(GL_BLEND);
 	//glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
-
-	/* draw the panels */
-	glBegin(GL_QUADS); // Floor
-		glFogCoordfEXT(0.0f);	glVertex3f(0.0f,0.0f,0.0f);
-		glFogCoordfEXT(0.0f);	glVertex3f(100.0f,0.0f,0.0f);
-		glFogCoordfEXT(0.0f);	glVertex3f(100.0f,0.0f, 100.0f);
-		glFogCoordfEXT(0.0f);	glVertex3f(0.0f,0.0f, 100.0f);
+	
+	int i;
+	//glLoadIdentity();
+
+	
+	glBegin( GL_LINES );
+		glNormal3f(0,1,0);
+		for(i=-20;i<=20;i+=2)
+		{
+			float fog_c;
+			float diff[3];
+
+			diff[0] = State::getCameraNode()->getAbsCoor().x - i;
+			diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
+			diff[1] = State::getCameraNode()->getAbsCoor().y;
+			fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
+			glFogCoordfEXT(fog_c*2);
+			glVertex3f(i,0,-20);
+
+			diff[0] = State::getCameraNode()->getAbsCoor().x - i;
+			diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
+			diff[1] = State::getCameraNode()->getAbsCoor().y;
+			fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
+			glFogCoordfEXT(fog_c*2);
+			glVertex3f(i,0,20);
+
+			diff[0] = State::getCameraNode()->getAbsCoor().x - i;
+			diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
+			diff[1] = State::getCameraNode()->getAbsCoor().y;
+			fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
+			glFogCoordfEXT(fog_c*2);
+			glVertex3f(-20,0,i);
+
+			diff[0] = State::getCameraNode()->getAbsCoor().x - i;
+			diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
+			diff[1] = State::getCameraNode()->getAbsCoor().y;
+			fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
+			glFogCoordfEXT(fog_c*2);
+			glVertex3f(20,0,i);
+		}
 	glEnd();
 
-	glBegin(GL_QUADS); // Roof
-		glFogCoordfEXT(1.0f);	glVertex3f(0.0f, 100.0f,0.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f( 100.0f, 100.0f,0.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f( 100.0f, 100.0f, 100.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f(0.0f, 100.0f, 100.0f);
-	glEnd();
-
-	glBegin(GL_QUADS); // Back Wall
-		glFogCoordfEXT(0.0f);	glVertex3f(0.0f,0.0f,0.0f);
-		glFogCoordfEXT(0.0f);	glVertex3f( 100.0f,0.0f,0.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f( 100.0f, 100.0f,0.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f(0.0f, 100.0f,0.0f);
-	glEnd();
-
-	glBegin(GL_QUADS); // Front Wall
-		glFogCoordfEXT(0.0f);	glVertex3f(0.0f,0.0f,100.0f);
-		glFogCoordfEXT(0.0f);	glVertex3f( 100.0f,0.0f,100.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f( 100.0f, 100.0f,100.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f(0.0f, 100.0f,100.0f);
-	glEnd();
-
-	glBegin(GL_QUADS); // Right Wall
-		glFogCoordfEXT(0.0f);	glVertex3f( 100.0f,0.0f, 100.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f( 100.0f, 100.0f, 100.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f( 100.0f, 100.0f,0.0f);
-		glFogCoordfEXT(0.0f);	glVertex3f( 100.0f,0.0f,0.0f);
-	glEnd();
-
-	glBegin(GL_QUADS); // Left Wall
-		glFogCoordfEXT(0.0f);	glVertex3f(0.0f,0.0f, 100.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f(0.0f, 100.0f, 100.0f);
-		glFogCoordfEXT(1.0f);	glVertex3f(0.0f, 100.0f,0.0f);
-		glFogCoordfEXT(0.0f);	glVertex3f(0.0f,0.0f,0.0f);
-	glEnd();
-	
-	/* process all buffered OpenGL commands */
-	glFlush();
+  glPopAttrib();
 
 }
