Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 10: Controlling Appearance with Materials

../ch10/10fig06.gif
Figure 10.6

A multicolored space station where the center sphere animates from red, to green, to blue, and back to red.

10fig06.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 [
    # Station Shapes
        Shape {
            appearance Appearance {
                material DEF BallColor Material {
                    diffuseColor 1.0 0.0 0.0
                }
            }
            geometry Sphere { }
        },
        Shape {
            appearance Appearance {
                material Material {
                    diffuseColor 0.5 0.25 1.0
                }
            }
            geometry Cylinder {
                radius 2.0
                height 0.05
            }
        },
        Shape {
            appearance Appearance {
                material Material {
                    diffuseColor 0.75 0.0 1.0
                }
            }
            geometry Cylinder {
                radius 0.15
                height 5.0
            }
        },
    # Animation clock
        DEF Clock TimeSensor {
            cycleInterval 4.0
            loop TRUE
        },
    # Animation path
        DEF ColorPath ColorInterpolator {
            key [ 0.0, 0.33, 0.67, 1.0 ]
            keyValue [
                1.0 0.0 0.0,  0.0 1.0 0.0,
                0.0 0.0 1.0,  1.0 0.0 0.0,
            ]
        }
    ]
}
ROUTE Clock.fraction_changed  TO ColorPath.set_fraction
ROUTE ColorPath.value_changed TO BallColor.set_diffuseColor