home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch11 / island / dsp.wrl < prev    next >
Text File  |  1997-03-31  |  12KB  |  446 lines

  1. #VRML V2.0 utf8
  2.  
  3. #  ================================================================
  4. #
  5. #   This prototype shows the minimum and maximum range ellipsoids
  6. #   of a Sound node.  The current version does NOT handle direction
  7. #   values, so for this to work, you must leave your sound direction
  8. #   set to 0 0 1 and use the rotation in a higher Transform node to
  9. #   aim your sound.  The prototype also does not track dynamic changes to
  10. #   the sound range values or location.  Watch http://vrml.sgi.com for
  11. #   newer versions.
  12. #
  13. #   debugSound proto by Geoff Brown
  14. #   (c) 1997 Silicon Graphics, Inc
  15. #
  16.  
  17. PROTO debugSound [
  18.         field        SFVec3f direction 0 0 1
  19.         field        SFFloat intensity 1
  20.         field        SFVec3f location 0 0 0
  21.         field        SFFloat maxBack 10
  22.         field        SFFloat maxFront 10
  23.         field        SFFloat minBack 1
  24.         field        SFFloat minFront 1
  25.         field        SFFloat priority 0
  26.         field        SFNode source NULL
  27.         field        SFBool spatialize TRUE
  28.       ]
  29. {
  30.   Group {
  31.     children    [
  32.       DEF dbgSound Sound {
  33.     source IS source
  34.     priority IS priority
  35.     location IS location
  36.     direction IS direction
  37.     minFront IS minFront
  38.     maxFront IS maxFront
  39.     minBack IS minBack
  40.     maxBack IS maxBack
  41.     spatialize IS spatialize
  42.       }
  43.       DEF rangeScript_0 Script {
  44.     eventOut    SFVec3f    maxScale
  45.     eventOut    SFVec3f    minScale
  46.     eventOut    SFVec3f    maxTrans
  47.     eventOut    SFVec3f    minTrans
  48.     eventOut    SFString    dbg1
  49.     eventOut    SFString    dbg2
  50.     eventOut    SFString    dbg3
  51.     field    SFFloat    maxFront IS maxFront
  52.     field    SFFloat    minFront IS minFront
  53.     field    SFFloat    maxBack IS maxBack
  54.     field    SFFloat    minBack IS minBack
  55.     field    SFVec3f    location IS location
  56.     field    SFFloat    maxf    10
  57.     field    SFFloat    minf    1
  58.     field    SFFloat    maxb    10
  59.     field    SFFloat    minb    1
  60.     field    SFFloat    minyx    1
  61.     field    SFFloat    maxxy    10
  62.     field    SFVec3f    loc    0 0 0
  63.     field    SFVec3f    maxs    10 10 1
  64.     field    SFVec3f    mins    1 1 1
  65.     field    SFVec3f    maxt    0 0 0
  66.     field    SFVec3f    mint    0 0 0
  67.     url    "vrmlscript:
  68.     function maxRange() {
  69.           maxxy = Math.sqrt(maxf*maxb);
  70.           maxs = new SFVec3f(maxxy, maxxy, ((maxf + maxb) * 0.5));
  71.           maxt = new SFVec3f(loc[0], loc[1], loc[2]+((maxf-maxb) * 0.5));
  72.           maxScale = maxs;
  73.           maxTrans = maxt;
  74.           dbg2 = \"maxScale = \" + maxs[0] + \" \" + maxs[1] + \" \"  + maxs[2];
  75.           dbg3 = \"maxTrans = \" + maxt[0] + \" \" + maxt[1] + \" \"  + maxt[2];
  76.     }
  77.     function minRange() {
  78.           minxy = Math.sqrt(minf*minb);
  79.           mins = new SFVec3f(minxy, minxy, ((minf + minb) * 0.5));
  80.           mint = new SFVec3f(loc[0], loc[1], loc[2]+((minf-minb) * 0.5));
  81.           minScale = mins;
  82.           minTrans = mint;
  83.           dbg2 = \"minScale = \" + mins[0] + \" \" + mins[1] + \" \"  + mins[2];
  84.           dbg3 = \"minTrans = \" + mint[0] + \" \" + mint[1] + \" \"  + mint[2];
  85.     }
  86.     function initialize() {
  87.           loc = location;
  88.           maxf = maxFront;
  89.           maxb = maxBack;
  90.           minf = minFront;
  91.           minb = minBack;
  92.           minRange();
  93.           maxRange();
  94.     }
  95.       "
  96.       }
  97.       DEF minRange Transform {
  98.     children    Transform {
  99.       children    Shape {
  100.         appearance    Appearance {
  101.           material    Material {
  102.         ambientIntensity    1.4
  103.         diffuseColor    0.3 0.3 0
  104.         specularColor    0 0 0
  105.         emissiveColor    0.3 0.3 0
  106.         shininess    0.2
  107.         transparency    0
  108.           }
  109.  
  110.           texture    NULL
  111.  
  112.           textureTransform    NULL
  113.  
  114.         }
  115.  
  116.         geometry    DEF wireframe IndexedLineSet {
  117.           coord    Coordinate {
  118.         point    [ 1 0 0,
  119.               0.9701 0.2425 0,
  120.               0.9701 0 0.2425,
  121.               0.9045 0.3015 0.3015,
  122.               0.8321 0 0.5547,
  123.               0.6667 0.3333 0.6667,
  124.               0.5547 0 0.8321,
  125.               0.3015 0.3015 0.9045,
  126.               0.2425 0 0.9701,
  127.               0 0.2425 0.9701,
  128.               0 0 1,
  129.               0.8321 0.5547 0,
  130.               0.6667 0.6667 0.3333,
  131.               0.3333 0.6667 0.6667,
  132.               0 0.5547 0.8321,
  133.               0.5547 0.8321 0,
  134.               0.3015 0.9045 0.3015,
  135.               0 0.8321 0.5547,
  136.               0.2425 0.9701 0,
  137.               0 0.9701 0.2425,
  138.               0 1 0,
  139.               -0.2425 0 0.9701,
  140.               -0.3015 0.3015 0.9045,
  141.               -0.5547 0 0.8321,
  142.               -0.6667 0.3333 0.6667,
  143.               -0.8321 0 0.5547,
  144.               -0.9045 0.3015 0.3015,
  145.               -0.9701 0 0.2425,
  146.               -0.9701 0.2425 0,
  147.               -1 0 0,
  148.               -0.3333 0.6667 0.6667,
  149.               -0.6667 0.6667 0.3333,
  150.               -0.8321 0.5547 0,
  151.               -0.3015 0.9045 0.3015,
  152.               -0.5547 0.8321 0,
  153.               -0.2425 0.9701 0,
  154.               0 -0.2425 0.9701,
  155.               0.3015 -0.3015 0.9045,
  156.               0.6667 -0.3333 0.6667,
  157.               0.9045 -0.3015 0.3015,
  158.               0.9701 -0.2425 0,
  159.               0 -0.5547 0.8321,
  160.               0.3333 -0.6667 0.6667,
  161.               0.6667 -0.6667 0.3333,
  162.               0.8321 -0.5547 0,
  163.               0 -0.8321 0.5547,
  164.               0.3015 -0.9045 0.3015,
  165.               0.5547 -0.8321 0,
  166.               0 -0.9701 0.2425,
  167.               0.2425 -0.9701 0,
  168.               0 -1 0,
  169.               -0.9701 -0.2425 0,
  170.               -0.9045 -0.3015 0.3015,
  171.               -0.6667 -0.3333 0.6667,
  172.               -0.3015 -0.3015 0.9045,
  173.               -0.8321 -0.5547 0,
  174.               -0.6667 -0.6667 0.3333,
  175.               -0.3333 -0.6667 0.6667,
  176.               -0.5547 -0.8321 0,
  177.               -0.3015 -0.9045 0.3015,
  178.               -0.2425 -0.9701 0,
  179.               0 0 -1,
  180.               0 0.2425 -0.9701,
  181.               0.2425 0 -0.9701,
  182.               0.3015 0.3015 -0.9045,
  183.               0.5547 0 -0.8321,
  184.               0.6667 0.3333 -0.6667,
  185.               0.8321 0 -0.5547,
  186.               0.9045 0.3015 -0.3015,
  187.               0.9701 0 -0.2425,
  188.               0 0.5547 -0.8321,
  189.               0.3333 0.6667 -0.6667,
  190.               0.6667 0.6667 -0.3333,
  191.               0 0.8321 -0.5547,
  192.               0.3015 0.9045 -0.3015,
  193.               0 0.9701 -0.2425,
  194.               -0.9701 0 -0.2425,
  195.               -0.9045 0.3015 -0.3015,
  196.               -0.8321 0 -0.5547,
  197.               -0.6667 0.3333 -0.6667,
  198.               -0.5547 0 -0.8321,
  199.               -0.3015 0.3015 -0.9045,
  200.               -0.2425 0 -0.9701,
  201.               -0.6667 0.6667 -0.3333,
  202.               -0.3333 0.6667 -0.6667,
  203.               -0.3015 0.9045 -0.3015,
  204.               0.9045 -0.3015 -0.3015,
  205.               0.6667 -0.3333 -0.6667,
  206.               0.3015 -0.3015 -0.9045,
  207.               0 -0.2425 -0.9701,
  208.               0.6667 -0.6667 -0.3333,
  209.               0.3333 -0.6667 -0.6667,
  210.               0 -0.5547 -0.8321,
  211.               0.3015 -0.9045 -0.3015,
  212.               0 -0.8321 -0.5547,
  213.               0 -0.9701 -0.2425,
  214.               -0.3015 -0.3015 -0.9045,
  215.               -0.6667 -0.3333 -0.6667,
  216.               -0.9045 -0.3015 -0.3015,
  217.               -0.3333 -0.6667 -0.6667,
  218.               -0.6667 -0.6667 -0.3333,
  219.               -0.3015 -0.9045 -0.3015 ]
  220.           }
  221.  
  222.           color    NULL
  223.  
  224.           coordIndex    [ 0, 1, 2, -1, 2, 1, 3, -1,
  225.                 2, 3, 4, -1, 4, 3, 5, -1,
  226.                 4, 5, 6, -1, 6, 5, 7, -1,
  227.                 6, 7, 8, -1, 8, 7, 9, -1,
  228.                 8, 9, 10, -1, 1, 11, 3, -1,
  229.                 3, 11, 12, -1, 3, 12, 5, -1,
  230.                 5, 12, 13, -1, 5, 13, 7, -1,
  231.                 7, 13, 14, -1, 7, 14, 9, -1,
  232.                 11, 15, 12, -1, 12, 15, 16, -1,
  233.                 12, 16, 13, -1, 13, 16, 17, -1,
  234.                 13, 17, 14, -1, 15, 18, 16, -1,
  235.                 16, 18, 19, -1, 16, 19, 17, -1,
  236.                 19, 18, 20, -1, 10, 9, 21, -1,
  237.                 21, 9, 22, -1, 21, 22, 23, -1,
  238.                 23, 22, 24, -1, 23, 24, 25, -1,
  239.                 25, 24, 26, -1, 25, 26, 27, -1,
  240.                 27, 26, 28, -1, 27, 28, 29, -1,
  241.                 9, 14, 22, -1, 22, 14, 30, -1,
  242.                 22, 30, 24, -1, 24, 30, 31, -1,
  243.                 24, 31, 26, -1, 26, 31, 32, -1,
  244.                 26, 32, 28, -1, 14, 17, 30, -1,
  245.                 30, 17, 33, -1, 30, 33, 31, -1,
  246.                 31, 33, 34, -1, 31, 34, 32, -1,
  247.                 17, 19, 33, -1, 33, 19, 35, -1,
  248.                 33, 35, 34, -1, 35, 19, 20, -1,
  249.                 10, 36, 8, -1, 8, 36, 37, -1,
  250.                 8, 37, 6, -1, 6, 37, 38, -1,
  251.                 6, 38, 4, -1, 4, 38, 39, -1,
  252.                 4, 39, 2, -1, 2, 39, 40, -1,
  253.                 2, 40, 0, -1, 36, 41, 37, -1,
  254.                 37, 41, 42, -1, 37, 42, 38, -1,
  255.                 38, 42, 43, -1, 38, 43, 39, -1,
  256.                 39, 43, 44, -1, 39, 44, 40, -1,
  257.                 41, 45, 42, -1, 42, 45, 46, -1,
  258.                 42, 46, 43, -1, 43, 46, 47, -1,
  259.                 43, 47, 44, -1, 45, 48, 46, -1,
  260.                 46, 48, 49, -1, 46, 49, 47, -1,
  261.                 49, 48, 50, -1, 29, 51, 27, -1,
  262.                 27, 51, 52, -1, 27, 52, 25, -1,
  263.                 25, 52, 53, -1, 25, 53, 23, -1,
  264.                 23, 53, 54, -1, 23, 54, 21, -1,
  265.                 21, 54, 36, -1, 21, 36, 10, -1,
  266.                 51, 55, 52, -1, 52, 55, 56, -1,
  267.                 52, 56, 53, -1, 53, 56, 57, -1,
  268.                 53, 57, 54, -1, 54, 57, 41, -1,
  269.                 54, 41, 36, -1, 55, 58, 56, -1,
  270.                 56, 58, 59, -1, 56, 59, 57, -1,
  271.                 57, 59, 45, -1, 57, 45, 41, -1,
  272.                 58, 60, 59, -1, 59, 60, 48, -1,
  273.                 59, 48, 45, -1, 48, 60, 50, -1,
  274.                 61, 62, 63, -1, 63, 62, 64, -1,
  275.                 63, 64, 65, -1, 65, 64, 66, -1,
  276.                 65, 66, 67, -1, 67, 66, 68, -1,
  277.                 67, 68, 69, -1, 69, 68, 1, -1,
  278.                 69, 1, 0, -1, 62, 70, 64, -1,
  279.                 64, 70, 71, -1, 64, 71, 66, -1,
  280.                 66, 71, 72, -1, 66, 72, 68, -1,
  281.                 68, 72, 11, -1, 68, 11, 1, -1,
  282.                 70, 73, 71, -1, 71, 73, 74, -1,
  283.                 71, 74, 72, -1, 72, 74, 15, -1,
  284.                 72, 15, 11, -1, 73, 75, 74, -1,
  285.                 74, 75, 18, -1, 74, 18, 15, -1,
  286.                 18, 75, 20, -1, 29, 28, 76, -1,
  287.                 76, 28, 77, -1, 76, 77, 78, -1,
  288.                 78, 77, 79, -1, 78, 79, 80, -1,
  289.                 80, 79, 81, -1, 80, 81, 82, -1,
  290.                 82, 81, 62, -1, 82, 62, 61, -1,
  291.                 28, 32, 77, -1, 77, 32, 83, -1,
  292.                 77, 83, 79, -1, 79, 83, 84, -1,
  293.                 79, 84, 81, -1, 81, 84, 70, -1,
  294.                 81, 70, 62, -1, 32, 34, 83, -1,
  295.                 83, 34, 85, -1, 83, 85, 84, -1,
  296.                 84, 85, 73, -1, 84, 73, 70, -1,
  297.                 34, 35, 85, -1, 85, 35, 75, -1,
  298.                 85, 75, 73, -1, 75, 35, 20, -1,
  299.                 0, 40, 69, -1, 69, 40, 86, -1,
  300.                 69, 86, 67, -1, 67, 86, 87, -1,
  301.                 67, 87, 65, -1, 65, 87, 88, -1,
  302.                 65, 88, 63, -1, 63, 88, 89, -1,
  303.                 63, 89, 61, -1, 40, 44, 86, -1,
  304.                 86, 44, 90, -1, 86, 90, 87, -1,
  305.                 87, 90, 91, -1, 87, 91, 88, -1,
  306.                 88, 91, 92, -1, 88, 92, 89, -1,
  307.                 44, 47, 90, -1, 90, 47, 93, -1,
  308.                 90, 93, 91, -1, 91, 93, 94, -1,
  309.                 91, 94, 92, -1, 47, 49, 93, -1,
  310.                 93, 49, 95, -1, 93, 95, 94, -1,
  311.                 95, 49, 50, -1, 61, 89, 82, -1,
  312.                 82, 89, 96, -1, 82, 96, 80, -1,
  313.                 80, 96, 97, -1, 80, 97, 78, -1,
  314.                 78, 97, 98, -1, 78, 98, 76, -1,
  315.                 76, 98, 51, -1, 76, 51, 29, -1,
  316.                 89, 92, 96, -1, 96, 92, 99, -1,
  317.                 96, 99, 97, -1, 97, 99, 100, -1,
  318.                 97, 100, 98, -1, 98, 100, 55, -1,
  319.                 98, 55, 51, -1, 92, 94, 99, -1,
  320.                 99, 94, 101, -1, 99, 101, 100, -1,
  321.                 100, 101, 58, -1, 100, 58, 55, -1,
  322.                 94, 95, 101, -1, 101, 95, 60, -1,
  323.                 101, 60, 58, -1, 60, 95, 50, -1 ]
  324.         }
  325.  
  326.       }
  327.  
  328.       translation    0 0 0
  329.       rotation    1 0 0  1.571
  330.       scale    1 1 1
  331.       scaleOrientation    0 0 1  0
  332.     }
  333.  
  334.     translation    0 0 0
  335.     scale    1 1 1
  336.       }
  337.       DEF maxRange Transform {
  338.     children    Transform {
  339.       children    Shape {
  340.         appearance    Appearance {
  341.           material    Material {
  342.         ambientIntensity    1.4
  343.         diffuseColor    0.41 0.11 0.11
  344.         specularColor    0 0 0
  345.         emissiveColor    0.41 0.11 0.11
  346.         shininess    0.2
  347.         transparency    0
  348.           }
  349.  
  350.           texture    NULL
  351.  
  352.           textureTransform    NULL
  353.  
  354.         }
  355.  
  356.         geometry    USE wireframe
  357.  
  358.       }
  359.  
  360.       translation    0 0 0
  361.       rotation    0 0 1  0
  362.       scale    1 1 1
  363.       scaleOrientation    0 0 1  0
  364.     }
  365.  
  366.     translation    0 0 0
  367.     scale    1 1 1
  368.       }
  369.     ]
  370.   }
  371.   ROUTE rangeScript_0.minTrans TO minRange.set_translation
  372.   ROUTE rangeScript_0.minScale TO minRange.set_scale
  373.   ROUTE rangeScript_0.maxTrans TO maxRange.set_translation
  374.   ROUTE rangeScript_0.maxScale TO maxRange.set_scale
  375. }
  376. NavigationInfo {
  377.   speed    3
  378.   type    "EXAMINE"
  379. }
  380. DEF background Transform {
  381.   children    Background {
  382.     groundAngle    1.01
  383.     groundColor    [ 0.1 0.1 0.09,
  384.           0.48 0.48 0.45 ]
  385.     skyAngle    [ 0.05, 0.1, 1, 1.57 ]
  386.     skyColor    [ 1 1 0,
  387.           1 1 0.5,
  388.           0.125 0.125 0.5,
  389.           0.3 0.3 0.55,
  390.           0.64 0.73 0.84 ]
  391.   }
  392.  
  393.   translation    139.5 161.9 -16.62
  394.   rotation    0 0 1  0
  395. }
  396. DEF xform Transform {
  397.   children    [
  398.     DEF click TouchSensor {
  399.     }
  400.     DEF clickScript Script {
  401.       eventOut      SFTime      start
  402.       eventOut      SFTime      stop
  403.       eventIn      SFTime      touch
  404.       field      SFBool      playing    FALSE
  405.       url    "vrmlscript:
  406.             function touch (value, time) {
  407.               if (playing) {
  408.             stop = value;
  409.             playing = FALSE;
  410.               }
  411.               else {
  412.             start = value;
  413.             playing = TRUE;
  414.               }
  415.             }
  416.           "
  417.     }
  418.     debugSound {
  419.       maxBack    5
  420.       maxFront    150
  421.       minBack    1
  422.       minFront    25
  423.       source    DEF aclip AudioClip {
  424. #    url    "forest.wav"
  425.     loop    TRUE
  426.     startTime    0
  427.     stopTime    1
  428.     description    "debug"
  429. #      }
  430.  
  431.     }
  432.     DEF mybox Shape {
  433.       appearance    NULL
  434.  
  435.       geometry    Box {
  436.     size    0.5 0.5 0.5
  437.       }
  438.  
  439.     }
  440.   ]
  441.   translation    -1 0 0
  442. }
  443. ROUTE click.touchTime TO clickScript.touch
  444. ROUTE clickScript.start TO aclip.set_startTime
  445. ROUTE clickScript.stop TO aclip.set_stopTime
  446.