Core Scene Graph Data Structures in C++


Transform

The Transform node is implemented as a subclass of the Group node, with additional functionality to represent a change of coordinate system with respect to the children of the node. This is how the Transform node is defined in the VRML'97 Standard.

Transform {
  SFVec3f center                0 0 0
  MFNode children	        []
  SFRotation rotation           0 0 1 0
  SFVec3f scale                 1 1 1
  SFRotation scaleOrientation   0 0 1 0
  SFVec3f translation           0 0 0
  SFVec3f bboxCenter            0 0 0
  SFVec3f bboxSize              1 1 1
}

The Transform node provides the functionality necessary to change the coordinate system of the Transform node children with respect to the coordinate system of the Transform node itself. To understand how this transformation is specified and represented in the Transform node fields you need to read the VRML'97 Standard. Some of these fields are used to store 3D rotations, which in VRML are specified by an axis of rotation and an angle. The axis of rotation is described by a 3D unit-­‐length vector, and the angle is measured in radians. Rodrigues’ Formula is used to convert this (axis,angle) representation into a 3x3 orthogonal matrix representation. For the mathematical detail of how to convert back and forth between these two representations, read the 3D Rotations http://mesh.brown.edu/rotations notes.

The overall transformation specified by the fields of a Transform node can be represented as a 4x4 matrix. The transformation is applied to a 3D point by multiplying the 4x4 matrix by the homogeneous coordinates of the 3D point. This is the standard in computer graphics pipelines such as OpenGL, which we use in the DGP2023 application.

This is how the public interface to the Transform class is defined in the DGP2023 application.

class Transform : public Group {
  public:
                        Transform();
    virtual            ~Transform();
    Vec3f&              getCenter();
    Rotation&           getRotation();
    Vec3f&              getScale();
    Rotation&           getScaleOrientation();
    Vec3f&              getTranslation();
    void                setCenter(Vec3f& value);
    void                setRotation(Rotation& value);
    void                setRotation(Vec4f& value);
    void                setScale(Vec3f& value);
    void                setScaleOrientation(Rotation& value);
    void                setScaleOrientation(Vec4f& value);
    void                setTranslation(Vec3f& value);
    void                getMatrix(float* T /*[16]*/);
    virtual bool        isTransform() const;
    virtual string      getType()     const;
};