<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN"   "http://www.web3d.org/specifications/x3d-3.1.dtd">
<X3D profile='Immersiveversion='3.1xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>
<head>
<meta name='titlecontent='ScriptEvents.x3d'/>
<meta name='descriptioncontent='A Script node drives the position and orientation of orbiting cones near the pump house.'/>
<meta name='authorscontent='Todd Gagnon and Mark A. Boyd'/>
<meta name='translatorcontent='Xeena VRML importer'/>
<meta name='createdcontent='8 June 1998'/>
<meta name='importedcontent='20 December 2002'/>
<meta name='modifiedcontent='8 October 2007'/>
<meta name='referencecontent='KelpTank.x3d'/>
<meta name='referencecontent=' http://X3dGraphics.com/examples/X3dForWebAuthors/KelpForestExhibit/PumpHouse.x3d '/>
<meta name='identifiercontent=' http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter09-EventUtilitiesScripting/ScriptEvents.x3d '/>
<meta name='generatorcontent='X3D-Edit, https://savage.nps.edu/X3D-Edit'/>
<meta name='generatorcontent='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/>
<meta name='licensecontent='../license.html'/>
</head>
<!--

Index for ExternProtoDeclare definition: WhereAmI
Index for DEF nodes: Angle, b1, CandyGreen, CandyRed, CandyTurquoise, Control, CylinderRod, EyeCandy, Filter, PISTON, PISTONClock, PISTONPath, pumpHouse, ROCKER1Path, ROCKER1Rotation, ROCKER2Path, ROCKER2Rotation, ROCKERARM1, ROCKERARM2, RunPump, Timer
Index for Viewpoint image: Viewpoint_1
-->
<Scene>
<WorldInfo info='DTG of last update: 081200Jun98 Added: Updated: cycleInterval to 5.5 Modeled by: Todd Gagnon and Mark A. Boydtitle='pumpHouse1.4.wrl'/>
<ExternProtoDeclare name='WhereAmI'
  url=' "../Chapter14-Prototypes/WhereAmI.x3d#WhereAmI" "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14-Prototypes/WhereAmI.x3d#WhereAmI" "../Chapter14-Prototypes/WhereAmI.wrl#WhereAmI" "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14-Prototypes/WhereAmI.wrl#WhereAmI" '/>
