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