Home | Hierarchy | Members | Alphabetical | Related Pages |
You will probably not use these directly, except for their transform() methods. Indeed the Traverser class maintains the current transformation for any traversed node as described below.
t
and pushes in a TransformatorHierarchy object accessible by the member function wrl::Traverser::transformHierarchy().When writing your own traversal by subclassing the Traverser class, you can use the transformHierarchy() to devise the local coordinate frame. Here is for example a traverser that outpouts the absolute coordinate of the center of all the spheres in a VRML file.
#ifndef SPHEREFLATTENER_H #define SPHEREFLATTENER_H #include <xdkwrl/tools/traverser.h> class SphereFlattener : public wrl::Traverser { protected: virtual void treat(wrl::Sphere*); }; #endif // SPHEREFLATTENER_H
#include "sphereflattener.h" #include <xdkwrl/nodes/sphere.h> #include <iostream> using namespace wrl; using namespace std; void SphereFlattener::treat(wrl::Sphere* s) { SFVec3f center(0.0f,0.0f,0.0f) ; SFVec3f C; transformHierarchy().transform(center,C); cout<<" sphere center : "<<C<<endl; cout<<" sphere *untransformed* radius : "<<s->radius<<endl; }
Note that non rigid transformation do not usually preserve the distance and therefore we cannot transform the "radius" of the transform sphere because it might not be a sphere anymore (e.g. it can be an ellipsis). In a future release we might add some functionality to the Transformator class to test if it has scales or not.
Generated on 24 Feb 2005 with version 1.3.9.1. |