Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3319 in orxonox.OLD for orxonox/branches/parenting/src


Ignore:
Timestamp:
Jan 3, 2005, 12:23:08 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/parenting: added a testCurve to world.cc, and removed curve from the vector-class.

Location:
orxonox/branches/parenting/src
Files:
9 edited

Legend:

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

    r3311 r3319  
    3232                 base_object.cc \
    3333                 helper_parent.cc \
    34                  track_manager.cc
     34                 track_manager.cc \
     35                 curve.cc
    3536
    3637noinst_HEADERS = ability.h \
     
    7071                 base_object.h \
    7172                 helper_parent.h \
    72                  track_manager.h
     73                 track_manager.h \
     74                 curve.h
    7375
    7476
  • orxonox/branches/parenting/src/Makefile.in

    r3311 r3319  
    6262        material.$(OBJEXT) list.$(OBJEXT) p_node.$(OBJEXT) \
    6363        null_parent.$(OBJEXT) base_object.$(OBJEXT) \
    64         helper_parent.$(OBJEXT) track_manager.$(OBJEXT)
     64        helper_parent.$(OBJEXT) track_manager.$(OBJEXT) \
     65        curve.$(OBJEXT)
    6566orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    6667orxonox_LDADD = $(LDADD)
     
    7273@AMDEP_TRUE@    ./$(DEPDIR)/base_object.Po ./$(DEPDIR)/camera.Po \
    7374@AMDEP_TRUE@    ./$(DEPDIR)/campaign.Po ./$(DEPDIR)/collision.Po \
    74 @AMDEP_TRUE@    ./$(DEPDIR)/command_node.Po \
     75@AMDEP_TRUE@    ./$(DEPDIR)/command_node.Po ./$(DEPDIR)/curve.Po \
    7576@AMDEP_TRUE@    ./$(DEPDIR)/data_tank.Po \
    7677@AMDEP_TRUE@    ./$(DEPDIR)/environment.Po \
     
    227228                 base_object.cc \
    228229                 helper_parent.cc \
    229                  track_manager.cc
     230                 track_manager.cc \
     231                 curve.cc
    230232
    231233noinst_HEADERS = ability.h \
     
    265267                 base_object.h \
    266268                 helper_parent.h \
    267                  track_manager.h
     269                 track_manager.h \
     270                 curve.h
    268271
    269272EXTRA_DIST = orxonox.conf
     
    350353@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collision.Po@am__quote@
    351354@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command_node.Po@am__quote@
     355@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/curve.Po@am__quote@
    352356@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_tank.Po@am__quote@
    353357@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/environment.Po@am__quote@
  • orxonox/branches/parenting/src/curve.cc

    r3311 r3319  
    156156  \return a Vector to the calculated position
    157157*/
    158 Vector BezierCurve::getPos() const
     158Vector BezierCurve::getPos(void) const
    159159{
    160160  return curvePoint;
  • orxonox/branches/parenting/src/curve.h

    r3311 r3319  
    5555 
    5656 
    57   Vector getPos () const;
     57  Vector getPos(void) const;
    5858};
    5959
  • orxonox/branches/parenting/src/stdincl.h

    r3302 r3319  
    3131
    3232#include "vector.h"
     33#include "curve.h"
    3334#include "coordinates.h"
    3435#include "list.h"
  • orxonox/branches/parenting/src/vector.cc

    r3234 r3319  
    844844}
    845845
    846 
    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   PathNode* tmpNode;
    886   if (nodeCount == 0 )
    887     tmpNode = firstNode;
    888   else
    889     {
    890       tmpNode = new PathNode;
    891       currentNode = currentNode->next = tmpNode;
    892     }
    893   tmpNode->position = newNode;
    894   tmpNode->next = 0; // not sure if this really points to NULL!!
    895   tmpNode->number = (++nodeCount);
    896   return;
    897 }
    898 
    899 /**
    900    \brief calculates the Position on the curve
    901    \param t The position on the Curve (0<=t<=1)
    902    \return the Position on the Path
    903 */
    904 Vector BezierCurve::calcPos(float t)
    905 {
    906   if (nodeCount <=4)
    907     {
    908       //      if (verbose >= 1)
    909       //      printf ("Please define at least 4 nodes, until now you have only defined %i.\n", nodeCount);
    910       curvePoint = Vector(0,0,0);
    911     }
    912   PathNode* tmpNode = firstNode;
    913    
    914   int k,kn,nn,nkn;
    915   double blend,muk,munk;
    916   Vector b = Vector(0.0,0.0,0.0);
    917  
    918   muk = 1;
    919   munk = pow(1-t,(double)nodeCount);
    920  
    921   for (k=0; k<=nodeCount; k++) {
    922     nn = nodeCount;
    923     kn = k;
    924     nkn = nodeCount - k;
    925     blend = muk * munk;
    926     muk *= t;
    927     munk /= (1-t);
    928     while (nn >= 1) {
    929       blend *= nn;
    930       nn--;
    931       if (kn > 1) {
    932         blend /= (double)kn;
    933         kn--;
    934       }
    935       if (nkn > 1) {
    936         blend /= (double)nkn;
    937         nkn--;
    938       }
    939     }
    940     b.x += tmpNode->position.x * blend;
    941     b.y += tmpNode->position.y * blend;
    942     b.z += tmpNode->position.z * blend;
    943 
    944     tmpNode = tmpNode->next;
    945   }
    946   return b;
    947 }
    948 
    949 Vector BezierCurve::calcDirection (float t)
    950 {
    951   double diff = .00000000001;
    952  
    953   Vector diffV = ((calcPos(t+diff) - calcPos(t))/diff);
    954   diffV.normalize();
    955   return diffV;
    956 }
    957 
    958 /**
    959   \brief returns the Position of the point calculated on the Curve
    960   \return a Vector to the calculated position
    961 */
    962 Vector BezierCurve::getPos() const
    963 {
    964   return curvePoint;
    965 }
  • orxonox/branches/parenting/src/vector.h

    r3228 r3319  
    149149};
    150150
    151 
    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  public:
    176   BezierCurve (void);
    177   ~BezierCurve (void);
    178   void addNode (const Vector& newNode);
    179   Vector calcPos (float t);
    180   Vector calcDirection (float t);
    181  
    182   Vector getPos () const;
    183 };
    184 
    185 
    186 
    187151#endif /* _VECTOR_H */
  • orxonox/branches/parenting/src/world.cc

    r3311 r3319  
    153153        case DEBUG_WORLD_0:
    154154          {
     155            testCurve = new BezierCurve();
     156            testCurve->addNode(Vector(0,0,0));
     157            testCurve->addNode(Vector(5,7,0));
     158            testCurve->addNode(Vector(10,-5,0));
     159            testCurve->addNode(Vector(20, 0,10));
     160            testCurve->addNode(Vector(50, 7,-5));
     161           
    155162            this->nullParent = NullParent::getInstance ();
    156163            this->nullParent->setName ("NullParent");
     
    438445  glEnd();
    439446
     447  glBegin(GL_LINES);
     448  for(float i=0.0; i<1; i+=.01)
     449    {
     450      glVertex3f(testCurve->calcPos(i).x, testCurve->calcPos(i).y, testCurve->calcPos(i).z);
     451    }
     452  glEnd();
    440453  glEndList();
    441454}
  • orxonox/branches/parenting/src/world.h

    r3311 r3319  
    6666  Camera* localCamera; 
    6767
     68
     69  BezierCurve* testCurve;
    6870 private:
    6971  Uint32 lastFrame; //!> last time of frame
Note: See TracChangeset for help on using the changeset viewer.