VRML : Transformations
As you should have noticed, all the shapes a drawn centered at (0,0,0),
and a particular way up. To get them to where you want them and at the
angle you want them you must use translations and rotations.
Transformations
- Rotation
- This node is affected by the current cumulative rotation and
translation values. This node allows you to rotate the axes of your
world. It defines a rotation in 3D space on an author-defined axis about
the origin. Rotations are cumulative (add up over time), instead of
replacing the old rotation, so it is a good idea to use
Separator
nodes to destroy rotation data. Rotations affect future
translations, so it is again a good idea to use Separator
nodes. This node has one parameter which defines the axis of rotation
(first three numbers), and the angle of rotation in radians (final
number).
Parameter | Default Value |
Data Type |
rotation | 0 0 1 0 | Rotation |
Example: rotation of 90 degrees about y axis.
Rotation {
rotation 0 1 0 1.570796
}
- Scale
- This node is affected by the current cumulative rotation, translation
and scale values. It defines a 3D scaling centered upon the origin.
The parameter
scaleFactor
defines the scaling to be made, and
this does not need to be uniform.
Parameter | Default Value |
Data Type |
scaleFactor | 1 1 1 | Vector3D |
Example: stretch the x axis by a factor 2 and invert the z axis.
Scale {
scaleFactor 2 1 -1
}
- Translation
- This node is affected by the current cumulative rotation, scale and
translation values. It defines a 3D translation, given by the
translation
parameter.
Parameter | Default Value |
Data Type |
translation | 0 0 0 | Vector3D |
Example: create a shiny red sphere at (4,3,2).
Material {
diffuseColor 1 0 0
shininess 0.7
}
Translation {
translation 4 3 2
}
Sphere {}
Next Topic (DEF and USE)
Previous Topic (Materials and Separators)
Back to the VRML Reference
Back to the Main Page
©Tom Thurston, 1997
Please feel free to use and redistribute this NONcommercially!