Changeset 3834 in orxonox.OLD for orxonox/branches/levelloader/src
- Timestamp:
- Apr 15, 2005, 3:15:36 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/story_entities/world.cc
r3753 r3834 220 220 this->setClassName ("World"); 221 221 222 this->worldName = name; 222 //this->worldName = name; 223 //this->worldName = new char[strlen(name)+1]; 224 //strcpy(this->worldName, name); 223 225 this->debugWorldNr = worldID; 224 226 this->entities = new tList<WorldEntity>(); … … 247 249 ErrorMessage World::load() 248 250 { 249 250 251 252 251 PRINTF0("> Loading world: '%s'\n", getPath()); 252 253 GameLoader* loader = GameLoader::getInstance(); 254 253 255 if( getPath() == NULL) 256 { 257 PRINTF0("World has no path specified for loading"); 258 return (ErrorMessage){213,"Path not specified","World::load()"}; 259 } 260 261 TiXmlDocument* XMLDoc = new TiXmlDocument( path); 262 // load the campaign document 263 if( !XMLDoc->LoadFile()) 264 //this->glmis->step(); 265 254 266 { 255 PRINTF0("World has no path specified for loading"); 256 return (ErrorMessage){213,"Path not specified","World::load()"}; 267 // report an error 268 PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 269 delete XMLDoc; 270 return (ErrorMessage){213,"XML File parsing error","World::load()"}; 257 271 } 258 272 259 TiXmlDocument* XMLDoc = new TiXmlDocument( path); 260 // load the campaign document 261 if( !XMLDoc->LoadFile()) 262 this->glmis->step(); 263 273 // check basic validity 274 TiXmlElement* root = XMLDoc->RootElement(); 275 assert( root != NULL); 276 277 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile")) 278 { 279 // report an error 280 PRINTF0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 281 delete XMLDoc; 282 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; 283 } 284 285 // load the parameters 286 // name 287 char* temp; 288 const char* string = grabParameter( root, "name"); 289 if( string == NULL) 290 { 291 PRINTF0("World is missing a proper 'name'\n"); 292 string = "Unknown"; 293 temp = new char[strlen(string + 2)]; 294 strcpy( temp, string); 295 this->worldName = temp; 296 } 297 else 298 { 299 temp = new char[strlen(string + 2)]; 300 strcpy( temp, string); 301 this->worldName = temp; 302 } 303 304 305 // find WorldEntities 306 TiXmlElement* element = root->FirstChildElement( "WorldEntities"); 307 308 if( element == NULL) 309 { 310 PRINTF0("World is missing 'WorldEntities'\n"); 311 } 312 else 313 { 314 element = element->FirstChildElement(); 315 // load Players/Objects/Whatever 316 PRINTF0("Loading WorldEntities\n"); 317 while( element != NULL) 264 318 { 265 // report an error 266 PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 267 delete XMLDoc; 268 return (ErrorMessage){213,"XML File parsing error","World::load()"}; 319 WorldEntity* created = (WorldEntity*) loader->fabricate( element); 320 if( created != NULL) this->spawn( created); 321 // if we load a 'Player' we use it as localPlayer 322 //todo do this more elegant 323 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created; 324 element = element->NextSiblingElement(); 269 325 } 270 271 // check basic validity 272 TiXmlElement* root = XMLDoc->RootElement(); 273 assert( root != NULL); 274 275 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile")) 276 { 277 // report an error 278 PRINTF0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 279 delete XMLDoc; 280 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; 281 } 282 283 // load the parameters 284 // name 285 char* temp; 286 const char* string = grabParameter( root, "name"); 287 if( string == NULL) 288 { 289 PRINTF0("World is missing a proper 'name'\n"); 290 string = "Unknown"; 291 temp = new char[strlen(string + 2)]; 292 strcpy( temp, string); 293 this->worldName = temp; 294 } 295 else 296 { 297 temp = new char[strlen(string + 2)]; 298 strcpy( temp, string); 299 this->worldName = temp; 300 } 301 302 303 // find WorldEntities 304 TiXmlElement* element = root->FirstChildElement( "WorldEntities"); 305 306 if( element == NULL) 307 { 308 PRINTF0("World is missing 'WorldEntities'\n"); 309 } 310 else 311 { 312 element = element->FirstChildElement(); 313 // load Players/Objects/Whatever 314 PRINTF0("Loading WorldEntities\n"); 315 while( element != NULL) 316 { 317 WorldEntity* created = (WorldEntity*) loader->fabricate( element); 318 if( created != NULL) this->spawn( created); 319 // if we load a 'Player' we use it as localPlayer 320 //todo do this more elegant 321 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created; 322 element = element->NextSiblingElement(); 323 } 324 PRINTF0("Done loading WorldEntities\n"); 325 } 326 327 // find Track 326 PRINTF0("Done loading WorldEntities\n"); 327 } 328 329 // find Track 328 330 element = root->FirstChildElement( "Track"); 329 331 if( element == NULL) 330 {331 PRINTF0("World is missing a 'Track'\n");332 }332 { 333 PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n"); 334 } 333 335 else 334 {335 336 PRINTF0("Loading Track\n");337 338 339 340 PRINTF0("Done loading Track\n");341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 336 { 337 //load track 338 PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n"); 339 trackManager = TrackManager::getInstance(); 340 trackManager->loadTrack( element); 341 trackManager->finalize(); 342 PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n"); 343 } 344 345 // free the XML data 346 delete XMLDoc; 347 348 // finalize world 349 // initialize Font 350 testFont = new FontSet(); 351 testFont->buildFont("../data/pictures/font.tga"); 352 353 // create null parent 354 this->nullParent = NullParent::getInstance (); 355 this->nullParent->setName ("NullParent"); 356 357 // finalize myPlayer 358 if( localPlayer == NULL) 359 { 360 PRINTF0("No Player specified in World '%s'\n", this->worldName); 361 return (ErrorMessage){213,"No Player defined","World::load()"}; 362 } 363 364 // bind input 365 Orxonox *orx = Orxonox::getInstance (); 366 orx->getLocalInput()->bind (localPlayer); 367 368 // bind camera 369 this->localCamera = new Camera(); 370 this->localCamera->setName ("camera"); 371 //this->localCamera->bind (localPlayer); 372 this->localPlayer->addChild (this->localCamera); 373 374 375 // stuff beyond this point remains to be loaded properly 376 377 /*monitor progress*/ 376 378 // this->glmis->step(); 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 379 380 // LIGHT initialisation 381 lightMan = LightManager::getInstance(); 382 lightMan->setAmbientColor(.1,.1,.1); 383 lightMan->addLight(); 384 // lightMan->setAttenuation(1.0, .01, 0.0); 385 // lightMan->setDiffuseColor(1,1,1); 386 // lightMan->addLight(1); 387 // lightMan->setPosition(20, 10, -20); 388 // lightMan->setDiffuseColor(0,0,0); 389 lightMan->debug(); 390 lightMan->setPosition(-5.0, 10.0, -40.0); 391 392 393 // Create SkySphere 394 this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg"); 395 this->skySphere->setName("SkySphere"); 396 this->localCamera->addChild(this->skySphere); 397 this->skySphere->setMode(PNODE_MOVEMENT); 398 399 400 // trackManager->setBindSlave(env); 401 PNode* tn = trackManager->getTrackNode(); 402 tn->addChild(this->localPlayer); 403 404 //localCamera->setParent(TrackNode::getInstance()); 405 tn->addChild(this->localCamera); 406 // localCamera->lookAt(tn); 407 this->localPlayer->setMode(PNODE_ALL); 408 //Vector* cameraOffset = new Vector (0, 5, -10); 409 //trackManager->condition(2, LEFTRIGHT, this->localPlayer); 410 409 411 // initialize debug coord system 410 412 objectList = glGenLists(1); 411 413 glNewList (objectList, GL_COMPILE); 412 414 413 415 trackManager->drawGraph(.01); 414 416 trackManager->debug(2); … … 697 699 this->tick (); 698 700 // Update the state 699 this->update (); 701 this->update (); 700 702 // Process collision 701 703 this->collide ();
Note: See TracChangeset
for help on using the changeset viewer.