Translation (Transform Node)


To begin, lets try values other than the default values:

#VRML V2.0 utf8
#try a translation

Transform{
translation 2 3 1
children[
Shape{
geometry Box{}
}
]
}

translation 2 3 1 moves the Box{} 2 meters in the x-direction, 3 meters in the y-direction and 1 meters in the z-direction. Take a look at it.

NB: certain browsers may center the initial viewpoint on the Box. However, browsers that correctly impliment the v2.0 spec should show the Box in the upper right side of the screen.

Try adding another Transform{}:

#VRML V2.0 utf8
#multiple nodes

Transform{
translation 2 3 1
children[
Shape{
geometry Box{} #the first box
}
]
}
Transform{
#no translation
children[
Shape{
geometry Box{}
}
]
}

The translation field of the Transform node moves the children as many meters as specified. With the line: translation 2 3 1 the children (the first box) are moved 2 meters in the x, 3 in the y, and 1 in the z. Note that since the second Transform{} is of the same generation, that the first Translation{} has no effect.


[ Next ] [ Previous ]