# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions

# vl::Transform Class Reference

Implements a 4x4 matrix transform used to define the position and orientation of an Actor. More...

`#include <Transform.hpp>`

Inheritance diagram for vl::Transform:

List of all members.

## Public Member Functions

virtual const char * | className ()
| Returns the name of the class.
| Transform ()
| Constructor.
| Transform (const mat4 &matrix)
| Constructor.
void | setLocalAndWorldMatrix (const mat4 &matrix)
| Sets both the local and the world matrices.
void | translate (Real x, Real y, Real z)
| Utility function equivalent to `setLocalMatrix`( mat4::getTranslation(x,y,z)*localMatrix() ).
void | translate (const vec3 &t)
| Utility function equivalent to `setLocalMatrix`( mat4::getTranslation(t)*localMatrix() ).
void | scale (Real x, Real y, Real z)
| Utility function equivalent to `setLocalMatrix`( mat4::getScaling(x,y,z)*localMatrix() ).
void | rotate (Real degrees, Real x, Real y, Real z)
| Utility function equivalent to `setLocalMatrix`( mat4::getRotation(degrees,x,y,z)*localMatrix() ).
void | rotate (const vec3 &from, const vec3 &to)
| Utility function equivalent to `setLocalMatrix`( mat4::getRotation(from,to)*localMatrix() ).

## Detailed Description

Implements a 4x4 matrix transform used to define the position and orientation of an Actor.

Transforms can be linked together to create a tree-like hierarchy.

Optimizing Your Transforms

- Don't use them unless strictly necessary: if an Actor uses an I (identity) transform you do not need one, just call `vl::Actor::setTransform(NULL)`.

- Don't create Transform hierarchies if not needed. Just call setLocalAndWorldMatrix() per-Transform if you have a set of parent-less Transforms.

- If the root of a hierarchy is an I (identity) transform, let VL know it by calling `setAssumeIdentityWorldMatrix(true)`. This will save unnecessary matrix multiplications since multiplying by an identity matrix has no effect.

- Call computeWorldMatrix() / computeWorldMatrixRecursive() not at each frame but only if the local matrix has actually changed.

- Do not add a Transform hierarchy to vl::Rendering::transform() if such Transforms are not animated every frame, this will cause VL unnecessarily update the Transforms at each frame.

- Remember: VL does not require your Actors to have a Transform or such Transforms to be part of any hierarchy, it just expect that the worldMatrix() of an Actor's Transform (if it has any) is up to date at rendering time. How and when they are updated can be fine tuned by the user according to the specific application needs.

See also:
  setLocalAndWorldMatrix(), setAssumeIdentityWorldMatrix(), Rendering::transform()
  Actor, Rendering, Effect, Renderable, Geometry

Definition at line 383 of file Transform.hpp.

## Constructor & Destructor Documentation

vl::Transform::Transform | ( | ) | `[inline]`

Constructor.

Definition at line 389 of file Transform.hpp.

References VL_DEBUG_SET_OBJECT_NAME.

vl::Transform::Transform | ( | const mat4 & | matrix ) | `[inline]`

Constructor.

The `matrix` parameter is used to set both the local and world matrix.

Definition at line 395 of file Transform.hpp.

References VL_DEBUG_SET_OBJECT_NAME.

## Member Function Documentation

virtual const char* vl::Transform::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::Object.

Reimplemented in vl::Billboard.

Definition at line 386 of file Transform.hpp.

void vl::Transform::setLocalAndWorldMatrix | ( | const mat4 & | matrix ) | `[inline]`

Sets both the local and the world matrices.

This function is useful to quickly set those Transforms that do not have a parent, for which is equivalent to: `setLocalMatrix(matrix)`; `computeWorldMatrix(NULL)`;

Definition at line 405 of file Transform.hpp.

void Transform::translate | ( | Real | x,
|  | Real | y,
|  | Real | z
| ) |  |

Utility function equivalent to `setLocalMatrix`( mat4::getTranslation(x,y,z)*localMatrix() ).

After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().

Definition at line 44 of file Transform.cpp.

References vl::Matrix4< GLfloat >::getTranslation(), vl::ITransform::localMatrix(), and vl::ITransform::setLocalMatrix().

void Transform::translate | ( | const vec3 & | t ) |

Utility function equivalent to `setLocalMatrix`( mat4::getTranslation(t)*localMatrix() ).

After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().

Definition at line 49 of file Transform.cpp.

References vl::Matrix4< GLfloat >::getTranslation(), vl::ITransform::localMatrix(), and vl::ITransform::setLocalMatrix().

void Transform::scale | ( | Real | x,
|  | Real | y,
|  | Real | z
| ) |  |

Utility function equivalent to `setLocalMatrix`( mat4::getScaling(x,y,z)*localMatrix() ).

After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().

Definition at line 54 of file Transform.cpp.

References vl::Matrix4< GLfloat >::getScaling(), vl::ITransform::localMatrix(), and vl::ITransform::setLocalMatrix().

void Transform::rotate | ( | Real | degrees,
|  | Real | x,
|  | Real | y,
|  | Real | z
| ) |  |

Utility function equivalent to `setLocalMatrix`( mat4::getRotation(degrees,x,y,z)*localMatrix() ).

After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().

Definition at line 59 of file Transform.cpp.

References vl::Matrix4< GLfloat >::getRotation(), vl::ITransform::localMatrix(), and vl::ITransform::setLocalMatrix().

void Transform::rotate | ( | const vec3 & | from,
|  | const vec3 & | to
| ) |  |

Utility function equivalent to `setLocalMatrix`( mat4::getRotation(from,to)*localMatrix() ).

After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().

Definition at line 64 of file Transform.cpp.

References vl::Matrix4< GLfloat >::getRotation(), vl::ITransform::localMatrix(), and vl::ITransform::setLocalMatrix().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/Transform.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/Transform.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:36.
Permission is granted to use this page to write and publish articles regarding Visualization Library.