Changeset 3542 in orxonox.OLD for orxonox/branches/levelloader/src/story_entities
- Timestamp:
- Mar 14, 2005, 9:58:58 AM (20 years ago)
- Location:
- orxonox/branches/levelloader/src/story_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/story_entities/campaign.cc
r3530 r3542 56 56 } 57 57 else this->setStoryID( id); 58 58 59 59 // find WorldList 60 60 element = root->FirstChildElement( "WorldList"); 61 61 62 62 // load Worlds/Subcampaigns/Whatever 63 StoryEntity* lastCreated = NULL; 63 64 while( element != NULL) 64 65 { 65 66 StoryEntity* created = (StoryEntity*) loader->fabricate( element); 66 if( created != NULL) addEntity( created); 67 if( lastCreated != NULL) created->setNextStoryID( lastCreated->getStoryID()); 68 if( created != NULL) 69 { 70 this->addEntity( created); 71 lastCreated = created; 72 } 67 73 element = element->NextSiblingElement(); 68 74 } 75 if( lastCreated != NULL) lastCreated->setStoryID( WORLD_ID_GAMEEND); 69 76 } 70 77 -
orxonox/branches/levelloader/src/story_entities/world.cc
r3530 r3542 42 42 int id; 43 43 44 PRINTF0("Creating a World\n"); 45 44 46 // identifier 45 47 string = grabParameter( root, "identifier"); 46 48 if( string == NULL || sscanf(string, "%d", &id) != 1) 47 49 { 48 PRINTF (1)("World is missing a proper 'identifier'\n");50 PRINTF0("World is missing a proper 'identifier'\n"); 49 51 this->setStoryID( -1); 50 52 } … … 55 57 if( string == NULL) 56 58 { 57 PRINTF (1)("World is missing a proper 'path'\n");59 PRINTF0("World is missing a proper 'path'\n"); 58 60 this->setPath( NULL); 59 61 } … … 65 67 } 66 68 67 69 localPlayer = NULL; 70 68 71 } 69 72 … … 138 141 ErrorMessage World::load() 139 142 { 143 144 PRINTF0("Loading world: '%s'\n", getPath()); 145 140 146 GameLoader* loader = GameLoader::getInstance(); 141 147 142 148 if( getPath() == NULL) 143 149 { 144 PRINTF (1)("World has no path specified for loading");150 PRINTF0("World has no path specified for loading"); 145 151 return (ErrorMessage){213,"Path not specified","World::load()"}; 146 152 } … … 151 157 { 152 158 // report an error 153 PRINTF (1)("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());159 PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 154 160 delete XMLDoc; 155 161 return (ErrorMessage){213,"XML File parsing error","World::load()"}; … … 165 171 { 166 172 // report an error 167 PRINTF (1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");173 PRINTF0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 168 174 delete XMLDoc; 169 175 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; … … 176 182 if( string == NULL) 177 183 { 178 PRINTF(1)("World is missing a proper 'name'\n"); 179 this->setStoryID( -1); 184 PRINTF0("World is missing a proper 'name'\n"); 185 string = "Unknown"; 186 temp = new char[strlen(string + 2)]; 187 strcpy( temp, string); 188 this->worldName = temp; 180 189 } 181 190 else 182 191 { 183 192 temp = new char[strlen(string + 2)]; 193 strcpy( temp, string); 184 194 this->worldName = temp; 185 195 } … … 191 201 if( element == NULL) 192 202 { 193 PRINTF (1)("World is missing 'WorldEntities'\n");203 PRINTF0("World is missing 'WorldEntities'\n"); 194 204 } 195 205 else … … 201 211 WorldEntity* created = (WorldEntity*) loader->fabricate( element); 202 212 if( created != NULL) spawn( created); 213 assert( element->Value() != NULL); 214 // if we load a 'Player' we use it as localPlayer 215 if( !strcmp( element->Value(), "Player")) localPlayer = (Player*) created; 203 216 element = element->NextSiblingElement(); 204 217 } … … 209 222 if( element == NULL) 210 223 { 211 PRINTF (1)("World is missing a 'Track'\n");224 PRINTF0("World is missing a 'Track'\n"); 212 225 } 213 226 else … … 216 229 trackManager = TrackManager::getInstance(); 217 230 trackManager->loadTrack( element); 218 } 219 231 trackManager->finalize(); 232 } 233 220 234 221 235 // free the XML data 222 236 delete XMLDoc; 223 237 224 // BezierCurve* tmpCurve = new BezierCurve(); 225 if(this->debugWorldNr != -1) 226 { 227 // initializing Font 228 testFont = new FontSet(); 229 testFont->buildFont("../data/pictures/font.tga"); 230 238 // finalize world 239 // initialize Font 240 testFont = new FontSet(); 241 testFont->buildFont("../data/pictures/font.tga"); 242 243 // create null parent 244 this->nullParent = NullParent::getInstance (); 245 this->nullParent->setName ("NullParent"); 246 247 // finalize myPlayer 248 if( localPlayer == NULL) 249 { 250 PRINTF0("No Player specified in World '%s'\n", this->worldName); 251 return (ErrorMessage){213,"No Player defined","World::load()"}; 252 } 253 254 // bind input 255 Orxonox *orx = Orxonox::getInstance (); 256 orx->getLocalInput()->bind (localPlayer); 257 258 // bind camera 259 this->localCamera = new Camera(this); 260 this->localCamera->setName ("camera"); 261 this->localCamera->bind (localPlayer); 262 this->localPlayer->addChild (this->localCamera); 263 264 265 // stuff beyond this point remains to be loaded properly 266 231 267 /*monitor progress*/ 232 this->glmis->step(); 233 234 /* 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(); 244 */ 245 switch(this->debugWorldNr) 246 { 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 */ 253 case DEBUG_WORLD_0: 254 { 255 this->nullParent = NullParent::getInstance (); 256 this->nullParent->setName ("NullParent"); 257 258 // !\todo old track-system has to be removed 259 260 //create helper for player 261 HelperParent* hp = new HelperParent (); 262 /* the player has to be added to this helper */ 263 264 // create a player 265 WorldEntity* myPlayer = new Player (); 266 myPlayer->setName ("player"); 267 this->spawn (myPlayer); 268 this->localPlayer = myPlayer; 269 /*monitor progress*/ 270 this->glmis->step(); 271 272 // bind input 273 Orxonox *orx = Orxonox::getInstance (); 274 orx->getLocalInput()->bind (myPlayer); 275 276 // bind camera 277 this->localCamera = new Camera(this); 278 this->localCamera->setName ("camera"); 279 this->localCamera->bind (myPlayer); 280 this->localPlayer->addChild (this->localCamera); 268 // this->glmis->step(); 281 269 282 270 // Create SkySphere … … 284 272 285 273 /*monitor progress*/ 286 this->glmis->step(); 287 288 Vector* es = new Vector (50, 2, 0); 289 Quaternion* qs = new Quaternion (); 290 WorldEntity* env = new Environment(); 291 env->setName ("env"); 292 this->spawn(env, es, qs); 293 294 /*monitor progress*/ 295 this->glmis->step(); 296 297 trackManager->setBindSlave(env); 298 299 break; 300 } 301 case DEBUG_WORLD_1: 302 { 303 /* 304 this->testCurve = new UPointCurve(); 305 this->testCurve->addNode(Vector( 0, 0, 0)); 306 this->testCurve->addNode(Vector(10, 0, 5)); 307 this->testCurve->addNode(Vector(20, -5,-5)); 308 this->testCurve->addNode(Vector(30, 5, 10)); 309 this->testCurve->addNode(Vector(40, 0,-10)); 310 this->testCurve->addNode(Vector(50, 0,-10)); 311 */ 312 313 this->nullParent = NullParent::getInstance (); 314 this->nullParent->setName ("NullParent"); 315 316 317 318 // create a player 319 WorldEntity* myPlayer = new Player(); 320 myPlayer->setName ("player"); 321 this->spawn(myPlayer); 322 this->localPlayer = myPlayer; 323 324 // bind input 325 Orxonox *orx = Orxonox::getInstance(); 326 orx->getLocalInput()->bind (myPlayer); 327 328 // bind camera 329 this->localCamera = new Camera (this); 330 this->localCamera->setName ("camera"); 331 this->localCamera->bind (myPlayer); 332 this->localPlayer->addChild (this->localCamera); 333 334 // Create SkySphere 335 skySphere = new Skysphere("../data/pictures/sky-replace.jpg"); 336 337 break; 338 339 340 } 341 default: 342 printf("World::load() - no world with ID %i found", this->debugWorldNr ); 343 } 344 } 345 else if(this->worldName != NULL) 346 { 347 348 } 274 // this->glmis->step(); 275 276 // trackManager->setBindSlave(env); 349 277 350 278 // initialize debug coord system
Note: See TracChangeset
for help on using the changeset viewer.