Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10297 in orxonox.OLD


Ignore:
Timestamp:
Jan 20, 2007, 9:27:04 PM (17 years ago)
Author:
bknecht
Message:

track now works a bit can be partly used now

Location:
branches/playability/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/lib/math/curve.cc

    r9110 r10297  
    142142    tmpNode = tmpNode->next;
    143143  return tmpNode->position;
     144}
     145
     146/**
     147 * This function returns an approximation of the length of the curve
     148 *
     149*/
     150float Curve::getLength()
     151{
     152      float length = 0;
     153      PathNode* tmpNode = this->firstNode;
     154      for(int i = 1; i < this->nodeCount; i++)
     155      {
     156              length += Vector(tmpNode->next->position - tmpNode->position).len();
     157      }
     158      return length;
    144159}
    145160
  • branches/playability/src/lib/math/curve.h

    r6616 r10297  
    4747  /** @returns the directional Curve */
    4848  Curve* getDirCurve() const { return this->dirCurve; };
     49  float getLength();
    4950
    5051  /** @param t the value on the curve [0-1] @returns Vector to the position */
  • branches/playability/src/util/track/track.cc

    r10284 r10297  
    6565  this->curveType = CURVE_BEZIER;
    6666//  this->startingTime = 0;
    67   this->duration = 10;
    68   this->endTime = 10;
     67  this->duration = 20;
     68  this->endTime = 20;
    6969  this->width = 10;
    7070  this->curve = new BezierCurve();
     
    8888           LoadParam_CYCLE(element, "addPoint", this, Track, addPoint)
    8989             .describe("Adds a new Point to the currently selected TrackElement");
     90           LoadParam_CYCLE(element, "speed", this, Track, setSpeed)
     91             .describe("Sets speed of traveling");
    9092
    9193     }
     
    116118   if( this->nodeCount == 0) this->trackNode->setAbsCoor(newPoint);
    117119   this->nodeCount++;
    118    PRINTF(4)("Point added to curve %d\n");
     120   // PRINTF(0)("Point added to curve\n");
     121}
     122
     123/**
     124 * This function sets the speed of the trackNode by altering the duration
     125 * of the time the trackNode travels on the whole track. This is bad because
     126 * the speed depends on the length of the curve. (by getting the curve's length
     127 * this function will make a lot more sense)
     128 */
     129void Track::setSpeed(float speed)
     130{
     131     this->duration = this->duration/speed;
     132     
    119133}
    120134
     
    211225       this->trackNode->shiftCoor(tmp - this->trackNode->getAbsCoor());
    212226       // set direction and roll angle of trackNode
    213        // this->trackNode->setAbsDir(quat);
     227       this->trackNode->setAbsDir(quat);
    214228     }
    215229}
     
    230244   eventually this will all be packed into a gl-list.
    231245*/
    232 void Track::drawGraph(float dt) const
     246/*void Track::drawGraph(float dt) const
    233247{
    234248      glBegin(GL_LINE_STRIP);
     
    240254          }
    241255      glEnd();
    242 }
     256}*/
  • branches/playability/src/util/track/track.h

    r10284 r10297  
    2525   void addPoint(float x, float y, float z);
    2626   void addPointV(Vector newPoint);
     27   void setSpeed(float speed);
    2728
    2829   //void finalize();
     
    3334   PNode* getTrackNode();
    3435   
    35    void drawGraph(float dt) const;
     36//   void drawGraph(float dt) const;
    3637     
    3738   //float                 startingTime;         //!< The time at which this Track begins.
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10291 r10297  
    843843        this->travelNode->updateNode(0.01f);
    844844        this->isTravelDistanceInit = false;
     845       
     846        if(this->entityTrack)
     847           this->travelNode->setParent(this->entityTrack->getTrackNode());
    845848
    846849        this->setParent(this->travelNode);
     
    10271030
    10281031    //this moves camera and ship along the travel path.
    1029     this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
     1032    if(!this->entityTrack)
     1033       this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
    10301034
    10311035    break;
  • branches/playability/src/world_entities/world_entity.cc

    r10284 r10297  
    683683    }
    684684   
    685     if (this->entityTrack)
    686        this->entityTrack->drawGraph(0.02);
     685    //if (this->entityTrack)
     686       //this->entityTrack->drawGraph(0.02);
    687687
    688688    //     if( this->aabbNode != NULL)
Note: See TracChangeset for help on using the changeset viewer.