00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef CAL_CORETRACK_H
00012 #define CAL_CORETRACK_H
00013
00014
00015 #include "cal3d/global.h"
00016 #include "cal3d/matrix.h"
00017 #include "cal3d/vector.h"
00018 #include "cal3d/quaternion.h"
00019
00020
00021 class CalCoreBone;
00022 class CalCoreKeyframe;
00023 class CalCoreSkeleton;
00024
00025
00026 class CAL3D_API CalCoreTrack
00027 {
00028 private:
00030 int m_coreBoneId;
00031
00032
00033
00034 bool m_translationRequired;
00035 bool m_highRangeRequired;
00036 bool m_translationIsDynamic;
00037 static int m_translationRequiredCount;
00038 static int m_translationNotRequiredCount;
00039
00041 std::vector<CalCoreKeyframe*> m_keyframes;
00042
00043
00044 public:
00045 CalCoreTrack();
00046 ~CalCoreTrack();
00047
00048 void create();
00049 void destroy();
00050 unsigned int size();
00051
00052 bool getState(float time, CalVector& translation, CalQuaternion& rotation) const;
00053
00054
00064 inline int getCoreBoneId() const
00065 {
00066 return m_coreBoneId;
00067 }
00068
00069 bool setCoreBoneId(int coreBoneId);
00070
00071 int getCoreKeyframeCount() const;
00072 CalCoreKeyframe *getCoreKeyframe(int idx);
00073 const CalCoreKeyframe *getCoreKeyframe(int idx) const;
00074
00075 static int translationRequiredCount() { return m_translationRequiredCount; }
00076 static int translationNotRequiredCount() { return m_translationNotRequiredCount; }
00077 bool addCoreKeyframe(CalCoreKeyframe *pCoreKeyframe);
00078 void removeCoreKeyFrame(int _i) { m_keyframes.erase( m_keyframes.begin() + _i); }
00079 bool getTranslationRequired() { return m_translationRequired; }
00080 void setTranslationRequired( bool p ) { m_translationRequired = p; }
00081 bool getTranslationIsDynamic() { return m_translationIsDynamic; }
00082 void setTranslationIsDynamic( bool p ) { m_translationIsDynamic = p; }
00083 bool getHighRangeRequired() { return m_highRangeRequired; }
00084 void setHighRangeRequired( bool p ) { m_highRangeRequired = p; }
00085 void fillInvalidTranslations( CalVector const & trans );
00086
00087 void scale(float factor);
00088 void compress( double translationTolerance, double rotationToleranceDegrees, CalCoreSkeleton * skelOrNull );
00089 bool roundTranslation( CalCoreKeyframe const * prev, CalCoreKeyframe * p, double translationTolerance );
00090 void translationCompressibility(
00091 bool * transRequiredResult, bool * transDynamicResult, bool * highRangeRequiredResult,
00092 float threshold, float highRangeThreshold, CalCoreSkeleton * skel );
00093 void collapseSequences( double translationTolerance, double rotationToleranceDegrees );
00094
00095 private:
00096 std::vector<CalCoreKeyframe *>::const_iterator getUpperBound(float time) const;
00097 bool keyframeEliminatable( CalCoreKeyframe * prev, CalCoreKeyframe * p, CalCoreKeyframe * next,
00098 double translationTolerance, double rotationToleranceDegrees);
00099 };
00100
00101 #endif