Visualization Library 2.0.0
A lightweight C++ OpenGL middleware for 2D/3D graphics
|
[Download] [Tutorials] [All Classes] [Grouped Classes] |
Implements a 4x4 matrix transform used to define the position and orientation of an Actor. More...
#include <Transform.hpp>
Public Member Functions | |
Transform () | |
Constructor. More... | |
Transform (const mat4 &matrix) | |
Constructor. More... | |
~Transform () | |
Destructor. More... | |
const Transform * | parent () const |
Returns the parent Transform. More... | |
Transform * | parent () |
Returns the parent Transform. More... | |
void | translate (real x, real y, real z) |
Utility function equivalent to setLocalMatrix ( mat4::getTranslation(x,y,z)*localMatrix() ). More... | |
void | translate (const vec3 &t) |
Utility function equivalent to setLocalMatrix ( mat4::getTranslation(t)*localMatrix() ). More... | |
void | scale (real x, real y, real z) |
Utility function equivalent to setLocalMatrix ( mat4::getScaling(x,y,z)*localMatrix() ). More... | |
void | rotate (real degrees, real x, real y, real z) |
Utility function equivalent to setLocalMatrix ( mat4::getRotation(degrees,x,y,z)*localMatrix() ). More... | |
void | rotate (const vec3 &from, const vec3 &to) |
Utility function equivalent to setLocalMatrix ( mat4::getRotation(from,to)*localMatrix() ). More... | |
void | preMultiply (const mat4 &m) |
Utility function equivalent to setLocalMatrix( m*localMatrix() ) . More... | |
void | postMultiply (const mat4 &m) |
Utility function equivalent to setLocalMatrix( localMatrix()*m ) . More... | |
void | setLocalMatrix (const mat4 &m) |
The matrix representing the transform's local space. More... | |
const mat4 & | localMatrix () const |
The matrix representing the transform's local space. More... | |
mat4 & | localMatrix () |
The matrix representing the transform's local space. More... | |
void | setWorldMatrix (const mat4 &matrix) |
Normally you should not use directly this function, call it only if you are sure you cannot do otherwise. More... | |
const mat4 & | worldMatrix () const |
Returns the world matrix used for rendering. More... | |
void | setLocalAndWorldMatrix (const mat4 &matrix) |
Sets both the local and the world matrices. More... | |
long long | worldMatrixUpdateTick () const |
Returns the internal update tick used to avoid unnecessary computations. More... | |
void | setAssumeIdentityWorldMatrix (bool assume_I) |
If set to true the world matrix of this transform will always be considered and identity. More... | |
bool | assumeIdentityWorldMatrix () |
If set to true the world matrix of this transform will always be considered and identity. More... | |
virtual void | computeWorldMatrix (Camera *=NULL) |
Computes the world matrix by concatenating the parent's world matrix with its own local matrix. More... | |
void | computeWorldMatrixRecursive (Camera *camera=NULL) |
Computes the world matrix by concatenating the parent's world matrix with its local matrix, recursively descending to the children. More... | |
mat4 | getComputedWorldMatrix () |
Returns the matrix computed concatenating this Transform's local matrix with the local matrices of all its parents. More... | |
const ref< Transform > * | children () const |
Returns the array containing the child Transforms. More... | |
ref< Transform > * | children () |
Returns the array containing the child Transforms. More... | |
size_t | childrenCount () const |
Returns the number of child Transform. More... | |
void | addChild (Transform *child) |
Adds a child transform. More... | |
void | addChildren (Transform *const *children, size_t count) |
Adds count children transforms. More... | |
void | addChildren (const ref< Transform > *children, size_t count) |
void | addChildren (const std::vector< ref< Transform > > &children) |
void | addChildren (const std::vector< Transform * > &children) |
Adds the specified children transforms. More... | |
void | setChild (int index, Transform *child) |
Sets the index-th child. More... | |
const Transform * | lastChild () const |
Returns the last child. More... | |
Transform * | lastChild () |
Returns the last child. More... | |
void | eraseChild (const Transform *child) |
Removes the given child Transform. More... | |
void | eraseChildren (int index, int count) |
Removes count children Transforms starting at position index . More... | |
void | eraseAllChildren () |
Removes all the children of a Transform. More... | |
void | eraseAllChildrenRecursive () |
Removes all the children of a Transform recursively descending the hierarchy. More... | |
void | flattenHierarchy () |
Disassembles a hierarchy of Transforms like eraseAllChildrenRecursive() does plus assigns the local matrix to equal the world matrix. More... | |
void | removeFromParent () |
Erases a Transform from it's parent and sets the local matrix to be equal to the world matrix. More... | |
void | shrink () |
Minimizes the amount of memory used to store the children Transforms. More... | |
void | shrinkRecursive () |
Minimizes recursively the amount of memory used to store the children Transforms. More... | |
void | reserveChildren (size_t count) |
Reserves space for count children. More... | |
bool | hasDuplicatedChildren () const |
Checks whether there are duplicated entries in the Transform's children list. More... | |
Public Member Functions inherited from vl::Object | |
Object () | |
Constructor. More... | |
Object (const Object &other) | |
Copy constructor: copies the name, ref count mutex and user data. More... | |
Object & | operator= (const Object &other) |
Copy operator: copies the object's name, ref count mutex and user data. More... | |
const std::string & | objectName () const |
The name of the object, by default set to the object's class name. More... | |
void | setObjectName (const char *name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setObjectName (const std::string &name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setRefCountMutex (IMutex *mutex) |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () const |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
int | referenceCount () const |
Returns the number of references of an object. More... | |
void | incReference () const |
Increments the reference count of an object. More... | |
void | decReference () |
Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More... | |
void | setAutomaticDelete (bool autodel_on) |
If set to true the Object is deleted when its reference count reaches 0. More... | |
bool | automaticDelete () const |
If set to true the Object is deleted when its reference count reaches 0. More... | |
template<class T > | |
T * | as () |
Casts an Object to the specified class. More... | |
template<class T > | |
const T * | as () const |
Casts an Object to the specified class. More... | |
Protected Attributes | |
mat4 | mLocalMatrix |
mat4 | mWorldMatrix |
long long | mWorldMatrixUpdateTick |
bool | mAssumeIdentityWorldMatrix |
std::vector< ref< Transform > > | mChildren |
Transform * | mParent |
Protected Attributes inherited from vl::Object | |
std::string | mObjectName |
IMutex * | mRefCountMutex |
int | mReferenceCount |
bool | mAutomaticDelete |
Additional Inherited Members | |
Protected Member Functions inherited from vl::Object | |
virtual | ~Object () |
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.
vl::Actor::setTransform(NULL)
.setAssumeIdentityWorldMatrix(true)
. This will save unnecessary matrix multiplications when calling computeWorldMatrix() / computeWorldMatrixRecursive().Definition at line 72 of file Transform.hpp.
|
inline |
|
inline |
Constructor.
The matrix
parameter is used to set both the local and world matrix.
Definition at line 88 of file Transform.hpp.
References NULL.
Transform::~Transform | ( | ) |
Destructor.
Definition at line 44 of file Transform.cpp.
References mChildren, NULL, vl::Log::warning(), and worldMatrix().
|
inline |
Adds a child transform.
Definition at line 246 of file Transform.hpp.
References mParent, NULL, and VL_CHECK.
Referenced by vlX::VLXClassWrapper_Transform::importTransform(), and vl::VolumePlot::setupLabels().
|
inline |
Adds count
children transforms.
Definition at line 256 of file Transform.hpp.
Definition at line 274 of file Transform.hpp.
Definition at line 292 of file Transform.hpp.
|
inline |
Adds the specified children
transforms.
Definition at line 299 of file Transform.hpp.
|
inline |
If set to true the world matrix of this transform will always be considered and identity.
Is usually used to save calculations for top Transforms with many sub-Transforms.
Definition at line 192 of file Transform.hpp.
Referenced by vl::Billboard::computeWorldMatrix().
Returns the array containing the child Transforms.
Definition at line 237 of file Transform.hpp.
References NULL.
Referenced by vlX::VLXClassWrapper_Transform::exportTransform().
Returns the array containing the child Transforms.
Definition at line 240 of file Transform.hpp.
References NULL.
|
inline |
Returns the number of child Transform.
Definition at line 243 of file Transform.hpp.
Referenced by vlX::VLXClassWrapper_Transform::exportTransform().
Computes the world matrix by concatenating the parent's world matrix with its own local matrix.
Reimplemented in vl::Billboard.
Definition at line 195 of file Transform.hpp.
Referenced by vl::TrackballManipulator::adjustView(), vl::Billboard::computeWorldMatrix(), and vl::VolumePlot::setupLabels().
Computes the world matrix by concatenating the parent's world matrix with its local matrix, recursively descending to the children.
Definition at line 214 of file Transform.hpp.
Referenced by vl::Rendering::render().
|
inline |
Removes all the children of a Transform.
Definition at line 350 of file Transform.hpp.
References NULL.
|
inline |
Removes all the children of a Transform recursively descending the hierarchy.
Definition at line 358 of file Transform.hpp.
References NULL.
|
inline |
Removes the given child
Transform.
Definition at line 322 of file Transform.hpp.
|
inline |
Removes count
children Transforms starting at position index
.
Definition at line 336 of file Transform.hpp.
|
inline |
Disassembles a hierarchy of Transforms like eraseAllChildrenRecursive() does plus assigns the local matrix to equal the world matrix.
Definition at line 369 of file Transform.hpp.
References NULL.
|
inline |
Returns the matrix computed concatenating this Transform's local matrix with the local matrices of all its parents.
Definition at line 222 of file Transform.hpp.
References localMatrix(), and parent().
|
inline |
Checks whether there are duplicated entries in the Transform's children list.
Definition at line 412 of file Transform.hpp.
|
inline |
Returns the last child.
Definition at line 316 of file Transform.hpp.
|
inline |
Returns the last child.
Definition at line 319 of file Transform.hpp.
|
inline |
The matrix representing the transform's local space.
Definition at line 145 of file Transform.hpp.
Referenced by vlX::VLXClassWrapper_Transform::exportTransform(), getComputedWorldMatrix(), vl::Billboard::position(), postMultiply(), preMultiply(), rotate(), scale(), and translate().
|
inline |
The matrix representing the transform's local space.
Use this non-const version to directly modify the local matrix. Call computeWorldMatrix() after modifying the local matrix.
Definition at line 153 of file Transform.hpp.
|
inline |
Returns the parent Transform.
Definition at line 104 of file Transform.hpp.
Referenced by vl::Billboard::computeWorldMatrix(), and getComputedWorldMatrix().
|
inline |
Returns the parent Transform.
Definition at line 107 of file Transform.hpp.
References vl::degrees().
void Transform::postMultiply | ( | const mat4 & | m | ) |
Utility function equivalent to setLocalMatrix( localMatrix()*m )
.
After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().
Definition at line 88 of file Transform.cpp.
References localMatrix(), and setLocalMatrix().
void Transform::preMultiply | ( | const mat4 & | m | ) |
Utility function equivalent to setLocalMatrix( m*localMatrix() )
.
After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().
Definition at line 83 of file Transform.cpp.
References localMatrix(), and setLocalMatrix().
|
inline |
Erases a Transform from it's parent and sets the local matrix to be equal to the world matrix.
Definition at line 381 of file Transform.hpp.
Referenced by vl::DaeLoader::load().
|
inline |
Reserves space for count
children.
This function is very useful when you need to add one by one a large number of children transforms.
eventually
contain count
of them. This will make subsequent calls to addChild() quicker as fewer or no reallocations of the buffer will be needed. Definition at line 409 of file Transform.hpp.
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 73 of file Transform.cpp.
References vl::Matrix4< float >::getRotation(), localMatrix(), and setLocalMatrix().
Utility function equivalent to setLocalMatrix
( mat4::getRotation(from,to)*localMatrix() ).
After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().
Definition at line 78 of file Transform.cpp.
References vl::Matrix4< float >::getRotation(), localMatrix(), and 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 68 of file Transform.cpp.
References vl::Matrix4< float >::getScaling(), localMatrix(), and setLocalMatrix().
|
inline |
If set to true the world matrix of this transform will always be considered and identity.
Is usually used to save calculations for top Transforms with many sub-Transforms.
Definition at line 188 of file Transform.hpp.
|
inline |
Sets the index-th
child.
Definition at line 306 of file Transform.hpp.
|
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 176 of file Transform.hpp.
Referenced by vlX::VLXClassWrapper_Transform::importTransform(), and vl::Terrain::init().
|
inline |
The matrix representing the transform's local space.
After calling this you might want to call computeWorldMatrix() or computeWorldMatrixRecursive().
Definition at line 139 of file Transform.hpp.
Referenced by vl::Molecule::atomsStyle(), vl::Molecule::ballAndStickStyle(), postMultiply(), preMultiply(), rotate(), scale(), vl::Billboard::setPosition(), vl::VolumePlot::setupLabels(), vl::Molecule::sticksStyle(), and translate().
|
inline |
Normally you should not use directly this function, call it only if you are sure you cannot do otherwise.
Usually you want to call computeWorldMatrix() or computeWorldMatrixRecursive(). Calling this function will also increment the worldMatrixUpdateTick().
Definition at line 161 of file Transform.hpp.
Referenced by vl::Billboard::computeWorldMatrix().
|
inline |
Minimizes the amount of memory used to store the children Transforms.
Definition at line 391 of file Transform.hpp.
|
inline |
Minimizes recursively the amount of memory used to store the children Transforms.
Definition at line 398 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 58 of file Transform.cpp.
References vl::Matrix4< float >::getTranslation(), localMatrix(), and 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 63 of file Transform.cpp.
References vl::Matrix4< float >::getTranslation(), localMatrix(), and setLocalMatrix().
|
inline |
Returns the world matrix used for rendering.
Definition at line 168 of file Transform.hpp.
Referenced by vl::ClipPlane::apply(), vl::Text::boundingRectTransformed(), vl::Billboard::computeWorldMatrix(), vl::DistanceLODEvaluator::evaluate(), vl::PixelLODEvaluator::evaluate(), vl::RayIntersector::intersectGeometry(), vl::DaeLoader::load(), vl::SlicedVolume::onActorRenderStarted(), vl::EdgeUpdateCallback::onActorRenderStarted(), vl::DepthSortCallback::onActorRenderStarted(), vl::DrawPixels::render_Implementation(), vl::EdgeRenderer::renderLines(), vl::EdgeRenderer::renderSolids(), vl::Text::renderText(), vl::RenderQueue::sort(), vl::ProjViewTransfCallback::updateMatrices(), vl::RaycastVolume::updateUniforms(), vl::SlicedVolume::updateUniforms(), and ~Transform().
|
inline |
Returns the internal update tick used to avoid unnecessary computations.
The world matrix thick gets incremented every time the setWorldMatrix() or setLocalAndWorldMatrix() functions are called.
Definition at line 184 of file Transform.hpp.
Referenced by vl::Actor::boundsDirty(), and vl::Actor::computeBounds().
|
protected |
Definition at line 434 of file Transform.hpp.
Definition at line 435 of file Transform.hpp.
Referenced by ~Transform().
|
protected |
Definition at line 431 of file Transform.hpp.
|
protected |
Definition at line 436 of file Transform.hpp.
Referenced by addChild(), addChildren(), and setChild().
|
protected |
Definition at line 432 of file Transform.hpp.
|
protected |
Definition at line 433 of file Transform.hpp.
Visualization Library 2.0.0 Reference Documentation
Updated on Wed Dec 23 2020 12:44:12.
© Copyright Michele Bosi. All rights reserved.