00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "LampBasic.h"
00026 #include "Animation/System/AnimationSet.h"
00027 #include "Animation/System/AnimationManager.h"
00028
00029 namespace Lamp{
00030
00031
00032
00033 AnimationSet::AnimationSet(String name, AnimationManager* manager) :
00034 Animation(name, manager){
00035 }
00036
00037
00038 AnimationSet::~AnimationSet(){
00039 }
00040
00041
00042 bool AnimationSet::bind(Scene* scene){
00043
00044 bool result = true;
00045 int animationCount = getAnimationCount();
00046 for(int i = 0; i < animationCount; i++){
00047 if(!getAnimation(i)->bind(scene)){ result = false; }
00048 }
00049 return result;
00050 }
00051
00052
00053 void AnimationSet::unbind(){
00054 int animationCount = getAnimationCount();
00055 for(int i = 0; i < animationCount; i++){
00056 getAnimation(i)->unbind();
00057 }
00058 }
00059
00060
00061 int AnimationSet::getSequenceCount() const{
00062
00063 int animationCount = getAnimationCount();
00064 if(animationCount == 0){ return 0; }
00065 int result = getAnimation(0)->getSequenceCount();
00066 for(int i = 1; i < animationCount; i++){
00067 int count = getAnimation(i)->getSequenceCount();
00068 if(count < result){ result = count; }
00069 }
00070 return result;
00071 }
00072
00073
00074 void AnimationSet::setSequence(int sequence, float time){
00075 Assert(sequence >= 0);
00076 Assert(sequence < getSequenceCount());
00077 int animationCount = getAnimationCount();
00078 for(int i = 0; i < animationCount; i++){
00079 getAnimation(i)->setSequence(sequence, time);
00080 }
00081 }
00082
00083
00084 int AnimationSet::getSequence() const{
00085
00086 int animationCount = getAnimationCount();
00087 if(animationCount == 0){ return 0; }
00088 int result = getAnimation(0)->getSequence();
00089 for(int i = 1; i < animationCount; i++){
00090 int sequence = getAnimation(i)->getSequence();
00091 if(sequence < result){ result = sequence; }
00092 }
00093 return result;
00094 }
00095
00096
00097 void AnimationSet::setTime(float time){
00098 int animationCount = getAnimationCount();
00099 for(int i = 0; i < animationCount; i++){ getAnimation(i)->setTime(time); }
00100 }
00101
00102
00103 float AnimationSet::getTime() const{
00104
00105 int animationCount = getAnimationCount();
00106 if(animationCount == 0){ return 0.f; }
00107 float result = getAnimation(0)->getTime();
00108 for(int i = 1; i < animationCount; i++){
00109 float time = getAnimation(i)->getTime();
00110 if(time < result){ result = time; }
00111 }
00112 return result;
00113 }
00114
00115
00116 bool AnimationSet::animate(float deltaTime, AnimationMask mask){
00117
00118 if(!isEnabled()){ return true; }
00119
00120 bool result = true;
00121 int animationCount = getAnimationCount();
00122 for(int i = 0; i < animationCount; i++){
00123 if(!getAnimation(i)->animate(deltaTime, mask)){ result = false; }
00124 }
00125 return result;
00126 }
00127
00128
00129 float AnimationSet::getLength() const{
00130
00131 int animationCount = getAnimationCount();
00132 if(animationCount == 0){ return 0.f; }
00133 float result = getAnimation(0)->getLength();
00134 for(int i = 1; i < animationCount; i++){
00135 float length = getAnimation(i)->getLength();
00136 if(length > result){ result = length; }
00137 }
00138 return result;
00139 }
00140
00141
00142 bool AnimationSet::isFinished() const{
00143
00144 bool result = true;
00145 int animationCount = getAnimationCount();
00146 for(int i = 0; i < animationCount; i++){
00147 if(!getAnimation(i)->isFinished()){ result = false; }
00148 }
00149 return result;
00150 }
00151
00152
00153 bool AnimationSet::isLooped() const{
00154
00155 int animationCount = getAnimationCount();
00156 for(int i = 0; i < animationCount; i++){
00157 if(getAnimation(i)->isLooped()){ return true; }
00158 }
00159 return false;
00160 }
00161
00162
00163 AnimationSet* AnimationSet::copyAnimationSet(DataCopyMask dataCopyMask) const{
00164 AnimationSet* animation = getManager()->createAnimationSet(getName());
00165 animation->setEnabled(isEnabled());
00166 int animationCount = getAnimationCount();
00167 for(int i = 0; i < animationCount; i++){
00168 animation->addAnimation(getAnimation(i)->copy(dataCopyMask));
00169 }
00170 return animation;
00171 }
00172
00173 }
00174