Changeset 3542 in orxonox.OLD for orxonox/branches/levelloader/src/world_entities
- Timestamp:
- Mar 14, 2005, 9:58:58 AM (20 years ago)
- Location:
- orxonox/branches/levelloader/src/world_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/world_entities/environment.cc
r3499 r3542 26 26 27 27 28 CREATE_FACTORY(Environment); 28 29 29 30 Environment::Environment () : WorldEntity() … … 32 33 } 33 34 34 35 Environment::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 } 35 100 36 101 Environment::~Environment () -
orxonox/branches/levelloader/src/world_entities/environment.h
r3499 r3542 18 18 public: 19 19 Environment (); 20 Environment (TiXmlElement* root); 20 21 ~Environment (); 21 22 -
orxonox/branches/levelloader/src/world_entities/player.cc
r3499 r3542 22 22 23 23 using namespace std; 24 25 CREATE_FACTORY(Player); 24 26 25 27 /** … … 59 61 60 62 /** 63 \brief creates a new Player from Xml Data 64 \param root the xml element containing player data 65 66 \todo add more parameters to load 67 */ 68 Player::Player(TiXmlElement* root) 69 { 70 char* temp; 71 const char* string; 72 string = grabParameter( root, "name"); 73 if( string == NULL) 74 { 75 PRINTF(1)("Player is missing a proper 'name'\n"); 76 string = "Unknown"; 77 temp = new char[strlen(string + 2)]; 78 strcpy( temp, string); 79 this->setName( temp); 80 } 81 else 82 { 83 temp = new char[strlen(string + 2)]; 84 strcpy( temp, string); 85 this->setName( temp); 86 } 87 88 this->model = NULL; 89 string = grabParameter( root, "model"); 90 if( string != NULL) 91 this->model = new OBJModel( string); 92 else 93 { 94 PRINTF(1)("Player is missing a proper 'model'\n"); 95 this->model = new OBJModel( "../data/models/reaplow.obj"); 96 } 97 if( this->model == NULL) 98 { 99 PRINTF(1)("Player model '%s' could not be loaded\n", string); 100 } 101 } 102 103 /** 61 104 \brief destructs the player 62 105 */ -
orxonox/branches/levelloader/src/world_entities/player.h
r3499 r3542 18 18 public: 19 19 Player(bool isFree = false); 20 Player(TiXmlElement* root); 20 21 ~Player(); 21 22
Note: See TracChangeset
for help on using the changeset viewer.