53 #ifndef ACG_GLMATRIX_HH 54 #define ACG_GLMATRIX_HH 60 #include "Matrix4x4T.hh" 61 #include "../Config/ACGDefines.hh" 78 template <
class Scalar>
90 template <
class OtherScalar>
105 inline GLMatrixT(
const Vec3 &col1,
const Vec3 &col2,
const Vec3 &col3) {
130 memcpy(this->mat_ + 0, col1.
data(),
sizeof(Scalar) * 3);
132 memcpy(this->mat_ + 4, col2.
data(),
sizeof(Scalar) * 3);
134 memcpy(this->mat_ + 8, col3.
data(),
sizeof(Scalar) * 3);
135 for (
int i = 11; i < 15; ++i) this->mat_[i] = 0;
145 template<
typename otherScalar>
150 template<
typename otherScalar>
157 inline void scale( Scalar _x, Scalar _y, Scalar _z,
162 scale(_v[0], _v[1], _v[2], _mult_from);
167 inline void translate( Scalar _x, Scalar _y, Scalar _z,
172 translate(_v[0], _v[1], _v[2], _mult_from);
178 void rotate( Scalar angle, Scalar x, Scalar y, Scalar z,
182 void rotate( Scalar _angle,
const Vec3& _axis,
184 rotate(_angle, _axis[0], _axis[1], _axis[2], _mult_from);
192 rotateXYZ( X, _angle, _mult_from );
198 rotateXYZ( Y, _angle, _mult_from );
204 rotateXYZ( Z, _angle, _mult_from );
213 void lookAt(
const Vec3& eye,
234 Scalar near_plane, Scalar far_plane);
238 Scalar near_plane,Scalar far_plane);
241 void frustum(Scalar left, Scalar right,
242 Scalar bottom, Scalar top,
243 Scalar near_plane, Scalar far_plane);
247 Scalar bottom, Scalar top,
248 Scalar near_plane, Scalar far_plane);
251 void ortho(Scalar left, Scalar right,
252 Scalar bottom, Scalar top,
253 Scalar near_plane, Scalar far_plane);
257 Scalar bottom, Scalar top,
258 Scalar near_plane, Scalar far_plane);
302 template <
typename T>
311 enum Axis { X, Y, Z };
312 void rotateXYZ( Axis _axis, Scalar _angle,
MultiplyFrom _mult_from );
330 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_GLMATRIX_C) 331 #define ACG_GLMATRIX_TEMPLATES 332 #include "GLMatrixT_impl.hh" 335 #endif // ACG_GLMATRIX_HH defined void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
void perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
void inverse_frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse of perspective projection matrix
void scale(const Vec3 &_v, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
void inverse_ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse orthographic projection matrix
GLMatrixT< Scalar > & operator=(const GLMatrixT< otherScalar > &_rhs)
assignement from other matrix type
void rotateX(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, x-axis)
void translate(const Vec3 &_v, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
Matrix4x4T & operator+=(const Matrix4x4T< Scalar > &_rhs)
self += _rhs
void ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with orthographic projection matrix
Namespace providing different geometric functions concerning angles.
GLMatrixT< Scalar > & operator=(const Matrix4x4T< otherScalar > &_rhs)
assignement from other matrix type
GLMatrixT(const Vec3 &col1, const Vec3 &col2, const Vec3 &col3)
void translate(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
void rotateZ(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, z-axis)
GLMatrixT(const Matrix4x4T< OtherScalar > &_rhs)
construct from other matrix type
void lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
GLMatrixT(const Scalar _array[16])
bool isOrtho() const
check if the matrix is an orthographic projection matrix
Scalar * data()
access to Scalar array
void rotate(Scalar _angle, const Vec3 &_axis, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
VectorT< Scalar, 2 > extract_planes_ortho() const
extract near and far clipping planes from an orthographic projection matrix
void rotateY(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, y-axis)
VectorT< Scalar, 2 > extract_planes_perspective() const
extract near and far clipping planes from a perspective projection matrix
GLMatrixT< double > GLMatrixd
typedef
4x4 matrix implementing OpenGL commands.
void scale(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
bool isPerspective() const
check if the matrix is a perspective projection matrix
Matrix4x4T & operator-=(const Matrix4x4T< Scalar > &_rhs)
self -= _rhs
Matrix4x4T & operator*=(const Matrix4x4T< Scalar > &_rhs)
self *= _rhs
GLMatrixT< float > GLMatrixf
typedef
void inverse_perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse of perspective projection matrix
Matrix4x4T< Scalar > & operator=(const Matrix4x4T< otherScalar > &_rhs)
assignment from other matrix type
void frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
Matrix4x4T operator*(const Matrix4x4T< Scalar > &inst) const
self * _rhs
void inverse_lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
multiply self from left with inverse lookAt matrix
GLMatrixT()
constructor: uninitialized values
Matrix4x4T & leftMult(const Matrix4x4T< Scalar > &_rhs)
multiply from left: self = _rhs * self
VectorT< Scalar, 2 > extract_planes() const
detect type of projection matrix and extract near and far clipping planes