Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 24: Adding Sound

../ch24/24fig07.gif
Figure 24.7

A virtual TV.

24fig07.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 [
    # Chassis
        Shape {
            appearance Appearance {
                material Material { diffuseColor 0.3 0.3 0.3 }
            }
            geometry Box { size 5.0 3.5 2.0 }
        },
    # Controls
        Shape {
            appearance Appearance {
                material Material { }
                texture ImageTexture {
                    url "tvcntrl.jpg"
                    repeatS FALSE
                    repeatT FALSE
                }
            }
            geometry IndexedFaceSet {
                coord Coordinate {
                    point [
                        1.75 -1.5 1.01,  2.40 -1.5 1.01,
                        2.40  1.5 1.01,  1.75  1.5 1.01,
                    ]
                }
                coordIndex [ 0, 1, 2, 3 ]
                texCoord TextureCoordinate {
                    point [
                        0.0 0.0,  1.0 0.0,
                        1.0 1.0,  0.0 1.0
                    ]
                }
            }
        },
    # Screen
        Shape {
            appearance Appearance {
                material Material {
                    diffuseColor 0.0 0.0 0.0
                    emissiveColor 1.0 1.0 1.0
                }
                texture DEF TV MovieTexture {
                    url "tv.mpg"
                    loop FALSE
                    repeatS FALSE
                    repeatT FALSE
                }
            }
            geometry IndexedFaceSet {
                coord Coordinate {
                    point [
                        -2.35 -1.5 1.01,
                         1.65 -1.5 1.01,
                         1.65  1.5 1.01,
                        -2.35  1.5 1.01
                    ]
                }
                coordIndex [ 0, 1, 2, 3 ]
            }
        },
    # Sound
        Sound {
            # Use MovieTexture as sound source
            source USE TV
            minFront 30.0
            minBack  30.0
            maxFront 100.0
            maxBack  100.0
        },
    # Trigger on touch
        DEF Touch TouchSensor { }
    ]
}
ROUTE Touch.touchTime TO TV.set_startTime