>

Sphere

In this exercise, we are going to create a Sphere. It is a simple geometric object and one of the fundamental parts of a Virtual World.

The size of the sphere will be determined by the radius, whose starting point is at 0/0/0 (X/Y/Z). The value of "radius" must be a decimal. The radius will rotate around point 0/0/0 in all directions to create a sphere.  The VRML plug-in does this calculation automatically.

Presently, the color of the sphere is set at a shade of green. If you wish to change the color, you will need to change the values of red, green and blue on line 5, "diffuseColor 0.0 1.0 0.0". Go back to the Subjects section on the main page and click on RGB Color, which will give additional information about color and a link to a color chart.

Here is the code for the creation of a sphere:

#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material {
diffuseColor 0.0 1.0 0.0
}
}
geometry Sphere {
radius 0.4
}
}

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, bring up Wordpad, copy and paste this code. Now, save the file as :

File Name:  anyname.wrl

Save as Type:   text document

Be sure to save the file with the "wrl" extension and as a "text document", or the Cosmo Player, Cortona 3D Plug-in will not recognize the file as being VRML, and it will not run.  In line 9 of the code you will see (radius 1.5), which determines the size of the sphere. It might be best if you leave this number alone initially to see what the sphere looks like on the plug-in. 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 anyname.wrl file. This will open a browser window (off line), the Cosmo Player, Cortona 3D screen will appear, as will the sphere. Now you can make the sphere do anything you want. Click on the "Examine" button to spin the sphere in virtually any direction, or speed. This can take a little practice. You'll see what I mean. For more info, go to the main menu and click on "Free VRML Plug-in" and check out the section on controls.

Special Notes:

1. When the VRML plug-in 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