Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 3, 2005, 3:52:05 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: cycling read-in of parameters should work now… this is quite tricky, and the TrackManager has to be rewritten in some parts…. :(

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/track/track_manager.cc

    r4489 r4496  
    2525#include "text_engine.h"
    2626#include "t_animation.h"
     27#include "load_param.h"
     28
     29
     30#include "tinyxml.h"
    2731#include "substring.h"
    28 #include "tinyxml.h"
    2932
    3033#include <stdarg.h>
     
    409412  while( element != NULL)
    410413    {
    411       if( !strcmp( element->Value(), "Point"))
    412         {
    413           container = element->FirstChild();
    414           if( container->ToText())
    415             {
    416               assert( container->Value() != NULL);
    417               if( sscanf( container->Value(), "%lf,%lf,%lf", &x, &y, &z) == 3)
    418                 {
    419                   PRINTF(5)("Loaded Point: %lf,%lf,%lf (%s)\n", x, y, z, container->Value());
    420                   addPoint( Vector( x, y, z));
    421                 }
    422               else
    423                 {
    424                   PRINTF(0)("Invalid Point in Track (skipped)\n");
    425                 }                       
    426             }
    427         }
    428       else if( !strcmp( element->Value(), "Duration"))
    429         {
    430           container = element->FirstChild();
    431           if( container->ToText())
    432             {
    433               assert( container->Value() != NULL);
    434               if( sscanf( container->Value(), "%lf", &d) == 1)
    435                 {
    436                   PRINTF(5)("Loaded Duration: %lf (%s)\n", d, container->Value());
    437                   setDuration( d);
    438                 }
    439               else
    440                 {
    441                   PRINTF(2)("Invalid Duration in Track (skipped)\n");
    442                 }                       
    443             }
    444         }
    445       else if( !strcmp( element->Value(), "SavePoint"))
     414      LoadParam<TrackManager>(element, "Point", this, &TrackManager::addPoint, true)
     415        .describe("Adds a new Point to the currently selected TrackElement");
     416
     417      LoadParam<TrackManager>(element, "Duration", this, &TrackManager::setDuration, true)
     418        .describe("Sets the Duration of the currently selected TrackElement");
     419     
     420      LoadParam<TrackManager>(element, "SavePoint", this, &TrackManager::setSavePoint, true);
     421
     422      /*
     423      if( !strcmp( element->Value(), "SavePoint"))
    446424        {
    447425          PRINTF(5)("Loaded Savepoint\n");
    448426          setSavePoint();
    449427        }
    450       else if( !strcmp( element->Value(), "Fork"))
     428      */
     429      if( !strcmp( element->Value(), "Fork"))
    451430        {
    452431          container = element->FirstChild();
     
    526505      newElem->startingTime = trackElem->endTime + trackElem->jumpTime;
    527506      // adds the conection Point
    528       this->addPoint(trackElem->curve->getNode(trackElem->curve->getNodeCount()),
     507      this->addPointV(trackElem->curve->getNode(trackElem->curve->getNodeCount()),
    529508                     newElem);
    530509      // add the new child to the childList.
     
    600579
    601580/**
     581   \param duration the duration of the TrackElement
     582   \see void TrackManager::setDuration(float duration, TrackElement* trackElem)
     583*/
     584void TrackManager::setDuration(float duration)
     585{
     586  this->setDuration(duration, NULL);
     587}
     588
     589/**
    602590   \brief Sets the duration of the current path in seconds.
    603591   \param duration The duration in seconds.
     
    615603/**
    616604   \brief adds a point to trackElem
     605   \param x x coord
     606   \param y y coord
     607   \param z z coord
     608   \param trackElem The TrackElement to add the Point to
     609*/
     610void TrackManager::addPoint(float x, float y, float z)
     611{
     612  this->addPointV(Vector(x,y,z));
     613}
     614
     615/**
     616   \brief adds a point to trackElem
    617617   \param newPoint The point to add.
    618618   \param trackElem The TrackElement to add the Point to
    619619*/
    620 bool TrackManager::addPoint(Vector newPoint, TrackElement* trackElem)
     620void TrackManager::addPointV(Vector newPoint, TrackElement* trackElem)
    621621{
    622622  if (!trackElem)
     
    653653  trackElem->nodeCount++;
    654654  this->initChildren(1, trackElem);
     655}
     656
     657/**
     658   \todo this must be better
     659*/
     660void TrackManager::setSavePoint(int isLoadable)
     661{
     662  this->setSavePoint();
    655663}
    656664
     
    946954          else
    947955            {
    948               this->addPoint(tmpc2Point, tmpJoinElem);
    949               this->addPoint(tmpTangentPoint, tmpJoinElem);
    950               this->addPoint(tmpEndPoint, tmpJoinElem);
     956              this->addPointV(tmpc2Point, tmpJoinElem);
     957              this->addPointV(tmpTangentPoint, tmpJoinElem);
     958              this->addPointV(tmpEndPoint, tmpJoinElem);
    951959              // time all other Joins
    952960              tmpJoinElem->jumpTime = tmpLatestTime - tmpJoinElem->endTime;
Note: See TracChangeset for help on using the changeset viewer.