Index: branches/atmospheric_engine/src/defs/class_id.h
===================================================================
--- branches/atmospheric_engine/src/defs/class_id.h	(revision 8729)
+++ branches/atmospheric_engine/src/defs/class_id.h	(revision 8730)
@@ -182,4 +182,5 @@
   CL_MAPPED_WATER               =    0x00000311,
   CL_BSP_ENTITY                 =    0x00000312,
+  CL_SKYDOME                    =    0x00000313,
 
   // Playables
Index: branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc	(revision 8729)
+++ branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc	(revision 8730)
@@ -54,4 +54,7 @@
   this->deactivate();
   
+  if (glIsTexture(noise3DTexName))
+    glDeleteTextures(1, &noise3DTexName);
+  
   delete shader;
 }
@@ -87,4 +90,7 @@
                0, GL_RGBA, GL_UNSIGNED_BYTE, noise3DTexPtr);
   
+  skydome = new Skydome();
+  skydome->setTexture(noise3DTexName);
+  
   shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
                       ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
@@ -99,4 +105,6 @@
 
   this->shader->deactivateShader();
+  
+  skydome->setShader(shader);
 }
 
@@ -130,5 +138,5 @@
   this->shader->deactivateShader();
   
-  this->generateSkyPlane(this->divs, this->planetRadius, this->atmosphericRadius, 1, 1);
+  skydome->generateSkyPlane(this->divs, this->planetRadius, this->atmosphericRadius, 1, 1);
 
   this->cloudActivate = true;
@@ -144,51 +152,4 @@
 void CloudEffect::draw() const
 {
-  if (!this->cloudActivate)
-    return;
-
-  glPushAttrib(GL_ENABLE_BIT);
-
-  glDisable(GL_LIGHTING);
-  glDisable(GL_BLEND);
-
-  glEnable(GL_TEXTURE_3D);
-  glBindTexture(GL_TEXTURE_3D, noise3DTexName);
-
-  this->shader->activateShader();
-  offset->set(0.0f, 0.0f, offsetZ);
-
-
-  /*glColor3f(1.0, 1.0, 1.0);
-  glBegin(GL_QUADS);
-
-  glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, 0.0f,  0.0f);
-  glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 10.0f,  0.0f);
-  glTexCoord2f(0.0f, 0.0f); glVertex3f( 10.0f, 10.0f,  0.0f);
-  glTexCoord2f(1.0f, 0.0f); glVertex3f(10.0f, 0.0f,  0.0f);
-
-  glEnd();*/
-
-  glPushMatrix();
-  glTranslatef(0.0f,pRadius,0.0f);
-  //glRotatef(timeGetTime()/2000.0f,0.0f, 1.0f, 0.0f);
-
-  glBegin(GL_TRIANGLES);
-
-  for (int i=0; i < numIndices; i++)
-  {
-    glColor3f(1.0f, 1.0f, 1.0f);
-
-    glTexCoord2f(planeVertices[indices[i]].u, planeVertices[indices[i]].v);
-    glVertex3f(planeVertices[indices[i]].x, planeVertices[indices[i]].y, planeVertices[indices[i]].z);
-  }
-
-  glEnd();
-
-  glPopMatrix();
-
-  this->shader->deactivateShader();
-
-  glPopAttrib();
-
 }
 
