Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/particles/quick_animation.h @ 7866

Last change on this file since 7866 was 7336, checked in by bensch, 19 years ago

doxy

File size: 2.8 KB
RevLine 
[4597]1/*!
[5039]2 * @file quick_animation.h
[7336]3 * Definition of the QuickAnimation-class
[3245]4*/
[1853]5
[4415]6#ifndef _QUICK_ANIMATION_H
7#define _QUICK_ANIMATION_H
[1853]8
[7333]9#include <vector>
[5405]10// FORWARD DECLARATION
[3543]11
[7333]12//! A class for that linearely interpolates between multiple values.
13/**
14 * QuickAnimation is a Class that creates a LookupTable with
15 * position between [0.0f - 1.0f] so that one can resolve the
16 * given Value.
17 */
18class QuickAnimation
19{
20public:
21  QuickAnimation(unsigned int resolution = 100);
22  virtual ~QuickAnimation();
[3543]23
[7333]24  bool addKey(float position, float value);
[2036]25
[7333]26  bool changeValueKey(unsigned int keyFrameNumber, float newValue);
27  bool changeValue(float position, float newValue, float region = 0.04f);
[1853]28
[7333]29  bool removeKey(unsigned int keyFrameNumber);
30  bool remove(float position, float region = 0.04f);
31
32  bool moveKey(unsigned int keyFrameNumber, float newPosition, float newValue);
33  bool moveKey(unsigned int keyFrameNumber, float newPosition);
34  bool move(float oldPosition, float newPosition, float newValue, float region = 0.04f);
35  bool move(float oldPosition, float newPosition, float region = 0.04f);
36
37  int getKeyAt(float position, float region = 0.04f);
38
39  /**
40   * @brief returns the value of the animation at a certain position
41   * @param value returns the calculated value.
42   * @param position The position to get the Value from.
43   */
[7335]44  void getValue(float& value, float position) const
[7333]45  {
46    value = this->lookupValues[int(position*this->lookupValues.size())];
47  }
48
[7334]49  /**
[7333]50   * @brief returns the value of the animation at a certain position
51   * @param position the position to get the value from :)
52   * @returns the calculated Value.
[7334]53   */
[7335]54  float getValue(float position) const
[7333]55  {
56    return this->lookupValues[int(position*this->lookupValues.size())];
57  }
[4415]58
[7333]59  void debug() const;
[7334]60
[7333]61private:
62  void rebuild();
[4415]63
[7333]64private:
[4415]65  //! a simple struct that stores keyframes for the QuickAnimation-Class.
66  struct QuickKeyFrame
67  {
[7333]68    //! Creates a new QuickKeyFrame with @param position position @param value value */
69    QuickKeyFrame(float position, float value) :  position(position), value(value) {};
[7335]70    //! compares this->position with position @param position pos to compare, @returns true on match.
71    bool operator==(float position) { return this->position == position; };
[7333]72    float            value;             //!< The value of this KeyFrame
73    float            position;          //!< The position of thies KeyFrame
[1853]74
[7333]75    static bool sortPositionPredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2);
76    static bool sortValuePredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2);
[4415]77  };
[3245]78
[7333]79  std::vector<QuickKeyFrame>    keyFrames;              //!< An Array of KeyFrames.
80  std::vector<float>            lookupValues;           //!< The lookup-table where the values are stored.
[1853]81};
82
[4415]83#endif /* _QUICK_ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.