|
|
VRML Script Tutorial
Full list
VRML Interactive Tutorial
Introduction
VRML File Structure
Drawing: Shape node
Geometry Nodes:
Appearance
Let there be Light
Materials with Colored Lights
Hierarchical Node Structures
Inlining Files
Defining and Instancing Nodes
Defining Levels of Detail
Events in VRML
Interpolators
Let the Music Play
Bindable Nodes
Adding Realism to the world
Information about your world
Definition for Auxiliary Nodes
|
|
|
|
Elevation Grid Example: Chessboard
A chess board is made of 64 tiles, in a 8x8 grid. The tiles are colored
black and white, so that two tiles sharing a side have different colors.
As far as defining the tiles, The ElevationGrid
for this purpose is as follows:
Example:
-
geometry ElevationGrid {
- xDimension 9
- zDimension 9
- xSpacing 1
- zSpacing 1
- height [
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- ]
}
Note that the dimensions specified are the number of tiles plus one.
The same goes for the list of heights, there are xDimension x zDimension
height values specified.
Now we need to define the colors. First set the field colorPerVertex
to FALSE. This implies that the colors defined are applied to each square
of the chessboard, and not to the vertices.
Next set the color field to a Color
node with 64 values, alternating between black and white. The complete
code is as follows:
Example:
-
geometry ElevationGrid {
- xDimension 9
- zDimension 9
- xSpacing 1
- zSpacing 1
- height [
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- ]
- colorPerVertex FALSE
- color Color {
- color [
- 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0,
1 1 1,
- 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1,
0 0 0,
- 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0,
1 1 1,
- 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1,
0 0 0,
- 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0,
1 1 1,
- 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1,
0 0 0,
- 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0,
1 1 1,
- 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1, 0 0 0, 1 1 1,
0 0 0,
- ]
- }
}
|