@@ -196,100 +157,13 @@
 {
   if (this->cloudActivate)
+  {
     this->offsetZ += 0.05 * dt * this->animationSpeed;
-}
-
-void CloudEffect::generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius, float hTile, float vTile)
-{
-  // Make sure our vertex array is clear
-  if (planeVertices) 
-  {
-    delete planeVertices;
-    planeVertices = NULL;
-  }
-
-  // Make sure our index array is clear
-  if (indices)
-  {
-    delete indices;
-    indices = NULL;
-  }
-
-  // Set the number of divisions into a valid range
-  int divs = divisions;
-  if (divisions < 1) 
-    divs = 1;
-
-  if (divisions > 256) 
-    divs = 256; 
-
-  pRadius = planetRadius;
-
-  // Initialize the Vertex and indices arrays
-  numPlaneVertices = (divs + 1) * (divs + 1);   // 1 division would give 4 verts
-  numIndices  = divs * divs * 2 * 3;       // 1 division would give 6 indices for 2 tris
-
-  planeVertices = new VERTEX[numPlaneVertices];
-  memset(planeVertices, 0, sizeof(VERTEX));
-
-  indices = new int[numIndices];
-  memset(indices, 0, sizeof(int)*numIndices);
-
-  // Calculate some values we will need
-  float plane_size = 2.0f * (float)sqrt((SQR(atmosphereRadius)-SQR(planetRadius)));
-  float delta = plane_size/(float)divs;
-  float tex_delta = 2.0f/(float)divs;
-  
-  // Variables we'll use during the dome's generation
-  float x_dist   = 0.0f;
-  float z_dist   = 0.0f;
-  float x_height = 0.0f;
-  float z_height = 0.0f;
-  float height = 0.0f;
-
-  VERTEX SV; // temporary vertex
-
-  for (int i=0;i <= divs;i++)
-  {
-    for (int j=0; j <= divs; j++)
-    {
-      x_dist = (-0.5f * plane_size) + ((float)j*delta);
-      z_dist = (-0.5f * plane_size) + ((float)i*delta);
-
-      x_height = (x_dist*x_dist) / atmosphereRadius;
-      z_height = (z_dist*z_dist) / atmosphereRadius;
-      height = x_height + z_height;
-
-      SV.x = x_dist;
-      SV.y = 0.0f - height;
-      SV.z = z_dist;
-
-      // Calculate the texture coordinates
-      SV.u = hTile*((float)j * tex_delta*0.5f);
-      SV.v = vTile*(1.0f - (float)i * tex_delta*0.5f);
-
-      planeVertices[i*(divs+1)+j] = SV;
-    }
-  }
-
-  // Calculate the indices
-  int index = 0;
-  for (int i=0; i < divs;i++)
-  {
-    for (int j=0; j < divs; j++)
-    {
-      int startvert = (i*(divs+1) + j);
-
-        // tri 1
-      indices[index++] = startvert;
-      indices[index++] = startvert+1;
-      indices[index++] = startvert+divs+1;
-
-      // tri 2
-      indices[index++] = startvert+1;
-      indices[index++] = startvert+divs+2;
-      indices[index++] = startvert+divs+1;
-    }
-  }  
-}
+    
+    this->shader->activateShader();
+    offset->set(0.0f, 0.0f, offsetZ);
+    this->shader->deactivateShader();
+  }
+}
+
 
 void CloudEffect::make3DNoiseTexture()
Index: branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h	(revision 8729)
+++ branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h	(revision 8730)
@@ -11,5 +11,5 @@
 #include "sound_source.h"
 
-#include "world_entity.h"
+#include "skydome.h"
 #include "material.h"
 #include "shader.h"
@@ -30,14 +30,4 @@
 #define at2(rx,ry) ( rx * q[0] + ry * q[1] )
 #define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
-
-
-#define DTOR (PI/180.0f)
-#define SQR(x) (x*x)
-
-typedef struct {
-  float x,y,z;
-  unsigned int color;
-  float u, v;
-} VERTEX;
 
 
@@ -100,4 +90,5 @@
 
   // Material                 cloudMaterial;
+  Skydome*         skydome;
   
   // SHADER STUFF
@@ -123,16 +114,4 @@
   int              B;
   int              BM;
-  
-  // SKYPLANE STUFF
-  VERTEX *planeVertices;
-  int numPlaneVertices;
-
-  int *indices;
-  int numIndices;
-
-  float pRadius;
-  
-  VERTEX *vertices;
-  int numVertices;
 };
 
Index: branches/atmospheric_engine/src/world_entities/WorldEntities.am
===================================================================
--- branches/atmospheric_engine/src/world_entities/WorldEntities.am	(revision 8729)
+++ branches/atmospheric_engine/src/world_entities/WorldEntities.am	(revision 8730)
@@ -8,4 +8,5 @@
                 world_entities/skysphere.cc \
                 world_entities/skybox.cc \
+                world_entities/skydome.cc \
                 world_entities/terrain.cc \
                 world_entities/satellite.cc \
@@ -64,4 +65,5 @@
                 skysphere.h \
                 skybox.h \
+                skydome.h \
                 terrain.h \
                 satellite.h \
