Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 16: Binding Colors to Points, Lines, Faces, and Coordinates

../ch16/16fig01.gif
Figure 16.1

A scatter plot with the points colored using colors from a Color node.

16fig01.wrl
Click on the image to view the VRML scene.

#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
    children [
    # Axes
        Shape {
            appearance Appearance {
                material Material {
                    emissiveColor 1.0 1.0 1.0
                    diffuseColor  1.0 1.0 1.0
                }
            }
            geometry IndexedLineSet {
                coord Coordinate {
                    point [
                        0.0 0.0 0.0, 10.0 0.0 0.0, 0.0 8.0 0.0
                    ]
                }
                coordIndex [ 0, 1, -1,  0, 2, -1 ]
            }
        },
    # Scatter plot with different color points
        Shape {
            # no appearance, use emissive coloring
            geometry PointSet {
                coord Coordinate {
                    point [
                    # Green points
                        1.0 1.0 0.0,   2.0 4.0 0.0,
                        3.0 5.0 0.0,   4.0 4.0 0.0,
                        5.0 6.0 0.0,   6.0 7.0 0.0,
                        7.0 5.0 0.0,   8.0 6.0 0.0,
                        9.0 4.0 0.0,  10.0 3.0 0.0,
                    # Yellow points
                        1.0 3.0 0.0,   2.0 2.0 0.0,
                        3.0 2.0 0.0,   4.0 1.0 0.0,
                        5.0 2.0 0.0,   6.0 4.0 0.0,
                        7.0 3.0 0.0,   8.0 5.0 0.0,
                        9.0 5.0 0.0,  10.0 6.0 0.0,
                    ]
                }
                color Color {
                    color [
                    # Green points
                        0.0 1.0 0.0,   0.0 1.0 0.0,
                        0.0 1.0 0.0,   0.0 1.0 0.0,
                        0.0 1.0 0.0,   0.0 1.0 0.0,
                        0.0 1.0 0.0,   0.0 1.0 0.0,
                        0.0 1.0 0.0,   0.0 1.0 0.0,
                    # Yellow points
                        1.0 1.0 0.0,   1.0 1.0 0.0,
                        1.0 1.0 0.0,   1.0 1.0 0.0,
                        1.0 1.0 0.0,   1.0 1.0 0.0,
                        1.0 1.0 0.0,   1.0 1.0 0.0,
                        1.0 1.0 0.0,   1.0 1.0 0.0,
                    ]
                }
            }
        }
    ]
}