00001
00002
00003
00004
00005
00006
00007
00008
00014 #ifndef _FM_MATRIX44_H_
00015 #define _FM_MATRIX44_H_
00016
00022 class FCOLLADA_EXPORT
00023 ALIGN_STRUCT(16)
00024 FMMatrix44
00025 {
00026 public:
00027
00028 float m[4][4];
00035 FMMatrix44(const float* _m);
00036 FMMatrix44(const double* _m);
00042 #ifndef _DEBUG
00043 inline FMMatrix44() {}
00044 #else
00045 inline FMMatrix44() { memset(m, 55, 16 * sizeof(float)); }
00046 #endif
00047
00053 inline operator float*() { return &m[0][0]; }
00054 inline operator const float*() const { return &m[0][0]; }
00059 template <class Integer> float* operator[](Integer a) { return m[a]; }
00060 template <class Integer> const float* operator[](Integer a) const { return m[a]; }
00066 FMMatrix44& operator=(const FMMatrix44& copy);
00067
00073 void Set(const float* _m);
00074 void Set(const double* _m);
00078 FMMatrix44 Transposed() const;
00079
00082 FMMatrix44 Inverted() const;
00083
00086 float Determinant() const;
00087
00099 void Decompose(FMVector3& scale, FMVector3& rotation, FMVector3& translation, float& inverted) const;
00100
00111 void Recompose(const FMVector3& scale, const FMVector3& rotation, const FMVector3& translation, float inverted = 1.0f);
00112
00116 FMVector3 TransformCoordinate(const FMVector3& coordinate) const;
00117 FMVector4 TransformCoordinate(const FMVector4& coordinate) const;
00122 FMVector3 TransformVector(const FMVector3& v) const;
00123
00126 inline const FMVector3& GetTranslation() const { return GetAxis(FMath::TRANS); }
00127 inline FMVector3& GetTranslation() { return GetAxis(FMath::TRANS); }
00131 inline void SetTranslation(const FMVector3& translation) { GetTranslation() = translation; }
00132
00136 inline const FMVector3& GetAxis(FMath::AXIS axis) const { return *(FMVector3*)(size_t)(m[axis]); }
00137 inline FMVector3& GetAxis(FMath::AXIS axis) { return *(FMVector3*)(size_t)(m[axis]); }
00139 public:
00140 static FMMatrix44 Identity;
00147 static FMMatrix44 TranslationMatrix(const FMVector3& translation);
00148
00154 static FMMatrix44 AxisRotationMatrix(const FMVector3& axis, float angle);
00155
00159 static FMMatrix44 XAxisRotationMatrix(float angle);
00160
00164 static FMMatrix44 YAxisRotationMatrix(float angle);
00165
00169 static FMMatrix44 ZAxisRotationMatrix(float angle);
00170
00176 static FMMatrix44 EulerRotationMatrix(const FMVector3& rotation);
00177
00181 static FMMatrix44 ScaleMatrix(const FMVector3& scale);
00182
00188 static FMMatrix44 LookAtMatrix(const FMVector3& eye, const FMVector3& target, const FMVector3& up);
00189 };
00190
00197 FMMatrix44 FCOLLADA_EXPORT operator*(const FMMatrix44& m1, const FMMatrix44& m2);
00198
00205 FMVector4 FCOLLADA_EXPORT operator*(const FMMatrix44& m, const FMVector4& v);
00206
00214 FMMatrix44 FCOLLADA_EXPORT operator*(float a, const FMMatrix44& m);
00215
00220 bool FCOLLADA_EXPORT IsEquivalent(const FMMatrix44& m1, const FMMatrix44& m2);
00221 inline bool operator==(const FMMatrix44& m1, const FMMatrix44& m2) { return IsEquivalent(m1, m2); }
00229 inline FMMatrix44& operator*=(FMMatrix44& m1, const FMMatrix44& m2) { return m1 = m1 * m2; }
00230
00232 typedef fm::vector<FMMatrix44> FMMatrix44List;
00233
00234 #endif // _FM_MATRIX44_H_