




![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
World 1
If you have gone through the Discussion topics and the four geometrical shapes, then you are ready to create your first Virtual World. Congratulations!!
The first thing you need to do is start a new folder. All of your world will go in it. You must keep these files separate because you can easily have duplicate names for files in different folders. Now copy the avatar.wrl file and paste it in this folder. Next, copy the four geometrical shape .wrl files and paste them in this folder.
You may recall line 18 (Inline { url "base.wrl" } in "avatar.wrl". The base will be the ground for your world. Here is the script:
#VRML V2.0 utf8
Group {
children [
Shape {
appearance Appearance {
texture ImageTexture {
url "tile.gif"
}
textureTransform TextureTransform {
scale 50.0 50.0
}
},
geometry Box {
size 200.0 0.6 200.0
}
},
DEF Sphere Transform {
translation 0.0 4.0 0.0
children [
DEF Sphere Inline {
url "sphere.wrl"
}
]
},
Insert additional DEF objects here.
]
}
Whoa!!! Hold on here. This does not look like the other script for a box. What is going on?
What is going on is that instead of having just a blank slab for the ground, which might look a little tacky, we are going to "map an image" onto the slab. In this case, we are using a wood tile and the image is "tile.gif". In the same way that your floor has a certain number of tiles on it, so does this slab. Under"textureTransform" you will not that there are some values for scale. The slab is X=200 and Y=200, so we are going to map 50 tiles in each direction. Try changing the scale values and see what happens. This is part of the learning curve.
The next new thing we are going to do is to and an object to your new world. In this case it will be the sphere you have in your folder. The phrase "DEF Sphere Transform" basically means "We are defining the object as Sphere and providing coordinates to place it in the world at some distance from the center of the base". The center of the base is the origin of your entire world. In this case, the sphere has been located at the center of the base, 4.0 above it. Just hanging there in the air.
Please understand that you are not finished at this point. On the contrary, things have just begun. Now you can begin to experiment on your own. Here are a few things you can do:
1. Go to Google Images. They have lots of tile images.
2. Try changing the scale for the tiles. See what happens.
3. If you do not want a sphere, just change the script from "sphere.wrl" to "cone.wrl", or any of the geometric shapes.
4. Change the size of the shapes in thier .wrl file.
5. Add objects to the world. Copy that little piece of "DEF" code, eight lines, in blue, from DEF down to the Bracket ( }, ), then paste it into the script just below the last DEF entry. Make sure that the last two brackets end up at the end of the script. Change the file name to the object you want and do not forget to change the location, or you could have one object inside another. Also, you can insert as many of the same objects as you like. Just give it a separate DEF code. If you want two different sized objects, just make a new .wrl file, give it a new name and change the size. There is no limit to the number of objects you can put in your world.
To download these files, right click on it and click on "Save Target as". Put these files in your new world folder. then open file "avatar.wrl". This will bring up a browser window(offline), the VRML viewer will start and the world will appear. Always put each new world in a new folder.