Changeset 10618 in orxonox.OLD for trunk/src/util
- Timestamp:
- Apr 4, 2007, 12:13:53 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 6 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 16 16 OrxonoxPlayability.kdevses 17 17 OrxonoxPlayability.kdevelop.pcs 18 orxonox.backtrace 19 orxonox.kdevses 20 orxonox.kdevelop.pcs
-
- Property svn:ignore
-
trunk/src/util/Makefile.am
r10368 r10618 26 26 animation/animation_player.cc \ 27 27 \ 28 track/pilot_node.cc \ 29 track/track.cc \ 30 track/track_manager.cc \ 31 track/track_node.cc 28 track/track.cc 32 29 33 30 noinst_HEADERS = \ … … 52 49 animation/t_animation.h \ 53 50 \ 54 track/pilot_node.h \ 55 track/track.h \ 56 track/track_manager.h \ 57 track/track_node.h 58 51 track/track.h -
trunk/src/util/animation/animation.h
r9869 r10618 10 10 #include "debug.h" 11 11 12 #include "list.h"12 #include <list> 13 13 // FORWARD DECLARATION 14 14 -
trunk/src/util/animation/animation3d.cc
r9406 r10618 35 35 36 36 // create a new List 37 this->keyFrameList = new tList<KeyFrame3D>(); 38 KeyFrame3D* tmpKeyFrame = new KeyFrame3D; 39 tmpKeyFrame->position = Vector(); 40 tmpKeyFrame->direction = Quaternion(); 41 keyFrameList->add(tmpKeyFrame); 42 43 this->currentKeyFrame = tmpKeyFrame; 44 this->nextKeyFrame = tmpKeyFrame; 37 KeyFrame3D tmpKeyFrame; 38 keyFrameList.push_back(tmpKeyFrame); 39 40 this->currentKeyFrame = keyFrameList.begin(); 41 this->nextKeyFrame = keyFrameList.begin(); 45 42 46 43 this->animFuncMov = NULL;//&Animation3D::mLinear; 47 44 this->animFuncRot = NULL;//&Animation3D::rLinear; 48 49 45 } 50 46 … … 56 52 Animation3D::~Animation3D() 57 53 { 58 // delete all the KeyFrames59 tIterator<KeyFrame3D>* itKF = keyFrameList->getIterator();60 KeyFrame3D* enumKF = itKF->firstElement();61 while (enumKF)62 {63 delete enumKF;64 enumKF = itKF->nextElement();65 }66 delete itKF;67 delete this->keyFrameList;68 54 } 69 55 … … 73 59 void Animation3D::rewind() 74 60 { 75 this->currentKeyFrame = keyFrameList ->firstElement();76 this->nextKeyFrame = keyFrameList ->nextElement(keyFrameList->firstElement());61 this->currentKeyFrame = keyFrameList.begin(); 62 this->nextKeyFrame = keyFrameList.begin()++; 77 63 this->localTime = 0.0; 78 this->setAnimFuncMov( this->currentKeyFrame->animFuncMov);79 this->setAnimFuncRot( this->currentKeyFrame->animFuncRot);64 this->setAnimFuncMov((*this->currentKeyFrame).animFuncMov); 65 this->setAnimFuncRot((*this->currentKeyFrame).animFuncRot); 80 66 } 81 67 … … 100 86 // animFuncRot = animFuncMov; 101 87 102 KeyFrame3D * tmpKeyFrame;88 KeyFrame3D& tmpKeyFrame = keyFrameList.front(); 103 89 104 90 // when adding the first frame 105 91 if (this->keyFrameCount == 0) 106 92 { 107 tmpKeyFrame = this->keyFrameList->firstElement();108 93 //this->setAnimFuncMov(animFuncMov); 109 94 //this->setAnimFuncRot(animFuncRot); … … 111 96 else 112 97 { 113 tmpKeyFrame = new KeyFrame3D;114 98 // when adding the second frame 99 this->keyFrameList.push_back(KeyFrame3D()); 115 100 if (this->currentKeyFrame == this->nextKeyFrame) 116 this->nextKeyFrame = tmpKeyFrame; 117 this->keyFrameList->add(tmpKeyFrame); 101 this->nextKeyFrame = --keyFrameList.end(); 118 102 } 119 103 120 tmpKeyFrame ->position = position;104 tmpKeyFrame.position = position; 121 105 //tmpKeyFrame->lastPosition = position; 122 tmpKeyFrame ->direction = direction;123 tmpKeyFrame ->duration = duration;124 tmpKeyFrame ->animFuncMov = animFuncMov;125 tmpKeyFrame ->animFuncRot = animFuncRot;106 tmpKeyFrame.direction = direction; 107 tmpKeyFrame.duration = duration; 108 tmpKeyFrame.animFuncMov = animFuncMov; 109 tmpKeyFrame.animFuncRot = animFuncRot; 126 110 this->keyFrameCount++; 127 111 } … … 146 130 this->currentKeyFrame = this->nextKeyFrame; 147 131 // checking, if we should still Play the animation 148 if (this->currentKeyFrame == this->keyFrameList->lastElement())132 if (this->currentKeyFrame == --this->keyFrameList.end()) 149 133 this->handleInfinity(); 150 this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 134 this->nextKeyFrame = this->currentKeyFrame; 135 this->nextKeyFrame++; 151 136 this->setAnimFuncMov(this->currentKeyFrame->animFuncMov); 152 137 this->setAnimFuncRot(this->currentKeyFrame->animFuncRot); -
trunk/src/util/animation/animation3d.h
r6616 r10618 16 16 This represents one point with direction of the animation 17 17 */ 18 typedef struct KeyFrame3D { 18 typedef struct KeyFrame3D 19 { 19 20 float duration; //!< The duration of this KeyFrame 20 21 Vector position; //!< The position of this KeyFrame … … 31 32 class Animation3D : public Animation 32 33 { 33 34 public: 34 35 Animation3D(PNode* object); 35 36 virtual ~Animation3D(); … … 44 45 virtual void tick(float dt); 45 46 46 47 private: 47 48 // animation functions 48 49 void setAnimFuncMov(ANIM_FUNCTION animFunc); … … 69 70 70 71 71 private: 72 KeyFrame3D* currentKeyFrame; //!< The current KeyFrame 73 KeyFrame3D* nextKeyFrame; //!< The KeyFrame we iterate to 74 tList<KeyFrame3D>* keyFrameList; //!< The KeyFrameList 72 private: 73 typedef std::list<KeyFrame3D> KeyFrameList; //!< A Type definition for th KeyFrame List 74 typedef KeyFrameList::iterator KeyFrameIterator; //!< A Type definition for th KeyFrame List 75 76 KeyFrameIterator currentKeyFrame; //!< The current KeyFrame 77 KeyFrameIterator nextKeyFrame; //!< The KeyFrame we iterate to 78 KeyFrameList keyFrameList; //!< The KeyFrameList 75 79 76 80 -
trunk/src/util/animation/t_animation.h
r8315 r10618 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2004 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: Benjamin Grauer … … 37 37 template<class T> class tAnimation : public Animation 38 38 { 39 39 public: 40 40 tAnimation(T* object = NULL, void (T::*funcToAnim)(float) = NULL); 41 virtual ~tAnimation();42 41 43 42 void setFuncToAnim(T* object, void (T::*funcToAnim)(float)); … … 48 47 virtual void tick(float dt); 49 48 50 49 private: 51 50 // animation functions 52 51 void setAnimFunc(ANIM_FUNCTION animFunc); … … 61 60 62 61 62 private: 63 typedef std::list<KeyFrameF> KeyFrameList; 64 typedef typename KeyFrameList::iterator KeyFrameIterator; 65 63 66 // ANIM_FUNCTION animFunc 64 67 float (tAnimation<T>::*animFunc)(float) const; //!< A Function for the AnimationType 65 68 66 KeyFrame F*currentKeyFrame; //!< The current KeyFrame67 KeyFrame F*nextKeyFrame; //!< The KeyFrame we iterate to68 tList<KeyFrameF>*keyFrameList; //!< The KeyFrameList69 KeyFrameIterator currentKeyFrame; //!< The current KeyFrame 70 KeyFrameIterator nextKeyFrame; //!< The KeyFrame we iterate to 71 KeyFrameList keyFrameList; //!< The KeyFrameList 69 72 70 73 T* object; //!< The Object from which to Animate something … … 83 86 { 84 87 // create a new List 85 this->keyFrameList = new tList<KeyFrameF>(); 86 KeyFrameF* tmpKeyFrame = new KeyFrameF; 87 tmpKeyFrame->value = 0.0; 88 tmpKeyFrame->duration = 1.0; 89 keyFrameList->add(tmpKeyFrame); 90 91 this->currentKeyFrame = tmpKeyFrame; 92 this->nextKeyFrame = tmpKeyFrame; 88 KeyFrameF tmpKeyFrame; 89 tmpKeyFrame.value = 0.0; 90 tmpKeyFrame.duration = 1.0; 91 keyFrameList.push_back(tmpKeyFrame); 92 93 this->currentKeyFrame = keyFrameList.begin(); 94 this->nextKeyFrame = keyFrameList.begin(); 93 95 94 96 this->animFunc = &tAnimation<T>::linear; … … 99 101 100 102 /** 101 * standard deconstructor102 103 deletes all the Keyframes104 */105 template<class T>106 tAnimation<T>::~tAnimation ()107 {108 // delete all the KeyFrames109 tIterator<KeyFrameF>* itKF = keyFrameList->getIterator();110 KeyFrameF* enumKF = itKF->firstElement();111 while (enumKF)112 {113 delete enumKF;114 enumKF = itKF->nextElement();115 }116 delete itKF;117 delete this->keyFrameList;118 }119 120 /**121 103 * rewinds the Animation to the beginning (first KeyFrame and time == 0) 122 104 */ … … 124 106 void tAnimation<T>::rewind() 125 107 { 126 this->currentKeyFrame = keyFrameList ->firstElement();127 this->nextKeyFrame = keyFrameList->nextElement(keyFrameList->firstElement());108 this->currentKeyFrame = keyFrameList.begin(); 109 this->nextKeyFrame = ++keyFrameList.begin(); 128 110 this->localTime = 0.0; 129 this->setAnimFunc( this->currentKeyFrame->animFunc);111 this->setAnimFunc((*this->currentKeyFrame).animFunc); 130 112 } 131 113 … … 157 139 animFunc = ANIM_DEFAULT_FUNCTION; 158 140 159 KeyFrameF * tmpKeyFrame;141 KeyFrameF& tmpKeyFrame = keyFrameList.front(); 160 142 161 143 // when adding the first frame 162 144 if (this->keyFrameCount == 0) 163 { 164 tmpKeyFrame = this->keyFrameList->firstElement(); 165 this->setAnimFunc(animFunc); 166 } 145 { 146 this->setAnimFunc(animFunc); 147 } 167 148 else 168 169 tmpKeyFrame = new KeyFrameF;170 // when adding the second frame171 if (this->currentKeyFrame == this->nextKeyFrame)172 this->nextKeyFrame = tmpKeyFrame;173 this-> keyFrameList->add(tmpKeyFrame);174 175 176 tmpKeyFrame ->value = value;177 tmpKeyFrame ->duration = duration;178 tmpKeyFrame ->animFunc = animFunc;149 { 150 this->keyFrameList.push_back(KeyFrameF()); 151 tmpKeyFrame = keyFrameList.back(); 152 // when adding the second frame 153 if (this->currentKeyFrame == this->nextKeyFrame) 154 this->nextKeyFrame = --keyFrameList.end(); 155 } 156 157 tmpKeyFrame.value = value; 158 tmpKeyFrame.duration = duration; 159 tmpKeyFrame.animFunc = animFunc; 179 160 this->keyFrameCount++; 180 161 } … … 188 169 { 189 170 if (this->bRunning) 171 { 172 this->localTime += dt; 173 if (localTime >= this->currentKeyFrame->duration) 190 174 { 191 this->localTime += dt; 192 if (localTime >= this->currentKeyFrame->duration) 193 { 194 if (likely(this->keyFramesToPlay != 0)) 195 { 196 if (unlikely(this->keyFramesToPlay > 0)) 197 --this->keyFramesToPlay; 198 // switching to the next Key-Frame 199 this->localTime -= this->currentKeyFrame->duration; 200 201 this->currentKeyFrame = this->nextKeyFrame; 202 // checking, if we should still Play the animation 203 if (this->currentKeyFrame == this->keyFrameList->lastElement()) 204 this->handleInfinity(); 205 this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 206 207 //printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value); 208 this->setAnimFunc(this->currentKeyFrame->animFunc); 209 } 210 else 211 this->pause(); 212 } 213 214 (this->object->*(funcToAnim))((this->*animFunc)(this->localTime)); 175 if (likely(this->keyFramesToPlay != 0)) 176 { 177 if (unlikely(this->keyFramesToPlay > 0)) 178 --this->keyFramesToPlay; 179 // switching to the next Key-Frame 180 this->localTime -= this->currentKeyFrame->duration; 181 182 this->currentKeyFrame = this->nextKeyFrame; 183 // checking, if we should still Play the animation 184 if (this->currentKeyFrame == --this->keyFrameList.end()) 185 this->handleInfinity(); 186 this->nextKeyFrame = this->currentKeyFrame; 187 this->nextKeyFrame++; 188 189 //printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value); 190 this->setAnimFunc(this->currentKeyFrame->animFunc); 191 } 192 else 193 this->pause(); 215 194 } 195 196 (this->object->*(funcToAnim))((this->*animFunc)(this->localTime)); 197 } 216 198 } 217 199 … … 224 206 { 225 207 switch (animFunc) 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 208 { 209 default: 210 case ANIM_CONSTANT: 211 this->animFunc = &tAnimation<T>::constant; 212 break; 213 case ANIM_LINEAR: 214 this->animFunc = &tAnimation<T>::linear; 215 break; 216 case ANIM_SINE: 217 this->animFunc = &tAnimation<T>::sine; 218 break; 219 case ANIM_COSINE: 220 this->animFunc = &tAnimation<T>::cosine; 221 break; 222 case ANIM_EXP: 223 this->animFunc = &tAnimation<T>::exp; 224 break; 225 case ANIM_NEG_EXP: 226 this->animFunc = &tAnimation<T>::negExp; 227 expFactor = - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X); 228 break; 229 case ANIM_QUADRATIC: 230 this->animFunc = &tAnimation<T>::quadratic; 231 break; 232 case ANIM_RANDOM: 233 this->animFunc = &tAnimation<T>::random; 234 break; 235 } 254 236 } 255 237 … … 274 256 { 275 257 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 276 * (timePassed / this->currentKeyFrame->duration);258 * (timePassed / this->currentKeyFrame->duration); 277 259 } 278 260 … … 286 268 if (timePassed * 2.0 < this->currentKeyFrame->duration) 287 269 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 288 * sin( M_PI * timePassed / this->currentKeyFrame->duration)/2;270 * sin( M_PI * timePassed / this->currentKeyFrame->duration)/2; 289 271 else 290 272 return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value) 291 * sin( M_PI * (1.0 - timePassed / this->currentKeyFrame->duration))/2;273 * sin( M_PI * (1.0 - timePassed / this->currentKeyFrame->duration))/2; 292 274 /* 293 275 printf("::%f::::%f::\n",timePassed/this->currentKeyFrame->duration,retVal); … … 304 286 { 305 287 return ((this->nextKeyFrame->value + this->currentKeyFrame->value) + 306 (this->currentKeyFrame->value - this->nextKeyFrame->value) *307 cos( M_PI * timePassed / this->currentKeyFrame->duration))/2;288 (this->currentKeyFrame->value - this->nextKeyFrame->value) * 289 cos( M_PI * timePassed / this->currentKeyFrame->duration))/2; 308 290 } 309 291 … … 348 330 { 349 331 return this->currentKeyFrame->value + 350 (this->nextKeyFrame->value - this->currentKeyFrame->value) *351 (float)rand()/(float)RAND_MAX;332 (this->nextKeyFrame->value - this->currentKeyFrame->value) * 333 (float)rand()/(float)RAND_MAX; 352 334 } 353 335 -
trunk/src/util/multiplayer_team_deathmatch.cc
r10114 r10618 31 31 32 32 #include "shared_network_data.h" 33 #include " terrain.h"33 #include "environments/terrain.h" 34 34 #include "space_ships/space_ship.h" 35 35 … … 44 44 #include "shell_command.h" 45 45 46 #include " spawning_point.h"46 #include "tools/spawning_point.h" 47 47 48 48 #include "creatures/fps_player.h" -
trunk/src/util/state.cc
r10379 r10618 19 19 20 20 21 #include " camera.h"22 #include " cameraman.h"21 #include "tools/camera.h" 22 #include "tools/cameraman.h" 23 23 24 24 #ifndef NULL -
trunk/src/util/track/track.cc
r10512 r10618 25 25 #include "util/loading/load_param.h" 26 26 #include "track/track.h" 27 27 #include "glincl.h" 28 28 #include "p_node.h" 29 30 #include "stdincl.h"31 29 32 30 #include "debug.h"
Note: See TracChangeset
for help on using the changeset viewer.