00001 /*
00002 File: Animation.h
00003
00004 Function:
00005
00006 Author: Andrew Willmott
00007
00008 Copyright: (c) 2000, Andrew Willmott
00009 */
00010
00011 #ifndef __Animation__
00012 #define __Animation__
00013
00014 #include "gcl/Avars.h"
00015 #include "gcl/Hermite.h"
00016 #include "gcl/Geometry.h"
00017 #include "cl/Hash.h"
00018
00019 const GCLReal kAutoVel = -999999.0;
00020 const GCLReal kAutoSplitVel = -999998.0;
00021
00022
00023 class AnimRec
00024 // keyframes for a single variable
00025 {
00026 public:
00027 AnimRec() : currentTimeIndex(-2) {};
00028
00029 Void SetupAnim();
00030
00031 Void AddKey(GCLReal time, GCLReal value,
00032 GCLReal velIn, GCLReal velOut);
00033
00034 GCLReal GetValue(GCLReal time);
00035
00036 Int FindTimeIndex(GCLReal time);
00037
00038 // fields
00039 ScalarList keyTimes;
00040 ScalarList values;
00041 ScalarList velIn;
00042 ScalarList velOut;
00043
00044 Int currentTimeIndex;
00045 Cubic currentCubic;
00046 };
00047
00048 typedef PtrArray<AnimRec> AnimRecList;
00049
00050 class Animation
00051 // holds AnimRecs for all avars being tweaked.
00052 {
00053 public:
00054 Bool ParseAnimFile(StrConst filename);
00055
00056 Void DumpAvars(GCLReal time, Int frame);
00057 // print current avar values
00058 Void SetAvarList(scAvarList *avarList, scCamera *itsCamera, GCLReal time);
00059 // set scene's avar list according to time
00060
00061 Void AddKey(StrConst avarName, GCLReal time, GCLReal value,
00062 GCLReal velIn = kAutoVel, GCLReal velOut = kAutoVel);
00063 GCLReal GetValue(StrConst avarName, GCLReal time);
00064
00065 IntHash avarNames;
00066 AnimRecList avarRecs;
00067 GCLReal length;
00068 Int quiet;
00069 Int addDash;
00070 StrConst tag;
00071 IndexList avarMap;
00072 };
00073
00074
00075 #endif