Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes
core::matrix4 Class Reference

#include <Matrix4.h>

List of all members.

Public Member Functions

void buildProjectionMatrixInfinitePerspectiveFov (f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear)
 Builds a right-handed infinite perspective projection matrix based on a field of view.
void buildProjectionMatrixOrtho (f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
 Builds a right-handed orthogonal projection matrix.
void buildProjectionMatrixOrtho (f32 left, f32 right, f32 bottom, f32 top, f32 zNear, f32 zFar)
 Builds a right-handed orthogonal projection matrix with left/right and bottom/top instead of only width and height.
void buildProjectionMatrixPerspective (f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
 Builds a right-handed perspective projection matrix.
void buildProjectionMatrixPerspectiveFov (f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar)
 Builds a right-handed perspective projection matrix based on a field of view.
void buildShadowMatrix (vector3d light, plane3d plane, f32 point=1.0f)
void buildViewMatrix (const vector3d &position, const vector3d &target, const vector3d &upVector)
 Builds a right-handed look-at matrix.
f32get ()
const f32get () const
matrix4 getInverse () const
 Returns the inversed matrix is exists else it returns the current matrix.
vector3d getRotationDegrees () const
 Returns the rotation, as set by setRotation(). This code was originally written by Chev.
vector3d getScale () const
 Get Scale.
vector3d getTranslation () const
 Gets the current translation.
matrix4 getTransposed () const
 Returns transposed matrix.
bool hasInverse ()
 Returns if the matrix has an inverse.
void inverseRotateVect (vector3d &vect) const
 Rotate a vector by the inverse of the rotation part of this matrix.
void inverseTranslateVector (vector3d &vect) const
 Translate a vector by the inverse of the translation part of this matrix.
bool isIdentity ()
 Returns true if the matrix is the identity matrix.
void makeIdentity ()
 Set matrix to identity.
 matrix4 (f32 m00, f32 m01, f32 m02, f32 m03, f32 m10, f32 m11, f32 m12, f32 m13, f32 m20, f32 m21, f32 m22, f32 m23, f32 m30, f32 m31, f32 m32, f32 m33)
 matrix4 ()
bool operator!= (const matrix4 &other) const
 Returns true if other matrix is not equal to this matrix.
f32operator() (s32 row, s32 col)
 Simple operator for directly accessing every element of the matrix.
const f32operator() (s32 row, s32 col) const
 Simple operator for directly accessing every element of the matrix.
matrix4 operator* (const matrix4 &other) const
 Multiply by another matrix.
matrix4operator*= (const matrix4 &other)
 Multiply by another matrix.
matrix4 operator+ (const matrix4 &other) const
 Add by another matrix.
matrix4operator+= (const matrix4 &other)
 Add by another matrix.
matrix4 operator- () const
matrix4 operator- (const matrix4 &other) const
 Subtract by another matrix.
matrix4operator-= (const matrix4 &other)
 Subtract by another matrix.
matrix4operator= (const matrix4 &other)
 Sets this matrix equal to the other matrix.
bool operator== (const matrix4 &other) const
 Returns true if other matrix is equal to this matrix.
f32operator[] (u32 index)
 Simple operator for linearly accessing every element of the matrix.
const f32operator[] (u32 index) const
 Simple operator for linearly accessing every element of the matrix.
void rotateVector (vector3d &vect) const
 Rotate a vector by the rotation part of this matrix.
void set (f32 m00, f32 m01, f32 m02, f32 m03, f32 m10, f32 m11, f32 m12, f32 m13, f32 m20, f32 m21, f32 m22, f32 m23, f32 m30, f32 m31, f32 m32, f32 m33)
void set (const matrix4 &other)
void setInverseRotationDegrees (const vector3d &rotation)
 Make an inverted rotation matrix from Euler angles. The 4th row and column are unmodified.
void setInverseRotationRadians (const vector3d &rotation)
 Make an inverted rotation matrix from Euler angles. The 4th row and column are unmodified.
void setInverseTranslation (const vector3d &translation)
 Set the inverse translation of the current matrix. Will erase any previous values.
void setRotationDegrees (const vector3d &rotation)
 Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
void setRotationRadians (const vector3d &rotation)
 Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
void setScale (const vector3d &scale)
 Set Scale.
void setTranslation (const vector3d &translation)
 Set the translation of the current matrix. Will erase any previous values.
void transformBox (aabox3d &box) const
 Transforms a axis aligned bounding box.
void transformPlane (const plane3d &in, plane3d &out) const
 Transforms a plane by this matrix.
void transformPlane (plane3d &plane) const
 Transforms a plane by this matrix.
void transformVector (const vector4d &in, vector4d &out) const
 Transforms input vector by this matrix and stores result in output vector.
void transformVector (const vector3d &in, vector3d &out) const
 Transforms input vector by this matrix and stores result in output vector.
void transformVector (vector4d &vect) const
 Transforms the vector by this matrix.
void transformVector (vector3d &vect) const
 Transforms the vector by this matrix.
void translateVector (vector3d &vect) const
 Translate a vector by the translation part of this matrix.

Static Public Attributes

static const matrix4 IDENTITY
static const matrix4 ZERO

Private Attributes

f32 M [16]
 Matrix data, stored in row-major order.

Static Private Attributes

static float empty = 0

Detailed Description

4x4 matrix. Mostly used as transformation matrix for 3d calculations. Matrix4 is mainly used by the K_Game engine for doing transformations. The matrix is a OpenGL style matrix, row major with translations in the 4th row. The generic form M * V which shows the layout of the matrix entries is shown below: [ m[ 0] m[ 1] m[ 2] m[ 3] ] {x} | m[ 4] m[ 5] m[ 6] m[ 7] | * {y} | m[ 8] m[ 9] m[10] m[11] | {z} [ m[12] m[13] m[14] m[15] ] {1}


Constructor & Destructor Documentation

core::matrix4::matrix4 ( ) [inline]

References makeIdentity().

core::matrix4::matrix4 ( f32  m00,
f32  m01,
f32  m02,
f32  m03,
f32  m10,
f32  m11,
f32  m12,
f32  m13,
f32  m20,
f32  m21,
f32  m22,
f32  m23,
f32  m30,
f32  m31,
f32  m32,
f32  m33 
) [inline]

References M.


Member Function Documentation

void core::matrix4::buildProjectionMatrixInfinitePerspectiveFov ( f32  fieldOfViewRadians,
f32  aspectRatio,
f32  zNear 
) [inline]

Builds a right-handed infinite perspective projection matrix based on a field of view.

References M, and core::tan().

Referenced by render::Camera::updateProjection().

void core::matrix4::buildProjectionMatrixOrtho ( f32  widthOfViewVolume,
f32  heightOfViewVolume,
f32  zNear,
f32  zFar 
) [inline]

Builds a right-handed orthogonal projection matrix.

References M.

Referenced by render::RenderManager::renderSingleOverlay(), render::RenderManager::renderVisibleOverlays(), and render::Camera::updateProjection().

void core::matrix4::buildProjectionMatrixOrtho ( f32  left,
f32  right,
f32  bottom,
f32  top,
f32  zNear,
f32  zFar 
) [inline]

Builds a right-handed orthogonal projection matrix with left/right and bottom/top instead of only width and height.

References M.

void core::matrix4::buildProjectionMatrixPerspective ( f32  widthOfViewVolume,
f32  heightOfViewVolume,
f32  zNear,
f32  zFar 
) [inline]

Builds a right-handed perspective projection matrix.

References M.

void core::matrix4::buildProjectionMatrixPerspectiveFov ( f32  fieldOfViewRadians,
f32  aspectRatio,
f32  zNear,
f32  zFar 
) [inline]

Builds a right-handed perspective projection matrix based on a field of view.

References M, and core::tan().

Referenced by render::Camera::updateProjection().

void core::matrix4::buildShadowMatrix ( vector3d  light,
plane3d  plane,
f32  point = 1.0f 
) [inline]

Builds a matrix that flattens geometry into a plane.

Parameters:
light,:light source
plane,:plane into which the geometry if flattened into
point,:value between 0 and 1, describing the light source. If this is 1, it is a point light, if it is 0, it is a directional light.

References core::plane3d::D, core::vector3d::dotProduct(), core::plane3d::Normal, core::vector3d::normalize(), core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.

void core::matrix4::buildViewMatrix ( const vector3d position,
const vector3d target,
const vector3d upVector 
) [inline]
f32 * core::matrix4::get ( )

References M.

Referenced by render::Shader::setParamerter().

const f32 * core::matrix4::get ( ) const

References M.

matrix4 core::matrix4::getInverse ( ) const [inline]
vector3d core::matrix4::getRotationDegrees ( ) const [inline]

Returns the rotation, as set by setRotation(). This code was originally written by Chev.

References core::abs(), core::asin(), core::atan2(), core::cos(), and core::RADTODEG.

vector3d core::matrix4::getScale ( ) const [inline]
vector3d core::matrix4::getTranslation ( ) const [inline]

Gets the current translation.

References M.

Referenced by render::RenderManager::renderSingleOverlay(), and render::RenderManager::renderVisibleOverlays().

matrix4 core::matrix4::getTransposed ( ) const [inline]
bool core::matrix4::hasInverse ( ) [inline]

Returns if the matrix has an inverse.

void core::matrix4::inverseRotateVect ( vector3d vect) const [inline]

Rotate a vector by the inverse of the rotation part of this matrix.

References M, core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.

void core::matrix4::inverseTranslateVector ( vector3d vect) const [inline]

Translate a vector by the inverse of the translation part of this matrix.

References M, core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.

bool core::matrix4::isIdentity ( ) [inline]

Returns true if the matrix is the identity matrix.

void core::matrix4::makeIdentity ( ) [inline]

Set matrix to identity.

References M.

Referenced by matrix4().

bool core::matrix4::operator!= ( const matrix4 other) const [inline]

Returns true if other matrix is not equal to this matrix.

References M.

f32 & core::matrix4::operator() ( s32  row,
s32  col 
)

Simple operator for directly accessing every element of the matrix.

References empty, and M.

const f32 & core::matrix4::operator() ( s32  row,
s32  col 
) const

Simple operator for directly accessing every element of the matrix.

References empty, and M.

matrix4 core::matrix4::operator* ( const matrix4 other) const [inline]

Multiply by another matrix.

References M.

matrix4 & core::matrix4::operator*= ( const matrix4 other) [inline]

Multiply by another matrix.

References M.

matrix4 core::matrix4::operator+ ( const matrix4 other) const [inline]

Add by another matrix.

References M.

matrix4 & core::matrix4::operator+= ( const matrix4 other) [inline]

Add by another matrix.

References M.

matrix4 core::matrix4::operator- ( const matrix4 other) const [inline]

Subtract by another matrix.

References M.

matrix4 core::matrix4::operator- ( ) const [inline]

References M.

matrix4 & core::matrix4::operator-= ( const matrix4 other) [inline]

Subtract by another matrix.

References M.

matrix4 & core::matrix4::operator= ( const matrix4 other) [inline]

Sets this matrix equal to the other matrix.

References M.

bool core::matrix4::operator== ( const matrix4 other) const [inline]

Returns true if other matrix is equal to this matrix.

References M.

f32 & core::matrix4::operator[] ( u32  index)

Simple operator for linearly accessing every element of the matrix.

References empty, and M.

const f32 & core::matrix4::operator[] ( u32  index) const

Simple operator for linearly accessing every element of the matrix.

References empty, and M.

void core::matrix4::rotateVector ( vector3d vect) const [inline]

Rotate a vector by the rotation part of this matrix.

References M, core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.

void core::matrix4::set ( const matrix4 other)

References M.

void core::matrix4::set ( f32  m00,
f32  m01,
f32  m02,
f32  m03,
f32  m10,
f32  m11,
f32  m12,
f32  m13,
f32  m20,
f32  m21,
f32  m22,
f32  m23,
f32  m30,
f32  m31,
f32  m32,
f32  m33 
)

References M.

void core::matrix4::setInverseRotationDegrees ( const vector3d rotation) [inline]

Make an inverted rotation matrix from Euler angles. The 4th row and column are unmodified.

References core::DEGTORAD, and setInverseRotationRadians().

void core::matrix4::setInverseRotationRadians ( const vector3d rotation) [inline]

Make an inverted rotation matrix from Euler angles. The 4th row and column are unmodified.

References core::cos(), getScale(), M, setScale(), core::sin(), core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.

Referenced by setInverseRotationDegrees().

void core::matrix4::setInverseTranslation ( const vector3d translation) [inline]

Set the inverse translation of the current matrix. Will erase any previous values.

References M, core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.

void core::matrix4::setRotationDegrees ( const vector3d rotation) [inline]

Make a rotation matrix from Euler angles. The 4th row and column are unmodified.

References core::DEGTORAD, and setRotationRadians().

void core::matrix4::setRotationRadians ( const vector3d rotation) [inline]

Make a rotation matrix from Euler angles. The 4th row and column are unmodified.

References core::cos(), getScale(), M, setScale(), core::sin(), core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.

Referenced by setRotationDegrees().

void core::matrix4::setScale ( const vector3d scale) [inline]
void core::matrix4::setTranslation ( const vector3d translation) [inline]
void core::matrix4::transformBox ( aabox3d box) const [inline]
void core::matrix4::transformPlane ( plane3d plane) const [inline]
void core::matrix4::transformPlane ( const plane3d in,
plane3d out 
) const [inline]

Transforms a plane by this matrix.

References transformPlane().

void core::matrix4::transformVector ( const vector4d in,
vector4d out 
) const [inline]

Transforms input vector by this matrix and stores result in output vector.

References M, core::vector4d::W, core::vector4d::X, core::vector4d::Y, and core::vector4d::Z.

void core::matrix4::transformVector ( vector4d vect) const [inline]

Transforms the vector by this matrix.

References M, core::vector4d::W, core::vector4d::X, core::vector4d::Y, and core::vector4d::Z.

void core::matrix4::transformVector ( vector3d vect) const [inline]
void core::matrix4::transformVector ( const vector3d in,
vector3d out 
) const [inline]

Transforms input vector by this matrix and stores result in output vector.

References M, core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.

void core::matrix4::translateVector ( vector3d vect) const [inline]

Translate a vector by the translation part of this matrix.

References M, core::vector3d::X, core::vector3d::Y, and core::vector3d::Z.


Member Data Documentation

float core::matrix4::empty = 0 [static, private]

Referenced by operator()(), and operator[]().

f32 core::matrix4::M[16] [private]
const matrix4 core::matrix4::ZERO [static]

The documentation for this class was generated from the following files:

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:07 by Doxygen (1.7.4)