Index: trunk/src/world_entities/terrain.cc
===================================================================
--- trunk/src/world_entities/terrain.cc	(revision 7193)
+++ trunk/src/world_entities/terrain.cc	(revision 7221)
@@ -48,6 +48,6 @@
     this->loadParams(root);
 
-//  if (this->model != NULL)
-    //this->ssp = new SpatialSeparation((Model*)this->model, 10.0f);
+  //  if (this->model != NULL)
+  //this->ssp = new SpatialSeparation((Model*)this->model, 10.0f);
 }
 
@@ -59,16 +59,16 @@
    this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found.
 */
-Terrain::Terrain(const char* fileName)
+Terrain::Terrain(const std::string& fileName)
 {
   this->init();
 
-  if (!strstr(fileName, ".obj") || !strstr(fileName, ".OBJ") )
-    {
-      this->loadModel(fileName);
-    }
+  if (fileName.rfind(".obj" ) != -1 || fileName.rfind(".OBJ") != -1 )
+  {
+    this->loadModel(fileName);
+  }
   else
-    {
-      // load the hightMap here.
-    }
+  {
+    // load the hightMap here.
+  }
 }
 
@@ -98,5 +98,5 @@
 
   if(this->heightMap)
-        delete heightMap;
+    delete heightMap;
 }
 
@@ -122,14 +122,14 @@
 
   LoadParam(root, "scale", this, Terrain, setScale)
-      .describe("The scale in x,y,z direction");
+  .describe("The scale in x,y,z direction");
 
   LoadParam(root, "texture", this, Terrain, loadTexture)
-      .describe("The name of the Texture for this heightMap");
+  .describe("The name of the Texture for this heightMap");
 
   LoadParam(root, "vegetation", this, Terrain, loadVegetation)
-      .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ;
+  .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ;
 
   LoadParam(root, "height-map", this, Terrain, loadHeightMap)
-      .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap");
+  .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap");
 
 }
@@ -140,5 +140,5 @@
 }
 
