Changeset 4220 in orxonox.OLD for orxonox/trunk
- Timestamp:
- May 18, 2005, 11:01:59 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/Makefile.am
r4143 r4220 81 81 lib/lang/base_object.cc \ 82 82 lib/util/ini_parser.cc \ 83 lib/util/substring.cc \ 83 84 util/common/list.cc \ 84 85 util/resource_manager.cc \ … … 150 151 util/resource_manager.h \ 151 152 lib/util/ini_parser.h \ 153 lib/util/substring.h \ 152 154 lib/math/vector.h \ 153 155 lib/math/curve.h \ -
orxonox/trunk/src/Makefile.in
r4145 r4220 87 87 particle_system.$(OBJEXT) particle_emitter.$(OBJEXT) \ 88 88 base_entity.$(OBJEXT) base_object.$(OBJEXT) \ 89 ini_parser.$(OBJEXT) list.$(OBJEXT) resource_manager.$(OBJEXT) \ 90 vector.$(OBJEXT) curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT) \ 91 tinyxml.$(OBJEXT) tinystr.$(OBJEXT) tinyxmlerror.$(OBJEXT) \ 89 ini_parser.$(OBJEXT) substring.$(OBJEXT) list.$(OBJEXT) \ 90 resource_manager.$(OBJEXT) vector.$(OBJEXT) curve.$(OBJEXT) \ 91 glmenu_imagescreen.$(OBJEXT) tinyxml.$(OBJEXT) \ 92 tinystr.$(OBJEXT) tinyxmlerror.$(OBJEXT) \ 92 93 tinyxmlparser.$(OBJEXT) benchmark.$(OBJEXT) 93 94 orxonox_OBJECTS = $(am_orxonox_OBJECTS) … … 136 137 @AMDEP_TRUE@ ./$(DEPDIR)/satellite.Po ./$(DEPDIR)/skybox.Po \ 137 138 @AMDEP_TRUE@ ./$(DEPDIR)/skysphere.Po \ 138 @AMDEP_TRUE@ ./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/terrain.Po \ 139 @AMDEP_TRUE@ ./$(DEPDIR)/story_entity.Po \ 140 @AMDEP_TRUE@ ./$(DEPDIR)/substring.Po ./$(DEPDIR)/terrain.Po \ 139 141 @AMDEP_TRUE@ ./$(DEPDIR)/test_bullet.Po ./$(DEPDIR)/test_gun.Po \ 140 142 @AMDEP_TRUE@ ./$(DEPDIR)/text_engine.Po ./$(DEPDIR)/texture.Po \ … … 324 326 lib/lang/base_object.cc \ 325 327 lib/util/ini_parser.cc \ 328 lib/util/substring.cc \ 326 329 util/common/list.cc \ 327 330 util/resource_manager.cc \ … … 393 396 util/resource_manager.h \ 394 397 lib/util/ini_parser.h \ 398 lib/util/substring.h \ 395 399 lib/math/vector.h \ 396 400 lib/math/curve.h \ … … 558 562 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/skysphere.Po@am__quote@ 559 563 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/story_entity.Po@am__quote@ 564 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/substring.Po@am__quote@ 560 565 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/terrain.Po@am__quote@ 561 566 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_bullet.Po@am__quote@ … … 1373 1378 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1374 1379 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ini_parser.obj `if test -f 'lib/util/ini_parser.cc'; then $(CYGPATH_W) 'lib/util/ini_parser.cc'; else $(CYGPATH_W) '$(srcdir)/lib/util/ini_parser.cc'; fi` 1380 1381 substring.o: lib/util/substring.cc 1382 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT substring.o -MD -MP -MF "$(DEPDIR)/substring.Tpo" -c -o substring.o `test -f 'lib/util/substring.cc' || echo '$(srcdir)/'`lib/util/substring.cc; \ 1383 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/substring.Tpo" "$(DEPDIR)/substring.Po"; else rm -f "$(DEPDIR)/substring.Tpo"; exit 1; fi 1384 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='lib/util/substring.cc' object='substring.o' libtool=no @AMDEPBACKSLASH@ 1385 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/substring.Po' tmpdepfile='$(DEPDIR)/substring.TPo' @AMDEPBACKSLASH@ 1386 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1387 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o substring.o `test -f 'lib/util/substring.cc' || echo '$(srcdir)/'`lib/util/substring.cc 1388 1389 substring.obj: lib/util/substring.cc 1390 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT substring.obj -MD -MP -MF "$(DEPDIR)/substring.Tpo" -c -o substring.obj `if test -f 'lib/util/substring.cc'; then $(CYGPATH_W) 'lib/util/substring.cc'; else $(CYGPATH_W) '$(srcdir)/lib/util/substring.cc'; fi`; \ 1391 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/substring.Tpo" "$(DEPDIR)/substring.Po"; else rm -f "$(DEPDIR)/substring.Tpo"; exit 1; fi 1392 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='lib/util/substring.cc' object='substring.obj' libtool=no @AMDEPBACKSLASH@ 1393 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/substring.Po' tmpdepfile='$(DEPDIR)/substring.TPo' @AMDEPBACKSLASH@ 1394 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1395 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o substring.obj `if test -f 'lib/util/substring.cc'; then $(CYGPATH_W) 'lib/util/substring.cc'; else $(CYGPATH_W) '$(srcdir)/lib/util/substring.cc'; fi` 1375 1396 1376 1397 list.o: util/common/list.cc -
orxonox/trunk/src/lib/util/substring.cc
r4010 r4220 22 22 #include "substring.h" 23 23 24 #include <string.h> 25 #include <assert.h> 26 24 27 SubString::SubString( const char* string) 25 28 { 26 29 n = 0; 27 30 28 31 assert( string != NULL); 29 32 30 33 for( int i = 0; i < strlen(string); i++) if( string[i] == ',') n++; 31 34 32 35 n += 1; 33 36 34 strings = new char*[n]; 37 strings = new char*[n]; 38 39 assert (strings != NULL); 35 40 36 assert( strings != NULL); 41 int i = 0; 42 int l = 0; 37 43 38 int i = 0; 39 int l = 0; 44 const char* offset = string; 45 char* end = strchr( string, ','); 46 while( end != NULL) 47 { 48 assert( i < n); 49 l = end - offset; 50 strings[i] = new char[l + 1]; 51 assert( strings[i] != NULL); 52 strncpy( strings[i], offset, l); 53 strings[i][l] = 0; 54 i++; 55 end++; 56 offset = end; 57 end = strchr( offset, ','); 58 } 40 59 41 const char* offset = string; 42 char* end = strchr( string, ','); 43 while( end != NULL) 44 { 45 assert( i < n); 46 l = end - offset; 47 strings[i] = new char[l + 1]; 48 assert( strings[i] != NULL); 49 strncpy( strings[i], offset, l); 50 strings[i][l] = 0; 51 i++; 52 end++; 53 offset = end; 54 end = strchr( offset, ','); 55 } 56 57 strings[i] = new char[l + 1]; 58 l = strlen( offset); 59 strncpy( strings[i], offset, l); 60 strings[i][l] = 0; 60 strings[i] = new char[l + 1]; 61 l = strlen( offset); 62 strncpy( strings[i], offset, l); 63 strings[i][l] = 0; 61 64 } 62 65 … … 66 69 SubString::~SubString() 67 70 { 68 69 70 71 71 for( int i = 0; i < n; i++) 72 { 73 delete strings[i]; 74 } 72 75 73 76 delete strings; 74 77 } 75 78 … … 78 81 \returns the amount of substrings 79 82 */ 80 int SubString::get N()83 int SubString::getCount() 81 84 { 82 85 return n; 83 86 } 84 87 … … 90 93 const char* SubString::getString( int i) 91 94 { 92 93 95 if( i < n && i >= 0) return strings[i]; 96 else return NULL; 94 97 } -
orxonox/trunk/src/lib/util/substring.h
r4010 r4220 1 1 /*! 2 3 2 \file substring.h 3 \brief a small class to get the parts of a string separated by commas 4 4 */ 5 5 … … 7 7 #define _SUBSTRING_H 8 8 9 #include "stdincl.h"10 11 9 class SubString 12 10 { 13 11 public: 14 12 15 16 13 SubString( const char* string); 14 ~SubString(); 17 15 18 int getN();19 16 int getCount(); 17 const char* getString( int i); 20 18 21 22 23 19 private: 20 char** strings; 21 int n; 24 22 }; 25 23 -
orxonox/trunk/src/story_entities/world.cc
r4176 r4220 399 399 trackManager->addPoint(Vector(250, -35, 5)); 400 400 trackManager->addPoint(Vector(320,-33,-.55)); 401 trackManager->setDuration( 2);401 trackManager->setDuration(1); 402 402 trackManager->setSavePoint(); 403 403 … … 406 406 trackManager->addPoint(Vector(550, 20, -10)); 407 407 trackManager->addPoint(Vector(570, 20, -10)); 408 trackManager->setDuration( 5);408 trackManager->setDuration(2); 409 409 410 int fork11, fork12; 411 trackManager->fork(2, &fork11, &fork12); 412 trackManager->workOn(fork11); 410 trackManager->forkS("testFork1,testFork2"); 411 trackManager->workOn("testFork1"); 413 412 trackManager->addPoint(Vector(640, 25, -30)); 414 413 trackManager->addPoint(Vector(700, 40, -120)); … … 419 418 trackManager->addPoint(Vector(1050, 65, -10)); 420 419 trackManager->addPoint(Vector(1100, 65, -20)); 421 trackManager->setDuration( 10);422 423 trackManager->workOn( fork12);420 trackManager->setDuration(4); 421 422 trackManager->workOn("testFork2"); 424 423 trackManager->addPoint(Vector(640, 25, 20)); 425 424 trackManager->addPoint(Vector(670, 50, 120)); … … 431 430 trackManager->addPoint(Vector(970, 24, 40)); 432 431 trackManager->addPoint(Vector(1000, 40, -7)); 433 trackManager->setDuration( 10);432 trackManager->setDuration(4); 434 433 435 436 trackManager->join(2, fork11, fork12); 437 438 trackManager->workOn(5); 434 435 trackManager->joinS("testFork1,testFork2"); 436 439 437 trackManager->addPoint(Vector(1200, 60, -50)); 440 438 trackManager->addPoint(Vector(1300, 50, -50)); … … 479 477 glNewList (objectList, GL_COMPILE); 480 478 481 //trackManager->drawGraph(.01);479 trackManager->drawGraph(.01); 482 480 trackManager->debug(2); 483 481 glEndList(); -
orxonox/trunk/src/track_manager.cc
r4166 r4220 25 25 #include "text_engine.h" 26 26 #include "t_animation.h" 27 #include "substring.h" 27 28 28 29 #include <stdarg.h> … … 401 402 \brief loads a trackElement from a TiXmlElement 402 403 \param root the TiXmlElement to load the Data from 403 404 404 */ 405 405 bool TrackManager::load( TiXmlElement* root) 406 406 { 407 TiXmlElement* element; 408 TiXmlNode* container; 409 double x, y, z, d; 410 411 element = root->FirstChildElement(); 412 413 while( element != NULL) 414 { 415 if( !strcmp( element->Value(), "Point")) 416 { 417 container = element->FirstChild(); 418 if( container->ToText()) 419 { 420 assert( container->Value() != NULL); 421 if( sscanf( container->Value(), "%lf,%lf,%lf", &x, &y, &z) == 3) 422 { 423 PRINTF(0)("Loaded Point: %lf,%lf,%lf (%s)\n", x, y, z, container->Value()); 424 addPoint( Vector( x, y, z)); 425 } 426 else 427 { 428 PRINTF(0)("Invalid Point in Track (skipped)\n"); 429 } 430 } 431 } 432 else if( !strcmp( element->Value(), "Duration")) 433 { 434 container = element->FirstChild(); 435 if( container->ToText()) 436 { 437 assert( container->Value() != NULL); 438 if( sscanf( container->Value(), "%lf", &d) == 1) 439 { 440 PRINTF(5)("Loaded Duration: %lf (%s)\n", d, container->Value()); 441 setDuration( d); 442 } 443 else 444 { 445 PRINTF(2)("Invalid Duration in Track (skipped)\n"); 446 } 447 } 448 } 449 else if( !strcmp( element->Value(), "SavePoint")) 450 { 451 PRINTF(5)("Loaded Savepoint\n"); 452 setSavePoint(); 453 } 454 else if( !strcmp( element->Value(), "Fork")) 455 { 456 container = element->FirstChild(); 457 if( container->ToText()) 458 { 459 assert( container->Value() != NULL); 460 PRINTF(4)("Loaded Fork: %s\n", container->Value()); 461 forkS(container->Value()); 462 } 463 } 464 else if( !strcmp( element->Value(), "Join")) 465 { 466 container = element->FirstChild(); 467 if( container->ToText()) 468 { 469 assert( container->Value() != NULL); 470 PRINTF0("Loaded Join: %s\n", container->Value()); 471 joinS(container->Value()); 472 } 473 } 474 else if( !strcmp( element->Value(), "WorkOn")) 475 { 476 container = element->FirstChild(); 477 if( container->ToText()) 478 { 479 assert( container->Value() != NULL); 480 PRINTF(4)("Loaded WorkOn: %s\n", container->Value()); 481 workOn( container->Value()); 482 } 483 } 484 485 element = element->NextSiblingElement(); 486 } 407 487 408 488 } … … 620 700 /** 621 701 \brief adds some interessting non-linear movments through the level. 622 \param count The Count of children s the current HotPoint will have.702 \param count The Count of children the fork will produce 623 703 624 704 If no HotPoint was defined the last added Point will be rendered into a fork. \n … … 628 708 { 629 709 int* trackIDs = new int[count]; 630 this->forkV(count, trackIDs );710 this->forkV(count, trackIDs, NULL); 631 711 va_list ID; 632 712 va_start (ID, count); … … 640 720 641 721 /** 722 \param string the String to parse. 723 \see TrackManager::fork(unsigned int count, ...) 724 725 does the same as fork, but has an array of strings as an input. 726 */ 727 void TrackManager::forkS(unsigned int count, ...) 728 { 729 int* trackIDs = new int[count]; 730 this->forkV(count, trackIDs, NULL); 731 va_list name; 732 va_start (name, count); 733 for(int i = 0; i < count; i++) 734 { 735 this->firstTrackElem->findByID(trackIDs[i])->setName(va_arg(name, const char*)); 736 } 737 va_end(name); 738 delete []trackIDs; 739 } 740 741 /** 742 \see TrackManager::fork(unsigned int count, ...) 743 */ 744 void TrackManager::forkS(const char* forkString) 745 { 746 SubString strings(forkString); 747 748 int* trackIDs = new int[strings.getCount()]; 749 this->forkV(strings.getCount(), trackIDs, NULL); 750 751 for(int i = 0; i < strings.getCount(); i++) 752 { 753 this->firstTrackElem->findByID(trackIDs[i])->setName(strings.getString(i)); 754 } 755 } 756 757 /** 642 758 \brief adds some interessting non-linear movments through the level. 643 759 \param count The Count of childrens the current HotPoint will have. 644 760 \param trackIDs A Pointer to an Array of ints which will hold the trackID's (the user will have to reserve space for this). 645 \param trackElem The TrackElement to appy this to. (if NULL cho se this->currentTrackElement)761 \param trackElem The TrackElement to appy this to. (if NULL choose this->currentTrackElement) 646 762 \see TrackManager::fork(unsigned int count, ...) 647 763 */ 648 void TrackManager::forkV(unsigned int count, int* trackIDs, TrackElement* trackElem)764 void TrackManager::forkV(unsigned int count, int* trackIDs, char** trackNames, TrackElement* trackElem) 649 765 { 650 766 if (!trackElem) … … 738 854 \brief Joins some Tracks together again. 739 855 \param count The count of trackElements to join 740 741 856 \see void TrackManager::join(unsigned int count, ...) 857 742 858 The difference to void TrackManager::join(unsigned int count, ...) is, that this function takes 743 859 the Names of the TrackElements as inputs and not their ID 744 860 */ 745 void TrackManager::join c(unsigned int count, ...)861 void TrackManager::joinS(unsigned int count, ...) 746 862 { 747 863 int* trackIDs = new int [count]; … … 750 866 for(int i = 0; i < count; i++) 751 867 { 752 c har* name = va_arg (NAME, char*);868 const char* name = va_arg (NAME, char*); 753 869 TrackElement* tmpElem = this->firstTrackElem->findByName(name); 754 870 if (tmpElem) … … 762 878 } 763 879 880 /** 881 \see void TrackManager::join(unsigned int count, ...) 882 */ 883 void TrackManager::joinS(const char* joinString) 884 { 885 SubString strings(joinString); 886 887 int* trackIDs = new int[strings.getCount()]; 888 this->joinV(strings.getCount(), trackIDs); 889 890 for(int i = 0; i < strings.getCount(); i++) 891 { 892 TrackElement* tmpElem = this->firstTrackElem->findByName(strings.getString(i)); 893 if (tmpElem) 894 trackIDs[i] = tmpElem->ID; 895 else 896 PRINTF(1)("Trying to join a Track, of which the name does not exist: %s\n", strings.getString(i)); 897 } 898 899 this->joinV(strings.getCount(), trackIDs); 900 delete []trackIDs; 901 } 764 902 765 903 /** … … 777 915 if (!this->firstTrackElem->findByID(trackIDs[i])) 778 916 { 779 PRINTF(1)(" Error trying to Connect Paths that do not exist yet: %d\n Not Joining Anything", trackIDs[i]);917 PRINTF(1)("Trying to Connect Paths that do not exist yet: %d\n Not Joining Anything\n", trackIDs[i]); 780 918 return; 781 919 } -
orxonox/trunk/src/track_manager.h
r4166 r4220 167 167 int setSavePoint(TrackElement* trackElem = NULL); 168 168 void fork(unsigned int count, ...); 169 void forkV(unsigned int count, int* trackIDs, TrackElement* trackElem = NULL); 169 void forkS(unsigned int count, ...); 170 void forkS(const char* forkString); 171 void forkV(unsigned int count, int* trackIDs, char** trackNames, TrackElement* trackElem = NULL); 170 172 void condition(unsigned int trackID, CONDITION cond, void* subject); 171 173 void condition(CONDITION cond, void* subject, TrackElement* trackElem = NULL); 172 174 void join(unsigned int count, ...); 173 void joinc(unsigned int count, ...); 175 void joinS(const char* joinString); 176 void joinS(unsigned int cound, ...); 174 177 void joinV(unsigned int count, int* trackIDs); 175 178 void finalize(void);
Note: See TracChangeset
for help on using the changeset viewer.