Changeset 6956 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Feb 1, 2006, 4:37:08 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/terrain.cc
r6815 r6956 26 26 #include "network_game_manager.h" 27 27 28 #include "height_map.h" 29 #include "material.h" 28 30 29 31 #include "glincl.h" 32 33 #include "state.h" 30 34 31 35 using namespace std; … … 41 45 if( root != NULL) 42 46 this->loadParams(root); 47 48 this->heightMapMaterial = new Material(); 49 heightMapMaterial->setTransparency(1.0); 50 51 heightMapMaterial->setDiffuse(0.4,0.4,0.4); 52 heightMapMaterial->setAmbient(0.4,0.4,0.4 ); 53 heightMapMaterial->setSpecular(0.4,0.4,0.4); 54 heightMapMaterial->setShininess(.5); 55 heightMapMaterial->setTransparency(1.0); 43 56 44 57 // if (this->model != NULL) … … 90 103 ResourceManager::getInstance()->unload(this->vegetation); 91 104 } 105 106 if(this->heightMap) 107 delete heightMap; 92 108 } 93 109 … … 101 117 this->ssp = NULL; 102 118 this->vegetation = NULL; 119 120 this->heightMap = NULL; 121 this->heightMapMaterial = NULL; 103 122 } 104 123 … … 110 129 LoadParam(root, "vegetation", this, Terrain, loadVegetation) 111 130 .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ; 112 } 131 132 133 LoadParam(root, "height-map", this, Terrain, loadHeightMap) 134 .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap"); 135 136 137 LoadParam(root, "heigt-texture", this, Terrain, loadTexture) 138 .describe("The name of the Texture for this heightMap"); 139 } 140 141 void Terrain::loadHeightMap(const char* heightMapFile, const char* colorMap) 142 { 143 if (this->heightMap != NULL) 144 delete this->heightMap; 145 this->heightMap = NULL; 146 147 char* hmName = ResourceManager::getFullName(heightMapFile); 148 char* hmColorName = ResourceManager::getFullName(colorMap); 149 150 151 this->heightMap = new HeightMap(hmName, hmColorName); 152 heightMap->scale(Vector(43.0f,4.7f,43.0f)); 153 heightMap->setAbsCoor(this->getAbsCoor()); 154 heightMap->load(); 155 delete[] hmName; 156 delete[] hmColorName; 157 158 } 159 160 161 void Terrain::loadTexture(const char* textureName) 162 { 163 if (this->heightMapMaterial != NULL) 164 delete this->heightMapMaterial; 165 166 delete this->heightMapMaterial; 167 168 this->heightMapMaterial = new Material(); 169 heightMapMaterial->setTransparency(1.0); 170 171 heightMapMaterial->setDiffuse(1.0,1.0,1.0); 172 heightMapMaterial->setAmbient(1.0,1.0,1.0 ); 173 heightMapMaterial->setSpecular(1.0,1.0,1.0); 174 heightMapMaterial->setShininess(.5); 175 heightMapMaterial->setTransparency(1.0); 176 177 heightMapMaterial->setDiffuseMap(textureName); 178 heightMapMaterial->setAmbientMap(textureName); 179 heightMapMaterial->setSpecularMap(textureName); 180 181 182 183 } 184 185 113 186 114 187 void Terrain::loadVegetation(const char* vegetationFile) … … 128 201 129 202 203 204 130 205 void Terrain::draw () const 131 206 { … … 137 212 this->getAbsCoor ().z); 138 213 /* rotate */ 139 Vector tmpRot = this->getAbsDir().getSpacialAxis();140 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );214 // Vector tmpRot = this->getAbsDir().getSpacialAxis(); 215 //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 141 216 142 217 if (this->objectList) … … 146 221 if (this->vegetation) 147 222 this->vegetation->draw(); 223 224 if(this->heightMap) 225 { 226 this->heightMapMaterial->select(); 227 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 228 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 229 glEnable(GL_LIGHTING); 230 glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ; 231 glEnable (GL_COLOR_MATERIAL) ; 232 this->heightMap->draw(); 233 } 148 234 glPopMatrix(); 149 235 236 237 238 239 240 glMatrixMode(GL_MODELVIEW); 241 glPushMatrix(); 242 glLoadIdentity(); 243 Vector camera = State::getCamera()->getAbsCoor(); // Go on here ..........!!! 244 245 /* 246 float height = heightMap->getHeight(camera.x, camera.z); 247 248 249 glEnable (GL_COLOR_MATERIAL) ; 250 glBegin(GL_QUADS); // Draw The Cube Using quads 251 glColor3f(0.0f,1.0f,0.0f); // Color Blue 252 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) 253 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) 254 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) 255 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) 256 glEnd(); // End Drawing The Plan 257 */ 258 259 glPopMatrix(); 150 260 /* THIS IS ONLY FOR DEBUGGING INFORMATION */ 151 261 if (this->ssp != NULL) … … 360 470 { 361 471 } 472 473 float Terrain::getHeight(float x, float y) 474 { 475 if(this->heightMap != NULL) 476 return (this->heightMap->getHeight(x, y)); 477 return 0; 478 } -
trunk/src/world_entities/terrain.h
r6512 r6956 15 15 // FORWARD DECLARATION 16 16 class SpatialSeparation; 17 class HeightMap; 18 class Material; 17 19 18 20 //! A simple method to call a desired debug world. … … 40 42 void loadVegetation(const char* vegetationFile); 41 43 44 void loadHeightMap(const char* heightMapFile, const char* colorMap = NULL); 45 void loadTexture(const char* textureName); 46 42 47 void buildDebugTerrain(DebugTerrain debugTerrain); 48 49 float getHeight(float x, float y); 43 50 virtual void draw() const; 44 51 … … 50 57 int objectList; 51 58 59 HeightMap* heightMap; 60 Material* heightMapMaterial; 52 61 }; 53 62
Note: See TracChangeset
for help on using the changeset viewer.