-void Terrain::loadHeightMap(const char* heightMapFile, const char* colorMap)
+void Terrain::loadHeightMap(const std::string& heightMapFile, const std::string& colorMap)
 {
   if (this->heightMap != NULL)
@@ -146,44 +146,41 @@
   this->heightMap = NULL;
 
-  char* hmName = ResourceManager::getFullName(heightMapFile);
-  char* hmColorName = ResourceManager::getFullName(colorMap);
+  std::string hmName = ResourceManager::getFullName(heightMapFile);
+  std::string hmColorName = ResourceManager::getFullName(colorMap);
 
 
   this->heightMap = new HeightMap(hmName, hmColorName);
-//   heightMap->scale(Vector(43.0f,4.7f,43.0f));
+  //   heightMap->scale(Vector(43.0f,4.7f,43.0f));
   heightMap->scale(this->terrainScale);
   heightMap->setAbsCoor(this->getAbsCoor());
   heightMap->load();
-  delete[] hmName;
-  delete[] hmColorName;
-
-}
-
-
-void Terrain::loadTexture(const char* textureName)
-{
-   PRINTF(0)("Load texture: %s\n", textureName);
-
-   heightMapMaterial->setDiffuse(1.0,1.0,1.0);
-   heightMapMaterial->setAmbient(1.0,1.0,1.0 );
-   heightMapMaterial->setSpecular(1.0,1.0,1.0);
-   heightMapMaterial->setShininess(.5);
-   heightMapMaterial->setTransparency(1.0);
-
-   heightMapMaterial->setDiffuseMap(textureName);
-   heightMapMaterial->setAmbientMap(textureName);
-   heightMapMaterial->setSpecularMap(textureName);
-}
-
-
-
-void Terrain::loadVegetation(const char* vegetationFile)
-{
-  PRINTF(0)("loadVegetation: %s\n", vegetationFile);
+}
+
+
+void Terrain::loadTexture(const std::string& textureName)
+{
+  PRINTF(4)("Load texture: %s\n", textureName.c_str());
+
+  heightMapMaterial->setDiffuse(1.0,1.0,1.0);
+  heightMapMaterial->setAmbient(1.0,1.0,1.0 );
+  heightMapMaterial->setSpecular(1.0,1.0,1.0);
+  heightMapMaterial->setShininess(.5);
+  heightMapMaterial->setTransparency(1.0);
+
+  heightMapMaterial->setDiffuseMap(textureName);
+  //   heightMapMaterial->setAmbientMap(textureName);
+  //   heightMapMaterial->setSpecularMap(textureName);
+}
+
+
+
+void Terrain::loadVegetation(const std::string& vegetationFile)
+{
+  PRINTF(4)("loadVegetation: %s\n", vegetationFile.c_str());
   if (this->vegetation)
     ResourceManager::getInstance()->unload(this->vegetation, RP_LEVEL);
-  if (vegetationFile != NULL)
-  {
-    PRINTF(4)("fetching %s\n", vegetationFile);
+  if (!vegetationFile.empty())
+  {
+    PRINTF(4)("fetching %s\n", vegetationFile.c_str());
     this->vegetation = dynamic_cast<Model*>(ResourceManager::getInstance()->load(vegetationFile, OBJ, RP_CAMPAIGN));
   }
@@ -205,5 +202,5 @@
                 this->getAbsCoor ().z);
   /* rotate */
- // Vector tmpRot = this->getAbsDir().getSpacialAxis();
+  // Vector tmpRot = this->getAbsDir().getSpacialAxis();
   //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
 
@@ -227,25 +224,25 @@
 
 
-/*
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  Vector camera =   State::getCameraNode()->getAbsCoor(); // Go on here ..........!!!
-
-  float height =    heightMap->getHeight(camera.x, camera.z);
-
-  glEnable (GL_COLOR_MATERIAL) ;
-  glBegin(GL_QUADS);            // Draw The Cube Using quads
-  glColor3f(0.0f,1.0f,0.0f);  // Color Blue
-  glVertex3f(camera.x + 63.0f,Terrain->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Right Of The Quad (Top)
-  glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Left Of The Quad (Top)
-  glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Left Of The Quad (Top)
-  glVertex3f(camera.x+ 63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Right Of The Quad (Top)
-  glEnd();                      // End Drawing The Plan
-
-  glPopMatrix();*/
-
-
-/* THIS IS ONLY FOR DEBUGGING INFORMATION */
+  /*
+    glMatrixMode(GL_MODELVIEW);
+    glPushMatrix();
+    glLoadIdentity();
+    Vector camera =   State::getCameraNode()->getAbsCoor(); // Go on here ..........!!!
+
+    float height =    heightMap->getHeight(camera.x, camera.z);
+
+    glEnable (GL_COLOR_MATERIAL) ;
+    glBegin(GL_QUADS);            // Draw The Cube Using quads
+    glColor3f(0.0f,1.0f,0.0f);  // Color Blue
+    glVertex3f(camera.x + 63.0f,Terrain->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Right Of The Quad (Top)
+    glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Left Of The Quad (Top)
+    glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Left Of The Quad (Top)
+    glVertex3f(camera.x+ 63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Right Of The Quad (Top)
+    glEnd();                      // End Drawing The Plan
+
+    glPopMatrix();*/
+
+
+  /* THIS IS ONLY FOR DEBUGGING INFORMATION */
   if (this->ssp != NULL)
     this->ssp->drawQuadtree();
@@ -257,163 +254,171 @@
   // if the terrain is the Terrain of Dave
   if (debugTerrain == TERRAIN_DAVE)
-    {
-      objectList = glGenLists(1);
-      glNewList (objectList, GL_COMPILE);
-
-      glColor3f(1.0,0,0);
-
-      int sizeX = 100;
-      int sizeZ = 80;
-      float length = 1000;
-      float width = 200;
-      float widthX = float (length /sizeX);
-      float widthZ = float (width /sizeZ);
-
-      float height [sizeX][sizeZ];
-      Vector normal_vectors[sizeX][sizeZ];
-
-
-      for ( int i = 0; i<sizeX-1; i+=1)
-        for (int j = 0; j<sizeZ-1;j+=1)
-          //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
+  {
+    objectList = glGenLists(1);
+    glNewList (objectList, GL_COMPILE);
+
+    glColor3f(1.0,0,0);
+
+    int sizeX = 100;
+    int sizeZ = 80;
+    float length = 1000;
+    float width = 200;
+    float widthX = float (length /sizeX);
+    float widthZ = float (width /sizeZ);
+
+    float height [sizeX][sizeZ];
+    Vector normal_vectors[sizeX][sizeZ];
+
+
+    for ( int i = 0; i<sizeX-1; i+=1)
+      for (int j = 0; j<sizeZ-1;j+=1)
+        //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
 #ifdef __WIN32__
-          height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
+        height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
 #else
-      height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;
+        height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;
 #endif
 
-      //Die Huegel ein wenig glaetten
-      for (int h=1; h<2;h++)
-        for (int i=1;i<sizeX-2 ;i+=1 )
-          for(int j=1;j<sizeZ-2;j+=1)
-            height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
-
-      //Berechnung von normalen Vektoren
-      for(int i=1;i<sizeX-2;i+=1)
-        for(int j=1;j<sizeZ-2 ;j+=1)
-          {
-            Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
-            Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
-            Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
-            Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
-            Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
-
-            Vector c1 = v2 - v1;
-            Vector c2 = v3 - v1;
-            Vector c3=  v4 - v1;
-            Vector c4 = v5 - v1;
-            Vector zero = Vector (0,0,0);
-            normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
-            normal_vectors[i][j].normalize();
-          }
-
-      glBegin(GL_QUADS);
-      int snowheight=3;
-      for ( int i = 0; i<sizeX; i+=1)
-        for (int j = 0; j<sizeZ;j+=1)
-          {
-            Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
-            Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
-            Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
-            Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
-            float a[3];
-            if(height[i][j]<snowheight){
-              a[0]=0;
-              a[1]=1.0-height[i][j]/10-.3;
-              a[2]=0;
-              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
-            }
-            else{
-              a[0]=1.0;
-              a[1]=1.0;
-              a[2]=1.0;
-              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
-
-            }
-            glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
-            glVertex3f(v1.x, v1.y, v1.z);
-            if(height[i+1][j]<snowheight){
-              a[0]=0;
-              a[1] =1.0-height[i+1][j]/10-.3;
-              a[2]=0;
-              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
-            }
-            else{
-              a[0]=1.0;
-              a[1]=1.0;
-              a[2]=1.0;
-              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
-
-            }
-            glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
-            glVertex3f(v2.x, v2.y, v2.z);
-            if(height[i+1][j+1]<snowheight){
-              a[0]=0;
-              a[1] =1.0-height[i+1][j+1]/10-.3;
-              a[2]=0;
-              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
-            }
-            else{
-              a[0]=1.0;
-              a[1]=1.0;
-              a[2]=1.0;
-              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
-
-
-            }
-            glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
-            glVertex3f(v3.x, v3.y, v3.z);
-            if(height[i][j+1]<snowheight){
-              a[0]=0;
-              a[1] =1.0-height[i+1][j+1]/10-.3;
-              a[2]=0;
-              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
-            }
-            else{
-              a[0]=1.0;
-              a[1]=1.0;
-              a[2]=1.0;
-              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
-            }
-            glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
-            glVertex3f(v4.x, v4.y, v4.z);
-
-          }
-      glEnd();
-      glEndList();
-    }
+    //Die Huegel ein wenig glaetten
+    for (int h=1; h<2;h++)
+      for (int i=1;i<sizeX-2 ;i+=1 )
+        for(int j=1;j<sizeZ-2;j+=1)
+          height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
+
+    //Berechnung von normalen Vektoren
+    for(int i=1;i<sizeX-2;i+=1)
+      for(int j=1;j<sizeZ-2 ;j+=1)
+      {
+        Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
+        Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
+        Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
+        Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
+        Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
+
+        Vector c1 = v2 - v1;
+        Vector c2 = v3 - v1;
+        Vector c3=  v4 - v1;
+        Vector c4 = v5 - v1;
+        Vector zero = Vector (0,0,0);
+        normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
+        normal_vectors[i][j].normalize();
+      }
+
+    glBegin(GL_QUADS);
+    int snowheight=3;
+    for ( int i = 0; i<sizeX; i+=1)
+      for (int j = 0; j<sizeZ;j+=1)
+      {
+        Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
+        Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
+        Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
+        Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
+        float a[3];
+        if(height[i][j]<snowheight)
+        {
+          a[0]=0;
+          a[1]=1.0-height[i][j]/10-.3;
+          a[2]=0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        else
+        {
+          a[0]=1.0;
+          a[1]=1.0;
+          a[2]=1.0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+
+        }
+        glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
+        glVertex3f(v1.x, v1.y, v1.z);
+        if(height[i+1][j]<snowheight)
+        {
+          a[0]=0;
+          a[1] =1.0-height[i+1][j]/10-.3;
+          a[2]=0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        else
+        {
+          a[0]=1.0;
+          a[1]=1.0;
+          a[2]=1.0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+
+        }
+        glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
+        glVertex3f(v2.x, v2.y, v2.z);
+        if(height[i+1][j+1]<snowheight)
+        {
+          a[0]=0;
+          a[1] =1.0-height[i+1][j+1]/10-.3;
+          a[2]=0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        else
+        {
+          a[0]=1.0;
+          a[1]=1.0;
+          a[2]=1.0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+
+
+        }
+        glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
+        glVertex3f(v3.x, v3.y, v3.z);
+        if(height[i][j+1]<snowheight)
+        {
+          a[0]=0;
+          a[1] =1.0-height[i+1][j+1]/10-.3;
+          a[2]=0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        else
+        {
+          a[0]=1.0;
+          a[1]=1.0;
+          a[2]=1.0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
+        glVertex3f(v4.x, v4.y, v4.z);
+
+      }
+    glEnd();
+    glEndList();
+  }
 
   if (debugTerrain == TERRAIN_BENSCH)
-    {
-      /*
-        this->model = (OBJModel*) new Model();
-      this->model->setName("CUBE");
-      this->model->addVertex (-0.5, -0.5, 0.5);
-      this->model->addVertex (0.5, -0.5, 0.5);
-      this->model->addVertex (-0.5, 0.5, 0.5);
-      this->model->addVertex (0.5, 0.5, 0.5);
-      this->model->addVertex (-0.5, 0.5, -0.5);
-      this->model->addVertex (0.5, 0.5, -0.5);
-      this->model->addVertex (-0.5, -0.5, -0.5);
-      this->model->addVertex (0.5, -0.5, -0.5);
-
-      this->model->addVertexTexture (0.0, 0.0);
-      this->model->addVertexTexture (1.0, 0.0);
-      this->model->addVertexTexture (0.0, 1.0);
-      this->model->addVertexTexture (1.0, 1.0);
-      this->model->addVertexTexture (0.0, 2.0);
-      this->model->addVertexTexture (1.0, 2.0);
-      this->model->addVertexTexture (0.0, 3.0);
-      this->model->addVertexTexture (1.0, 3.0);
-      this->model->addVertexTexture (0.0, 4.0);
-      this->model->addVertexTexture (1.0, 4.0);
-      this->model->addVertexTexture (2.0, 0.0);
-      this->model->addVertexTexture (2.0, 1.0);
-      this->model->addVertexTexture (-1.0, 0.0);
-      this->model->addVertexTexture (-1.0, 1.0);
-
-      this->model->finalize();
-      */
-    }
+  {
+    /*
+      this->model = (OBJModel*) new Model();
+    this->model->setName("CUBE");
+    this->model->addVertex (-0.5, -0.5, 0.5);
+    this->model->addVertex (0.5, -0.5, 0.5);
+    this->model->addVertex (-0.5, 0.5, 0.5);
+    this->model->addVertex (0.5, 0.5, 0.5);
+    this->model->addVertex (-0.5, 0.5, -0.5);
+    this->model->addVertex (0.5, 0.5, -0.5);
+    this->model->addVertex (-0.5, -0.5, -0.5);
+    this->model->addVertex (0.5, -0.5, -0.5);
+
+    this->model->addVertexTexture (0.0, 0.0);
+    this->model->addVertexTexture (1.0, 0.0);
+    this->model->addVertexTexture (0.0, 1.0);
+    this->model->addVertexTexture (1.0, 1.0);
+    this->model->addVertexTexture (0.0, 2.0);
+    this->model->addVertexTexture (1.0, 2.0);
+    this->model->addVertexTexture (0.0, 3.0);
+    this->model->addVertexTexture (1.0, 3.0);
+    this->model->addVertexTexture (0.0, 4.0);
+    this->model->addVertexTexture (1.0, 4.0);
+    this->model->addVertexTexture (2.0, 0.0);
+    this->model->addVertexTexture (2.0, 1.0);
+    this->model->addVertexTexture (-1.0, 0.0);
+    this->model->addVertexTexture (-1.0, 1.0);
+
+    this->model->finalize();
+    */
+  }
 }
 
@@ -453,15 +458,13 @@
 
 void Terrain::writeDebug( ) const
-{
-}
+  {}
 
 void Terrain::readDebug( ) const
-{
-}
+  {}
 
 float Terrain::getHeight(float x, float y)
 {
-        if(this->heightMap != NULL)
-                return (this->heightMap->getHeight(x, y));
-        return 0;
-}
+  if(this->heightMap != NULL)
+    return (this->heightMap->getHeight(x, y));
+  return 0;
+}