<ProtoInstance name='WhereAmIcontainerField='children'/>
<Background skyColor='1 1 1'/>
<Viewpoint description='Book Vieworientation='-0.969 0.239 0.056 0.13position='1.66 1.34 5.95'/>
<Group>
<Transform scale='0.91 0.6 0.3translation='0.8 -0.65 0.5'>
<Shape>
<Appearance>
<Material diffuseColor='0.749 0.694 0.651'/>
</Appearance>
<Cylinder bottom='falsetop='false'/>
</Shape>
</Transform>
<Group>
<Shape>
<Appearance DEF='pumpHouse'>
<Material diffuseColor='0.82 0.78 0.74'/>
</Appearance>
<IndexedFaceSet coordIndex='0 1 5 4 -1 5 1 2 6 -1 6 2 3 7 -1 3 0 4 7 -1 1 12 13 2 -1 2 13 14 -1 12 15 16 13 -1 15 0 3 16 -1 16 3 17 -1 9 5 6 10 -1 8 9 10 11 -1 4 8 11 7 -1 4 5 9 8 -1 11 10 6 7 -1 3 2 14 17 -1 13 16 17 14 -1'>
<Coordinate point='0.0 0.0 0.0 2.0 0.0 0.0 2.0 1.75 0.0 0.0 1.75 0.0 0.625 0.75 0.0 1.0 0.75 0.0 1.0 1.6 0.0 0.625 1.6 0.0 0.625 0.75 -0.65 1.0 0.75 -0.65 1.0 1.6 -0.65 0.625 1.6 -0.65 2.0 0.0 -2.7 2.0 1.75 -2.7 2.0 2.5 -1.0 0.0 0.0 -2.7 0.0 1.75 -2.7 0.0 2.5 -1.0'/>
</IndexedFaceSet>
</Shape>
<!-- RunPump ROUTE:  [from isActive to Filter.set_boolean ] -->
<TouchSensor DEF='RunPumpdescription='touch to activate'/>
</Group>
</Group>
<Group>
<Transform scale='0.5 0.5 0.5translation='1.0 1.1 -1.5'>
<!-- PISTON ROUTE:  [from PISTONPath.value_changed to set_translation ] -->
<Transform DEF='PISTON'>
<Transform scale='1.8 1.2 0.6translation='0.0 -0.2 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.427 0.427 0.42'/>
</Appearance>
<Cylinder height='1.0radius='0.98'/>
</Shape>
</Transform>
<Transform DEF='CylinderRodrotation='0.0 0.0 -1.0 0.523599translation='-0.25 0.75 0.0'>
<Shape>
<Appearance USE='pumpHouse'/>
<Cylinder height='1.0radius='0.1'/>
</Shape>
</Transform>
<Transform rotation='0.0 0.0 1.0 1.047198translation='1.0 0.6 0.0'>
<Transform USE='CylinderRod'/>
</Transform>
<Transform translation='0.0 1.2 0.0'>
<Shape>
<Appearance USE='pumpHouse'/>
<Sphere radius='0.15'/>
</Shape>
</Transform>
<!-- ROCKERARM1 ROUTEs:  [from ROCKER1Path.value_changed to set_translation ] [from ROCKER1Rotation.value_changed to set_rotation ] -->
<Transform DEF='ROCKERARM1center='0.0 -0.4 0.0'>
<Shape>
<Appearance USE='pumpHouse'/>
<Cylinder height='1.8radius='0.1'/>
</Shape>
<Transform translation='0.0 0.95 0.0'>
<Shape>
<Appearance USE='pumpHouse'/>
<Sphere radius='0.15'/>
</Shape>
</Transform>
<!-- ROCKER1Path ROUTEs:  [from PISTONClock.fraction_changed to set_fraction ] [from value_changed to ROCKERARM1.set_translation ] -->
<PositionInterpolator DEF='ROCKER1Pathkey='0.0 0.3 0.32 0.5 0.75 1.0keyValue='0.0 2.0 -0.25 0.0 1.8 -0.35 0.0 1.8 -0.35 0.0 2.0 -0.25 0.0 2.0 -0.12 0.0 2.0 -0.25'/>
<!-- ROCKER1Rotation ROUTEs:  [from PISTONClock.fraction_changed to set_fraction ] [from value_changed to ROCKERARM1.set_rotation ] -->
<OrientationInterpolator DEF='ROCKER1Rotationkey='0.0 0.3 0.32 0.5 0.75 1.0keyValue='-1.0 0.0 0.0 0.523599 -1.0 0.0 0.0 1.0471976 -1.0 0.0 0.0 1.0471976 -1.0 0.0 0.0 0.523599 -1.0 0.0 0.0 0.2617994 -1.0 0.0 0.0 0.523599'/>
</Transform>
<!-- ROCKERARM2 ROUTEs:  [from ROCKER2Path.value_changed to set_translation ] [from ROCKER2Rotation.value_changed to set_rotation ] -->
<Transform DEF='ROCKERARM2center='0.0 0.7 0.0'>
<Shape>
<Appearance USE='pumpHouse'/>
<Cylinder height='1.8radius='0.1'/>
</Shape>
<Transform translation='0.0 -0.95 0.0'>
<Shape>
<Appearance USE='pumpHouse'/>
<Sphere radius='0.15'/>
</Shape>
</Transform>
<!-- ROCKER2Path ROUTEs:  [from PISTONClock.fraction_changed to set_fraction ] [from value_changed to ROCKERARM2.set_translation ] -->
<PositionInterpolator DEF='ROCKER2Pathkey='0.0 0.3 0.32 0.5 0.75 1.0keyValue='0.0 1.95 -1.0 0.0 1.2 -1.6 0.0 1.2 -1.6 0.0 1.95 -1.0 0.0 2.2 -0.65 0.0 1.95 -1.0'/>
<!-- ROCKER2Rotation ROUTEs:  [from PISTONClock.fraction_changed to set_fraction ] [from value_changed to ROCKERARM2.set_rotation ] -->
<OrientationInterpolator DEF='ROCKER2Rotationkey='0.0 0.3 0.32 0.5 0.75 1.0keyValue='1.0 0.0 0.0 0.523599 1.0 0.0 0.0 0.4 1.0 0.0 0.0 0.4 1.0 0.0 0.0 0.523599 1.0 0.0 0.0 1.570796 1.0 0.0 0.0 0.523599'/>
</Transform>
</Transform>
<!-- PISTONClock ROUTEs:  [from Filter.inputFalse to enabled ] [from fraction_changed to PISTONPath.set_fraction ] [from fraction_changed to ROCKER1Path.set_fraction ] [from fraction_changed to ROCKER1Rotation.set_fraction ] [from fraction_changed to ROCKER2Path.set_fraction ] [from fraction_changed to ROCKER2Rotation.set_fraction ] -->
<TimeSensor DEF='PISTONClockcycleInterval='5.5loop='true'/>
<!-- PISTONPath ROUTEs:  [from PISTONClock.fraction_changed to set_fraction ] [from value_changed to PISTON.set_translation ] -->
<PositionInterpolator DEF='PISTONPathkey='0.0 0.3 0.32 0.5 0.75 1.0keyValue='-0.4 -2.3 4.0 -0.4 -1.5 4.0 -0.4 -1.5 4.0 -0.4 -2.3 4.0 -0.4 -3.3 4.0 -0.4 -2.3 4.0'/>
<!-- Timer ROUTEs:  [from Filter.inputTrue to enabled ] [from fraction_changed to Angle.set_fraction ] -->
<TimeSensor DEF='TimercycleInterval='2enabled='falseloop='truestartTime='1'/>
<!-- Angle ROUTEs:  [from Timer.fraction_changed to set_fraction ] [from value_changed to Control.angle ] -->
<ScalarInterpolator DEF='Anglekey='0 1keyValue='0 6.28319'/>
<!-- Filter ROUTEs:  [from RunPump.isActive to set_boolean ] [from inputTrue to Timer.enabled ] [from inputFalse to PISTONClock.enabled ] -->
<BooleanFilter DEF='FiltercontainerField='children'/>
<Transform translation='3 2 4'>
<Transform DEF='EyeCandy'>
<!-- CandyRed ROUTEs:  [from Control.posRed to translation ] [from Control.orRed to rotation ] -->
<Transform DEF='CandyRedrotation='0 0 1 3.14translation='0 -1.5 .5'>
<Shape>
<Appearance>
<Material diffuseColor='1 0 0'/>
</Appearance>
<Cone DEF='b1bottomRadius='.5height='1'/>
</Shape>
</Transform>
<!-- CandyGreen ROUTEs:  [from Control.posGrn to translation ] [from Control.orGrn to rotation ] -->
<Transform DEF='CandyGreenrotation='0 0 1 -1.05translation='1.3 .75 0'>
<Shape>
<Appearance>
<Material diffuseColor='0 1 1'/>
</Appearance>
<Cone USE='b1'/>
</Shape>
</Transform>
<!-- CandyTurquoise ROUTEs:  [from Control.posTuq to translation ] [from Control.orTuq to rotation ] -->
<Transform DEF='CandyTurquoiserotation='0 0 1 1.05translation='-1.3 .75 -.5'>
<Shape>
<Appearance>
<Material diffuseColor='1 1 0'/>
</Appearance>
<Cone USE='b1'/>
</Shape>
</Transform>
</Transform>
</Transform>
<!-- Control ROUTEs:  [from Angle.value_changed to angle ] [from posRed to CandyRed.translation ] [from posGrn to CandyGreen.translation ] [from posTuq to CandyTurquoise.translation ] [from orRed to CandyRed.rotation ] [from orGrn to CandyGreen.rotation ] [from orTuq to CandyTurquoise.rotation ] -->
<Script DEF='Control'>
<field name='angletype='SFFloataccessType='inputOnly'/>
<field name='posRedtype='SFVec3faccessType='outputOnly'/>
<field name='posGrntype='SFVec3faccessType='outputOnly'/>
<field name='posTuqtype='SFVec3faccessType='outputOnly'/>
<field name='orRedtype='SFRotationaccessType='outputOnly'/>
<field name='orGrntype='SFRotationaccessType='outputOnly'/>
<field name='orTuqtype='SFRotationaccessType='outputOnly'/>
<![CDATA[
          
            ecmascript:

//  The function'angle' computes the position
//  and orientation of each of the cones. The
//  values 2.094 and 4.189 are 1/3 and 2/3 of 2*pi
//  radians

function angle (value) {
  posRed = new SFVec3f (Math.cos (value), 1.5 * Math.sin(value), .5);
  posGrn = new SFVec3f (Math.cos (value+2.094), 1.5 * Math.sin(value+2.094),   0);
  posTuq = new SFVec3f (Math.cos (value+4.189), 1.5 * Math.sin(value+4.189), -.5);

  orRed = new SFRotation (0, 0, 1, -2*value);
  orGrn = new SFRotation (0, 0, 1, -2*(value+2.094));
  orTuq = new SFRotation (0, 0, 1, -2*(value+4.189));

}
  
        
]]>
</Script>
</Transform>
</Group>
<ROUTE fromNode='RunPumpfromField='isActivetoNode='FiltertoField='set_boolean'/>
<ROUTE fromNode='FilterfromField='inputTruetoNode='TimertoField='enabled'/>
<ROUTE fromNode='TimerfromField='fraction_changedtoNode='AngletoField='set_fraction'/>
<ROUTE fromNode='AnglefromField='value_changedtoNode='ControltoField='angle'/>
<ROUTE fromNode='ControlfromField='posRedtoNode='CandyRedtoField='translation'/>
<ROUTE fromNode='ControlfromField='posGrntoNode='CandyGreentoField='translation'/>
<ROUTE fromNode='ControlfromField='posTuqtoNode='CandyTurquoisetoField='translation'/>
<ROUTE fromNode='ControlfromField='orRedtoNode='CandyRedtoField='rotation'/>
<ROUTE fromNode='ControlfromField='orGrntoNode='CandyGreentoField='rotation'/>
<ROUTE fromNode='ControlfromField='orTuqtoNode='CandyTurquoisetoField='rotation'/>
<ROUTE fromNode='FilterfromField='inputFalsetoNode='PISTONClocktoField='enabled'/>
<ROUTE fromNode='PISTONClockfromField='fraction_changedtoNode='PISTONPathtoField='set_fraction'/>
<ROUTE fromNode='PISTONPathfromField='value_changedtoNode='PISTONtoField='set_translation'/>
<ROUTE fromNode='PISTONClockfromField='fraction_changedtoNode='ROCKER1PathtoField='set_fraction'/>
<ROUTE fromNode='ROCKER1PathfromField='value_changedtoNode='ROCKERARM1toField='set_translation'/>
<ROUTE fromNode='PISTONClockfromField='fraction_changedtoNode='ROCKER1RotationtoField='set_fraction'/>
<ROUTE fromNode='ROCKER1RotationfromField='value_changedtoNode='ROCKERARM1toField='set_rotation'/>
<ROUTE fromNode='PISTONClockfromField='fraction_changedtoNode='ROCKER2PathtoField='set_fraction'/>
<ROUTE fromNode='ROCKER2PathfromField='value_changedtoNode='ROCKERARM2toField='set_translation'/>
<ROUTE fromNode='PISTONClockfromField='fraction_changedtoNode='ROCKER2RotationtoField='set_fraction'/>
<ROUTE fromNode='ROCKER2RotationfromField='value_changedtoNode='ROCKERARM2toField='set_rotation'/>
</Scene>
</X3D>
<!--

Index for ExternProtoDeclare definition: WhereAmI
Index for DEF nodes: Angle, b1, CandyGreen, CandyRed, CandyTurquoise, Control, CylinderRod, EyeCandy, Filter, PISTON, PISTONClock, PISTONPath, pumpHouse, ROCKER1Path, ROCKER1Rotation, ROCKER2Path, ROCKER2Rotation, ROCKERARM1, ROCKERARM2, RunPump, Timer
Index for Viewpoint image: Viewpoint_1
-->

<!-- Tag color codes: <Node DEF='idName' attribute='value'/> <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->