Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3018 in orxonox.OLD for orxonox/branches/bezierTrack


Ignore:
Timestamp:
Nov 28, 2004, 1:31:21 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/bezierTrack: moved Curve to its own file. I expect this class to be bigger than I thought at the beginning:

  1. Class Curve and its subclasses: a) BezierCurve b) closedBezierCurve c) Nurbs d) any other curve that might occure

this will take some time and many hours of thinking so please help

Location:
orxonox/branches/bezierTrack/src
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/bezierTrack/src/Makefile.am

    r2990 r3018  
    77bin_PROGRAMS=orxonox
    88
    9 orxonox_SOURCES=orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc environment.cc array.cc material.cc list.cc
    10 noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h story_entity.h story_def.h game_loader.h campaign.h
     9orxonox_SOURCES=orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc environment.cc array.cc material.cc list.cc curve.cc
     10noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h story_entity.h story_def.h game_loader.h campaign.h curve.h
    1111
    1212
  • orxonox/branches/bezierTrack/src/Makefile.in

    r2991 r3018  
    6060        campaign.$(OBJEXT) story_entity.$(OBJEXT) object.$(OBJEXT) \
    6161        environment.$(OBJEXT) array.$(OBJEXT) material.$(OBJEXT) \
    62         list.$(OBJEXT)
     62        list.$(OBJEXT) curve.$(OBJEXT)
    6363orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    6464orxonox_LDADD = $(LDADD)
     
    6969@AMDEP_TRUE@    ./$(DEPDIR)/base_entity.Po ./$(DEPDIR)/camera.Po \
    7070@AMDEP_TRUE@    ./$(DEPDIR)/campaign.Po ./$(DEPDIR)/collision.Po \
    71 @AMDEP_TRUE@    ./$(DEPDIR)/command_node.Po \
     71@AMDEP_TRUE@    ./$(DEPDIR)/command_node.Po ./$(DEPDIR)/curve.Po \
    7272@AMDEP_TRUE@    ./$(DEPDIR)/data_tank.Po \
    7373@AMDEP_TRUE@    ./$(DEPDIR)/environment.Po \
     
    185185AM_CXXFLAGS = "-I/usr/X11R6/include"
    186186AM_LDFLAGS = "-L/usr/Mesa-6.0.1/lib  -L/usr/X11R6/lib -lXt -lX11" $(MWINDOWS)
    187 orxonox_SOURCES = orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc environment.cc array.cc material.cc list.cc
    188 noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h story_entity.h story_def.h game_loader.h campaign.h
     187orxonox_SOURCES = orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc environment.cc array.cc material.cc list.cc curve.cc
     188noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h story_entity.h story_def.h game_loader.h campaign.h curve.h
    189189all: all-am
    190190
     
    259259@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collision.Po@am__quote@
    260260@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command_node.Po@am__quote@
     261@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/curve.Po@am__quote@
    261262@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_tank.Po@am__quote@
    262263@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/environment.Po@am__quote@
  • orxonox/branches/bezierTrack/src/track.cc

    r3017 r3018  
    119119{
    120120  t+=.0001;
    121   if (t > 1) t =0;
     121  //  printf ("%f\n", t);
     122  //  if (t > 1) t =0;
    122123  //  printf ("Pos: %f, %f, %f\n", curve.calcPos(t).x, curve.calcPos(t).y, curve.calcPos(t).z);
    123124  //Line trace(*offset, *end - *offset);
  • orxonox/branches/bezierTrack/src/track.h

    r3015 r3018  
    88
    99#include "stdincl.h"
     10#include "curve.h"
    1011
    1112//!     The Red Line through a level
  • orxonox/branches/bezierTrack/src/vector.cc

    r3017 r3018  
    845845
    846846
    847 /**
    848    \brief Creates a new BezierCurve
    849 */
    850 BezierCurve::BezierCurve (void)
    851 {
    852   nodeCount = 0;
    853   firstNode = new PathNode;
    854   currentNode = firstNode;
    855 
    856   firstNode->position = Vector (.0, .0, .0);
    857   firstNode->number = 0;
    858   firstNode->next = 0; // not sure if this really points to NULL!!
    859 
    860   return;
    861 }
    862 
    863 /**
    864    \brief Deletes a BezierCurve.
    865    It does this by freeing all the space taken over from the nodes
    866 */
    867 BezierCurve::~BezierCurve (void)
    868 {
    869   PathNode* tmpNode;
    870   currentNode = firstNode;
    871   while (tmpNode != 0)
    872     {
    873       tmpNode = currentNode;
    874       currentNode = currentNode->next;
    875       delete tmpNode;
    876     }
    877 }
    878 
    879 /**
    880    \brief adds a new Node to the bezier Curve
    881    \param newNode a Vector to the position of the new node
    882 */
    883 void BezierCurve::addNode(const Vector& newNode)
    884 {
    885   if (nodeCount != 0 )
    886     {
    887       currentNode = currentNode->next = new PathNode;
    888     }
    889   currentNode->position = newNode;
    890   currentNode->next = 0; // not sure if this really points to NULL!!
    891   currentNode->number = (++nodeCount);
    892   return;
    893 }
    894 
    895 /**
    896    \brief calculates the Position on the curve
    897    \param t The position on the Curve (0<=t<=1)
    898    \return the Position on the Path
    899 */
    900 Vector BezierCurve::calcPos(float t)
    901 {
    902   if (nodeCount <=4)
    903     {
    904       //      if (verbose >= 1)
    905       //      printf ("Please define at least 4 nodes, until now you have only defined %i.\n", nodeCount);
    906       return Vector(0,0,0);
    907     }
    908   PathNode* tmpNode = firstNode;
    909    
    910   Vector ret = Vector(0.0,0.0,0.0);
    911   double factor;
    912   int k=0;
    913   while(tmpNode!=0)
    914     {
    915       k++;
    916       factor = ncr (nodeCount, k);
    917      
    918       for (int j=0; j<nodeCount-k; j++)
    919         factor*=(1-t);
    920       for (int j=0; j<k; j++)
    921         factor*=t;
    922       ret.x += factor * tmpNode->position.x;
    923       ret.y += factor * tmpNode->position.y;
    924       ret.z += factor * tmpNode->position.z;
    925      
    926       tmpNode = tmpNode->next;
    927 
    928     }
    929   return ret;
    930 }
    931 
    932 Vector BezierCurve::calcDir (float t)
    933 {
    934   PathNode* tmpNode = firstNode;
    935   BezierCurve* tmpCurve = new BezierCurve();
    936   Vector ret;
    937   Vector tmpVector;
    938 
    939   while (tmpNode->next != 0)
    940     {
    941       tmpVector = (tmpNode->next->position)- (tmpNode->position);
    942       tmpVector.x*=(float)nodeCount;
    943       tmpVector.y*=(float)nodeCount;
    944       tmpVector.z*=(float)nodeCount;
    945 
    946       tmpCurve->addNode(tmpVector);
    947       tmpNode = tmpNode->next;
    948     }
    949   ret = tmpCurve->calcPos(t);
    950   ret.normalize();
    951 
    952   return Vector (0,0,0);//ret;
    953 }
    954 
    955 /**
    956   \brief returns the Position of the point calculated on the Curve
    957   \return a Vector to the calculated position
    958 */
    959 Vector BezierCurve::getPos() const
    960 {
    961   return curvePoint;
    962 }
    963 
    964 
    965 int BezierCurve::ncr(int n, int i)
    966 {
    967   int ret = 1;
    968   for (int k=1; k<=n; k++)
    969     ret*=k;
    970   for (int k=1; k<=i; k++)
    971     ret/=k;
    972   for (int k=1; k<=n-i; k++)
    973     ret/=k;
    974 
    975   return ret;
    976 }
  • orxonox/branches/bezierTrack/src/vector.h

    r3015 r3018  
    150150
    151151
    152 
    153 //! Bezier Curve
    154 /**
    155    Class to handle bezier curves in 3-dimesnsional space
    156    
    157    needed for  the Tracking system in OrxOnoX.
    158 */
    159 class BezierCurve
    160 {
    161  private:
    162   int nodeCount;
    163   Vector curvePoint;
    164  
    165   struct PathNode
    166   {
    167     int number;
    168     Vector position;
    169     PathNode* next;
    170   };
    171 
    172   PathNode* firstNode;
    173   PathNode* currentNode;
    174 
    175   int ncr(int n, int i);
    176 
    177  public:
    178   BezierCurve (void);
    179   ~BezierCurve (void);
    180   void addNode (const Vector& newNode);
    181   Vector calcPos (float t);
    182   Vector calcDir (float t);
    183  
    184   Vector getPos () const;
    185 };
    186 
    187 
    188 
    189152#endif
  • orxonox/branches/bezierTrack/src/world.cc

    r3017 r3018  
    104104
    105105            track->addPoint (Vector(0, 0, 0));
    106             track->addPoint (Vector(10, 5, 0));
     106            track->addPoint (Vector(10, 0, 0));
     107            track->addPoint (Vector(11, 0, 0));
     108            track->addPoint (Vector(12, 0, 0));
     109            track->addPoint (Vector(13, 0, 0));
    107110            track->addPoint (Vector(20, 0, 0));
    108             track->addPoint (Vector(30, -10, 0));
    109             track->addPoint (Vector(40, 5, 0));
    110             track->addPoint (Vector(60, -10, 0));
     111            track->addPoint (Vector(30, 0, 0));
     112            track->addPoint (Vector(40, 0, 0));
     113            track->addPoint (Vector(60, 0, 0));
    111114           
    112115           
Note: See TracChangeset for help on using the changeset viewer.