Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3855 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Apr 17, 2005, 2:46:27 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: animation of weapon reimplemented (but only with Linear interpolation.
doxy-tags

Location:
orxonox/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/animation3d.cc

    r3853 r3855  
    2020#include "animation3d.h"
    2121
    22 #include "stdincl.h"
    23 #include "vector.h"
    2422#include "p_node.h"
    2523
    2624using namespace std;
    2725
    28 
     26/**
     27   \brief standard constructor
     28*/
    2929Animation3D::Animation3D(PNode* object)
    3030{
     
    4444}
    4545
     46/**
     47   \brief standard deconstructor
     48   
     49   deletes all the Keyframes
     50*/
    4651Animation3D::~Animation3D(void)
    4752{
     
    5863}
    5964
    60 
     65/**
     66   \brief rewinds the Animation to the beginning (first KeyFrame and time == 0)
     67*/
    6168void Animation3D::rewind(void)
    6269{
     
    6673}
    6774
    68 
    69 void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration = 1.0, ANIM_FUNCTION animFunc)
     75/**
     76   \brief Appends a new Keyframe
     77   \param position The position of the new Keyframe
     78   \param direction The direction of the new Keyframe.
     79   \param duration The duration from the new KeyFrame to the next one
     80   \param animFunc The function to animate between this keyFrame and the next one
     81*/
     82void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration, ANIM_FUNCTION animFunc)
    7083{
    7184  // some small check
     
    97110}
    98111
     112/**
     113   \brief ticks the Animation
     114   \param dt how much time to tick
     115*/
    99116void Animation3D::tick(float dt)
    100117{
     
    171188
    172189
    173 
     190/**
     191   \brief Sets The kind of Animation between this keyframe and the next one
     192   \param animFunc The Type of Animation to set
     193*/
    174194void Animation3D::setAnimFunc(ANIM_FUNCTION animFunc)
    175195{
     
    204224}
    205225
     226/**
     227   \brief stays at the value of the currentKeyFrame
     228   \param timePassed The time passed since this Keyframe began
     229*/
    206230void Animation3D::constant(float timePassed) const
    207231{
     
    216240}
    217241
     242/**
     243   \brief linear interpolation between this keyframe and the next one
     244   \param timePassed The time passed since this Keyframe began
     245*/
    218246void Animation3D::linear(float timePassed) const
    219247{
     
    223251}
    224252
     253/**
     254   \brief a Sinusodial Interpolation between this keyframe and the next one
     255   \param timePassed The time passed since this Keyframe began
     256*/
    225257void Animation3D::sine(float timePassed) const
    226258{
     
    228260}
    229261
     262/**
     263   \brief a cosine interpolation between this keyframe and the next one
     264   \param timePassed The time passed since this Keyframe began
     265*/
    230266void Animation3D::cosine(float timePassed) const
    231267{
     
    233269}
    234270
     271/**
     272   \brief an exponential interpolation between this keyframe and the next one
     273   \param timePassed The time passed since this Keyframe began
     274*/
    235275void Animation3D::exp(float timePassed) const
    236276{
     
    238278}
    239279
     280/**
     281   \brief a negative exponential interpolation between this keyframe and the next one
     282   \param timePassed The time passed since this Keyframe began
     283*/
    240284void Animation3D::negExp(float timePassed) const
    241285{
    242 
    243 }
    244 
     286  this->linear(timePassed);
     287}
     288
     289/**
     290   \brief a quadratic interpolation between this keyframe and the next one
     291   \param timePassed The time passed since this Keyframe began
     292*/
    245293void Animation3D::quadratic(float timePassed) const
    246294{
     
    248296}
    249297
     298/**
     299   \brief some random animation (fluctuating)
     300   \param timePassed The time passed since this Keyframe began
     301*/
    250302void Animation3D::random(float timePassed) const
    251303{
  • orxonox/trunk/src/animation3d.h

    r3852 r3855  
    1313*/
    1414typedef struct KeyFrame3D {
    15   float duration;
    16   Vector position;
    17   Quaternion direction;
    18   ANIM_FUNCTION animFunc;
     15  float duration;                   //!< The duration of this KeyFrame
     16  Vector position;                  //!< The position of this KeyFrame
     17  Quaternion direction;             //!< The direction of this KeyFrame
     18  ANIM_FUNCTION animFunc;           //!< with whitch function to iterate to the next KeyFrame3D
    1919};
    2020
     
    3232
    3333  void addKeyFrame(Vector position, Quaternion direction, float time, ANIM_FUNCTION animFunc = ANIM_LINEAR);
    34   void addKeyFrame(KeyFrame3D* frame);
     34  //  void addKeyFrame(KeyFrame3D* frame);
    3535
    3636  virtual void tick(float dt);
     
    4949  void random(float timePassed) const;
    5050  //  ANIM_FUNCTION animFunc;
    51   KeyFrame3D* currentKeyFrame;
    52   KeyFrame3D* nextKeyFrame;
    53   tList<KeyFrame3D>* keyFrameList;
    54   void (Animation3D::*animFunc)(float) const;
     51  void (Animation3D::*animFunc)(float) const;      //!< A Function for the AnimationType
     52
     53  KeyFrame3D* currentKeyFrame;                     //!< The current KeyFrame
     54  KeyFrame3D* nextKeyFrame;                        //!< The KeyFrame we iterate to
     55  tList<KeyFrame3D>* keyFrameList;                 //!< The KeyFrameList
    5556
    5657  // more class-local description
    57   PNode* object;
    58   Vector lastPosition;
    59   Vector tmpVect;
    60   float deltaT;
     58  PNode* object;                                   //!< The Object from which to Animate something
     59  Vector lastPosition;   //!< ??
     60  Vector tmpVect;        //!< what for??
     61  float deltaT;          //!< ??
    6162};
  • orxonox/trunk/src/t_animation.h

    r3854 r3855  
    5454  //  ANIM_FUNCTION animFunc;
    5555  float (tAnimation<T>::*animFunc)(float) const;  //!< A Function for the AnimationType
     56
    5657  KeyFrameF* currentKeyFrame;                     //!< The current KeyFrame
    5758  KeyFrameF* nextKeyFrame;                        //!< The KeyFrame we iterate to
     
    247248
    248249// animation functions
    249 
    250 /**
    251    \brief some random animation (fluctuating)
    252    \param timePassed The time passed since this Keyframe began
    253 */
    254 template<class T>
    255 float tAnimation<T>::random(float timePassed) const
    256 {
    257   return this->currentKeyFrame->value * (float)rand()/(float)RAND_MAX;
    258 }
    259 
    260250/**
    261251   \brief stays at the value of the currentKeyFrame
     
    345335}
    346336
     337/**
     338   \brief some random animation (fluctuating)
     339   \param timePassed The time passed since this Keyframe began
     340*/
     341template<class T>
     342float tAnimation<T>::random(float timePassed) const
     343{
     344  return this->currentKeyFrame->value * (float)rand()/(float)RAND_MAX;
     345}
    347346
    348347#endif /* _T_ANIMATION_H */
  • orxonox/trunk/src/world_entities/test_gun.cc

    r3852 r3855  
    5454
    5555  this->dummy1 = new WorldEntity(); // a world entity that is not drawed: use this for the weapon
    56   this->animaton = new Animation3D(dummy1);
    57 
     56  this->animation = new Animation3D(dummy1);
     57
     58  parent->addChild(this->dummy1, PNODE_ALL);
     59
     60  this->animation->setInfinity(ANIM_INF_CONSTANT);
     61  // ANIM_LINEAR was ANIM_NEG_EXP
     62  if( this->leftRight == 0)
     63    {
     64      this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR);
     65      this->animation->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.5, ANIM_LINEAR);
     66      this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR);
     67    }
     68  else if( this->leftRight == 1)
     69    {
     70      this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);
     71      this->animation->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.5, ANIM_LINEAR);
     72      this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);
     73    }
    5874  /*
    59   parent->addChild(this->dummy1, PNODE_ALL);
    60 
    61  
    62   this->animator->animatorBegin();
    63   this->animator->selectObject(this->dummy1);
    64   this->animator->setAnimationMode(SINGLE);
    65   if( this->leftRight == 0)
    66     {
    67       this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.0, NEG_EXP);
    68       this->animator->addKeyFrame(new Vector(-3.0, 0.1, 3.0), new Quaternion(), 0.1, NEG_EXP);
    69       this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.5, NEG_EXP);
    70     }
    71   else if( this->leftRight == 1)
    72     {
    73       this->animator->addKeyFrame(new Vector(-2.6, 0.1, -2.5), new Quaternion(), 0.0, NEG_EXP);
    74       this->animator->addKeyFrame(new Vector(-3.0, 0.1, -2.5), new Quaternion(), 0.1, NEG_EXP);
    75       this->animator->addKeyFrame(new Vector(-2.6, 0.1, -2.5), new Quaternion(), 0.5, NEG_EXP);
    76     }
    77   this->animator->animatorEnd();
     75  if( this->leftRight == 0)
     76    {
     77      this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.0, ANIM_NEG_EXP);
     78      this->animation->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.1, ANIM_NEG_EXP);
     79      this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.5, ANIM_NEG_EXP);
     80    }
     81  else if( this->leftRight == 1)
     82    {
     83      this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.0, ANIM_NEG_EXP);
     84      this->animation->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.1, ANIM_NEG_EXP);
     85      this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.5, ANIM_NEG_EXP);
     86    }
    7887  */
    7988}
     
    134143  this->localTime = 0;
    135144 
    136   /*
    137     this->animator->animatorBegin();
    138     this->animator->selectObject(this->dummy1);
    139     this->animator->start();
    140     this->animator->animatorEnd();
    141   */
     145  this->animation->replay();
    142146}
    143147
  • orxonox/trunk/src/world_entities/test_gun.h

    r3851 r3855  
    5252
    5353 private:
    54   Animation3D* animaton;
     54  Animation3D* animation;
    5555  Vector* projOffset;
    5656  WorldEntity* dummy1;
Note: See TracChangeset for help on using the changeset viewer.