[4597] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[3565] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
[5357] | 15 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
[1853] | 16 | |
---|
| 17 | |
---|
[3559] | 18 | #include "terrain.h" |
---|
[4607] | 19 | |
---|
[5356] | 20 | #include "load_param.h" |
---|
[4607] | 21 | #include "factory.h" |
---|
[4842] | 22 | #include "spatial_separation.h" |
---|
| 23 | |
---|
[5465] | 24 | #include "resource_manager.h" |
---|
[5511] | 25 | #include "model.h" |
---|
[6341] | 26 | #include "network_game_manager.h" |
---|
[5465] | 27 | |
---|
[6495] | 28 | #include "height_map.h" |
---|
| 29 | #include "material.h" |
---|
[6341] | 30 | |
---|
[5511] | 31 | #include "glincl.h" |
---|
| 32 | |
---|
[6727] | 33 | #include "state.h" |
---|
| 34 | |
---|
[1856] | 35 | using namespace std; |
---|
[1853] | 36 | |
---|
[5750] | 37 | CREATE_FACTORY(Terrain, CL_TERRAIN); |
---|
[1856] | 38 | |
---|
[3245] | 39 | /** |
---|
[4836] | 40 | * standard constructor |
---|
[5357] | 41 | */ |
---|
[4607] | 42 | Terrain::Terrain (const TiXmlElement* root) |
---|
[3365] | 43 | { |
---|
[3564] | 44 | this->init(); |
---|
[4607] | 45 | this->loadParams(root); |
---|
[4844] | 46 | |
---|
[6579] | 47 | this->heightMapMaterial = new Material(); |
---|
| 48 | heightMapMaterial->setTransparency(1.0); |
---|
| 49 | heightMapMaterial->setIllum(0.2); |
---|
| 50 | |
---|
| 51 | heightMapMaterial->setDiffuse(1.0,1.0,1.0); |
---|
| 52 | heightMapMaterial->setAmbient(1.0,1.0,1.0 ); |
---|
| 53 | heightMapMaterial->setSpecular(1.0,1.0,1.0); |
---|
| 54 | heightMapMaterial->setShininess(.5); |
---|
| 55 | heightMapMaterial->setTransparency(1.0); |
---|
| 56 | |
---|
| 57 | heightMapMaterial->diffuseTexture = NULL; |
---|
| 58 | heightMapMaterial->ambientTexture = NULL; |
---|
| 59 | heightMapMaterial->specularTexture = NULL; |
---|
| 60 | |
---|
| 61 | const char* texture_name = "pictures/ground.tga"; |
---|
| 62 | heightMapMaterial->setDiffuseMap(texture_name); |
---|
| 63 | heightMapMaterial->setAmbientMap(texture_name); |
---|
| 64 | heightMapMaterial->setSpecularMap(texture_name); |
---|
| 65 | |
---|
[5308] | 66 | // if (this->model != NULL) |
---|
[6022] | 67 | //this->ssp = new SpatialSeparation((Model*)this->model, 10.0f); |
---|
[3365] | 68 | } |
---|
[1853] | 69 | |
---|
[4855] | 70 | |
---|
[3564] | 71 | /** |
---|
[4836] | 72 | * Constructor for loading a Terrain out of a file |
---|
| 73 | * @param fileName The file to load data from. |
---|
[4597] | 74 | |
---|
[3566] | 75 | this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found. |
---|
| 76 | */ |
---|
[4597] | 77 | Terrain::Terrain(const char* fileName) |
---|
[3566] | 78 | { |
---|
| 79 | this->init(); |
---|
| 80 | |
---|
[5415] | 81 | if (!strstr(fileName, ".obj") || !strstr(fileName, ".OBJ") ) |
---|
[3566] | 82 | { |
---|
[5308] | 83 | this->loadModel(fileName); |
---|
[3566] | 84 | } |
---|
| 85 | else |
---|
| 86 | { |
---|
| 87 | // load the hightMap here. |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | /** |
---|
[4836] | 92 | * a Constructor for the Debug-Worlds |
---|
[5308] | 93 | */ |
---|
[3564] | 94 | Terrain::Terrain(DebugTerrain debugTerrain) |
---|
| 95 | { |
---|
| 96 | this->init(); |
---|
| 97 | this->buildDebugTerrain(debugTerrain); |
---|
| 98 | } |
---|
| 99 | |
---|
[3245] | 100 | /** |
---|
[4836] | 101 | * standard deconstructor |
---|
[1853] | 102 | |
---|
[3245] | 103 | */ |
---|
[4746] | 104 | Terrain::~Terrain () |
---|
[3543] | 105 | { |
---|
[3564] | 106 | if (objectList) |
---|
| 107 | glDeleteLists(this->objectList, 1); |
---|
[4889] | 108 | if( this->ssp) |
---|
| 109 | delete ssp; |
---|
[5465] | 110 | if (this->vegetation) |
---|
| 111 | { |
---|
| 112 | ResourceManager::getInstance()->unload(this->vegetation); |
---|
| 113 | } |
---|
[3543] | 114 | } |
---|
[1853] | 115 | |
---|
[3245] | 116 | |
---|
[4746] | 117 | void Terrain::init() |
---|
[3559] | 118 | { |
---|
[4320] | 119 | this->setClassID(CL_TERRAIN, "Terrain"); |
---|
[6142] | 120 | this->toList(OM_ENVIRON_NOTICK); |
---|
[4597] | 121 | |
---|
[4136] | 122 | this->objectList = 0; |
---|
[5308] | 123 | this->ssp = NULL; |
---|
[5465] | 124 | this->vegetation = NULL; |
---|
[6495] | 125 | |
---|
| 126 | this->heightMap = NULL; |
---|
| 127 | this->heightMapMaterial = NULL; |
---|
[3559] | 128 | } |
---|
| 129 | |
---|
[4924] | 130 | |
---|
[4607] | 131 | void Terrain::loadParams(const TiXmlElement* root) |
---|
| 132 | { |
---|
[6495] | 133 | WorldEntity::loadParams(root); |
---|
[3559] | 134 | |
---|
[5671] | 135 | LoadParam(root, "vegetation", this, Terrain, loadVegetation) |
---|
[5465] | 136 | .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ; |
---|
[6495] | 137 | |
---|
| 138 | |
---|
| 139 | LoadParam(root, "height-map", this, Terrain, loadHeightMap) |
---|
| 140 | .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap"); |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | LoadParam(root, "heigt-texture", this, Terrain, loadTexture) |
---|
| 144 | .describe("The name of the Texture for this heightMap"); |
---|
[4607] | 145 | } |
---|
| 146 | |
---|
[6495] | 147 | void Terrain::loadHeightMap(const char* heightMapFile, const char* colorMap) |
---|
| 148 | { |
---|
| 149 | if (this->heightMap != NULL) |
---|
| 150 | delete this->heightMap; |
---|
| 151 | this->heightMap = NULL; |
---|
| 152 | |
---|
[6496] | 153 | char* hmName = ResourceManager::getFullName(heightMapFile); |
---|
| 154 | char* hmColorName = ResourceManager::getFullName(colorMap); |
---|
[6495] | 155 | |
---|
| 156 | |
---|
[6496] | 157 | this->heightMap = new HeightMap(hmName, hmColorName); |
---|
[6727] | 158 | heightMap->scale(Vector(23.0f,1.1f,23.0f)); |
---|
| 159 | heightMap->setAbsCoor(this->getAbsCoor()); |
---|
[6579] | 160 | heightMap->load(); |
---|
[6496] | 161 | delete[] hmName; |
---|
| 162 | delete[] hmColorName; |
---|
| 163 | |
---|
[6495] | 164 | } |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | void Terrain::loadTexture(const char* textureName) |
---|
| 168 | { |
---|
| 169 | if (this->heightMapMaterial != NULL) |
---|
[6727] | 170 | delete this->heightMapMaterial; |
---|
[6603] | 171 | |
---|
| 172 | |
---|
| 173 | this->heightMapMaterial = new Material(); |
---|
| 174 | heightMapMaterial->setTransparency(1.0); |
---|
| 175 | heightMapMaterial->setIllum(0.2); |
---|
| 176 | |
---|
| 177 | heightMapMaterial->setDiffuse(1.0,1.0,1.0); |
---|
| 178 | heightMapMaterial->setAmbient(1.0,1.0,1.0 ); |
---|
| 179 | heightMapMaterial->setSpecular(1.0,1.0,1.0); |
---|
| 180 | heightMapMaterial->setShininess(.5); |
---|
| 181 | heightMapMaterial->setTransparency(1.0); |
---|
| 182 | |
---|
| 183 | heightMapMaterial->diffuseTexture = NULL; |
---|
| 184 | heightMapMaterial->ambientTexture = NULL; |
---|
| 185 | heightMapMaterial->specularTexture = NULL; |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | heightMapMaterial->setDiffuseMap(textureName); |
---|
| 189 | heightMapMaterial->setAmbientMap(textureName); |
---|
| 190 | heightMapMaterial->setSpecularMap(textureName); |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | |
---|
[6495] | 194 | } |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | |
---|
[5465] | 198 | void Terrain::loadVegetation(const char* vegetationFile) |
---|
| 199 | { |
---|
[6341] | 200 | PRINTF(0)("loadVegetation: %s\n", vegetationFile); |
---|
[5465] | 201 | if (this->vegetation) |
---|
| 202 | ResourceManager::getInstance()->unload(this->vegetation, RP_LEVEL); |
---|
| 203 | if (vegetationFile != NULL) |
---|
| 204 | { |
---|
| 205 | PRINTF(4)("fetching %s\n", vegetationFile); |
---|
[6341] | 206 | this->vegetation = (Model*)ResourceManager::getInstance()->load(vegetationFile, OBJ, RP_CAMPAIGN); |
---|
[5465] | 207 | } |
---|
| 208 | else |
---|
| 209 | this->vegetation = NULL; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | |
---|
| 213 | |
---|
[6495] | 214 | |
---|
| 215 | |
---|
[5500] | 216 | void Terrain::draw () const |
---|
[4597] | 217 | { |
---|
[6727] | 218 | |
---|
| 219 | |
---|
| 220 | |
---|
[3559] | 221 | glMatrixMode(GL_MODELVIEW); |
---|
| 222 | glPushMatrix(); |
---|
[4597] | 223 | |
---|
[3559] | 224 | /* translate */ |
---|
[6730] | 225 | glTranslatef (this->getAbsCoor ().x, |
---|
[4597] | 226 | this->getAbsCoor ().y, |
---|
| 227 | this->getAbsCoor ().z); |
---|
[3559] | 228 | /* rotate */ |
---|
[6727] | 229 | // Vector tmpRot = this->getAbsDir().getSpacialAxis(); |
---|
| 230 | //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); |
---|
[3559] | 231 | |
---|
[4136] | 232 | if (this->objectList) |
---|
| 233 | glCallList(this->objectList); |
---|
[5994] | 234 | else if (this->getModel()) |
---|
| 235 | this->getModel()->draw(); |
---|
[5465] | 236 | if (this->vegetation) |
---|
| 237 | this->vegetation->draw(); |
---|
[6496] | 238 | |
---|
[6579] | 239 | if(this->heightMap) |
---|
| 240 | { |
---|
| 241 | this->heightMapMaterial->select(); |
---|
[6603] | 242 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
---|
| 243 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
---|
[6727] | 244 | glEnable(GL_LIGHTING); |
---|
[6579] | 245 | glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ; |
---|
| 246 | glEnable (GL_COLOR_MATERIAL) ; |
---|
| 247 | this->heightMap->draw(); |
---|
| 248 | } |
---|
[3559] | 249 | glPopMatrix(); |
---|
[4904] | 250 | |
---|
[6730] | 251 | |
---|
| 252 | |
---|
| 253 | |
---|
| 254 | |
---|
[6727] | 255 | glMatrixMode(GL_MODELVIEW); |
---|
| 256 | glPushMatrix(); |
---|
| 257 | glLoadIdentity(); |
---|
| 258 | Vector camera = State::getCamera()->getAbsCoor(); // Go on here ..........!!! |
---|
| 259 | float height = heightMap->getHeight(camera.x, camera.z); |
---|
| 260 | |
---|
| 261 | glEnable (GL_COLOR_MATERIAL) ; |
---|
| 262 | glBegin(GL_QUADS); // Draw The Cube Using quads |
---|
| 263 | glColor3f(0.0f,1.0f,0.0f); // Color Blue |
---|
| 264 | glVertex3f(camera.x + 13.0f,height+13.0f,camera.z-13.0f); // Top Right Of The Quad (Top) |
---|
| 265 | glVertex3f(camera.x-13.0f, height+13.0f,camera.z-13.0f); // Top Left Of The Quad (Top) |
---|
| 266 | glVertex3f(camera.x-13.0f, height+13.0f, camera.z+13.0f); // Bottom Left Of The Quad (Top) |
---|
| 267 | glVertex3f(camera.x+ 13.0f, height+13.0f, camera.z+13.0f); // Bottom Right Of The Quad (Top) |
---|
| 268 | glEnd(); // End Drawing The Plan |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | glPopMatrix(); |
---|
[4924] | 272 | /* THIS IS ONLY FOR DEBUGGING INFORMATION */ |
---|
[5308] | 273 | if (this->ssp != NULL) |
---|
| 274 | this->ssp->drawQuadtree(); |
---|
[3559] | 275 | } |
---|
[3564] | 276 | |
---|
| 277 | |
---|
| 278 | void Terrain::buildDebugTerrain(DebugTerrain debugTerrain) |
---|
| 279 | { |
---|
| 280 | // if the terrain is the Terrain of Dave |
---|
| 281 | if (debugTerrain == TERRAIN_DAVE) |
---|
| 282 | { |
---|
| 283 | objectList = glGenLists(1); |
---|
| 284 | glNewList (objectList, GL_COMPILE); |
---|
[4597] | 285 | |
---|
[3564] | 286 | glColor3f(1.0,0,0); |
---|
[4597] | 287 | |
---|
[3564] | 288 | int sizeX = 100; |
---|
| 289 | int sizeZ = 80; |
---|
| 290 | float length = 1000; |
---|
| 291 | float width = 200; |
---|
| 292 | float widthX = float (length /sizeX); |
---|
| 293 | float widthZ = float (width /sizeZ); |
---|
[4597] | 294 | |
---|
[3564] | 295 | float height [sizeX][sizeZ]; |
---|
| 296 | Vector normal_vectors[sizeX][sizeZ]; |
---|
[4597] | 297 | |
---|
| 298 | |
---|
[3564] | 299 | for ( int i = 0; i<sizeX-1; i+=1) |
---|
[4597] | 300 | for (int j = 0; j<sizeZ-1;j+=1) |
---|
| 301 | //height[i][j] = rand()/20046 + (j-25)*(j-25)/30; |
---|
[3564] | 302 | #ifdef __WIN32__ |
---|
[4597] | 303 | height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5; |
---|
[3564] | 304 | #else |
---|
| 305 | height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5; |
---|
| 306 | #endif |
---|
[4597] | 307 | |
---|
[3564] | 308 | //Die Huegel ein wenig glaetten |
---|
| 309 | for (int h=1; h<2;h++) |
---|
[4597] | 310 | for (int i=1;i<sizeX-2 ;i+=1 ) |
---|
| 311 | for(int j=1;j<sizeZ-2;j+=1) |
---|
| 312 | height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4; |
---|
| 313 | |
---|
[3564] | 314 | //Berechnung von normalen Vektoren |
---|
| 315 | for(int i=1;i<sizeX-2;i+=1) |
---|
[4597] | 316 | for(int j=1;j<sizeZ-2 ;j+=1) |
---|
| 317 | { |
---|
| 318 | Vector v1 = Vector (widthX*(1), height[i][j], widthZ*(j) ); |
---|
| 319 | Vector v2 = Vector (widthX*(i-1), height[i-1][j], widthZ*(j)); |
---|
| 320 | Vector v3 = Vector (widthX*(i), height[i][j+1], widthZ*(j+1)); |
---|
| 321 | Vector v4 = Vector (widthX*(i+1), height[i+1][j], widthZ*(j)); |
---|
| 322 | Vector v5 = Vector (widthX*(i), height[i][j-1], widthZ*(j-1)); |
---|
| 323 | |
---|
| 324 | Vector c1 = v2 - v1; |
---|
| 325 | Vector c2 = v3 - v1; |
---|
| 326 | Vector c3= v4 - v1; |
---|
| 327 | Vector c4 = v5 - v1; |
---|
| 328 | Vector zero = Vector (0,0,0); |
---|
| 329 | normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4); |
---|
| 330 | normal_vectors[i][j].normalize(); |
---|
| 331 | } |
---|
| 332 | |
---|
[3564] | 333 | glBegin(GL_QUADS); |
---|
| 334 | int snowheight=3; |
---|
| 335 | for ( int i = 0; i<sizeX; i+=1) |
---|
[4597] | 336 | for (int j = 0; j<sizeZ;j+=1) |
---|
| 337 | { |
---|
| 338 | Vector v1 = Vector (widthX*(i), height[i][j]-20, widthZ*(j) -width/2); |
---|
| 339 | Vector v2 = Vector (widthX*(i+1), height[i+1][j]-20, widthZ*(j) -width/2); |
---|
| 340 | Vector v3 = Vector (widthX*(i+1), height[i+1][j+1]-20, widthZ*(j+1)-width/2); |
---|
| 341 | Vector v4 = Vector (widthX*(i), height[i][j+1]-20, widthZ*(j+1)-width/2); |
---|
| 342 | float a[3]; |
---|
| 343 | if(height[i][j]<snowheight){ |
---|
| 344 | a[0]=0; |
---|
| 345 | a[1]=1.0-height[i][j]/10-.3; |
---|
| 346 | a[2]=0; |
---|
| 347 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 348 | } |
---|
| 349 | else{ |
---|
| 350 | a[0]=1.0; |
---|
| 351 | a[1]=1.0; |
---|
| 352 | a[2]=1.0; |
---|
| 353 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 354 | |
---|
| 355 | } |
---|
| 356 | glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z); |
---|
| 357 | glVertex3f(v1.x, v1.y, v1.z); |
---|
| 358 | if(height[i+1][j]<snowheight){ |
---|
| 359 | a[0]=0; |
---|
| 360 | a[1] =1.0-height[i+1][j]/10-.3; |
---|
| 361 | a[2]=0; |
---|
| 362 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 363 | } |
---|
| 364 | else{ |
---|
| 365 | a[0]=1.0; |
---|
| 366 | a[1]=1.0; |
---|
| 367 | a[2]=1.0; |
---|
| 368 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 369 | |
---|
| 370 | } |
---|
| 371 | glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z); |
---|
| 372 | glVertex3f(v2.x, v2.y, v2.z); |
---|
| 373 | if(height[i+1][j+1]<snowheight){ |
---|
| 374 | a[0]=0; |
---|
| 375 | a[1] =1.0-height[i+1][j+1]/10-.3; |
---|
| 376 | a[2]=0; |
---|
| 377 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 378 | } |
---|
| 379 | else{ |
---|
| 380 | a[0]=1.0; |
---|
| 381 | a[1]=1.0; |
---|
| 382 | a[2]=1.0; |
---|
| 383 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 384 | |
---|
| 385 | |
---|
| 386 | } |
---|
| 387 | glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z); |
---|
| 388 | glVertex3f(v3.x, v3.y, v3.z); |
---|
| 389 | if(height[i][j+1]<snowheight){ |
---|
| 390 | a[0]=0; |
---|
| 391 | a[1] =1.0-height[i+1][j+1]/10-.3; |
---|
| 392 | a[2]=0; |
---|
| 393 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 394 | } |
---|
| 395 | else{ |
---|
| 396 | a[0]=1.0; |
---|
| 397 | a[1]=1.0; |
---|
| 398 | a[2]=1.0; |
---|
| 399 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 400 | } |
---|
| 401 | glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z); |
---|
| 402 | glVertex3f(v4.x, v4.y, v4.z); |
---|
| 403 | |
---|
| 404 | } |
---|
[3564] | 405 | glEnd(); |
---|
| 406 | glEndList(); |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | if (debugTerrain == TERRAIN_BENSCH) |
---|
| 410 | { |
---|
| 411 | /* |
---|
[4597] | 412 | this->model = (OBJModel*) new Model(); |
---|
[3564] | 413 | this->model->setName("CUBE"); |
---|
| 414 | this->model->addVertex (-0.5, -0.5, 0.5); |
---|
| 415 | this->model->addVertex (0.5, -0.5, 0.5); |
---|
| 416 | this->model->addVertex (-0.5, 0.5, 0.5); |
---|
| 417 | this->model->addVertex (0.5, 0.5, 0.5); |
---|
| 418 | this->model->addVertex (-0.5, 0.5, -0.5); |
---|
| 419 | this->model->addVertex (0.5, 0.5, -0.5); |
---|
| 420 | this->model->addVertex (-0.5, -0.5, -0.5); |
---|
| 421 | this->model->addVertex (0.5, -0.5, -0.5); |
---|
[4597] | 422 | |
---|
[3564] | 423 | this->model->addVertexTexture (0.0, 0.0); |
---|
| 424 | this->model->addVertexTexture (1.0, 0.0); |
---|
| 425 | this->model->addVertexTexture (0.0, 1.0); |
---|
| 426 | this->model->addVertexTexture (1.0, 1.0); |
---|
| 427 | this->model->addVertexTexture (0.0, 2.0); |
---|
| 428 | this->model->addVertexTexture (1.0, 2.0); |
---|
| 429 | this->model->addVertexTexture (0.0, 3.0); |
---|
| 430 | this->model->addVertexTexture (1.0, 3.0); |
---|
| 431 | this->model->addVertexTexture (0.0, 4.0); |
---|
| 432 | this->model->addVertexTexture (1.0, 4.0); |
---|
| 433 | this->model->addVertexTexture (2.0, 0.0); |
---|
| 434 | this->model->addVertexTexture (2.0, 1.0); |
---|
| 435 | this->model->addVertexTexture (-1.0, 0.0); |
---|
| 436 | this->model->addVertexTexture (-1.0, 1.0); |
---|
| 437 | |
---|
| 438 | this->model->finalize(); |
---|
| 439 | */ |
---|
| 440 | } |
---|
| 441 | } |
---|
[6341] | 442 | |
---|
| 443 | int Terrain::writeBytes( const byte * data, int length, int sender ) |
---|
| 444 | { |
---|
| 445 | setRequestedSync( false ); |
---|
| 446 | setIsOutOfSync( false ); |
---|
| 447 | |
---|
| 448 | SYNCHELP_READ_BEGIN(); |
---|
| 449 | SYNCHELP_READ_FKT( WorldEntity::writeState ); |
---|
| 450 | |
---|
| 451 | return SYNCHELP_READ_N; |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | int Terrain::readBytes( byte * data, int maxLength, int * reciever ) |
---|
| 455 | { |
---|
| 456 | if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) |
---|
| 457 | { |
---|
| 458 | (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); |
---|
| 459 | setRequestedSync( true ); |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | int rec = this->getRequestSync(); |
---|
| 463 | if ( rec > 0 ) |
---|
| 464 | { |
---|
| 465 | *reciever = rec; |
---|
| 466 | |
---|
| 467 | return WorldEntity::readState( data, maxLength ); |
---|
| 468 | |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | *reciever = 0; |
---|
| 472 | return 0; |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | void Terrain::writeDebug( ) const |
---|
| 476 | { |
---|
| 477 | } |
---|
| 478 | |
---|
| 479 | void Terrain::readDebug( ) const |
---|
| 480 | { |
---|
| 481 | } |
---|
[6727] | 482 | |
---|
| 483 | float Terrain::getHeight(float x, float y) |
---|
| 484 | { |
---|
| 485 | if(this->heightMap != NULL) |
---|
| 486 | return (this->heightMap->getHeight(x, y)); |
---|
| 487 | return 0; |
---|
| 488 | } |
---|