V-ART
|
Geometric transformations. More...
#include <transform.h>
Public Member Functions | |
Transform () | |
Creates an uninitialized transform. More... | |
Transform (const Transform &trans) | |
Copy constructor. More... | |
virtual VART::SceneNode * | Copy () |
Returns a copy of an Transform. Every derived class must reimplements this method, to avoid errors with VART::SceneNode::RecursiveCopy. More... | |
void | MakeIdentity () |
Turns transform into identity. More... | |
Point4D | operator* (const Point4D &point) const |
Applies transformation to a point. More... | |
Transform | operator* (const Transform &t) const |
Applies transformation to another transform. More... | |
Transform & | operator= (const Transform &t) |
Copies data from anoter transform. More... | |
void | Apply (const Transform &t) |
Applies a transformation to itself. More... | |
void | ApplyTo (Point4D *ptPoint) const |
Applies tranformation to a point. More... | |
void | MakeTranslation (const Point4D &translationVector) |
Turns transform into a translation. More... | |
void | MakeTranslation (double tx, double ty, double tz) |
Turns transform into a translation. More... | |
void | MakeXRotation (double radians) |
Turns transform into a rotation around the X axis. More... | |
void | MakeYRotation (double radians) |
Turns transform into a rotation around the Y axis. More... | |
void | MakeZRotation (double radians) |
Turns transform into a rotation around the Z axis. More... | |
void | MakeRotation (const Point4D &refVec, const float radians) |
Turns transform into a rotation (around some reference vetor). More... | |
void | MakeRotation (const Point4D &refPoint, const Point4D &refVec, const float radians) |
Turns transform into a rotation (around some reference axis). More... | |
void | MakeScale (double sX, double sY, double sZ) |
Turns transform into a scale. More... | |
void | MakeShear (double shX, double shY) |
Turns transform into a shear. More... | |
void | SetData (double *data) |
Set all data in the transform. More... | |
const double * | GetData () const |
Returns the address of transformation matrix. More... | |
void | GetVectorX (Point4D *result) const |
Returns the X vector of the transform. More... | |
void | GetVectorY (Point4D *result) const |
Returns the Y vector of the transform. More... | |
void | GetVectorZ (Point4D *result) const |
Returns the Z vector of the transform. More... | |
void | GetTranslation (Point4D *result) const |
Returns the translation part of the transform. More... | |
bool | HasNaN () const |
Check for NaNs inside the matrix. More... | |
virtual bool | DrawOGL () const |
Apply transform to rendering engine. More... | |
virtual void | DrawForPicking () const |
Draws and object, setting pick info. More... | |
virtual TypeID | GetID () const |
Returns type identification of the node. More... | |
virtual bool | RecursiveBoundingBox (BoundingBox *bBox) |
Returns the recursive bounding box. More... | |
void | ToggleRecVisibility () |
Toggles the recursive object's visibility. More... | |
void | CopyMatrix (const Transform &t) |
Copies matrix data from another transform. More... | |
Public Member Functions inherited from VART::SceneNode | |
SceneNode () | |
Creates an uninitialized scene node. More... | |
SceneNode (SceneNode &node) | |
virtual | ~SceneNode () |
SceneNode & | operator= (const SceneNode &node) |
virtual SceneNode * | RecursiveCopy () |
const std::string & | GetDescription () const |
Returns a copy of the object's description. More... | |
void | SetDescription (const std::string &desc) |
Changes the object's description. More... | |
void | AddChild (SceneNode &child) |
Add a child at the end of child list. More... | |
bool | DetachChild (SceneNode *childPtr) |
Removes a child from the child list. More... | |
void | AutoDeleteChildren () const |
Deletes (dealocate memory) recursively all children marked as 'autoDelete'. More... | |
SceneNode * | FindChildByName (const std::string &name) const |
Recusively searches its children for a given name. More... | |
std::list< SceneNode * > | GetChilds () |
bool | FindPathTo (SceneNode *targetPtr, SGPath *resultPtr) const |
Search target among children. More... | |
bool | FindPathTo (const std::string &targetName, SGPath *resultPtr) const |
Search target among children. More... | |
int | GetNodeTypeList (TypeID type, std::list< SceneNode * > &nodeList) |
Find all the nodes of with typeID 'type'. More... | |
virtual void | TraverseDepthFirst (SNOperator *operatorPtr) const |
Process all children in depth-first order. More... | |
virtual void | TraverseBreadthFirst (SNOperator *operatorPtr) const |
Process all children in breadth-first order. More... | |
virtual void | LocateDepthFirst (SNLocator *locatorPtr) const |
Seaches for a particular scene node (depth first) More... | |
virtual void | LocateBreadthFirst (SNLocator *locatorPtr) const |
Seaches for a particular scene node (breadth first) More... | |
virtual void | XmlPrintOn (std::ostream &os, unsigned int indent) const |
Recursively outputs XML representation of the scene node. More... | |
Public Member Functions inherited from VART::MemoryObj | |
MemoryObj () | |
Default constructor. More... | |
MemoryObj (const VART::MemoryObj &obj) | |
Copy constructor. More... | |
Protected Attributes | |
double | matrix [16] |
Protected Attributes inherited from VART::SceneNode | |
std::list< SceneNode * > | childList |
Child list. More... | |
std::string | description |
Textual identification. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &output, const Transform &t) |
'ostream' class extension to output a transformation on the console. More... | |
Additional Inherited Members | |
Public Types inherited from VART::SceneNode | |
enum | TypeID { NONE, GRAPHIC_OBJ, BOX, CONE, CURVE, BEZIER, CYLINDER, IMAGE, IMAGE_2D, VOLUME, MESH_OBJECT, SPHERE, JOINT, BIAXIAL_JOINT, CONDYLAR_JOINT, ELLIPSOID_JOINT, SADDLE_JOINT, PLANE_JOINT, POLYAXIAL_JOINT, UNIAXIAL_JOINT, HINGE_JOINT, PIVOT_JOINT, TRANSFORM } |
Public Attributes inherited from VART::MemoryObj | |
bool | autoDelete |
Static Public Attributes inherited from VART::SceneNode | |
static bool | recursivePrinting = true |
Protected Member Functions inherited from VART::SceneNode | |
virtual bool | DrawInstanceOGL () const |
Non-recursive drawing - should be overriden by every derived class. More... | |
bool | RecursiveFindPathTo (SceneNode *targetPtr, SGPath *resultPtr) const |
Recursive auxiliar method for FindPathTo. More... | |
bool | RecursiveFindPathTo (const std::string &targetName, SGPath *resultPtr) const |
Recursive auxiliar method for FindPathTo. More... | |
Geometric transformations.
A transformation matrix is represented by a 4x4 pre-multiplication matrix, i.e., to apply T1, then T2, then T3, one must multiply T3*T2*T1. Translation values are at the rightmost column. In a scene graph, the innermost transformation (the one close to the graphic object, farther away from root) is the one applied first.
Definition at line 24 of file transform.h.
VART::Transform::Transform | ( | ) |
Creates an uninitialized transform.
Definition at line 24 of file transform.cpp.
VART::Transform::Transform | ( | const Transform & | trans | ) |
Copy constructor.
trans | [in] Source transform |
Definition at line 44 of file transform.cpp.
void VART::Transform::Apply | ( | const Transform & | t | ) |
Applies a transformation to itself.
Definition at line 144 of file transform.cpp.
void VART::Transform::ApplyTo | ( | VART::Point4D * | ptPoint | ) | const |
Applies tranformation to a point.
ptPoint | [in,out] Point to be transformed |
Definition at line 149 of file transform.cpp.
References VART::Point4D::GetW(), VART::Point4D::GetX(), VART::Point4D::GetY(), VART::Point4D::GetZ(), and VART::Point4D::SetXYZW().
Referenced by VART::Curve::ApplyTransform(), VART::MeshObject::ApplyTransform(), VART::Camera::MoveForward(), VART::Camera::MoveSideways(), VART::Camera::MoveUp(), VART::Camera::PitchAroundTarget(), VART::Camera::Roll(), VART::Camera::Yaw(), and VART::Camera::YawAroundTarget().
|
virtual |
Returns a copy of an Transform. Every derived class must reimplements this method, to avoid errors with VART::SceneNode::RecursiveCopy.
Implements VART::SceneNode.
Reimplemented in VART::Joint, VART::UniaxialJoint, VART::PolyaxialJoint, and VART::BiaxialJoint.
Definition at line 28 of file transform.cpp.
void VART::Transform::CopyMatrix | ( | const Transform & | t | ) |
Copies matrix data from another transform.
Unlike operator=, CopyMatrix copies only the internal matrix.
Definition at line 138 of file transform.cpp.
References matrix.
Referenced by VART::Dof::ApplyTransformTo(), VART::Dof::GetLim(), VART::SGPath::GetTransform(), and VART::IKChain::MoveTowardsSolution().
|
virtual |
Draws and object, setting pick info.
This method should be called in selection mode in order to identify objects that are selected by the mouse (see Scene::Pick).
Implements VART::SceneNode.
Definition at line 278 of file transform.cpp.
|
virtual |
Apply transform to rendering engine.
Reimplemented from VART::SceneNode.
Definition at line 260 of file transform.cpp.
|
inline |
Returns the address of transformation matrix.
Use this method to get an OpenGl like transformation matrix, compatible with methods such as "glLoadMatrixd" and "glMultMatrixd".
Definition at line 111 of file transform.h.
References matrix.
|
inlinevirtual |
Returns type identification of the node.
Reimplemented from VART::SceneNode.
Definition at line 154 of file transform.h.
References VART::SceneNode::TRANSFORM.
void VART::Transform::GetTranslation | ( | VART::Point4D * | result | ) | const |
Returns the translation part of the transform.
Definition at line 252 of file transform.cpp.
References VART::Point4D::SetW(), VART::Point4D::SetX(), VART::Point4D::SetY(), and VART::Point4D::SetZ().
void VART::Transform::GetVectorX | ( | VART::Point4D * | result | ) | const |
Returns the X vector of the transform.
A rigid transformation matrix may be interpreted as a coordinate system. This method returns the 1st column of the matrix which may be interpreted as the X vector of such coordinate system.
Definition at line 228 of file transform.cpp.
References VART::Point4D::SetW(), VART::Point4D::SetX(), VART::Point4D::SetY(), and VART::Point4D::SetZ().
void VART::Transform::GetVectorY | ( | VART::Point4D * | result | ) | const |
Returns the Y vector of the transform.
A rigid transformation matrix may be interpreted as a coordinate system. This method returns the 2nd column of the matrix which may be interpreted as the Y vector of such coordinate system.
Definition at line 236 of file transform.cpp.
References VART::Point4D::SetW(), VART::Point4D::SetX(), VART::Point4D::SetY(), and VART::Point4D::SetZ().
void VART::Transform::GetVectorZ | ( | VART::Point4D * | result | ) | const |
Returns the Z vector of the transform.
A rigid transformation matrix may be interpreted as a coordinate system. This method returns the 3rd column of the matrix which may be interpreted as the Z vector of such coordinate system.
Definition at line 244 of file transform.cpp.
References VART::Point4D::SetW(), VART::Point4D::SetX(), VART::Point4D::SetY(), and VART::Point4D::SetZ().
bool VART::Transform::HasNaN | ( | ) | const |
Check for NaNs inside the matrix.
This is for debugging purposes only.
Definition at line 362 of file transform.cpp.
void VART::Transform::MakeIdentity | ( | ) |
Turns transform into identity.
Definition at line 49 of file transform.cpp.
Referenced by VART::SGPath::GetTransform(), VART::XmlScene::LoadSceneNode(), and VART::IKChain::MoveTowardsSolution().
void VART::Transform::MakeRotation | ( | const Point4D & | refVec, |
const float | radians | ||
) |
Turns transform into a rotation (around some reference vetor).
refVec | [in] Reference vector |
radians | [in] Angle of rotation |
Definition at line 171 of file transform.cpp.
References VART::Point4D::AngleTo(), VART::Point4D::GetX(), VART::Point4D::GetY(), VART::Point4D::GetZ(), MakeXRotation(), MakeYRotation(), MakeZRotation(), VART::Point4D::Normalize(), and VART::Point4D::SetXYZW().
Referenced by MakeRotation(), VART::Camera::MoveSideways(), VART::Camera::PitchAroundTarget(), VART::Camera::Roll(), VART::Camera::Yaw(), and VART::Camera::YawAroundTarget().
void VART::Transform::MakeRotation | ( | const Point4D & | refPoint, |
const Point4D & | refVec, | ||
const float | radians | ||
) |
Turns transform into a rotation (around some reference axis).
refPoint | [in] Reference point (defines an axis together with refVec) |
refVec | [in] Reference vector (defines an axis together with refPoint) |
radians | [in] Angle of rotation |
Definition at line 216 of file transform.cpp.
References MakeRotation(), and MakeTranslation().
void VART::Transform::MakeScale | ( | double | sX, |
double | sY, | ||
double | sZ | ||
) |
Turns transform into a scale.
Definition at line 91 of file transform.cpp.
void VART::Transform::MakeShear | ( | double | shX, |
double | shY | ||
) |
Turns transform into a shear.
Definition at line 99 of file transform.cpp.
void VART::Transform::MakeTranslation | ( | const Point4D & | translationVector | ) |
Turns transform into a translation.
MakeTranslation expects a vector but actualy ignores the W coordinate.
translationVector | [in] Vector representation of the translation |
Definition at line 56 of file transform.cpp.
References VART::Point4D::GetX(), VART::Point4D::GetY(), and VART::Point4D::GetZ().
Referenced by VART::Arrow::Arrow(), MakeRotation(), MakeTranslation(), VART::Camera::MoveForward(), VART::Camera::MoveSideways(), and VART::Camera::MoveUp().
|
inline |
Turns transform into a translation.
tx | [in] X component of translation |
ty | [in] Y component of translation |
tz | [in] Z component of translation |
Definition at line 72 of file transform.h.
References MakeTranslation().
void VART::Transform::MakeXRotation | ( | double | radians | ) |
Turns transform into a rotation around the X axis.
radians | [in] Angle of rotation |
Definition at line 64 of file transform.cpp.
Referenced by VART::XmlScene::LoadSceneNode(), and MakeRotation().
void VART::Transform::MakeYRotation | ( | double | radians | ) |
Turns transform into a rotation around the Y axis.
radians | [in] Angle of rotation |
Definition at line 73 of file transform.cpp.
Referenced by VART::Arrow::Arrow(), VART::XmlScene::LoadSceneNode(), MakeRotation(), and VART::RefSystem::RefSystem().
void VART::Transform::MakeZRotation | ( | double | radians | ) |
Turns transform into a rotation around the Z axis.
radians | [in] Angle of rotation |
Definition at line 82 of file transform.cpp.
Referenced by VART::Arrow::Arrow(), VART::XmlScene::LoadSceneNode(), MakeRotation(), and VART::RefSystem::RefSystem().
VART::Point4D VART::Transform::operator* | ( | const Point4D & | point | ) | const |
Applies transformation to a point.
point | [in] Point to apply transformation |
Definition at line 106 of file transform.cpp.
References VART::Point4D::GetW(), VART::Point4D::GetX(), VART::Point4D::GetY(), and VART::Point4D::GetZ().
VART::Transform VART::Transform::operator* | ( | const Transform & | t | ) | const |
Applies transformation to another transform.
t | [in] Transform to apply transformation |
Definition at line 120 of file transform.cpp.
References matrix.
VART::Transform & VART::Transform::operator= | ( | const Transform & | t | ) |
|
virtual |
Returns the recursive bounding box.
bBox | [out] recursive bounding box. |
Definition at line 293 of file transform.cpp.
References VART::BoundingBox::ApplyTransform(), VART::GraphicObj::ComputeRecursiveBoundingBox(), VART::BoundingBox::CopyGeometryFrom(), VART::GraphicObj::GetRecursiveBoundingBox(), VART::BoundingBox::MergeWith(), VART::BoundingBox::ProcessCenter(), and RecursiveBoundingBox().
Referenced by VART::Scene::ComputeBoundingBox(), VART::GraphicObj::ComputeRecursiveBoundingBox(), and RecursiveBoundingBox().
void VART::Transform::SetData | ( | double * | data | ) |
Set all data in the transform.
Definition at line 33 of file transform.cpp.
Referenced by VART::XmlScene::LoadSceneNode().
void VART::Transform::ToggleRecVisibility | ( | ) |
Toggles the recursive object's visibility.
Definition at line 340 of file transform.cpp.
References VART::GraphicObj::ToggleRecVisibility(), ToggleRecVisibility(), and VART::GraphicObj::ToggleVisibility().
Referenced by VART::GraphicObj::ToggleRecVisibility(), and ToggleRecVisibility().
|
friend |
'ostream' class extension to output a transformation on the console.
|
protected |
Definition at line 171 of file transform.h.
Referenced by CopyMatrix(), GetData(), operator*(), and operator=().