- Timestamp:
- Feb 6, 2006, 11:52:50 AM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/terrain.cc
r7014 r7046 127 127 WorldEntity::loadParams(root); 128 128 129 LoadParam(root, "scale", this, Terrain, setScale) 130 .describe("The scale in x,y,z direction"); 131 132 LoadParam(root, "texture", this, Terrain, loadTexture) 133 .describe("The name of the Texture for this heightMap"); 134 129 135 LoadParam(root, "vegetation", this, Terrain, loadVegetation) 130 136 .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ; 131 137 132 133 138 LoadParam(root, "height-map", this, Terrain, loadHeightMap) 134 139 .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap"); 135 140 136 137 LoadParam(root, "heigt-texture", this, Terrain, loadTexture) 138 .describe("The name of the Texture for this heightMap"); 141 } 142 143 void Terrain::setScale(float x, float y, float z) 144 { 145 this->terrainScale = Vector(x, y, z); 139 146 } 140 147 … … 150 157 151 158 this->heightMap = new HeightMap(hmName, hmColorName); 152 heightMap->scale(Vector(43.0f,4.7f,43.0f)); 159 // heightMap->scale(Vector(43.0f,4.7f,43.0f)); 160 heightMap->scale(this->terrainScale); 153 161 heightMap->setAbsCoor(this->getAbsCoor()); 154 162 heightMap->load(); … … 164 172 delete this->heightMapMaterial; 165 173 166 delete this->heightMapMaterial;167 168 174 this->heightMapMaterial = new Material(); 169 heightMapMaterial->setTransparency(1.0); 175 176 PRINTF(0)("Load texture: %s\n", textureName); 170 177 171 178 heightMapMaterial->setDiffuse(1.0,1.0,1.0); … … 176 183 177 184 heightMapMaterial->setDiffuseMap(textureName); 178 heightMapMaterial->setAmbientMap(textureName); 179 heightMapMaterial->setSpecularMap(textureName); 180 181 182 185 // heightMapMaterial->setAmbientMap(textureName); 186 // heightMapMaterial->setSpecularMap(t extureName); 183 187 } 184 188 … … 219 223 else if (this->getModel()) 220 224 this->getModel()->draw(); 225 221 226 if (this->vegetation) 222 227 this->vegetation->draw(); 223 228 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 } 229 if( this->heightMap) 230 { 231 this->heightMapMaterial->select(); 232 233 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 234 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 235 this->heightMap->draw(); 236 } 234 237 glPopMatrix(); 235 238 236 239 237 238 239 240 glMatrixMode(GL_MODELVIEW); 241 glPushMatrix(); 242 glLoadIdentity(); 243 Vector camera = State::getCameraNode()->getAbsCoor(); // Go on here ..........!!! 244 245 /* 246 float height = heightMap->getHeight(camera.x, camera.z); 247 240 /* 241 glMatrixMode(GL_MODELVIEW); 242 glPushMatrix(); 243 glLoadIdentity(); 244 Vector camera = State::getCameraNode()->getAbsCoor(); // Go on here ..........!!! 245 246 float height = heightMap->getHeight(camera.x, camera.z); 248 247 249 248 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(); 260 /* THIS IS ONLY FOR DEBUGGING INFORMATION */ 249 glBegin(GL_QUADS); // Draw The Cube Using quads 250 glColor3f(0.0f,1.0f,0.0f); // Color Blue 251 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) 252 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) 253 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) 254 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) 255 glEnd(); // End Drawing The Plan 256 257 glPopMatrix();*/ 258 259 260 /* THIS IS ONLY FOR DEBUGGING INFORMATION */ 261 261 if (this->ssp != NULL) 262 262 this->ssp->drawQuadtree(); -
trunk/src/world_entities/terrain.h
r6956 r7046 12 12 13 13 #include "world_entity.h" 14 #include "vector.h" 14 15 15 16 // FORWARD DECLARATION … … 44 45 void loadHeightMap(const char* heightMapFile, const char* colorMap = NULL); 45 46 void loadTexture(const char* textureName); 47 void setScale(float x, float y, float z); 46 48 47 49 void buildDebugTerrain(DebugTerrain debugTerrain); 48 50 49 51 float getHeight(float x, float y); 50 52 virtual void draw() const; … … 59 61 HeightMap* heightMap; 60 62 Material* heightMapMaterial; 63 Vector terrainScale; 61 64 }; 62 65
Note: See TracChangeset
for help on using the changeset viewer.