Rotation

Rotation is a simple concept, and opens the door to many possibilities for creativity.

Grouping, or nesting objects is an interesting part of rotation. The animation on the left demonstrates nesting and was created using the script shown below. Please note that when the box rotates, the sphere moves with it. We could attach 100 objects to the box and they would all move when the box moves. This box exemplifies the definition of a World. The box is the base, or center of the world and all other objects are part of it.

Line 3 of the script contains "rotation 1.0 1.0 0.0 0.524", which is the only command you need to rotate the object. This does not animate the object. That is a different subject to be covered in another section. "1.0 1.0 0.0" refers to the X, Y and Z axis. "0.524" is the angle the object is being repositioned at, which is in radians and equal to 30 degrees. Therefore, the box is repositioned 30 degrees on the X and Y axis. Z is set at 0.0 and is not active.

Line 8 contains the texture field, which calls up the image file "tile.gif" that will be mapped onto the box. You can get more information on this at Subjects/Mapping.

Line 16 contains the "DEF Sphere Transform" command, which attaches "sphere.wrl" to the box. The next line, "translation 0.0 1.5 0.0", is stating that the sphere will be positioned on the Y axis of the box and its center will be a distance of 1.5 from the center of the box.

#VRML V2.0 utf8
Transform {
rotation 1.0 1.0 0.0 0.524
children [
Shape {
appearance Appearance {
material Material { }
texture ImageTexture {
url "tile.gif"
}
}
geometry Box {
size 2.0 2.0 2.0
}
}
DEF Sphere Transform {
translation 0.0 1.5 0.0
children [
DEF Sphere Inline {
url "sphere.wrl"
}
]
}
]
}

rotate.wrl

tile.gif

sphere.wrl

Here is something for you to play with. First, download and install Cosmo Player, or Cortona 3D and it might be best if you start a new folder on your drive and keep all of your VRML stuff in it. Second, download the code files "rotate.wrl", sphere.wrl and tile.gif by right clicking on the link and "Save Target as". It might be best if you leave these numbers alone initially to see what the box and sphere look like on the viewer. If you want to change the size, put in a new number and save the file.

To open this file, go to your VRML folder and double click, or open the rotate.wrl file. This will open a browser window (off line), the Cosmo Player, Cortona 3D screen will appear, as will the box and sphere. Now you can make the box do anything you want. Click on the "Examine" button to spin the box in virtually any direction, or speed. This can take a little practice. You'll see what I mean. For more info, go to Discussion and click on "VRML Viewer" and check out the section on controls.

Special Notes:

1. When the VRML viewer creates an object, it only shows the surface. The object is not solid.

2. VRML, like other programing languages, is very unforgiving. The format, shown above, will prove to be very useful as you progress into more complex scripts. Particularly when you are trying to find an error. If you are missing a component, such as a bracket, or a misspelling, the script will not run.

Have fun!!

SL Button 125

Contact Blog Privacy