Changeset 7333 in orxonox.OLD for trunk/src/lib/particles/quick_animation.h
- Timestamp:
- Apr 18, 2006, 8:29:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/quick_animation.h
r5405 r7333 8 8 #define _QUICK_ANIMATION_H 9 9 10 #include "base_object.h" 11 10 #include <vector> 12 11 // FORWARD DECLARATION 13 14 15 16 12 17 13 //! A class for that linearely interpolates between multiple values. 18 14 /** 19 to be quick this only has the capability to store very little date 15 * QuickAnimation is a Class that creates a LookupTable with 16 * position between [0.0f - 1.0f] so that one can resolve the 17 * given Value. 18 */ 19 class QuickAnimation 20 { 21 public: 22 QuickAnimation(unsigned int resolution = 100); 23 virtual ~QuickAnimation(); 20 24 21 this class is optimized for a raising value. eg. 100 particles sorted 22 by age. 23 */ 24 class QuickAnimation : public BaseObject { 25 bool addKey(float position, float value); 25 26 26 public: 27 bool changeValueKey(unsigned int keyFrameNumber, float newValue); 28 bool changeValue(float position, float newValue, float region = 0.04f); 27 29 30 bool removeKey(unsigned int keyFrameNumber); 31 bool remove(float position, float region = 0.04f); 32 33 bool moveKey(unsigned int keyFrameNumber, float newPosition, float newValue); 34 bool moveKey(unsigned int keyFrameNumber, float newPosition); 35 bool move(float oldPosition, float newPosition, float newValue, float region = 0.04f); 36 bool move(float oldPosition, float newPosition, float region = 0.04f); 37 38 int getKeyAt(float position, float region = 0.04f); 39 40 /** 41 * @brief returns the value of the animation at a certain position 42 * @param value returns the calculated value. 43 * @param position The position to get the Value from. 44 */ 45 void QuickAnimation::getValue(float& value, float position) const 46 { 47 value = this->lookupValues[int(position*this->lookupValues.size())]; 48 } 49 50 /** 51 * @brief returns the value of the animation at a certain position 52 * @param position the position to get the value from :) 53 * @returns the calculated Value. 54 */ 55 float QuickAnimation::getValue(float position) const 56 { 57 return this->lookupValues[int(position*this->lookupValues.size())]; 58 } 59 60 void debug() const; 61 private: 62 void rebuild(); 63 64 private: 28 65 //! a simple struct that stores keyframes for the QuickAnimation-Class. 29 66 struct QuickKeyFrame 30 67 { 31 float value; //!< The starting value of this KeyFrame 32 float position; //!< The end position of thies KeyFrame 68 //! Creates a new QuickKeyFrame with @param position position @param value value */ 69 QuickKeyFrame(float position, float value) : position(position), value(value) {}; 70 float value; //!< The value of this KeyFrame 71 float position; //!< The position of thies KeyFrame 33 72 34 QuickKeyFrame* next; //!< The next Animation35 QuickKeyFrame* prev; //!< The previous QuickKeyFrame73 static bool sortPositionPredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2); 74 static bool sortValuePredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2); 36 75 }; 37 76 38 QuickAnimation(); 39 virtual ~QuickAnimation(); 40 41 void addEntry(float position, float value); 42 void changeEntry(float position, float value, float region = .04); 43 44 void removeEntry(float position); 45 /** @todo implemente those functions 46 bool moveEntry(float position); 47 */ 48 49 float getValue(float position); 50 51 void debug(); 52 53 private: 54 QuickKeyFrame* first; //!< The first KeyFrame in a Sequence of Keyframes. 55 QuickKeyFrame* current; //!< The currently selected KeyFrame. 56 unsigned int count; //!< How many Keyframes the QuickAnimation has. 77 std::vector<QuickKeyFrame> keyFrames; //!< An Array of KeyFrames. 78 std::vector<float> lookupValues; //!< The lookup-table where the values are stored. 57 79 }; 58 80
Note: See TracChangeset
for help on using the changeset viewer.