Changeset 3542 in orxonox.OLD for orxonox/branches
- Timestamp:
- Mar 14, 2005, 9:58:58 AM (20 years ago)
- Location:
- orxonox/branches/levelloader/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/defs/debug.h
r3530 r3542 27 27 28 28 #include <stdio.h> 29 30 #ifndef DEBUG 31 #define DEBUG 4 32 #endif 29 33 30 34 #define NO 0 -
orxonox/branches/levelloader/src/factory.cc
r3530 r3542 63 63 { 64 64 assert( classname != NULL); 65 PRINTF(3)("Initializing %sFactory\n", classname);66 65 GameLoader* gl = GameLoader::getInstance(); 67 66 gl->registerFactory( this); -
orxonox/branches/levelloader/src/game_loader.cc
r3530 r3542 161 161 if( name == NULL) 162 162 { 163 PRINTF (1)("No filename specified for loading");163 PRINTF0("No filename specified for loading"); 164 164 return NULL; 165 165 } … … 170 170 { 171 171 // report an error 172 PRINTF (1)("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());172 PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 173 173 delete XMLDoc; 174 174 return NULL; … … 176 176 177 177 // check basic validity 178 TiXmlElement* element = XMLDoc->RootElement(); 179 assert( element != NULL); 180 181 element = element->FirstChildElement( "Campaign"); 182 183 if( element == NULL ) 178 TiXmlElement* root = XMLDoc->RootElement(); 179 assert( root != NULL); 180 181 if( strcmp( root->Value(), "Campaign")) 184 182 { 185 183 // report an error 186 PRINTF (1)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");184 PRINTF0("Specified XML File is not an orxonox campaign file (Campaign element missing)\n"); 187 185 delete XMLDoc; 188 186 return NULL; … … 190 188 191 189 // construct campaign 192 Campaign* c = new Campaign( element);190 Campaign* c = new Campaign( root); 193 191 194 192 // free the XML data … … 272 270 assert( factory != NULL); 273 271 274 printf("Registered factory for '%s'\n", factory->getClassname());272 PRINTF0("Registered factory for '%s'\n", factory->getClassname()); 275 273 276 274 if( first == NULL) first = factory; … … 286 284 if( first == NULL) 287 285 { 288 PRINTF (1)("GameLoader does not know any factories, fabricate() failed\n");286 PRINTF0("GameLoader does not know any factories, fabricate() failed\n"); 289 287 return NULL; 290 288 } -
orxonox/branches/levelloader/src/lib/graphics/importer/objModel.cc
r3499 r3542 24 24 \param fileName file to parse and load (must be a .obj file) 25 25 */ 26 OBJModel::OBJModel(c har* fileName)26 OBJModel::OBJModel(const char* fileName) 27 27 { 28 28 this->initializeOBJ(); … … 40 40 \param scaling The factor that the model will be scaled with. 41 41 */ 42 OBJModel::OBJModel(c har* fileName, float scaling)42 OBJModel::OBJModel(const char* fileName, float scaling) 43 43 { 44 44 this->initializeOBJ(); … … 84 84 \param fileName The file to import 85 85 */ 86 bool OBJModel::importFile (c har* fileName)86 bool OBJModel::importFile (const char* fileName) 87 87 { 88 88 PRINTF(3)("preparing to read in file: %s\n", fileName); … … 96 96 char pathSplitter='/'; 97 97 #endif /* __WIN32__ */ 98 c har* tmpName = fileName;98 const char* tmpName = fileName; 99 99 if (tmpName[0] == pathSplitter) 100 100 tmpName++; 101 c har* name = tmpName;101 const char* name = tmpName; 102 102 while (( tmpName = strchr (tmpName+1, pathSplitter))) 103 103 { … … 212 212 213 213 */ 214 bool OBJModel::readMtlLib (c har* mtlFile)214 bool OBJModel::readMtlLib (const char* mtlFile) 215 215 { 216 216 this->mtlFileName = new char [strlen(mtlFile)+1]; -
orxonox/branches/levelloader/src/lib/graphics/importer/objModel.h
r3499 r3542 13 13 { 14 14 public: 15 OBJModel(c har* fileName);16 OBJModel(c har* fileName, float scaling);15 OBJModel(const char* fileName); 16 OBJModel(const char* fileName, float scaling); 17 17 virtual ~OBJModel(); 18 18 void initializeOBJ(void); … … 25 25 26 26 ///// readin ///// 27 bool importFile (c har* fileName);27 bool importFile (const char* fileName); 28 28 bool readFromObjFile (void); 29 bool readMtlLib (c har* matFile);29 bool readMtlLib (const char* matFile); 30 30 31 31 }; -
orxonox/branches/levelloader/src/orxonox.cc
r3499 r3542 251 251 252 252 this->gameLoader = GameLoader::getInstance(); 253 this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0); 253 this->gameLoader->loadCampaign("../data/worlds/DefaultCampaign.oxc"); 254 //this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0); 254 255 this->gameLoader->init(); 255 256 this->gameLoader->start(); -
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 -
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.