CMatrix Class Reference
Collaboration diagram for CMatrix:
[legend]List of all members.
Detailed Description
The matrix class is currently just a wrapper for Allegro's matrix functions + stack. Matrices are used to transform geometry (vectors). Matrices can be concatenated to create hierarchical transformations. Both vector and float versions exist of every function to make programming a bit more comfortable.
CMatrix matrix;
CVector position, rotation;
CTriangle* triangle;
int triangles;
void render_scene()
{
matrix.push();
matrix.identity();
matrix.rotate(rotation);
matrix.translate(position);
for (int i = 0; i < triangles; ++i) {
CVector tmp[3];
for (int j=0; j < 3; ++j)
matrix.apply(triangle[i][j], tmp[j]);
render_triangle(tmp);
}
matrix.pop();
}
Definition at line 111 of file CMatrix.h.
|
Public Member Functions |
int | push () |
int | pop () |
void | mul () |
void | identity () |
void | scale (float x, float y, float z) |
void | scale (CVector vector) |
void | translate (float x, float y, float z) |
void | translate (CVector vector) |
void | rotate (float x, float y, float z) |
void | rotate (CVector vector) |
void | st (float sx, float sy, float sz, float tx, float ty, float tz) |
void | clearRotation () |
void | clearTranslation () |
void | apply (float x, float y, float z, float &xout, float &yout, float &zout) |
void | apply (CVector &v, CVector &vout) |
Public Attributes |
CMatrix4 | m [MATRIX_STACK_SIZE] |
| Matrix stack.
|
int | depth |
| Matrix stack depth.
|
CMatrix4 | tmp |
| Temp matrix used by mul().
|
Member Function Documentation
|
Pushes the current matrix on the stack. - Returns:
- The current stack depth.
- See also:
- pop
Definition at line 139 of file CMatrix.h. |
|
Pops the last pushed matrix from the stack. - Returns:
- The current stack depth.
- See also:
- push
Definition at line 150 of file CMatrix.h. |
|
Multiplies the current matrix by tmp. - See also:
- tmp
Definition at line 159 of file CMatrix.h. |
void CMatrix::identity |
( |
|
) |
|
|
|
Loads the current matrix with the identity matrix.
Definition at line 169 of file CMatrix.h. |
Here is the call graph for this function:
void CMatrix::scale |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
z |
|
) |
|
|
|
Scales the matrix. - Parameters:
-
| x | Factor to scale x axis. |
| y | Factor to scale y axis. |
| z | Factor to scale z axis. |
Definition at line 179 of file CMatrix.h. |
Here is the call graph for this function:
void CMatrix::scale |
( |
CVector |
vector |
) |
|
|
|
Scales the matrix using vector[0], vector[1], vector[2]. - Parameters:
-
| vector | Vector with (x, y, z) scaling values. |
- See also:
- scale()
Definition at line 189 of file CMatrix.h. |
Here is the call graph for this function:
void CMatrix::translate |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
z |
|
) |
|
|
|
Translates x, y, z along x, y and z axis. - Parameters:
-
| x | Amount to translate along x axis. |
| y | Amount to translate along y axis. |
| z | Amount to translate along z axis. |
Definition at line 199 of file CMatrix.h. |
Here is the call graph for this function:
void CMatrix::translate |
( |
CVector |
vector |
) |
|
|
|
Translates by vector[0], vector[1] and vector[2]. - Parameters:
-
| vector | Vector with (x, y, z) translation. |
- See also:
- translate()
Definition at line 209 of file CMatrix.h. |
Here is the call graph for this function:
void CMatrix::rotate |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
z |
|
) |
|
|
|
Rotates the matrix around the x, y and z axis by specified amounts in radians. - Parameters:
-
| x | Rotation around the x axis. |
| y | Rotation around the y axis. |
| z | Rotation around the z axis. |
Definition at line 219 of file CMatrix.h. |
Here is the call graph for this function:
void CMatrix::rotate |
( |
CVector |
vector |
) |
|
|
|
- Parameters:
-
| vector | Vector with (x, y, z) rotation. |
- See also:
- rotate()
Definition at line 228 of file CMatrix.h. |
Here is the call graph for this function:
void CMatrix::st |
( |
float |
sx, |
|
|
float |
sy, |
|
|
float |
sz, |
|
|
float |
tx, |
|
|
float |
ty, |
|
|
float |
tz |
|
) |
|
|
|
Scales, rotates and traslates matrix. - Parameters:
-
| s* | Scaling factors. |
| t* | Translation. |
- See also:
- scale()
translate()
Definition at line 239 of file CMatrix.h. |
Here is the call graph for this function:
void CMatrix::clearRotation |
( |
|
) |
|
|
|
Clears to rotation part of the matrix. This will still translate to points, but won't rotate them. Use it to implement billboarding. - See also:
- clear_translation()
Definition at line 249 of file CMatrix.h. |
void CMatrix::clearTranslation |
( |
|
) |
|
|
|
Clears the translation part of the matrix. The new matrix will only rotate points. Use it to rotate eg. normal vectors. - See also:
- clear_rotation()
Definition at line 258 of file CMatrix.h. |
void CMatrix::apply |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
z, |
|
|
float & |
xout, |
|
|
float & |
yout, |
|
|
float & |
zout |
|
) |
|
|
|
Applies the current matrix to (x, y, z), storing the result in xout, yout and zout. - Parameters:
-
| x | X component to transform. |
| y | Y component to transform. |
| z | Z component to transform. |
| xout | Variable to store new x value. |
| yout | Variable to store new y value. |
| zout | Variable to store new z value. |
Definition at line 271 of file CMatrix.h. |
|
- Parameters:
-
| v | Vector to transform. |
| vout | Vector to store result. |
- See also:
- apply()
Definition at line 283 of file CMatrix.h. |
The documentation for this class was generated from the following file:
Generated on Tue Feb 8 21:59:41 2005 for MarSTDv2004 by
1.4.1