00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LUX_MOTIONSYSTEM_H
00024 #define LUX_MOTIONSYSTEM_H
00025
00026
00027 #include "lux.h"
00028 #include "geometry/quaternion.h"
00029 #include "geometry/bbox.h"
00030 #include "geometry/matrix4x4.h"
00031 #include "geometry/transform.h"
00032
00033
00034 namespace lux
00035 {
00036
00037 class Transforms {
00038 public:
00039 Transforms() : Sx(0), Sy(0), Sz(0),
00040 Sxy(0), Sxz(0), Syz(0),
00041 R(new Matrix4x4()),
00042 Tx(0), Ty(0), Tz(0),
00043 Px(0), Py(0), Pz(0), Pw(0) {
00044 }
00045
00046
00047 float Sx, Sy, Sz;
00048
00049 float Sxy, Sxz, Syz;
00050
00051 boost::shared_ptr<Matrix4x4> R;
00052
00053 float Tx, Ty, Tz;
00054
00055 float Px, Py, Pz, Pw;
00056 };
00057
00058 class MotionSystem {
00059 public:
00060 MotionSystem() { startTime = endTime = 0; start = end = Transform(); }
00061
00062 MotionSystem(float st, float et,
00063 const Transform &s, const Transform &e);
00064
00065 ~MotionSystem() {};
00066
00067 Transform Sample(float time) const;
00068
00069 BBox Bound(BBox ibox) {
00070
00071
00072 BBox tbox;
00073 const float s = 1.f/1024;
00074 for(u_int i=0; i<=1024; i++) {
00075 Transform t = Sample(s*i);
00076 tbox = Union(tbox, t(ibox));
00077 }
00078 return tbox;
00079 }
00080
00081
00082 bool isActive;
00083
00084 protected:
00085
00086
00087
00088
00089
00090 bool DecomposeMatrix(const boost::shared_ptr<Matrix4x4> m, Transforms &trans) const;
00091
00092
00093 float startTime, endTime;
00094 Transform start, end;
00095 Transforms startT, endT;
00096 boost::shared_ptr<Matrix4x4> startMat, endMat;
00097 Quaternion startQ, endQ;
00098 bool hasRotation, hasTranslation, hasScale;
00099 bool hasTranslationX, hasTranslationY, hasTranslationZ;
00100 bool hasScaleX, hasScaleY, hasScaleZ;
00101 };
00102
00103 }
00104
00105 #endif // LUX_MOTIONSYSTEM_H