home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch11 / ambient / Ambient.wrl next >
Text File  |  1997-03-30  |  3KB  |  194 lines

  1. #VRML V2.0 utf8 CosmoWorlds V1.0
  2. # $Id: Ambient.wrl /main/1 1997/02/20 19:38:44 sandvik Exp $
  3.  
  4.  
  5.  
  6. # Our background node.
  7.  
  8. Background {
  9.    skyColor [
  10.          0.0 0.2 0.75,
  11.          0.0 0.56 1.0,
  12.          1.0 1.0 1.0
  13.          ]
  14.    skyAngle [ 1.309, 1.571]
  15.    groundColor [
  16.         0.1 0.50 0.0,
  17.         0.4 0.55, 0.2,
  18.         0.6, 0.70, 0.6
  19.         ]
  20.    groundAngle [ 1.309, 1.571]
  21. }
  22.  
  23.  
  24.  
  25. # This is our control proto, has geometry as well as default
  26. # behavior concerning selection and dragging.
  27.  
  28. PROTO MusicElement [
  29.             exposedField MFNode children []
  30.             exposedField SFVec3f position 0. 0. 0.
  31.             exposedField MFString audioSource []
  32.             exposedField SFFloat max 40
  33. ]
  34.  
  35. {
  36.    DEF TOP_LEVEL Group {
  37.       children [
  38.  
  39.      # TouchSensor
  40.      DEF TOUCH TouchSensor {}
  41.  
  42.      # The Object itself
  43.      DEF MAIN_NODE Transform {
  44.         translation IS position
  45.         children [
  46.            DEF OBJECT Transform {
  47.           children IS children
  48.            }
  49.            # Sound Source
  50.            Sound {
  51.           source AudioClip {
  52.              url IS audioSource
  53.              loop TRUE
  54.              startTime 1
  55.              #description "debug"
  56.           }
  57.           minFront 5.0
  58.           minBack 5.0
  59.           maxFront IS max
  60.           maxBack IS max
  61.            }
  62.           ]
  63.      }
  64.     
  65.      # Light -- only turn on when the mouse is over the object
  66.      DEF HILIGHT PointLight {
  67.         location 0.0 0.0 0.0
  68.         radius 10.0
  69.         on FALSE
  70.         color 1.0 0.5 0.67
  71.      }
  72.      
  73.      # Planesensor that moves the object
  74.      DEF SENSOR PlaneSensor {}
  75.  
  76.      # Script that tweaks the plane sensor info
  77.      DEF TWEAK Script {
  78.         eventIn SFVec3f set_translation
  79.         eventOut SFVec3f position_changed
  80.         eventOut SFString stdout
  81.         url "vrmlscript:
  82. function set_translation(translation, eventTime){
  83.    position_changed[0] = translation[0] * 2.0;
  84.    position_changed[1] = 0;
  85.    position_changed[2] = -translation[1] * 2.0;
  86. }"
  87.      }
  88.  
  89.      # Debugger
  90.     # DEF DEBUG CoRouteDebugger{}
  91.     ]
  92.    }
  93.  
  94.  
  95. # ROUTES
  96. ROUTE TOUCH.isOver TO HILIGHT.on 
  97. ROUTE SENSOR.translation_changed TO TWEAK.set_translation
  98. ROUTE TWEAK.position_changed TO MAIN_NODE.set_translation
  99. #ROUTE TWEAK.stdout TO DEBUG.SFString
  100. }
  101.  
  102.  
  103.  
  104.  
  105.  
  106. # Here are the actual instances of the music elements.
  107.  
  108. DEF A MusicElement {
  109.    position -4. 0. -30.0
  110.    audioSource "jungle.wav"
  111.    max 60.0
  112.    children [
  113.       Shape {
  114.      appearance Appearance {
  115.         material Material {
  116.            diffuseColor 0.88 0.8 0.28
  117.         }
  118.      }
  119.      geometry Sphere{}
  120.       }
  121.      ]
  122. }
  123.  
  124. DEF B MusicElement {
  125.    position -8. 0. -30.0
  126.    audioSource "sweep.wav"
  127.    children [
  128.       Shape {
  129.      appearance Appearance {
  130.         material Material {
  131.            diffuseColor 0.12 0.99 0.12
  132.         }
  133.      }
  134.      geometry Sphere{}
  135.       }
  136.      ]
  137. }
  138.  
  139. DEF C MusicElement {
  140.    position 0. 0. -30.0
  141.    audioSource "thema.wav"
  142.    children [
  143.       Shape {
  144.      appearance Appearance {
  145.         material Material {
  146.            diffuseColor 0.44 0.3 0.98
  147.         }
  148.      }
  149.      geometry Sphere{}
  150.       }
  151.      ]
  152. }
  153.  
  154.  
  155. DEF D MusicElement {
  156.    position 4. 0. -30.0
  157.    audioSource "beatbw.wav"
  158.    max 30
  159.    children [
  160.       Shape {
  161.      appearance Appearance {
  162.         material Material {
  163.            diffuseColor 0.99 0.1 0.98
  164.         }
  165.      }
  166.      geometry Sphere{}
  167.       }
  168.      ]
  169. }
  170.  
  171.  
  172. DEF E MusicElement {
  173.    position 8. 0. -30.0
  174.    audioSource "didjOver13.wav"
  175.    max 20
  176.    children [
  177.       Shape {
  178.      appearance Appearance {
  179.         material Material {
  180.            diffuseColor 0.11 0.4 0.98
  181.         }
  182.      }
  183.      geometry Sphere{}
  184.       }
  185.      ]
  186. }
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.