Changeset 4415 in orxonox.OLD for orxonox/trunk/src/lib/graphics/particles/quick_animation.cc
- Timestamp:
- May 31, 2005, 9:12:33 AM (19 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/particles/quick_animation.cc
r4394 r4415 16 16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ 17 17 18 #include "proto_class.h" 18 #include "quick_animation.h" 19 20 #include "compiler.h" 21 #include "debug.h" 22 #ifndef NULL 23 #define NULL 0 24 #endif 25 19 26 20 27 using namespace std; … … 23 30 /** 24 31 \brief standard constructor 25 \todo this constructor is not jet implemented - do it26 32 */ 27 ProtoClass::ProtoClass () 33 QuickAnimation::QuickAnimation (float rangeStart, float valueStart, float rangeEnd, float valueEnd) 28 34 { 29 this->setClass ID(CL_PROTO_ID, "ProtoClass");35 this->setClassName("QuickAnimation"); 30 36 31 /* If you make a new class, what is most probably the case when you write this file 32 don't forget to: 33 1. Add the new file new_class.cc to the ./src/Makefile.am 34 2. Add the class identifier to ./src/class_list.h eg. CL_NEW_CLASS 35 36 Advanced Topics: 37 - if you want to let your object be managed via the ObjectManager make sure to read 38 the object_manager.h header comments. You will use this most certanly only if you 39 make many objects of your class, like a weapon bullet. 40 */ 37 this->first = this->current = new QuickKeyFrame; 38 this->current->positionStart = rangeStart; 39 this->current->positionEnd = rangeEnd; 40 this->current->valueStart = valueStart; 41 this->current->valueEnd = valueEnd; 42 this->current->next = NULL; 41 43 } 42 44 … … 46 48 47 49 */ 48 ProtoClass::~ProtoClass()50 QuickAnimation::~QuickAnimation () 49 51 { 50 // delete what has to be deleted here 52 this->current = this->first; 53 QuickKeyFrame delKF; 54 55 while (this->current != NULL) 56 { 57 this->first = this->current->next; 58 delete this->current; 59 this->current = this->first; 60 } 61 51 62 } 63 64 65 void QuickAnimation::addEntry(float position, float value) 66 { 67 this->current = this->first; 68 if (position < this->current->positionStart) 69 { 70 this->current = new QuickKeyFrame; 71 72 this->current->positionStart = position; 73 this->current->positionEnd = this->first->positionStart; 74 75 this->current->valueStart = value; 76 this->current->valueEnd = this->first->valueStart; 77 78 this->current->next = this->first; 79 this->first = this->current; 80 } 81 82 while(this->current != NULL) 83 { 84 if (this->current->positionStart < position) 85 { 86 QuickKeyFrame* tmpKey = new QuickKeyFrame; 87 tmpKey->positionStart = position; 88 tmpKey->positionEnd = this->current->positionEnd; 89 tmpKey->valueStart = value; 90 tmpKey->valueEnd = this->current->valueEnd; 91 tmpKey->next = this->current->next; 92 93 this->current->positionEnd = tmpKey->positionStart; 94 this->current->valueEnd = tmpKey->valueStart; 95 } 96 } 97 } 98 99 100 float QuickAnimation::getValue(float position) 101 { 102 while (likely (this->current->positionStart > position || this->current->positionEnd < position)) 103 { 104 if (likely(this->current->next != NULL)) 105 this->current = this->current->next; 106 else 107 { 108 if (unlikely(this->first->positionStart > position)) 109 { 110 PRINTF(2)("Position out of range. chose %f, min is: %f, max is\n", position, this->first->positionStart, this->current->positionEnd); 111 return 0; 112 } 113 this->current = this->first; 114 } 115 } 116 return this->current->valueStart + (this->current->positionEnd - position) * 117 (this->current->valueEnd - this->current->valueStart) / 118 (this->current->positionEnd - this->current->positionStart); 119 } 120
Note: See TracChangeset
for help on using the changeset viewer.