<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'>
  <head>
    <meta content='HudControlPanelExample.x3d' name='title'/>
    <meta content='Example world using an adjustable Heads-Up Display (HUD) or control panel. The panel always appears in the same position in the brower&apos;s window, independent of view point. The HUD can be dragged around the window by grabbing onto the border and sliding.' name='description'/>
    <meta content='Leonard Daly' name='creator'/>
    <meta content='Dan Kucik' name='translator'/>
    <meta content='1999' name='created'/>
    <meta content='8 June 2003' name='translated'/>
    <meta content='28 November 2019' name='modified'/>
    <meta content='HUD does not sit still when navigating' name='error'/>
    <meta content='http://www.realism.com/Web3D/Examples/examples.cgi?ID=5' name='reference'/>
    <meta content='This code may be reused in part or total. Please include this paragraph when it is used. Copyright 1999, Leonard Daly #****************' name='rights'/>
    <meta content='http://www.realism.com/vrml/Example/HUD/CP.gif' name='Image'/>
    <meta content='Heads-up display example' name='subject'/>
    <meta content='Original VRML File: http://www.realism.com/vrml/Example/HUD/HUD.wrl' name='reference'/>
    <meta content='https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/HudControlPanelExample.x3d' name='identifier'/>
    <meta content='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html' name='generator'/>
    <meta content='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit' name='generator'/>
    <meta content='../../license.html' name='license'/>
  </head>
  <Scene>
    <WorldInfo title='HudControlPanelExample.x3d'/>
    <ExternProtoDeclare appinfo='Heads Up Display (HUD) Control Panel' name='HudControlPanel' url='"HudControlPanelPrototype.x3d#HudControlPanel" "../../Tools/HeadsUpDisplays/HudControlPanelPrototype.x3d#HudControlPanel" "https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/HudControlPanelPrototype.x3d#HudControlPanel" "../../Tools/HeadsUpDisplays/HudControlPanelPrototype.wrl#HudControlPanel" "HudControlPanelPrototype.wrl#HudControlPanel" "https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/HudControlPanelPrototype.wrl#HudControlPanel"'>
      <field accessType='initializeOnly' appinfo='SFVec3f Position of the panel relative to the viewpoint. The X and Y components can be changed by dragging the window around.' name='translation' type='SFVec3f'/>
      <field accessType='inputOutput' appinfo='SFRotation This field should be the object of a ROUTE statement from the orientation_changed event from a ProximitySensor. For some reason the ProximitySensor does not correctly report the current viewpoint when the sensor is located inside of the PROTO.' name='orientation' type='SFRotation'/>
      <field accessType='outputOnly' appinfo='Out - SFBool event is generated when the cursor is over the texture mapped region of the control panel. Set to false when the cursor leaves the texture mapped region.' name='isOver' type='SFBool'/>
      <field accessType='outputOnly' appinfo='Out - SFVec2f The X/Y normalized coordinates (S and T) of the cursor location when &apos;isOver&apos; is true.' name='hitTexCoord_changed' type='SFVec2f'/>
      <field accessType='inputOutput' appinfo='SFColor The color of the panel border. This is the region that can be used to drag the panel around the screen.' name='borderColor' type='SFColor'/>
      <field accessType='initializeOnly' appinfo='SFVec3f Size of the panel. The texture mapped area (see textureMap) is 95% in X and 90% in Y of this size.' name='scale' type='SFVec3f'/>
      <field accessType='inputOutput' appinfo='SFVec3f This field should be the object of a ROUTE statement from the position_changed event from a ProximitySensor. See &apos;orientation&apos; for more details.' name='position' type='SFVec3f'/>
      <field accessType='inputOutput' appinfo='MFString The texture map URLs. This is specified in the same manner as the URL field in ImageTexture. The first one that can be loaded is the that is displayed. If this field is not specified then this region of the object is painted white.' name='textureMap' type='MFString'/>
      <field accessType='outputOnly' appinfo='Out - SFTime The time when a mouse button is released provided that the just prior to release &apos;isOver&apos; and &apos;isActive&apos; are true.' name='touchTime' type='SFTime'/>
      <field accessType='outputOnly' appinfo='Out - SFBool A true event is generated when the mouse button is depressed and the cursor is over the texture mapped region. A false event is generated when the button is released or when &apos;isOver&apos; becomes false.' name='isActive' type='SFBool'/>
    </ExternProtoDeclare>
    <NavigationInfo DEF='NavInfo' type='"FLY" "EXAMINE" "ANY"'/>
    <Viewpoint DEF='SIDE_VP' description='Side View' jump='false'/>
    <Viewpoint DEF='TOP_VP' description='Top View' jump='false' orientation='1.0 0.0 0.0 -1.57' position='0.0 10.0 0.0'/>
    <Transform DEF='Revolver'>
      <Transform DEF='Body1' translation='3.0 0.0 0.0'>
        <PointLight color='0.0 0.0 1.0'/>
        <Shape>
          <Appearance>
            <Material diffuseColor='1.0 0.0 0.0' emissiveColor='0.0 0.0 1.0' specularColor='0.0 1.0 0.0'/>
          </Appearance>
          <Sphere radius='0.75'/>
        </Shape>
      </Transform>
      <Transform DEF='Body2' translation='-3.0 0.0 0.0'>
        <SpotLight beamWidth='1.57' direction='0.0 -1.0 0.0'/>
        <Shape>
          <Appearance>
            <Material diffuseColor='0.0 1.0 1.0'/>
          </Appearance>
          <Cone bottomRadius='0.75' height='1.5'/>
        </Shape>
      </Transform>
    </Transform>
    <TimeSensor DEF='Timer1' cycleInterval='5.0' loop='true' startTime='1.0'/>
    <TimeSensor DEF='Timer2' cycleInterval='3.0' loop='true' startTime='1.0'/>
    <OrientationInterpolator DEF='Spinner' key='0.0 0.333 0.667 1.0' keyValue='0.0 1.0 0.0 0.0 0.0 1.0 0.0 2.09 0.0 1.0 0.0 4.18 0.0 1.0 0.0 0.0'/>
    <OrientationInterpolator DEF='Tumble' key='0.0 0.14 0.28 0.43 0.57 0.71 0.86 1.0' keyValue='0.0 1.0 0.0 0.0 0.0 1.0 0.5 0.898 0.0 0.5 1.0 1.795 0.5 0.0 1.0 2.693 1.0 0.2 0.8 3.59 1.0 0.8 0.5 4.488 0.5 1.0 0.0 5.386 0.0 1.0 0.0 6.283'/>
    <ROUTE fromField='fraction_changed' fromNode='Timer1' toField='set_fraction' toNode='Spinner'/>
    <ROUTE fromField='fraction_changed' fromNode='Timer2' toField='set_fraction' toNode='Tumble'/>
    <ROUTE fromField='value_changed' fromNode='Spinner' toField='rotation' toNode='Revolver'/>
    <ROUTE fromField='value_changed' fromNode='Tumble' toField='rotation' toNode='Body2'/>
    <ProtoInstance DEF='HUD' name='HudControlPanel'>
      <fieldValue name='translation' value='4 -2 -10'/>
      <fieldValue name='orientation' value='0.0 1.0 0.0 0.0'/>
      <fieldValue name='borderColor' value='0.0 0.4 0.0'/>
      <fieldValue name='scale' value='2.5 1.5 0.05'/>
      <fieldValue name='position' value='0.0 0.0 0.0'/>
      <fieldValue name='textureMap' value='"HudControlPanel.gif" "http://www.realism.com/vrml/Example/HUD/CP.gif" "https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/HudControlPanel.gif"'/>
    </ProtoInstance>
    <ProximitySensor DEF='Where' size='1000.0 1000.0 1000.0'/>
    <Script DEF='Controller'>
      <field accessType='outputOnly' name='Headlight' type='SFBool'/>
      <field accessType='inputOnly' name='Position' type='SFVec2f'/>
      <field accessType='inputOnly' name='Touch' type='SFTime'/>
      <field accessType='initializeOnly' name='Light' type='SFBool' value='true'/>
      <![CDATA[
ecmascript:

      function Position (value) {
	msg = 'Control Panel';
	if (value[1] < .5) {
	  if (value[0] > .5) {
	    Light = false;
	    msg = 'Headlight Off';
	   } else {
	    Light = true;
	    msg = 'Headlight On';
	  }
	}
	// Browser.setDescription (msg); // TODO figure this out, see Table 7.2 in Ecmascript SAI
      }

      function Touch (value) {
	Headlight = Light;
      }
]]>
    </Script>
    <ROUTE fromField='hitTexCoord_changed' fromNode='HUD' toField='Position' toNode='Controller'/>
    <ROUTE fromField='touchTime' fromNode='HUD' toField='Touch' toNode='Controller'/>
    <ROUTE fromField='Headlight' fromNode='Controller' toField='headlight' toNode='NavInfo'/>
  </Scene>
</X3D>