
![]()
|
VRML, 3D, and TransformingEvery visual application you'll run across has something to do with space. Web pages are displayed on your screen. Java happens to have an entire code library specifically defining layouts for use in creating your standard dialog box. Those previous examples have something in common: their results are displayed in a two-dimensional space, where the only things you have to work with are height and width (granted, those "OK" buttons in a Windows dialog box were shaded to look 3D by some shifty Microsoft engineers, but they're not). VRML is a little bit more advanced.This is virtual reality we're talking about after all, and it's 3D. When you have three dimensions, you get to work with three directions--height, width, and depth. They're simply directions you've taken for granted in the everyday world, but now they have a use in a computer language. Height is a measure of how tall something is, width is a measure of how wide something is, and depth is a measure of something's length, that is, how far it comes out at you from your screen. VRML is centered around this 3D world, so be prepared to use these three standard measurements in defining lots of things, ranging from the height of a cylinder to the width of a bounding box. The Transform NodeTheTransform node is VRML's way of telling the browser where to put an object:
Transform {
children []
translation 0.0 0.0 0.0
rotation 0.0 0.0 1.0 0.0
scale 1.0 1.0 1.0
scaleOrientation 0.0 0.0 1.0 0.0
bboxCenter 0.0 0.0 0.0
bboxSize -1.0 -1.0 -1.0
center 0.0 0.0 0.0
addChildren
removeChildren
}
Now let's break it down:
Transform node, the only things we're concerned with are the children and translation fields. To understand how these work, however, you need to understand how the node itself works.
Whenever you put this node into use in your code, a new coordinate system is created. Coordinate system is just the coder's way of saying that a miniature world is created inside of the larger world. This miniature world contains nodes...that's right, the ones that were put into the
If you use the Enough documentation...let's go see what this thing can do. Movin' StuffAlright, let's have some fun transforming some stuff. By the way, the fields we aren't going to use don't need to be in the file. First, let's translate a red cone two units upwards:
The resulting world has just what was expected: a red cone raised above your head. One quick thing to notice from the code is that the Sphere does not have its own Transform node. Since it has none, it is automatically dumped into the center of the parent world. You can also translate along the other two axes:
And, as expected, here's the resulting world. Feel free to experiment with the Transform node. Although it may seem amazingly simple, it's actually a whole lot of fun to use.
|