Creating a VRML model from
formZ (including trees).
Step
1:
Create
your 3D model in formZ. Texture map the
model by using tif or tga images (do not use the procedural texture mapping
such as the brick variable size).
Suppose
that we have a cube and a panel and we texture map (see previous section) the
following two images (palm.tga and marble.tga):
The
resulting rendered formZ file should look as follows (in formZ):
Step 2:
Then we save the cube-panel file as VRML (using
the options mentioned earlier in this section). If we have already called this file cubePanel.fmz then the
resulting file will be called cubePanel.wrl.
In the folder where cubePanel.wrl was saved formZ has also saved the two
images in png format, that is, palm.png and marble.png
In
the VRML options choose: v2.0 and Rendered in the Export Textures (if you
have concave faces choose the Subdivide
Concave Faces option in the Decomposition section)
Once
you have saved the file you will have a .wrl file (in this case it is called
cubePanel.wrl). Opening the file in a
Cosmo plug-in in Netscape will make your file look like this:
Play
with switched to see what real-time animation is all about.
If you bring up an editor (such as notepad.exe)
and open the .wrl file, you will see
that it is a text file. It may look
something like this:
Notice
that the textured image used is displayed as text. This means that we can replace that file with another (say
pine.png) and have a pine instead of a palm.
We will use this principle in a little bit. Fi
As
we said, you can modify the text (if you know what it means. You can read the manuals of VRML and find
out all the commands so you can modify the text). For example, to get a
blue sky and a gray land paste the following piece of text right after the last
#User:… line:
That
will produce the following effect:
To
create trees or to map images that are not rectangular use the alpha channels
as follows (the problem with trees is that they are not rectangular and so the
background appears as white. We need to
make the white pixels transparent and that is why we use alpha channels):
When
formZ creates a VRML file (that is, a .wrl -extension file) it exports its
textured images as .png. To include
transparency in those images we need to take the image into a image processor
(such as photoshop and create the alpha channels and then replace the .png file
with the .gif file (we use .gif because it supports alpha channels)
Then
we replace the text in the .wrl file as follows:
DEF mosaic ImageTexture {
url
[
"palm.png"
]
repeatS
TRUE
repeatT
TRUE
}
becomes
DEF mosaic ImageTexture {
url
[
"palm.gif"
]
repeatS
TRUE
repeatT
TRUE
}
So,
to create transparency we open the palm.png image in photoshop, we select the
background, then inverse the selection and create a mask (see previous section
for how to create trees as described in steps 1 and 2). When done, select the Indexed color Mode in the Image file menu. Then save the file as Export gif 89 and you will see the following dialog box. Select Transparency from Alpha1 and you will
see the transparent pixels as gray.
Select OK and you will have a new file called palm.gif that includes
transparency (or alpha channels). This
is the file you want to replace with in the .wrl text.
The
resulting VRML world should look like this: