Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 14, 2005, 9:58:58 AM (19 years ago)
Author:
chris
Message:

orxonox/branches/levelloader: First incarnation of a debugworld loaded from a XML-File in place, compilability in place, all necessary basic loading constuctors in place. Unfortunately the code still generates interferences with the old hardcoded debugworld resulting in SegFault crash.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/levelloader/src/story_entities/world.cc

    r3530 r3542  
    4242        int id;
    4343
     44        PRINTF0("Creating a World\n");
     45       
    4446        // identifier
    4547        string = grabParameter( root, "identifier");
    4648        if( string == NULL || sscanf(string, "%d", &id) != 1)
    4749        {
    48                 PRINTF(1)("World is missing a proper 'identifier'\n");
     50                PRINTF0("World is missing a proper 'identifier'\n");
    4951                this->setStoryID( -1);
    5052        }
     
    5557        if( string == NULL)
    5658        {
    57                 PRINTF(1)("World is missing a proper 'path'\n");
     59                PRINTF0("World is missing a proper 'path'\n");
    5860                this->setPath( NULL);
    5961        }
     
    6567        }
    6668       
    67        
     69        localPlayer = NULL;
     70               
    6871}
    6972
     
    138141ErrorMessage World::load()
    139142{
     143       
     144        PRINTF0("Loading world: '%s'\n", getPath());
     145       
    140146        GameLoader* loader = GameLoader::getInstance();
    141147       
    142148  if( getPath() == NULL)
    143149  {
    144                 PRINTF(1)("World has no path specified for loading");
     150                PRINTF0("World has no path specified for loading");
    145151                return (ErrorMessage){213,"Path not specified","World::load()"};
    146152  }
     
    151157        {
    152158                // 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());
    154160                delete XMLDoc;
    155161                return (ErrorMessage){213,"XML File parsing error","World::load()"};
     
    165171        {
    166172                // 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");
    168174                delete XMLDoc;
    169175                return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
     
    176182        if( string == NULL)
    177183        {
    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;
    180189        }
    181190        else
    182191        {
    183192                temp = new char[strlen(string + 2)];
     193                strcpy( temp, string);
    184194                this->worldName = temp;
    185195        }
     
    191201  if( element == NULL)
    192202  {
    193                 PRINTF(1)("World is missing 'WorldEntities'\n");
     203                PRINTF0("World is missing 'WorldEntities'\n");
    194204  }
    195205  else
     
    201211                        WorldEntity* created = (WorldEntity*) loader->fabricate( element);
    202212                        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;
    203216                        element = element->NextSiblingElement();
    204217                }
     
    209222  if( element == NULL)
    210223  {
    211                 PRINTF(1)("World is missing a 'Track'\n");
     224                PRINTF0("World is missing a 'Track'\n");
    212225  }
    213226  else
     
    216229        trackManager = TrackManager::getInstance();
    217230        trackManager->loadTrack( element);
    218         }
    219  
     231        trackManager->finalize();
     232        }
     233
    220234       
    221235        // free the XML data
    222236        delete XMLDoc;
    223237       
    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       
    231267      /*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();
    281269
    282270            // Create SkySphere
     
    284272
    285273            /*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);
    349277
    350278  // initialize debug coord system
Note: See TracChangeset for help on using the changeset viewer.