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/world_entities/environment.cc

    r3499 r3542  
    2626
    2727
     28CREATE_FACTORY(Environment);
    2829
    2930Environment::Environment () : WorldEntity()
     
    3233}
    3334
    34 
     35Environment::Environment ( TiXmlElement* root)
     36{
     37        char* temp;
     38        const char* string = grabParameter( root, "name");
     39        if( string == NULL)
     40        {
     41                PRINTF(1)("Environment is missing a proper 'name'\n");
     42                string = "Unknown";
     43                temp = new char[strlen(string + 2)];
     44                strcpy( temp, string);
     45                this->setName( temp);
     46        }
     47        else
     48        {
     49                temp = new char[strlen(string + 2)];
     50                strcpy( temp, string);
     51                this->setName( temp);
     52        }
     53       
     54        this->model = NULL;
     55        string = grabParameter( root, "model");
     56        if( string != NULL)
     57                this->model = new OBJModel( string);
     58        else
     59        {
     60                PRINTF(1)("Environment is missing a proper 'model'\n");
     61                this->model = new OBJModel( "../data/models/reaplow.obj");
     62        }
     63        if( this->model == NULL)
     64        {
     65                PRINTF(1)("Environment model '%s' could not be loaded\n", string);
     66        }
     67       
     68        double buff[3];
     69       
     70        string = grabParameter( root, "position");
     71        if( string != NULL && sscanf( string, "%f,%f,%f", &(buff[0]), &(buff[1]), &(buff[2])) == 3)
     72        {
     73                Vector* es = new Vector( buff[0], buff[1], buff[2]);
     74                this->setAbsCoor(es);
     75                delete es;
     76        }
     77        else
     78        {
     79                PRINTF(1)("Environment is missing a proper 'position'\n");
     80                Vector* es = new Vector();
     81                this->setAbsCoor(es);
     82                delete es;
     83        }
     84       
     85        string = grabParameter( root, "orientation");
     86        if( string != NULL && sscanf( string, "%f,%f,%f", &(buff[0]), &(buff[1]), &(buff[2])) == 3)
     87        {
     88                Quaternion* qs = new Quaternion( buff[0], buff[1], buff[2]);
     89                this->setAbsDir(qs);
     90                delete qs;
     91        }
     92        else
     93        {
     94                PRINTF(1)("Environment is missing a proper 'orientation'\n");
     95        Quaternion* qs = new Quaternion ();
     96                this->setAbsDir(qs);
     97                delete qs;
     98        }
     99}
    35100
    36101Environment::~Environment ()
Note: See TracChangeset for help on using the changeset viewer.