Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10088 in orxonox.OLD


Ignore:
Timestamp:
Dec 18, 2006, 1:28:49 AM (17 years ago)
Author:
patrick
Message:

added the track subsystem to the buildprocess again, integrated it into the new basobject framework and commented out big regions of code because it didn't compile.
@beni: your work now can begin :D

Location:
branches/playability/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/util/Makefile.am

    r9869 r10088  
    2626                        animation/animation_player.cc \
    2727                        \
    28                         track/pilot_node.cc
    29 
    30 #                       track/track_manager.cc \
     28                        track/pilot_node.cc \
     29                        track/track.cc \
     30                        track/track_manager.cc \
    3131                        track/track_node.cc
    3232
     
    5252                        animation/t_animation.h \
    5353                        \
    54                         track/pilot_node.h
     54                        track/pilot_node.h \
     55                        track/track.h \
     56                        track/track_manager.h \
     57                        track/track_node.h
    5558
    56 #                       track/track_manager.h \
    57                         track/track_node.h
  • branches/playability/src/util/track/track.cc

    r10085 r10088  
    1313   This is anohter installment of the infamous track system. It serves for
    1414   temporary use only and is mainly a slimmed version of the old track.
    15    
     15
    1616   The track is used to steer the spaceship. In this case the track will have
    1717   to control a PNode. The spaceship will be able to fly around this node.
    1818   The camera will always be focused on that point.
    19    
     19
    2020   As we do this we have exactly the verticalscroller feeling we want.
    21    
     21
    2222   main-programmer: Benjamin Knecht
    2323*/
    2424
    2525#include "util/loading/load_param.h"
    26 
    27 #include "class_id_DEPRECATED.h"
     26#include "track/track.h"
     27
     28#include "track/track_manager.h"
     29#include "p_node.h"
     30
     31#include "debug.h"
    2832
    2933ObjectListDefinition(Track);
    30 CREATE_FACTORY(Track);
     34// CREATE_FACTORY(Track);
     35
    3136
    3237/**
     
    3540Track::Track()
    3641{
    37       this->firstTrackElem = new TrackElement();
    38       this->firstTrackElem->ID = 1;
    39       this->firstTrackElem->setName("root");
    40      
    41       this->currentTrackElem = firstTrackElem;
    42      
    43       this->curveType = CURVE_BEZIER;
    44       this->trackElemCount = 1;
    45      
    46       this->trackNode = new PNode(PNode::getNullParent(), PNODE_ALL);
     42  this->init();
     43}
     44
     45
     46/**
     47 * this is a constructor for use with the xml loading file
     48 * @param root xml root element for this object
     49 */
     50Track::Track(const TiXmlElement* root)
     51{
     52  this->init();
     53}
     54
     55
     56/**
     57 * initializes this class
     58 */
     59void Track::init()
     60{
     61  // resetting all elements
     62  this->firstTrackElem = NULL;
     63
     64
     65  // make a debug track
     66  this->firstTrackElem = new TrackElement();
     67  this->firstTrackElem->ID = 1;
     68  this->firstTrackElem->setName("root");
     69
     70  this->currentTrackElem = firstTrackElem;
     71
     72  this->curveType = CURVE_BEZIER;
     73  this->trackElemCount = 1;
     74
     75  this->trackNode = new PNode(PNode::getNullParent(), PNODE_ALL);
    4776}
    4877
     
    5281Track::~Track()
    5382{
    54   delete this->firstTrackElem;
    55 }
     83  if( this->firstTrackElem)
     84    delete this->firstTrackElem;
     85}
     86
    5687
    5788void Track::loadParams(const TiXmlElement* root)
     
    6192           LoadParam_CYCLE(element, "Point", this, Track, addPoint)
    6293             .describe("Adds a new Point to the currently selected TrackElement");
    63            
     94
    6495     }
    6596     LOAD_PARAM_END_CYCLE(element);
    6697}
    6798
     99
     100
     101/**
     102 *
     103 * @param x
     104 * @param y
     105 * @param z
     106 */
    68107void Track::addPoint(float x, float y, float z)
    69108{
     
    71110}
    72111
     112
     113/**
     114 *
     115 * @param newPoint
     116 */
    73117void Track::addPoint(Vector newPoint)
    74118{
    75   if (this->currentTrackElem->isFresh)
    76     {
    77       this->setCurveType(CURVE_BEZIER, this->currentTrackElem);
    78       this->currentTrackElem->isFresh = false;
    79     }
    80   trackElem->curve->addNode(newPoint);
    81   trackElem->nodeCount++;
    82 }
    83 
     119//   if (this->currentTrackElem->isFresh)
     120//     {
     121//       this->setCurveType(CURVE_BEZIER, this->currentTrackElem);
     122//       this->currentTrackElem->isFresh = false;
     123//     }
     124//   trackElem->curve->addNode(newPoint);
     125//   trackElem->nodeCount++;
     126}
     127
     128/**
     129 *
     130 */
    84131void Track::finalize()
    85132{
    86   for (int i = 1; i<= trackElemCount ;i++)
    87     {
    88       TrackElement* tmpElem = this->firstTrackElem->findByID(i);
    89       if( tmpElem->childCount > 0)
    90         {
    91           tIterator<TrackElement>* iterator = tmpElem->children->getIterator();
    92           TrackElement* enumElem = iterator->firstElement();
    93           //TrackElement* enumElem = tmpElem->children->enumerate();
    94           while (enumElem)
    95             {
    96 
    97               // c1-continuity
    98               enumElem->curve->addNode(enumElem->curve->getNode(0) +
    99                                                    ((enumElem->curve->getNode(0) -
    100                                                     tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1))
    101                                                     ),2);
    102               enumElem->nodeCount++;
    103               // c2-continuity
    104               enumElem->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-
    105                                                     tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 +
    106                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3);
    107               enumElem->nodeCount++;
    108               PRINTF(5)("accelerations: %d-in: count: %d, %f, %f, %f\n                  %d-out: count: %d %f, %f, %f\n",
    109                      tmpElem->ID, tmpElem->nodeCount,
    110                      tmpElem->curve->calcAcc(0.999).x, tmpElem->curve->calcAcc(0.999).y, tmpElem->curve->calcAcc(0.999).z,
    111                      enumElem->ID, enumElem->nodeCount,
    112                      enumElem->curve->calcAcc(0).x, enumElem->curve->calcAcc(0).y, enumElem->curve->calcAcc(0).z);
    113 
    114               enumElem = iterator->nextElement();
    115             }
    116           delete iterator;
    117         }
    118     }
     133//   for (int i = 1; i<= trackElemCount ;i++)
     134//     {
     135//       TrackElement* tmpElem = this->firstTrackElem->findByID(i);
     136//       if( tmpElem->childCount > 0)
     137//         {
     138//           tIterator<TrackElement>* iterator = tmpElem->children->getIterator();
     139//           TrackElement* enumElem = iterator->firstElement();
     140//           //TrackElement* enumElem = tmpElem->children->enumerate();
     141//           while (enumElem)
     142//             {
     143//
     144//               // c1-continuity
     145//               enumElem->curve->addNode(enumElem->curve->getNode(0) +
     146//                                                    ((enumElem->curve->getNode(0) -
     147//                                                     tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1))
     148//                                                     ),2);
     149//               enumElem->nodeCount++;
     150//               // c2-continuity
     151//               enumElem->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-
     152//                                                     tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 +
     153//                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3);
     154//               enumElem->nodeCount++;
     155//               PRINTF(5)("accelerations: %d-in: count: %d, %f, %f, %f\n                  %d-out: count: %d %f, %f, %f\n",
     156//                      tmpElem->ID, tmpElem->nodeCount,
     157//                      tmpElem->curve->calcAcc(0.999).x, tmpElem->curve->calcAcc(0.999).y, tmpElem->curve->calcAcc(0.999).z,
     158//                      enumElem->ID, enumElem->nodeCount,
     159//                      enumElem->curve->calcAcc(0).x, enumElem->curve->calcAcc(0).y, enumElem->curve->calcAcc(0).z);
     160//
     161//               enumElem = iterator->nextElement();
     162//             }
     163//           delete iterator;
     164//         }
     165//     }
     166
     167
     168
    119169  /*for (int i = 1; i <= trackElemCount;i++)
    120170    if (this->firstTrackElem->findByID(i)->endTime > this->maxTime)
     
    135185void Track::tick(float dt)
    136186{
    137   PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
    138   if (this->localTime <= this->firstTrackElem->duration)
    139     this->jumpTo(this->localTime);
    140   if (this->localTime <= this->maxTime)
    141     this->localTime += dt;
    142   if (this->localTime > this->currentTrackElem->endTime
    143       && this->currentTrackElem->children)
    144     {
    145       if (this->currentTrackElem->jumpTime != 0.0)
    146         this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
    147       // jump to the next TrackElement and also set the history of the new Element to the old one.
    148       TrackElement* tmpHistoryElem = this->currentTrackElem;
    149       this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
    150       this->currentTrackElem->history = tmpHistoryElem;
    151       if (this->currentTrackElem->getName())
    152         {
    153           this->trackText->setText(this->currentTrackElem->getName());
    154           this->textAnimation->replay();
    155         }
    156     }
    157   if (this->bindSlave)
    158     {
    159       Vector tmp = this->calcPos();
    160       Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
    161 
    162       Vector v(0.0, 1.0, 0.0);
    163       Quaternion q(-PI/2, v);
    164       quat = quat * q;
    165 
    166       this->bindSlave->setAbsCoor(tmp);
    167       this->bindSlave->setAbsDir(quat);
    168     }
     187//   PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
     188//   if (this->localTime <= this->firstTrackElem->duration)
     189//     this->jumpTo(this->localTime);
     190//   if (this->localTime <= this->maxTime)
     191//     this->localTime += dt;
     192//   if (this->localTime > this->currentTrackElem->endTime
     193//       && this->currentTrackElem->children)
     194//     {
     195//       if (this->currentTrackElem->jumpTime != 0.0)
     196//         this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
     197//       // jump to the next TrackElement and also set the history of the new Element to the old one.
     198//       TrackElement* tmpHistoryElem = this->currentTrackElem;
     199//       this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
     200//       this->currentTrackElem->history = tmpHistoryElem;
     201//       if (this->currentTrackElem->getName())
     202//         {
     203//           this->trackText->setText(this->currentTrackElem->getName());
     204//           this->textAnimation->replay();
     205//         }
     206//     }
     207//   if (this->bindSlave)
     208//     {
     209//       Vector tmp = this->calcPos();
     210//       Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
     211//
     212//       Vector v(0.0, 1.0, 0.0);
     213//       Quaternion q(-PI/2, v);
     214//       quat = quat * q;
     215//
     216//       this->bindSlave->setAbsCoor(tmp);
     217//       this->bindSlave->setAbsDir(quat);
     218//     }
    169219}
    170220
  • branches/playability/src/util/track/track.h

    r10085 r10088  
    22 * @file track.h
    33 */
    4  
     4
    55#ifndef _TRACK_H_
    66#define _TRACK_H_
     
    1212class PNode;
    1313class TiXmlElement;
     14class TrackElement;
    1415
    1516class Track : public BaseObject
    1617{
     18  ObjectListDeclaration(Track);
     19
    1720 public:
     21   Track();
     22   Track(const TiXmlElement* root);
     23   virtual ~Track();
     24
    1825      virtual void loadParams(const TiXmlElement* root);
    1926      void addPoint(float x, float y, float z);
    2027      void addPoint(Vector newPoint);
    21      
     28
    2229      void finalize();
    2330      inline Vector calcPos() const;
    2431      inline Vector calcDir() const;
    2532      void tick(float dt);
    26      
     33
    2734      PNode* getTrackNode();
    28  
     35
     36  private:
     37    void init();
     38
     39
    2940 private:
    3041      TrackElement*        firstTrackElem;         //!< The first TrackElement that exists.
     
    3243      CurveType            curveType;              //!< The CurveType the entire TrackSystem will have.
    3344      int                  trackElemCount;         //!< The count of TrackElements that exist.
    34      
     45
    3546      PNode*               trackNode;              //!< The node that is slave to the Track. This node will be moved while update the Track, and must NOT move itself.
    3647};
  • branches/playability/src/util/track/track_manager.cc

    r9406 r10088  
    2626#include "t_animation.h"
    2727
     28#include <string.h>
     29
    2830
    2931#include "parser/tinyxml/tinyxml.h"
     
    3234#include <stdarg.h>
    3335
     36ObjectListDefinition(TrackElement);
    3437
    3538
     
    3942TrackElement::TrackElement()
    4043{
    41   this->setClassID(CL_TRACK_ELEMENT, "TrackElement");
     44  this->registerObject(this, TrackElement::_objectList);
     45
    4246
    4347  this->isFresh = true;
     
    126130{
    127131  // return if Found.
    128   if (this->getName() && !strcmp(this->getName(), trackName))
    129     return this;
     132//   if (this->getName() && !strcmp(this->getName(), trackName))
     133//     return this;
    130134  // search all children
    131135  if (this->childCount > 0)
     
    217221void TrackElement::debug() const
    218222{
    219   PRINT(0)("--== TrackElement:%i ==--", this->ID);
    220   if(this->getName())
    221     PRINT(0)("--++Name: %s++--", this->getName());
    222   if(this->isFresh)
    223     PRINT(0)("  -- has not jet eddited in any way --\n");
    224   PRINT(0)("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", this->startingTime, this->endTime, this->duration, this->jumpTime);
    225   PRINT(0)("   consists of %d Points\n", this->nodeCount);
    226   if (this->childCount == 0)
    227     PRINT(0)("   has no child\n");
    228   else if (this->childCount == 1)
    229     PRINT(0)("   has 1 child: =%d=\n", this->getChild(0)->ID);
    230   else if (this->childCount > 1)
    231     {
    232       PRINT(0)("   has %d children: ", this->childCount);
    233       //TrackElement* enumElem = this->children->enumerate();
    234       tIterator<TrackElement>* iterator = this->children->getIterator();
    235       TrackElement* enumElem = iterator->firstElement();
    236       while (enumElem)
    237         {
    238           PRINT(0)("=%d= ", enumElem->ID);
    239           enumElem = iterator->nextElement();
    240         }
    241       delete iterator;
    242       PRINT(0)("\n");
    243     }
    244 
    245   if(this->isHotPoint)
    246     PRINT(0)("   is a special Point:\n");
    247   if(this->isSavePoint)
    248     PRINT(0)("    is a SavePoint\n");
    249   if(this->isFork)
    250     {
    251       PRINT(0)("    is A Fork with with %d children.\n", this->childCount);
    252     }
    253   if(this->isJoined)
    254     PRINT(0)("   is Joined at the End\n");
    255 
    256   if(!this->backLoopCheck()) /* this should not happen */
    257     PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
     223//   PRINT(0)("--== TrackElement:%i ==--", this->ID);
     224//   if(this->getName())
     225//     PRINT(0)("--++Name: %s++--", this->getName());
     226//   if(this->isFresh)
     227//     PRINT(0)("  -- has not jet eddited in any way --\n");
     228//   PRINT(0)("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", this->startingTime, this->endTime, this->duration, this->jumpTime);
     229//   PRINT(0)("   consists of %d Points\n", this->nodeCount);
     230//   if (this->childCount == 0)
     231//     PRINT(0)("   has no child\n");
     232//   else if (this->childCount == 1)
     233//     PRINT(0)("   has 1 child: =%d=\n", this->getChild(0)->ID);
     234//   else if (this->childCount > 1)
     235//     {
     236//       PRINT(0)("   has %d children: ", this->childCount);
     237//       //TrackElement* enumElem = this->children->enumerate();
     238//       tIterator<TrackElement>* iterator = this->children->getIterator();
     239//       TrackElement* enumElem = iterator->firstElement();
     240//       while (enumElem)
     241//         {
     242//           PRINT(0)("=%d= ", enumElem->ID);
     243//           enumElem = iterator->nextElement();
     244//         }
     245//       delete iterator;
     246//       PRINT(0)("\n");
     247//     }
     248//
     249//   if(this->isHotPoint)
     250//     PRINT(0)("   is a special Point:\n");
     251//   if(this->isSavePoint)
     252//     PRINT(0)("    is a SavePoint\n");
     253//   if(this->isFork)
     254//     {
     255//       PRINT(0)("    is A Fork with with %d children.\n", this->childCount);
     256//     }
     257//   if(this->isJoined)
     258//     PRINT(0)("   is Joined at the End\n");
     259//
     260//   if(!this->backLoopCheck()) /* this should not happen */
     261//     PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
    258262}
    259263
     
    358362TrackManager::TrackManager()
    359363{
    360   this->setClassID(CL_TRACK_MANAGER, "TrackManager");
    361   this->setName("TrackManager");
    362 
    363364  TrackManager::singletonRef = this; // do this because otherwise the TrackNode cannot get The instance of the TrackManager
    364365
     
    395396void TrackManager::loadParams(const TiXmlElement* root)
    396397{
    397   double x, y, z, d;
    398 
    399   LOAD_PARAM_START_CYCLE(root, element);
    400   {
    401 
    402     LoadParam_CYCLE(element, "WorkOn", this, TrackManager, workOnS)
    403         .describe("Selects a TrackElement (by name) to work on");
    404 
    405     LoadParam_CYCLE(element, "Point", this, TrackManager, addPoint)
    406         .describe("Adds a new Point to the currently selected TrackElement");
    407 
    408     LoadParam_CYCLE(element, "Duration", this, TrackManager, setDuration)
    409         .describe("Sets the Duration of the currently selected TrackElement");
    410 
    411     LoadParam_CYCLE(element, "HotPoint", this, TrackManager, addHotPoint)
    412         .describe("Sets a new Point that acts as a hot point. meaning, the curve will flow through this Point");
    413 
    414     LoadParam_CYCLE(element, "SavePoint", this, TrackManager, setSavePointS)
    415         .describe("Sets the current selected Point to a Savepoint, meaning that the curve will be ended and a new one starts, and that one starts again from this point on");
    416 
    417     LoadParam_CYCLE(element, "Fork", this, TrackManager, forkS)
    418         .describe("Forks the Path into multiple forked Path names seperated by ','");
    419 
    420     LoadParam_CYCLE(element, "Join", this, TrackManager, joinS)
    421         .describe("Joins multiple joining Path names seperated by ','");
     398//   double x, y, z, d;
     399//
     400//   LOAD_PARAM_START_CYCLE(root, element);
     401//   {
     402//
     403//     LoadParam_CYCLE(element, "WorkOn", this, TrackManager, workOnS)
     404//         .describe("Selects a TrackElement (by name) to work on");
     405//
     406//     LoadParam_CYCLE(element, "Point", this, TrackManager, addPoint)
     407//         .describe("Adds a new Point to the currently selected TrackElement");
     408//
     409//     LoadParam_CYCLE(element, "Duration", this, TrackManager, setDuration)
     410//         .describe("Sets the Duration of the currently selected TrackElement");
     411//
     412//     LoadParam_CYCLE(element, "HotPoint", this, TrackManager, addHotPoint)
     413//         .describe("Sets a new Point that acts as a hot point. meaning, the curve will flow through this Point");
     414//
     415//     LoadParam_CYCLE(element, "SavePoint", this, TrackManager, setSavePointS)
     416//         .describe("Sets the current selected Point to a Savepoint, meaning that the curve will be ended and a new one starts, and that one starts again from this point on");
     417//
     418//     LoadParam_CYCLE(element, "Fork", this, TrackManager, forkS)
     419//         .describe("Forks the Path into multiple forked Path names seperated by ','");
     420//
     421//     LoadParam_CYCLE(element, "Join", this, TrackManager, joinS)
     422//         .describe("Joins multiple joining Path names seperated by ','");
    422423
    423424      /*
     
    445446        }
    446447      */
    447   }
    448   LOAD_PARAM_END_CYCLE(element);
     448
     449//   }
     450//   LOAD_PARAM_END_CYCLE(element);
    449451}
    450452
     
    477479void TrackManager::initChildren(unsigned int childCount, TrackElement* trackElem)
    478480{
    479   if (!trackElem)
    480     trackElem = this->currentTrackElem;
    481 
    482   trackElem->childCount = childCount;
    483   trackElem->mainJoin = true;  // this tells join, that this one is the Main Join, if it tries to join multiple Tracks
    484   trackElem->children =  new tList<TrackElement>();
    485   for (int i = 0; i < childCount; i++)
    486     {
    487       // create a new Element
    488       TrackElement* newElem = new TrackElement();
    489       // setting up the new ID
    490       newElem->ID = ++trackElemCount;
    491       // setting up the Time
    492       newElem->startingTime = trackElem->endTime + trackElem->jumpTime;
    493       // adds the conection Point
    494       this->addPointV(trackElem->curve->getNode(trackElem->curve->getNodeCount()),
    495                      newElem);
    496       // add the new child to the childList.
    497       trackElem->children->add(newElem);
    498     }
    499 
    500   // setting the Name of the new TrackElement to the name of the last one + _childI
    501 
    502   if (trackElem->getName())
    503     {
    504       for (int i = 0; i < trackElem->childCount; i++)
    505       {
    506         char* childName = new char[strlen(trackElem->getName())+10];
    507         sprintf(childName, "%s_child%d", trackElem->getName(), i);
    508         trackElem->getChild(i)->setName(childName);
    509       }
    510     }
    511   // select the first Child to work on.
    512   this->currentTrackElem = trackElem->getChild(0);
     481//   if (!trackElem)
     482//     trackElem = this->currentTrackElem;
     483//
     484//   trackElem->childCount = childCount;
     485//   trackElem->mainJoin = true;  // this tells join, that this one is the Main Join, if it tries to join multiple Tracks
     486//   trackElem->children =  new tList<TrackElement>();
     487//   for (int i = 0; i < childCount; i++)
     488//     {
     489//       // create a new Element
     490//       TrackElement* newElem = new TrackElement();
     491//       // setting up the new ID
     492//       newElem->ID = ++trackElemCount;
     493//       // setting up the Time
     494//       newElem->startingTime = trackElem->endTime + trackElem->jumpTime;
     495//       // adds the conection Point
     496//       this->addPointV(trackElem->curve->getNode(trackElem->curve->getNodeCount()),
     497//                      newElem);
     498//       // add the new child to the childList.
     499//       trackElem->children->add(newElem);
     500//     }
     501//
     502//   // setting the Name of the new TrackElement to the name of the last one + _childI
     503//
     504//   if (trackElem->getName())
     505//     {
     506//       for (int i = 0; i < trackElem->childCount; i++)
     507//       {
     508//         char* childName = new char[strlen(trackElem->getName())+10];
     509//         sprintf(childName, "%s_child%d", trackElem->getName(), i);
     510//         trackElem->getChild(i)->setName(childName);
     511//       }
     512//     }
     513//   // select the first Child to work on.
     514//   this->currentTrackElem = trackElem->getChild(0);
    513515}
    514516
     
    659661void TrackManager::setSavePointS(const std::string& nextElementName)
    660662{
    661   this->setSavePoint(NULL);
    662   if (strcmp(nextElementName, ""))
    663     this->firstTrackElem->findByID(this->trackElemCount)->setName(nextElementName);
     663//   this->setSavePoint(NULL);
     664//   if (strcmp(nextElementName, ""))
     665//     this->firstTrackElem->findByID(this->trackElemCount)->setName(nextElementName);
    664666}
    665667
     
    736738void TrackManager::forkS(const std::string& forkString)
    737739{
    738   SubString strings(forkString, ',');
    739 
    740   int* trackIDs = new int[strings.getCount()];
    741   this->forkV(strings.getCount(), trackIDs, NULL);
    742 
    743   for(int i = 0; i < strings.getCount(); i++)
    744     {
    745       this->firstTrackElem->findByID(trackIDs[i])->setName(strings.getString(i));
    746     }
    747   delete []trackIDs;
     740//   SubString strings(forkString, ',');
     741//
     742//   int* trackIDs = new int[strings.getCount()];
     743//   this->forkV(strings.getCount(), trackIDs, NULL);
     744//
     745//   for(int i = 0; i < strings.getCount(); i++)
     746//     {
     747//       this->firstTrackElem->findByID(trackIDs[i])->setName(strings.getString(i));
     748//     }
     749//   delete []trackIDs;
    748750}
    749751
     
    877879void TrackManager::joinS(const std::string& joinString)
    878880{
    879   SubString strings(joinString, ',');
    880 
    881   int* trackIDs = new int[strings.getCount()];
    882   this->joinV(strings.getCount(), trackIDs);
    883 
    884   for(unsigned int i = 0; i < strings.getCount(); i++)
    885     {
    886       TrackElement* tmpElem = this->firstTrackElem->findByName(strings.getString(i).c_str());
    887       if (tmpElem != NULL)
    888         trackIDs[i] = tmpElem->ID;
    889       else
    890       {
    891         PRINTF(1)("Trying to join a Track, of which the name does not exist: %s\n", strings.getString(i).c_str());
    892         trackIDs[i] = -1;
    893       }
    894     }
    895   this->joinV(strings.getCount(), trackIDs);
    896   delete []trackIDs;
     881//   SubString strings(joinString, ',');
     882//
     883//   int* trackIDs = new int[strings.getCount()];
     884//   this->joinV(strings.getCount(), trackIDs);
     885//
     886//   for(unsigned int i = 0; i < strings.getCount(); i++)
     887//     {
     888//       TrackElement* tmpElem = this->firstTrackElem->findByName(strings.getString(i).c_str());
     889//       if (tmpElem != NULL)
     890//         trackIDs[i] = tmpElem->ID;
     891//       else
     892//       {
     893//         PRINTF(1)("Trying to join a Track, of which the name does not exist: %s\n", strings.getString(i).c_str());
     894//         trackIDs[i] = -1;
     895//       }
     896//     }
     897//   this->joinV(strings.getCount(), trackIDs);
     898//   delete []trackIDs;
    897899}
    898900
     
    10731075void TrackManager::tick(float dt)
    10741076{
    1075   PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
    1076   if (this->localTime <= this->firstTrackElem->duration)
    1077     this->jumpTo(this->localTime);
    1078   if (this->localTime <= this->maxTime)
    1079     this->localTime += dt;
    1080   if (this->localTime > this->currentTrackElem->endTime
    1081       && this->currentTrackElem->children)
    1082     {
    1083       if (this->currentTrackElem->jumpTime != 0.0)
    1084         this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
    1085       // jump to the next TrackElement and also set the history of the new Element to the old one.
    1086       TrackElement* tmpHistoryElem = this->currentTrackElem;
    1087       this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
    1088       this->currentTrackElem->history = tmpHistoryElem;
    1089       if (this->currentTrackElem->getName())
    1090         {
    1091           this->trackText->setText(this->currentTrackElem->getName());
    1092           this->textAnimation->replay();
    1093         }
    1094     }
    1095   if (this->bindSlave)
    1096     {
    1097       Vector tmp = this->calcPos();
    1098       Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
    1099 
    1100       Vector v(0.0, 1.0, 0.0);
    1101       Quaternion q(-PI/2, v);
    1102       quat = quat * q;
    1103 
    1104       this->bindSlave->setAbsCoor(tmp);
    1105       this->bindSlave->setAbsDir(quat);
    1106     }
     1077//   PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
     1078//   if (this->localTime <= this->firstTrackElem->duration)
     1079//     this->jumpTo(this->localTime);
     1080//   if (this->localTime <= this->maxTime)
     1081//     this->localTime += dt;
     1082//   if (this->localTime > this->currentTrackElem->endTime
     1083//       && this->currentTrackElem->children)
     1084//     {
     1085//       if (this->currentTrackElem->jumpTime != 0.0)
     1086//         this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
     1087//       // jump to the next TrackElement and also set the history of the new Element to the old one.
     1088//       TrackElement* tmpHistoryElem = this->currentTrackElem;
     1089//       this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
     1090//       this->currentTrackElem->history = tmpHistoryElem;
     1091//       if (this->currentTrackElem->getName())
     1092//         {
     1093//           this->trackText->setText(this->currentTrackElem->getName());
     1094//           this->textAnimation->replay();
     1095//         }
     1096//     }
     1097//   if (this->bindSlave)
     1098//     {
     1099//       Vector tmp = this->calcPos();
     1100//       Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
     1101//
     1102//       Vector v(0.0, 1.0, 0.0);
     1103//       Quaternion q(-PI/2, v);
     1104//       quat = quat * q;
     1105//
     1106//       this->bindSlave->setAbsCoor(tmp);
     1107//       this->bindSlave->setAbsDir(quat);
     1108//     }
    11071109}
    11081110
     
    11161118void TrackManager::jumpTo(float time)
    11171119{
    1118   if (time == 0)
    1119     {
    1120       this->currentTrackElem = this->firstTrackElem;
    1121       if (this->currentTrackElem->getName())
    1122         {
    1123           this->trackText->setText(this->currentTrackElem->getName());
    1124           this->textAnimation->play();
    1125         }
    1126     }
    1127   this->localTime = time;
     1120//   if (time == 0)
     1121//     {
     1122//       this->currentTrackElem = this->firstTrackElem;
     1123//       if (this->currentTrackElem->getName())
     1124//         {
     1125//           this->trackText->setText(this->currentTrackElem->getName());
     1126//           this->textAnimation->play();
     1127//         }
     1128//     }
     1129//   this->localTime = time;
    11281130}
    11291131
  • branches/playability/src/util/track/track_manager.h

    r7221 r10088  
    4141class TrackElement : public BaseObject
    4242{
     43  ObjectListDeclaration(TrackElement);
     44
    4345 public:
    4446  TrackElement();
     
    131133    \li TrackElement: A Part of A whole Track
    132134*/
    133 class TrackManager : public BaseObject
     135class TrackManager
    134136{
    135137 public:
  • branches/playability/src/util/track/track_node.cc

    r9869 r10088  
    1717
    1818
    19 #include "track_node.h"
     19#include "track/track_node.h"
    2020
    21 #include "track_manager.h"
     21#include "track/track_manager.h"
    2222
    2323
    24 ObjectListDefinition(TracNode);
     24ObjectListDefinition(TrackNode);
     25
    2526/**
    2627 *  standard constructor
     
    2829TrackNode::TrackNode ()
    2930{
    30   this->registerObject(this, TracNode::_objectList);
    31   this->setName("TrackNode");
     31  this->registerObject(this, TrackNode::_objectList);
    3232
    3333  PNode::getNullParent()->addChild(this);
  • branches/playability/src/util/track/track_node.h

    r9869 r10088  
    1414#include "p_node.h"
    1515
     16
    1617/* FORWARD DECLARATION */
    1718class TrackManager;
     
    2021class TrackNode : public PNode
    2122{
    22   ObjectListDeclaratrion(TracNode);
     23  ObjectListDeclaration(TrackNode);
    2324 public:
    2425  TrackNode ();
  • branches/playability/src/world_entities/world_entity.cc

    r9869 r10088  
    2828
    2929#include "util/loading/load_param.h"
     30#include "loading/load_param_xml.h"
     31#include "util/loading/factory.h"
     32
    3033#include "obb_tree.h"
    3134
     
    4043#include "kill.h"
    4144#include "debug.h"
     45
     46#include "track/track.h"
    4247
    4348#include "projectiles/projectile.h"
     
    8388  this->bOnGround = false;
    8489
     90  // Track of this entity
     91  this->entityTrack = NULL;
     92
    8593  // registering default reactions:
    8694  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /* WorldEntity::staticClassID(), */ Projectile::staticClassID());
     
    136144  .defaultValues("", 1.0f, 0);
    137145
     146  // Entity Attributes
    138147  LoadParam(root, "maxHealth", this, WorldEntity, setHealthMax)
    139148  .describe("The Maximum health that can be loaded onto this entity")
     
    145154
    146155  LoadParam(root, "list", this, WorldEntity, toListS);
     156
     157
     158  // Track
     159  LoadParamXML(root, "Track", this, WorldEntity, addTrack)
     160   .describe("creates and adds a track to this WorldEntity");
     161}
     162
     163
     164/**
     165 * this functions adds a track to this workd entity. This can be usefull, if you like this WE to follow a some waypoints.
     166 * here the track is created and further initializing left for the Track itself
     167 */
     168void WorldEntity::addTrack(const TiXmlElement* root)
     169{
     170  LOAD_PARAM_START_CYCLE(root, element);
     171  {
     172    PRINTF(4)("element is: %s\n", element->Value());
     173    Factory::fabricate(element);
     174  }
     175  LOAD_PARAM_END_CYCLE(element);
    147176}
    148177
  • branches/playability/src/world_entities/world_entity.h

    r9869 r10088  
    3232class CollisionHandle;
    3333class Collision;
     34class Track;
     35class TiXmlElement;
    3436
    3537
     
    174176private:
    175177  void updateHealthWidget();
     178  void addTrack(const TiXmlElement* root);
    176179
    177180private:
     
    218221  bool                    bOnGround;                       //!< true if this entity is standing on the ground
    219222
     223
     224  Track*                  entityTrack;                     //!< this is the track this entity follows (or NULL if none)
     225
    220226protected:
    221227  Vector                  velocity;                        //!< speed of the entity
Note: See TracChangeset for help on using the changeset viewer.