[1853] | 1 | |
---|
| 2 | /* |
---|
| 3 | orxonox - the future of 3D-vertical-scrollers |
---|
| 4 | |
---|
| 5 | Copyright (C) 2004 orx |
---|
| 6 | |
---|
| 7 | This program is free software; you can redistribute it and/or modify |
---|
| 8 | it under the terms of the GNU General Public License as published by |
---|
| 9 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 10 | any later version. |
---|
[1855] | 11 | |
---|
| 12 | ### File Specific: |
---|
| 13 | main-programmer: Patrick Boenzli |
---|
[2190] | 14 | co-programmer: Christian Meyer |
---|
[1853] | 15 | */ |
---|
| 16 | |
---|
[2190] | 17 | #include "world.h" |
---|
| 18 | #include "world_entity.h" |
---|
| 19 | #include "collision.h" |
---|
[3365] | 20 | #include "track_manager.h" |
---|
[2036] | 21 | #include "player.h" |
---|
[2190] | 22 | #include "command_node.h" |
---|
| 23 | #include "camera.h" |
---|
[2816] | 24 | #include "environment.h" |
---|
[3365] | 25 | #include "p_node.h" |
---|
| 26 | #include "null_parent.h" |
---|
| 27 | #include "helper_parent.h" |
---|
| 28 | #include "glmenu_imagescreen.h" |
---|
[2036] | 29 | |
---|
[1856] | 30 | using namespace std; |
---|
[1853] | 31 | |
---|
| 32 | |
---|
[1858] | 33 | /** |
---|
[2551] | 34 | \brief create a new World |
---|
| 35 | |
---|
| 36 | This creates a new empty world! |
---|
[1858] | 37 | */ |
---|
[2636] | 38 | World::World (char* name) |
---|
[1855] | 39 | { |
---|
[3365] | 40 | this->setClassName ("World"); |
---|
[2636] | 41 | this->worldName = name; |
---|
| 42 | this->debugWorldNr = -1; |
---|
[2822] | 43 | this->entities = new tList<WorldEntity>(); |
---|
[1855] | 44 | } |
---|
| 45 | |
---|
[2636] | 46 | World::World (int worldID) |
---|
| 47 | { |
---|
| 48 | this->debugWorldNr = worldID; |
---|
| 49 | this->worldName = NULL; |
---|
[2822] | 50 | this->entities = new tList<WorldEntity>(); |
---|
[2636] | 51 | } |
---|
| 52 | |
---|
[1858] | 53 | /** |
---|
[2551] | 54 | \brief remove the World from memory |
---|
[3365] | 55 | |
---|
| 56 | delete everything explicitly, that isn't contained in the parenting tree! |
---|
| 57 | things contained in the tree are deleted automaticaly |
---|
[1858] | 58 | */ |
---|
[2190] | 59 | World::~World () |
---|
[1872] | 60 | { |
---|
[3220] | 61 | printf("World::~World() - deleting current world\n"); |
---|
[3226] | 62 | CommandNode* cn = Orxonox::getInstance()->getLocalInput(); |
---|
[3220] | 63 | cn->unbind(this->localPlayer); |
---|
| 64 | cn->reset(); |
---|
| 65 | this->localCamera->destroy(); |
---|
| 66 | |
---|
[3365] | 67 | this->nullParent->destroy (); |
---|
| 68 | |
---|
| 69 | //delete this->trackManager; |
---|
| 70 | |
---|
| 71 | /* |
---|
[3220] | 72 | WorldEntity* entity = entities->enumerate(); |
---|
| 73 | while( entity != NULL ) |
---|
| 74 | { |
---|
| 75 | entity->destroy(); |
---|
| 76 | entity = entities->nextElement(); |
---|
| 77 | } |
---|
| 78 | this->entities->destroy(); |
---|
[3365] | 79 | */ |
---|
[3220] | 80 | |
---|
[3365] | 81 | /* FIX the parent list has to be cleared - not possible if we got the old list also*/ |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | //delete this->entities; |
---|
| 85 | //delete this->localCamera; |
---|
[3220] | 86 | /* this->localPlayer hasn't to be deleted explicitly, it is |
---|
| 87 | contained in entities*/ |
---|
[1872] | 88 | } |
---|
[1858] | 89 | |
---|
[3365] | 90 | GLfloat ctrlpoints[4][3] = { |
---|
| 91 | {20.0, 10.0, 5.0}, {40.0, -10.0, 0.0}, |
---|
| 92 | {60.0, -10.0, 5.0}, {80.0, 10.0, 5.0}}; |
---|
[2636] | 93 | |
---|
[3365] | 94 | |
---|
[3222] | 95 | ErrorMessage World::init() |
---|
[2636] | 96 | { |
---|
| 97 | this->bPause = false; |
---|
[3226] | 98 | CommandNode* cn = Orxonox::getInstance()->getLocalInput(); |
---|
[3216] | 99 | cn->addToWorld(this); |
---|
| 100 | cn->enable(true); |
---|
[3365] | 101 | |
---|
| 102 | //glMap1f (GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]); |
---|
| 103 | //glEnable (GL_MAP1_VERTEX_3); |
---|
| 104 | |
---|
| 105 | //theNurb = gluNewNurbsRenderer (); |
---|
| 106 | //gluNurbsProperty (theNurb, GLU_NURBS_MODE, GLU_NURBS_TESSELLATOR); |
---|
| 107 | //gluNurbsProperty (theNurb, GLU_NURBS_VERTEX, vertexCallback ); |
---|
| 108 | |
---|
[2636] | 109 | } |
---|
| 110 | |
---|
[3365] | 111 | |
---|
| 112 | |
---|
[3222] | 113 | ErrorMessage World::start() |
---|
[2636] | 114 | { |
---|
[3220] | 115 | printf("World::start() - starting current World: nr %i\n", this->debugWorldNr); |
---|
| 116 | this->bQuitOrxonox = false; |
---|
| 117 | this->bQuitCurrentGame = false; |
---|
[2636] | 118 | this->mainLoop(); |
---|
| 119 | } |
---|
| 120 | |
---|
[3222] | 121 | ErrorMessage World::stop() |
---|
[2636] | 122 | { |
---|
[3220] | 123 | printf("World::stop() - got stop signal\n"); |
---|
[2636] | 124 | this->bQuitCurrentGame = true; |
---|
| 125 | } |
---|
| 126 | |
---|
[3222] | 127 | ErrorMessage World::pause() |
---|
[2636] | 128 | { |
---|
| 129 | this->isPaused = true; |
---|
| 130 | } |
---|
| 131 | |
---|
[3365] | 132 | |
---|
[3222] | 133 | ErrorMessage World::resume() |
---|
[2636] | 134 | { |
---|
| 135 | this->isPaused = false; |
---|
| 136 | } |
---|
| 137 | |
---|
[3365] | 138 | |
---|
[3221] | 139 | void World::destroy() |
---|
| 140 | { |
---|
[3376] | 141 | delete trackManager; |
---|
[3365] | 142 | } |
---|
[3221] | 143 | |
---|
[3365] | 144 | |
---|
| 145 | void World::displayLoadScreen () |
---|
| 146 | { |
---|
| 147 | printf ("World::displayLoadScreen - start\n"); |
---|
| 148 | |
---|
| 149 | //GLMenuImageScreen* |
---|
| 150 | glmis = new GLMenuImageScreen(); |
---|
| 151 | glmis->init(); |
---|
| 152 | glmis->draw(); |
---|
| 153 | |
---|
| 154 | printf ("World::displayLoadScreen - end\n"); |
---|
[3221] | 155 | } |
---|
| 156 | |
---|
[3365] | 157 | |
---|
| 158 | void World::releaseLoadScreen () |
---|
| 159 | { |
---|
| 160 | printf ("World::releaseLoadScreen - start\n"); |
---|
| 161 | |
---|
| 162 | printf ("World::releaseLoadScreen - end\n"); |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | |
---|
[2636] | 166 | void World::load() |
---|
| 167 | { |
---|
[3365] | 168 | // BezierCurve* tmpCurve = new BezierCurve(); |
---|
[2636] | 169 | if(this->debugWorldNr != -1) |
---|
| 170 | { |
---|
[3365] | 171 | trackManager = TrackManager::getInstance(); |
---|
| 172 | trackManager->addPoint(Vector(0,-5,0)); |
---|
| 173 | trackManager->addPoint(Vector(10,0,5)); |
---|
| 174 | trackManager->addPoint(Vector(20,0,-5)); |
---|
| 175 | trackManager->addPoint(Vector(30,0,5)); |
---|
| 176 | trackManager->addPoint(Vector(40,0,5)); |
---|
[3371] | 177 | trackManager->setDuration(2); |
---|
[3365] | 178 | trackManager->setSavePoint(); |
---|
| 179 | trackManager->addPoint(Vector(50,10,10)); |
---|
| 180 | trackManager->addPoint(Vector(60,0, 10)); |
---|
| 181 | trackManager->addPoint(Vector(70,0, 10)); |
---|
| 182 | trackManager->addPoint(Vector(80,0,-10)); |
---|
| 183 | trackManager->addPoint(Vector(90,0,-10)); |
---|
[3371] | 184 | trackManager->setDuration(5); |
---|
[3365] | 185 | trackManager->setSavePoint(); |
---|
| 186 | trackManager->addPoint(Vector(110,0,5)); |
---|
| 187 | trackManager->addPoint(Vector(120,0, 10)); |
---|
| 188 | trackManager->addPoint(Vector(130,0, 10)); |
---|
| 189 | trackManager->addPoint(Vector(140,0,-10)); |
---|
| 190 | trackManager->addPoint(Vector(150,0,-10)); |
---|
[3371] | 191 | trackManager->setDuration(3); |
---|
[3365] | 192 | int fork11, fork12, fork13, fork14; |
---|
| 193 | trackManager->fork(4, &fork11, &fork12, &fork13, &fork14); |
---|
| 194 | trackManager->workOn(fork11); |
---|
| 195 | trackManager->addPoint(Vector(170, 0, -15)); |
---|
| 196 | trackManager->addPoint(Vector(180, 0, -15)); |
---|
[3371] | 197 | trackManager->setDuration(3); |
---|
[3365] | 198 | trackManager->workOn(fork12); |
---|
| 199 | trackManager->addPoint(Vector(170, 0, 10)); |
---|
| 200 | trackManager->addPoint(Vector(180, 0, 10)); |
---|
| 201 | trackManager->addPoint(Vector(190,2,5)); |
---|
| 202 | trackManager->addPoint(Vector(200,2,5)); |
---|
[3371] | 203 | trackManager->setDuration(7); |
---|
[3365] | 204 | int fork21, fork22; |
---|
| 205 | trackManager->fork(2, &fork21, &fork22); |
---|
| 206 | trackManager->workOn(fork21); |
---|
| 207 | trackManager->addPoint(Vector(220, 10,-10)); |
---|
| 208 | trackManager->addPoint(Vector(230, 0,-10)); |
---|
| 209 | trackManager->addPoint(Vector(240, 0, 2)); |
---|
| 210 | trackManager->addPoint(Vector(250, 0, 0)); |
---|
| 211 | trackManager->addPoint(Vector(260, 0, 5)); |
---|
[3371] | 212 | trackManager->setDuration(3); |
---|
[3365] | 213 | trackManager->join(2, fork12, fork11); |
---|
| 214 | trackManager->workOn(fork22); |
---|
| 215 | trackManager->addPoint(Vector(220, -10,10)); |
---|
| 216 | trackManager->addPoint(Vector(230, 0, 10)); |
---|
| 217 | trackManager->addPoint(Vector(240, 0, 10)); |
---|
| 218 | trackManager->addPoint(Vector(250, 0, 5)); |
---|
[3371] | 219 | trackManager->setDuration(6); |
---|
[3365] | 220 | trackManager->workOn(fork13); |
---|
| 221 | trackManager->addPoint(Vector(200,-10,5)); |
---|
| 222 | trackManager->addPoint(Vector(250,-10,5)); |
---|
[3371] | 223 | trackManager->setDuration(3); |
---|
[3365] | 224 | trackManager->workOn(fork14); |
---|
| 225 | trackManager->addPoint(Vector(200,15,0)); |
---|
| 226 | trackManager->addPoint(Vector(210,0,10)); |
---|
[3371] | 227 | trackManager->setDuration(1); |
---|
[3365] | 228 | trackManager->join(4, fork21, fork22, fork13, fork14); |
---|
[3373] | 229 | trackManager->workOn(10); |
---|
| 230 | trackManager->addPoint(Vector(250,-10,5)); |
---|
[3376] | 231 | trackManager->addPoint(Vector(260,-10,5)); |
---|
| 232 | trackManager->finalize(); |
---|
[3373] | 233 | |
---|
[3365] | 234 | /* |
---|
[3375] | 235 | tmpCurve->addNode(Vector(10, -1, -1)); |
---|
| 236 | tmpCurve->addNode(Vector(10, -2, 2)); |
---|
| 237 | tmpCurve->addNode(Vector(10, 3, 3)); |
---|
| 238 | tmpCurve->addNode(Vector(10, 4, -4), 0); |
---|
| 239 | tmpCurve->addNode(Vector(10, -1, -1)); |
---|
| 240 | tmpCurve->addNode(Vector(10, -2, 2)); |
---|
| 241 | tmpCurve->addNode(Vector(10, 3, 3)); |
---|
| 242 | tmpCurve->addNode(Vector(10, 4, -4), 0); |
---|
| 243 | tmpCurve->debug(); |
---|
[3365] | 244 | */ |
---|
[2636] | 245 | switch(this->debugWorldNr) |
---|
| 246 | { |
---|
[3225] | 247 | /* |
---|
| 248 | this loads the hard-coded debug world. this only for simplicity and will be |
---|
| 249 | removed by a reald world-loader, which interprets a world-file. |
---|
| 250 | if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and |
---|
| 251 | make whatever you want... |
---|
| 252 | */ |
---|
[2636] | 253 | case DEBUG_WORLD_0: |
---|
| 254 | { |
---|
[3365] | 255 | this->nullParent = NullParent::getInstance (); |
---|
| 256 | this->nullParent->setName ("NullParent"); |
---|
| 257 | |
---|
[3194] | 258 | // !\todo old track-system has to be removed |
---|
| 259 | |
---|
[3365] | 260 | //create helper for player |
---|
| 261 | HelperParent* hp = new HelperParent (); |
---|
| 262 | /* the player has to be added to this helper */ |
---|
| 263 | |
---|
[2636] | 264 | // create a player |
---|
[3365] | 265 | WorldEntity* myPlayer = new Player (); |
---|
| 266 | myPlayer->setName ("player"); |
---|
| 267 | this->spawn (myPlayer); |
---|
[2640] | 268 | this->localPlayer = myPlayer; |
---|
[2636] | 269 | // bind input |
---|
[3365] | 270 | Orxonox *orx = Orxonox::getInstance (); |
---|
[3226] | 271 | orx->getLocalInput()->bind (myPlayer); |
---|
[2636] | 272 | |
---|
| 273 | // bind camera |
---|
| 274 | this->localCamera = new Camera(this); |
---|
[3365] | 275 | this->localCamera->setName ("camera"); |
---|
| 276 | this->getCamera()->bind (myPlayer); |
---|
| 277 | this->localPlayer->addChild (this->localCamera); |
---|
| 278 | |
---|
[2816] | 279 | |
---|
[3365] | 280 | Vector* es = new Vector (50, 2, 0); |
---|
| 281 | Quaternion* qs = new Quaternion (); |
---|
[2816] | 282 | WorldEntity* env = new Environment(); |
---|
[3365] | 283 | env->setName ("env"); |
---|
| 284 | this->spawn(env, es, qs); |
---|
[3371] | 285 | trackManager->setBindSlave(env); |
---|
[2816] | 286 | |
---|
[2636] | 287 | break; |
---|
| 288 | } |
---|
| 289 | case DEBUG_WORLD_1: |
---|
| 290 | { |
---|
[3365] | 291 | /* |
---|
| 292 | this->testCurve = new UPointCurve(); |
---|
| 293 | this->testCurve->addNode(Vector( 0, 0, 0)); |
---|
| 294 | this->testCurve->addNode(Vector(10, 0, 5)); |
---|
| 295 | this->testCurve->addNode(Vector(20, -5,-5)); |
---|
| 296 | this->testCurve->addNode(Vector(30, 5, 10)); |
---|
| 297 | this->testCurve->addNode(Vector(40, 0,-10)); |
---|
| 298 | this->testCurve->addNode(Vector(50, 0,-10)); |
---|
| 299 | */ |
---|
| 300 | |
---|
| 301 | this->nullParent = NullParent::getInstance (); |
---|
| 302 | this->nullParent->setName ("NullParent"); |
---|
| 303 | |
---|
[2636] | 304 | // create some path nodes |
---|
| 305 | this->pathnodes = new Vector[6]; |
---|
| 306 | this->pathnodes[0] = Vector(0, 0, 0); |
---|
| 307 | this->pathnodes[1] = Vector(20, 10, 10); |
---|
| 308 | this->pathnodes[2] = Vector(40, 0, 10); |
---|
| 309 | this->pathnodes[3] = Vector(60, 10, 0); |
---|
| 310 | this->pathnodes[4] = Vector(80, 20, 10); |
---|
| 311 | this->pathnodes[5] = Vector(30, 50, 0); |
---|
| 312 | |
---|
[3365] | 313 | |
---|
| 314 | |
---|
| 315 | |
---|
[2636] | 316 | // create a player |
---|
[2644] | 317 | WorldEntity* myPlayer = new Player(); |
---|
[3365] | 318 | myPlayer->setName ("player"); |
---|
[2644] | 319 | this->spawn(myPlayer); |
---|
[3194] | 320 | this->localPlayer = myPlayer; |
---|
[2636] | 321 | |
---|
| 322 | // bind input |
---|
| 323 | Orxonox *orx = Orxonox::getInstance(); |
---|
[3226] | 324 | orx->getLocalInput()->bind (myPlayer); |
---|
[2636] | 325 | |
---|
| 326 | // bind camera |
---|
[3365] | 327 | this->localCamera = new Camera (this); |
---|
| 328 | this->localCamera->setName ("camera"); |
---|
[2636] | 329 | this->getCamera()->bind (myPlayer); |
---|
[3365] | 330 | this->localPlayer->addChild (this->localCamera); |
---|
[2636] | 331 | break; |
---|
| 332 | } |
---|
| 333 | default: |
---|
| 334 | printf("World::load() - no world with ID %i found", this->debugWorldNr ); |
---|
| 335 | } |
---|
| 336 | } |
---|
| 337 | else if(this->worldName != NULL) |
---|
| 338 | { |
---|
| 339 | |
---|
| 340 | } |
---|
[2731] | 341 | |
---|
| 342 | // initialize debug coord system |
---|
| 343 | objectList = glGenLists(1); |
---|
| 344 | glNewList (objectList, GL_COMPILE); |
---|
| 345 | glLoadIdentity(); |
---|
[2792] | 346 | glColor3f(1.0,0,0); |
---|
[2817] | 347 | glBegin(GL_QUADS); |
---|
[3200] | 348 | |
---|
| 349 | int sizeX = 100; |
---|
[3365] | 350 | int sizeZ = 80; |
---|
[3200] | 351 | float length = 1000; |
---|
| 352 | float width = 200; |
---|
| 353 | float widthX = float (length /sizeX); |
---|
[3365] | 354 | float widthZ = float (width /sizeZ); |
---|
[3199] | 355 | |
---|
[3365] | 356 | float height [sizeX][sizeZ]; |
---|
| 357 | Vector normal_vectors[sizeX][sizeZ]; |
---|
[3199] | 358 | |
---|
[3200] | 359 | |
---|
| 360 | for ( int i = 0; i<sizeX-1; i+=1) |
---|
[3365] | 361 | for (int j = 0; j<sizeZ-1;j+=1) |
---|
[3200] | 362 | //height[i][j] = rand()/20046 + (j-25)*(j-25)/30; |
---|
[3199] | 363 | #ifdef __WIN32__ |
---|
[3200] | 364 | height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5; |
---|
[3199] | 365 | #else |
---|
[3200] | 366 | height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5; |
---|
[3199] | 367 | #endif |
---|
[3200] | 368 | |
---|
[3365] | 369 | //Die Huegel ein wenig glaetten |
---|
[3199] | 370 | for (int h=1; h<2;h++) |
---|
[3200] | 371 | for (int i=1;i<sizeX-2 ;i+=1 ) |
---|
[3365] | 372 | for(int j=1;j<sizeZ-2;j+=1) |
---|
[3199] | 373 | height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4; |
---|
| 374 | |
---|
| 375 | //Berechnung von normalen Vektoren |
---|
[3200] | 376 | for(int i=1;i<sizeX-2;i+=1) |
---|
[3365] | 377 | for(int j=1;j<sizeZ-2 ;j+=1) |
---|
[2792] | 378 | { |
---|
[3365] | 379 | Vector v1 = Vector (widthX*(1), height[i][j], widthZ*(j) ); |
---|
| 380 | Vector v2 = Vector (widthX*(i-1), height[i-1][j], widthZ*(j)); |
---|
| 381 | Vector v3 = Vector (widthX*(i), height[i][j+1], widthZ*(j+1)); |
---|
| 382 | Vector v4 = Vector (widthX*(i+1), height[i+1][j], widthZ*(j)); |
---|
| 383 | Vector v5 = Vector (widthX*(i), height[i][j-1], widthZ*(j-1)); |
---|
[3199] | 384 | |
---|
[3200] | 385 | Vector c1 = v2 - v1; |
---|
| 386 | Vector c2 = v3 - v1; |
---|
| 387 | Vector c3= v4 - v1; |
---|
| 388 | Vector c4 = v5 - v1; |
---|
| 389 | Vector zero = Vector (0,0,0); |
---|
[3365] | 390 | normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4); |
---|
[3199] | 391 | normal_vectors[i][j].normalize(); |
---|
[3200] | 392 | } |
---|
| 393 | |
---|
| 394 | int snowheight=3; |
---|
| 395 | for ( int i = 0; i<sizeX; i+=1) |
---|
[3365] | 396 | for (int j = 0; j<sizeZ;j+=1) |
---|
[3200] | 397 | { |
---|
[3365] | 398 | Vector v1 = Vector (widthX*(i), height[i][j]-20, widthZ*(j) -width/2); |
---|
| 399 | Vector v2 = Vector (widthX*(i+1), height[i+1][j]-20, widthZ*(j) -width/2); |
---|
| 400 | Vector v3 = Vector (widthX*(i+1), height[i+1][j+1]-20, widthZ*(j+1)-width/2); |
---|
| 401 | Vector v4 = Vector (widthX*(i), height[i][j+1]-20, widthZ*(j+1)-width/2); |
---|
[3200] | 402 | float a[3]; |
---|
| 403 | if(height[i][j]<snowheight){ |
---|
| 404 | a[0]=0; |
---|
| 405 | a[1]=1.0-height[i][j]/10-.3; |
---|
| 406 | a[2]=0; |
---|
| 407 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
[3199] | 408 | } |
---|
[3200] | 409 | else{ |
---|
[3199] | 410 | a[0]=1.0; |
---|
| 411 | a[1]=1.0; |
---|
| 412 | a[2]=1.0; |
---|
| 413 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
[2817] | 414 | |
---|
[3199] | 415 | } |
---|
[3200] | 416 | glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z); |
---|
| 417 | glVertex3f(v1.x, v1.y, v1.z); |
---|
| 418 | if(height[i+1][j]<snowheight){ |
---|
| 419 | a[0]=0; |
---|
| 420 | a[1] =1.0-height[i+1][j]/10-.3; |
---|
| 421 | a[2]=0; |
---|
| 422 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 423 | } |
---|
| 424 | else{ |
---|
| 425 | a[0]=1.0; |
---|
| 426 | a[1]=1.0; |
---|
| 427 | a[2]=1.0; |
---|
| 428 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 429 | |
---|
| 430 | } |
---|
| 431 | glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z); |
---|
| 432 | glVertex3f(v2.x, v2.y, v2.z); |
---|
| 433 | if(height[i+1][j+1]<snowheight){ |
---|
| 434 | a[0]=0; |
---|
| 435 | a[1] =1.0-height[i+1][j+1]/10-.3; |
---|
| 436 | a[2]=0; |
---|
| 437 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 438 | } |
---|
| 439 | else{ |
---|
| 440 | a[0]=1.0; |
---|
| 441 | a[1]=1.0; |
---|
| 442 | a[2]=1.0; |
---|
| 443 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 444 | |
---|
| 445 | |
---|
| 446 | } |
---|
| 447 | glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z); |
---|
| 448 | glVertex3f(v3.x, v3.y, v3.z); |
---|
| 449 | if(height[i][j+1]<snowheight){ |
---|
| 450 | a[0]=0; |
---|
| 451 | a[1] =1.0-height[i+1][j+1]/10-.3; |
---|
| 452 | a[2]=0; |
---|
| 453 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 454 | } |
---|
| 455 | else{ |
---|
| 456 | a[0]=1.0; |
---|
| 457 | a[1]=1.0; |
---|
| 458 | a[2]=1.0; |
---|
| 459 | glMaterialfv(GL_FRONT,GL_DIFFUSE,a); |
---|
| 460 | } |
---|
| 461 | glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z); |
---|
| 462 | glVertex3f(v4.x, v4.y, v4.z); |
---|
| 463 | |
---|
| 464 | } |
---|
[3199] | 465 | glEnd(); |
---|
| 466 | /* |
---|
[2792] | 467 | glBegin(GL_LINES); |
---|
[2731] | 468 | for( float x = -128.0; x < 128.0; x += 25.0) |
---|
| 469 | { |
---|
| 470 | for( float y = -128.0; y < 128.0; y += 25.0) |
---|
| 471 | { |
---|
| 472 | glColor3f(1,0,0); |
---|
| 473 | glVertex3f(x,y,-128.0); |
---|
| 474 | glVertex3f(x,y,0.0); |
---|
| 475 | glColor3f(0.5,0,0); |
---|
| 476 | glVertex3f(x,y,0.0); |
---|
| 477 | glVertex3f(x,y,128.0); |
---|
| 478 | } |
---|
| 479 | } |
---|
| 480 | for( float y = -128.0; y < 128.0; y += 25.0) |
---|
| 481 | { |
---|
| 482 | for( float z = -128.0; z < 128.0; z += 25.0) |
---|
| 483 | { |
---|
| 484 | glColor3f(0,1,0); |
---|
| 485 | glVertex3f(-128.0,y,z); |
---|
| 486 | glVertex3f(0.0,y,z); |
---|
| 487 | glColor3f(0,0.5,0); |
---|
| 488 | glVertex3f(0.0,y,z); |
---|
| 489 | glVertex3f(128.0,y,z); |
---|
| 490 | } |
---|
| 491 | } |
---|
| 492 | for( float x = -128.0; x < 128.0; x += 25.0) |
---|
| 493 | { |
---|
| 494 | for( float z = -128.0; z < 128.0; z += 25.0) |
---|
| 495 | { |
---|
| 496 | glColor3f(0,0,1); |
---|
| 497 | glVertex3f(x,-128.0,z); |
---|
| 498 | glVertex3f(x,0.0,z); |
---|
| 499 | glColor3f(0,0,0.5); |
---|
| 500 | glVertex3f(x,0.0,z); |
---|
| 501 | glVertex3f(x,128.0,z); |
---|
| 502 | } |
---|
| 503 | |
---|
| 504 | } |
---|
[2792] | 505 | */ |
---|
[3365] | 506 | /* |
---|
| 507 | glBegin(GL_LINE_STRIP); |
---|
| 508 | glColor3f(1.0, 5.0, 1.0); |
---|
| 509 | for( int i = 0; i <= 30; i++) |
---|
| 510 | { |
---|
| 511 | glEvalCoord1f ((GLfloat) i/30.0); |
---|
| 512 | } |
---|
| 513 | glEnd(); |
---|
| 514 | */ |
---|
| 515 | |
---|
| 516 | trackManager->drawGraph(.01); |
---|
| 517 | trackManager->debug(2); |
---|
[3375] | 518 | /* |
---|
[3365] | 519 | glBegin(GL_LINES); |
---|
| 520 | float i; |
---|
| 521 | for(i = 0.0; i<1; i+=.01) |
---|
| 522 | { |
---|
| 523 | printf("%f, %f, %f\n",tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z); |
---|
| 524 | glVertex3f(tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z); |
---|
| 525 | } |
---|
| 526 | glEnd(); |
---|
| 527 | */ |
---|
[2731] | 528 | glEndList(); |
---|
[2636] | 529 | } |
---|
| 530 | |
---|
| 531 | |
---|
| 532 | /** |
---|
[2551] | 533 | \brief checks for collisions |
---|
| 534 | |
---|
| 535 | This method runs through all WorldEntities known to the world and checks for collisions |
---|
| 536 | between them. In case of collisions the collide() method of the corresponding entities |
---|
| 537 | is called. |
---|
[1858] | 538 | */ |
---|
[2190] | 539 | void World::collide () |
---|
[1858] | 540 | { |
---|
[2816] | 541 | /* |
---|
| 542 | List *a, *b; |
---|
[2551] | 543 | WorldEntity *aobj, *bobj; |
---|
[2816] | 544 | |
---|
| 545 | a = entities; |
---|
[2551] | 546 | |
---|
| 547 | while( a != NULL) |
---|
| 548 | { |
---|
[2816] | 549 | aobj = a->nextElement(); |
---|
[2551] | 550 | if( aobj->bCollide && aobj->collisioncluster != NULL) |
---|
[2190] | 551 | { |
---|
[2816] | 552 | b = a->nextElement(); |
---|
[2551] | 553 | while( b != NULL ) |
---|
| 554 | { |
---|
[2816] | 555 | bobj = b->nextElement(); |
---|
[2551] | 556 | if( bobj->bCollide && bobj->collisioncluster != NULL ) |
---|
[2190] | 557 | { |
---|
[2551] | 558 | unsigned long ahitflg, bhitflg; |
---|
| 559 | if( check_collision ( &aobj->place, aobj->collisioncluster, |
---|
| 560 | &ahitflg, &bobj->place, bobj->collisioncluster, |
---|
| 561 | &bhitflg) ); |
---|
| 562 | { |
---|
| 563 | aobj->collide (bobj, ahitflg, bhitflg); |
---|
| 564 | bobj->collide (aobj, bhitflg, ahitflg); |
---|
| 565 | } |
---|
[2190] | 566 | } |
---|
[2816] | 567 | b = b->nextElement(); |
---|
[2551] | 568 | } |
---|
[2190] | 569 | } |
---|
[2816] | 570 | a = a->enumerate(); |
---|
[2551] | 571 | } |
---|
[2816] | 572 | */ |
---|
[1858] | 573 | } |
---|
| 574 | |
---|
| 575 | /** |
---|
[2551] | 576 | \brief runs through all entities calling their draw() methods |
---|
[1931] | 577 | */ |
---|
[2190] | 578 | void World::draw () |
---|
[2077] | 579 | { |
---|
[2551] | 580 | // draw entities |
---|
| 581 | WorldEntity* entity; |
---|
[2822] | 582 | entity = this->entities->enumerate(); |
---|
[2816] | 583 | while( entity != NULL ) |
---|
[2551] | 584 | { |
---|
[2822] | 585 | if( entity->bDraw ) entity->draw(); |
---|
| 586 | entity = this->entities->nextElement(); |
---|
[3365] | 587 | } |
---|
[2551] | 588 | |
---|
[3365] | 589 | //glmis = new GLMenuImageScreen(); |
---|
| 590 | ///glmis->init(); |
---|
| 591 | |
---|
[2551] | 592 | // draw debug coord system |
---|
[2731] | 593 | glCallList (objectList); |
---|
[2551] | 594 | |
---|
[1931] | 595 | } |
---|
| 596 | |
---|
| 597 | /** |
---|
[2551] | 598 | \brief updates Placements and notifies entities when they left the |
---|
| 599 | world |
---|
| 600 | |
---|
| 601 | This runs trough all WorldEntities and maps Locations to Placements |
---|
| 602 | if they are bound, checks whether they left the level boundaries |
---|
| 603 | and calls appropriate functions. |
---|
[1883] | 604 | */ |
---|
[2190] | 605 | void World::update () |
---|
[1883] | 606 | { |
---|
[3365] | 607 | /* |
---|
[2816] | 608 | //List<WorldEntity> *l; |
---|
[2551] | 609 | WorldEntity* entity; |
---|
| 610 | Location* loc; |
---|
| 611 | Placement* plc; |
---|
| 612 | Uint32 t; |
---|
| 613 | |
---|
[2816] | 614 | // l = entities->enumerate(); |
---|
| 615 | entity = this->entities->enumerate(); |
---|
| 616 | while( entity != NULL ) |
---|
[2551] | 617 | { |
---|
[2816] | 618 | |
---|
[2551] | 619 | |
---|
| 620 | if( !entity->isFree() ) |
---|
| 621 | { |
---|
[3233] | 622 | loc = entity->getLocation(); |
---|
| 623 | plc = entity->getPlacement(); |
---|
[2551] | 624 | t = loc->part; |
---|
| 625 | |
---|
[3371] | 626 | if( t >= traclen ) |
---|
[2551] | 627 | { |
---|
| 628 | printf("An entity is out of the game area\n"); |
---|
[3233] | 629 | entity->leftWorld (); |
---|
[2551] | 630 | } |
---|
| 631 | else |
---|
| 632 | { |
---|
[3233] | 633 | while( track[t].mapCoords( loc, plc) ) |
---|
[2190] | 634 | { |
---|
[3233] | 635 | track[t].postLeave (entity); |
---|
[2551] | 636 | if( loc->part >= tracklen ) |
---|
| 637 | { |
---|
| 638 | printf("An entity has left the game area\n"); |
---|
[3233] | 639 | entity->leftWorld (); |
---|
[2551] | 640 | break; |
---|
| 641 | } |
---|
[3233] | 642 | track[loc->part].postEnter (entity); |
---|
[2190] | 643 | } |
---|
[2551] | 644 | } |
---|
[2190] | 645 | } |
---|
[2551] | 646 | else |
---|
| 647 | { |
---|
| 648 | } |
---|
| 649 | |
---|
[2816] | 650 | entity = entities->nextElement(); |
---|
[2551] | 651 | } |
---|
[3365] | 652 | */ |
---|
[1883] | 653 | } |
---|
| 654 | |
---|
[2077] | 655 | /** |
---|
[2551] | 656 | \brief relays the passed time since the last frame to entities and Track parts |
---|
| 657 | \param deltaT: the time passed since the last frame in milliseconds |
---|
[2077] | 658 | */ |
---|
[3225] | 659 | void World::timeSlice (Uint32 deltaT) |
---|
[2077] | 660 | { |
---|
[2816] | 661 | //List<WorldEntity> *l; |
---|
[2551] | 662 | WorldEntity* entity; |
---|
[3175] | 663 | float seconds = deltaT / 1000.0; |
---|
[2551] | 664 | |
---|
[3365] | 665 | this->nullParent->update (seconds); |
---|
| 666 | //this->nullParent->processTick (seconds); |
---|
| 667 | |
---|
[2816] | 668 | entity = entities->enumerate(); |
---|
| 669 | while( entity != NULL) |
---|
[2551] | 670 | { |
---|
| 671 | entity->tick (seconds); |
---|
[2816] | 672 | entity = entities->nextElement(); |
---|
[2551] | 673 | } |
---|
[2816] | 674 | |
---|
[3209] | 675 | //for( int i = 0; i < tracklen; i++) track[i].tick (seconds); |
---|
[2077] | 676 | } |
---|
[1883] | 677 | |
---|
[2190] | 678 | /** |
---|
[2551] | 679 | \brief removes level data from memory |
---|
[1858] | 680 | */ |
---|
[2190] | 681 | void World::unload() |
---|
[1858] | 682 | { |
---|
[1879] | 683 | |
---|
[2636] | 684 | } |
---|
| 685 | |
---|
| 686 | |
---|
[3225] | 687 | /** |
---|
| 688 | \brief function to put your own debug stuff into it. it can display informations about |
---|
| 689 | the current class/procedure |
---|
| 690 | */ |
---|
[2640] | 691 | void World::debug() |
---|
| 692 | { |
---|
[3365] | 693 | printf ("World::debug() - starting debug\n"); |
---|
| 694 | PNode* p1 = NullParent::getInstance (); |
---|
| 695 | PNode* p2 = new PNode (new Vector(2, 2, 2), p1); |
---|
| 696 | PNode* p3 = new PNode (new Vector(4, 4, 4), p1); |
---|
| 697 | PNode* p4 = new PNode (new Vector(6, 6, 6), p2); |
---|
| 698 | |
---|
| 699 | p1->debug (); |
---|
| 700 | p2->debug (); |
---|
| 701 | p3->debug (); |
---|
| 702 | p4->debug (); |
---|
| 703 | |
---|
| 704 | p1->shiftCoor (new Vector(-1, -1, -1)); |
---|
| 705 | |
---|
| 706 | printf("World::debug() - shift\n"); |
---|
| 707 | p1->debug (); |
---|
| 708 | p2->debug (); |
---|
| 709 | p3->debug (); |
---|
| 710 | p4->debug (); |
---|
| 711 | |
---|
| 712 | p1->update (1); |
---|
| 713 | |
---|
| 714 | printf ("World::debug() - update\n"); |
---|
| 715 | p1->debug (); |
---|
| 716 | p2->debug (); |
---|
| 717 | p3->debug (); |
---|
| 718 | p4->debug (); |
---|
| 719 | |
---|
| 720 | p2->shiftCoor (new Vector(-1, -1, -1)); |
---|
| 721 | p1->update (2); |
---|
| 722 | |
---|
| 723 | p1->debug (); |
---|
| 724 | p2->debug (); |
---|
| 725 | p3->debug (); |
---|
| 726 | p4->debug (); |
---|
| 727 | |
---|
| 728 | p2->setAbsCoor (new Vector(1,2,3)); |
---|
| 729 | |
---|
| 730 | |
---|
| 731 | p1->update (2); |
---|
| 732 | |
---|
| 733 | p1->debug (); |
---|
| 734 | p2->debug (); |
---|
| 735 | p3->debug (); |
---|
| 736 | p4->debug (); |
---|
| 737 | |
---|
| 738 | p1->destroy (); |
---|
| 739 | |
---|
| 740 | |
---|
| 741 | /* |
---|
[2640] | 742 | WorldEntity* entity; |
---|
| 743 | printf("counting all entities\n"); |
---|
[2816] | 744 | printf("World::debug() - enumerate()\n"); |
---|
| 745 | entity = entities->enumerate(); |
---|
| 746 | while( entity != NULL ) |
---|
[2640] | 747 | { |
---|
| 748 | if( entity->bDraw ) printf("got an entity\n"); |
---|
[2816] | 749 | entity = entities->nextElement(); |
---|
[2640] | 750 | } |
---|
[3365] | 751 | */ |
---|
[2640] | 752 | } |
---|
[2636] | 753 | |
---|
[2640] | 754 | |
---|
[3225] | 755 | /* |
---|
| 756 | \brief main loop of the world: executing all world relevant function |
---|
| 757 | |
---|
| 758 | in this loop we synchronize (if networked), handle input events, give the heart-beat to |
---|
| 759 | all other member-entities of the world (tick to player, enemies etc.), checking for |
---|
| 760 | collisions drawing everything to the screen. |
---|
| 761 | */ |
---|
[2636] | 762 | void World::mainLoop() |
---|
| 763 | { |
---|
[3365] | 764 | this->lastFrame = SDL_GetTicks (); |
---|
[3220] | 765 | printf("World::mainLoop() - Entering main loop\n"); |
---|
[3215] | 766 | while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */ |
---|
[2551] | 767 | { |
---|
[2636] | 768 | // Network |
---|
[3365] | 769 | this->synchronize (); |
---|
[2636] | 770 | // Process input |
---|
[3365] | 771 | this->handleInput (); |
---|
[3215] | 772 | if( this->bQuitCurrentGame || this->bQuitOrxonox) |
---|
| 773 | { |
---|
| 774 | printf("World::mainLoop() - leaving loop earlier...\n"); |
---|
| 775 | break; |
---|
| 776 | } |
---|
[2636] | 777 | // Process time |
---|
[3365] | 778 | this->timeSlice (); |
---|
[2636] | 779 | // Process collision |
---|
[3365] | 780 | this->collision (); |
---|
[2636] | 781 | // Draw |
---|
[3365] | 782 | this->display (); |
---|
[2816] | 783 | |
---|
[3365] | 784 | for( int i = 0; i < 5000000; i++) {} |
---|
| 785 | /* \todo this is to slow down the program for openGl Software emulator computers, reimplement*/ |
---|
[2551] | 786 | } |
---|
[3215] | 787 | printf("World::mainLoop() - Exiting the main loop\n"); |
---|
[1899] | 788 | } |
---|
| 789 | |
---|
[2190] | 790 | /** |
---|
[2636] | 791 | \brief synchronize local data with remote data |
---|
[1855] | 792 | */ |
---|
[2636] | 793 | void World::synchronize () |
---|
[1855] | 794 | { |
---|
[2636] | 795 | // Get remote input |
---|
| 796 | // Update synchronizables |
---|
[1855] | 797 | } |
---|
[2636] | 798 | |
---|
| 799 | /** |
---|
| 800 | \brief run all input processing |
---|
[3225] | 801 | |
---|
| 802 | the command node is the central input event dispatcher. the node uses the even-queue from |
---|
| 803 | sdl and has its own event-passing-queue. |
---|
[2636] | 804 | */ |
---|
[3225] | 805 | void World::handleInput () |
---|
[2636] | 806 | { |
---|
| 807 | // localinput |
---|
[3225] | 808 | CommandNode* cn = Orxonox::getInstance()->getLocalInput(); |
---|
[3216] | 809 | cn->process(); |
---|
[2636] | 810 | // remoteinput |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | /** |
---|
| 814 | \brief advance the timeline |
---|
[3225] | 815 | |
---|
| 816 | this calculates the time used to process one frame (with all input handling, drawing, etc) |
---|
| 817 | the time is mesured in ms and passed to all world-entities and other classes that need |
---|
| 818 | a heart-beat. |
---|
[2636] | 819 | */ |
---|
[3225] | 820 | void World::timeSlice () |
---|
[2636] | 821 | { |
---|
| 822 | Uint32 currentFrame = SDL_GetTicks(); |
---|
| 823 | if(!this->bPause) |
---|
| 824 | { |
---|
| 825 | Uint32 dt = currentFrame - this->lastFrame; |
---|
[2816] | 826 | |
---|
[2636] | 827 | if(dt > 0) |
---|
| 828 | { |
---|
| 829 | float fps = 1000/dt; |
---|
| 830 | printf("fps = %f\n", fps); |
---|
| 831 | } |
---|
| 832 | else |
---|
| 833 | { |
---|
[3225] | 834 | /* the frame-rate is limited to 100 frames per second, all other things are for |
---|
| 835 | nothing. |
---|
| 836 | */ |
---|
[3194] | 837 | printf("fps = 1000 - frame rate is adjusted\n"); |
---|
| 838 | SDL_Delay(10); |
---|
| 839 | dt = 10; |
---|
[2636] | 840 | } |
---|
[3225] | 841 | this->timeSlice (dt); |
---|
[2636] | 842 | this->update (); |
---|
[3225] | 843 | this->localCamera->timeSlice(dt); |
---|
[3371] | 844 | this->trackManager->tick(dt); |
---|
[2636] | 845 | } |
---|
| 846 | this->lastFrame = currentFrame; |
---|
| 847 | } |
---|
| 848 | |
---|
[3216] | 849 | |
---|
[2636] | 850 | /** |
---|
| 851 | \brief compute collision detection |
---|
| 852 | */ |
---|
| 853 | void World::collision () |
---|
| 854 | { |
---|
| 855 | this->collide (); |
---|
| 856 | } |
---|
| 857 | |
---|
| 858 | |
---|
| 859 | /** |
---|
[3225] | 860 | \brief render the current frame |
---|
| 861 | |
---|
| 862 | clear all buffers and draw the world |
---|
[2636] | 863 | */ |
---|
| 864 | void World::display () |
---|
| 865 | { |
---|
| 866 | // clear buffer |
---|
| 867 | glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); |
---|
| 868 | // set camera |
---|
| 869 | this->localCamera->apply (); |
---|
| 870 | // draw world |
---|
| 871 | this->draw(); |
---|
| 872 | // draw HUD |
---|
[3365] | 873 | /* \todo draw HUD */ |
---|
[2636] | 874 | // flip buffers |
---|
| 875 | SDL_GL_SwapBuffers(); |
---|
[3365] | 876 | //SDL_Surface* screen = Orxonox::getInstance()->getScreen (); |
---|
| 877 | //SDL_Flip (screen); |
---|
[2636] | 878 | } |
---|
| 879 | |
---|
[3225] | 880 | /** |
---|
| 881 | \brief give back active camera |
---|
| 882 | |
---|
| 883 | this passes back the actualy active camera |
---|
| 884 | \todo ability to define more than one camera or camera-places |
---|
| 885 | */ |
---|
[2636] | 886 | Camera* World::getCamera() |
---|
| 887 | { |
---|
| 888 | return this->localCamera; |
---|
| 889 | } |
---|
[2644] | 890 | |
---|
| 891 | |
---|
[3225] | 892 | /** |
---|
| 893 | \brief add and spawn a new entity to this world |
---|
| 894 | \param entity to be added |
---|
| 895 | */ |
---|
[2644] | 896 | void World::spawn(WorldEntity* entity) |
---|
| 897 | { |
---|
[3365] | 898 | if( this->nullParent != NULL && entity->parent == NULL) |
---|
| 899 | this->nullParent->addChild (entity); |
---|
[2816] | 900 | |
---|
[3365] | 901 | this->entities->add (entity); |
---|
| 902 | |
---|
[3233] | 903 | entity->postSpawn (); |
---|
[2816] | 904 | } |
---|
| 905 | |
---|
| 906 | |
---|
[3225] | 907 | /** |
---|
| 908 | \brief add and spawn a new entity to this world |
---|
| 909 | \param entity to be added |
---|
| 910 | \param location where to add |
---|
| 911 | */ |
---|
[3365] | 912 | void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir) |
---|
[2816] | 913 | { |
---|
[3365] | 914 | entity->setAbsCoor (absCoor); |
---|
| 915 | entity->setAbsDir (absDir); |
---|
| 916 | |
---|
| 917 | if( this->nullParent != NULL && entity->parent == NULL) |
---|
| 918 | this->nullParent->addChild (entity); |
---|
| 919 | |
---|
[2816] | 920 | this->entities->add (entity); |
---|
[3365] | 921 | |
---|
[3233] | 922 | entity->postSpawn (); |
---|
[2644] | 923 | } |
---|
[2816] | 924 | |
---|
| 925 | |
---|
[3216] | 926 | |
---|
[3225] | 927 | /* |
---|
| 928 | \brief commands that the world must catch |
---|
| 929 | \returns false if not used by the world |
---|
| 930 | */ |
---|
[3216] | 931 | bool World::command(Command* cmd) |
---|
| 932 | { |
---|
| 933 | return false; |
---|
| 934 | } |
---|
[3365] | 935 | |
---|
| 936 | |
---|
| 937 | |
---|
| 938 | |
---|
| 939 | void World::swap (unsigned char &a, unsigned char &b) |
---|
| 940 | { |
---|
| 941 | unsigned char temp; |
---|
| 942 | temp = a; |
---|
| 943 | a = b; |
---|
| 944 | b = temp; |
---|
| 945 | } |
---|