59 #ifndef ACG_GLMATRIX_HH 60 #define ACG_GLMATRIX_HH 66 #include "Matrix4x4T.hh" 67 #include "../Config/ACGDefines.hh" 84 template <
class Scalar>
96 template <
class OtherScalar>
113 inline GLMatrixT(
const Vec3 &col1,
const Vec3 &col2,
const Vec3 &col3) {
138 memcpy(this->mat_ + 0, col1.
data(),
sizeof(Scalar) * 3);
140 memcpy(this->mat_ + 4, col2.
data(),
sizeof(Scalar) * 3);
142 memcpy(this->mat_ + 8, col3.
data(),
sizeof(Scalar) * 3);
143 for (
int i = 11; i < 15; ++i) this->mat_[i] = 0;
153 template<
typename otherScalar>
158 template<
typename otherScalar>
165 inline void scale( Scalar _x, Scalar _y, Scalar _z,
170 scale(_v[0], _v[1], _v[2], _mult_from);
175 inline void translate( Scalar _x, Scalar _y, Scalar _z,
180 translate(_v[0], _v[1], _v[2], _mult_from);
186 void rotate( Scalar angle, Scalar x, Scalar y, Scalar z,
190 void rotate( Scalar _angle,
const Vec3& _axis,
192 rotate(_angle, _axis[0], _axis[1], _axis[2], _mult_from);
200 rotateXYZ( X, _angle, _mult_from );
206 rotateXYZ( Y, _angle, _mult_from );
212 rotateXYZ( Z, _angle, _mult_from );
221 void lookAt(
const Vec3& eye,
242 Scalar near_plane, Scalar far_plane);
246 Scalar near_plane,Scalar far_plane);
249 void frustum(Scalar left, Scalar right,
250 Scalar bottom, Scalar top,
251 Scalar near_plane, Scalar far_plane);
255 Scalar bottom, Scalar top,
256 Scalar near_plane, Scalar far_plane);
259 void ortho(Scalar left, Scalar right,
260 Scalar bottom, Scalar top,
261 Scalar near_plane, Scalar far_plane);
265 Scalar bottom, Scalar top,
266 Scalar near_plane, Scalar far_plane);
310 template <
typename T>
319 enum Axis { X, Y, Z };
320 void rotateXYZ( Axis _axis, Scalar _angle,
MultiplyFrom _mult_from );
338 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_GLMATRIX_C) 339 #define ACG_GLMATRIX_TEMPLATES 340 #include "GLMatrixT.cc" 343 #endif // ACG_GLMATRIX_HH defined void inverse_lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
multiply self from left with inverse lookAt matrix
GLMatrixT(const Matrix4x4T< OtherScalar > &_rhs)
construct from other matrix type
GLMatrixT(const GLMatrixT< Scalar > &_rhs)
copy constructor
GLMatrixT< float > GLMatrixf
typedef
void rotate(Scalar _angle, const Vec3 &_axis, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
void translate(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
void rotateX(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, x-axis)
Matrix4x4T & operator*=(const Matrix4x4T< Scalar > &_rhs)
self *= _rhs
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)
VectorT< Scalar, 2 > extract_planes() const
detect type of projection matrix and extract near and far clipping planes
Matrix4x4T & operator+=(const Matrix4x4T< Scalar > &_rhs)
self += _rhs
GLMatrixT(const Scalar _array[16])
void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
void translate(const Vec3 &_v, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
void rotateY(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, y-axis)
GLMatrixT< double > GLMatrixd
typedef
GLMatrixT< Scalar > & operator=(const GLMatrixT< otherScalar > &_rhs)
assignement from other matrix type
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
VectorT< Scalar, 2 > extract_planes_perspective() const
extract near and far clipping planes from a perspective projection matrix
GLMatrixT(const Vec3 &col1, const Vec3 &col2, const Vec3 &col3)
4x4 matrix implementing OpenGL commands.
Matrix4x4T & leftMult(const Matrix4x4T< Scalar > &_rhs)
multiply from left: self = _rhs * self
void perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
Matrix4x4T & operator-=(const Matrix4x4T< Scalar > &_rhs)
self -= _rhs
VectorT< Scalar, 2 > extract_planes_ortho() const
extract near and far clipping planes from an orthographic projection matrix
Namespace providing different geometric functions concerning angles.
void scale(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
void frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
GLMatrixT()
constructor: uninitialized values
bool isOrtho() const
check if the matrix is an orthographic projection matrix
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 lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
Matrix4x4T operator*(const Matrix4x4T< Scalar > &inst) const
self * _rhs
GLMatrixT< Scalar > & operator=(const Matrix4x4T< otherScalar > &_rhs)
assignement from other matrix type
bool isPerspective() const
check if the matrix is a perspective projection matrix
void rotateZ(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, z-axis)
void ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with orthographic projection matrix
4x4 matrix implementing OpenGL commands.
Scalar * data()
access to Scalar array