<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile='Immersive' version='3.3' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.3.xsd'>
  <head>
    <meta content='ReportedContactPrototype.x3d' name='title'/>
    <meta content='Example instance of prototype for a reported mine-like contact.' name='description'/>
    <meta content='Don Brutzman, Jeff Weekley, Frederic Roussille and Jane Wu' name='creator'/>
    <meta content='15 October 2001' name='created'/>
    <meta content='28 November 2019' name='modified'/>
    <meta content='/ads/src/mil/navy/nps/ads/x3dArchive/DataArchiver.java' name='reference'/>
    <meta content='/ads/doc/mil/navy/nps/ads/x3dArchive/DataArchiver.html' name='reference'/>
    <meta content='https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/ReportedContactPrototype.x3d' name='identifier'/>
    <meta content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit' name='generator'/>
    <meta content='../../license.html' name='license'/>
  </head>
  <Scene>
    <WorldInfo title='ReportedContactPrototype.x3d'/>
    <ExternProtoDeclare appinfo='PDM-1 underwater mine' name='Pdm1BottomMine' url='"Pdm1BottomMinePrototype.x3d#Pdm1BottomMine" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/Pdm1BottomMinePrototype.x3d#Pdm1BottomMine" "Pdm1BottomMinePrototype.wrl#Pdm1BottomMine" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/Pdm1BottomMinePrototype.wrl#Pdm1BottomMine"'>
      <field accessType='initializeOnly' appinfo='customize to match each instance' name='viewpointDescription' type='SFString'/>
      <field accessType='inputOutput' appinfo='useful for classification' name='mineColor' type='SFColor'/>
    </ExternProtoDeclare>
    <ExternProtoDeclare appinfo='Manta underwater mine' name='MantaMine' url='"MantaMinePrototype.x3d#MantaMine" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/MantaMinePrototype.x3d#MantaMine" "MantaMinePrototype.wrl#MantaMine" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/MantaMinePrototype.wrl#MantaMine"'>
      <field accessType='inputOutput' appinfo='useful for visual classification' name='MineColor' type='SFColor'/>
      <field accessType='initializeOnly' appinfo='describe each instance' name='viewpointDescription' type='SFString'/>
    </ExternProtoDeclare>
    <ExternProtoDeclare appinfo='Spherical floating mine moored to bottom' name='SphericalMine' url='"SphericalMinePrototype.x3d#SphericalMine" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/SphericalMinePrototype.x3d#SphericalMine" "SphericalMinePrototype.wrl#SphericalMine" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/SphericalMinePrototype.wrl#SphericalMine"'>
      <field accessType='initializeOnly' appinfo='Description for each mine contact.' name='description' type='SFString'/>
      <field accessType='inputOutput' appinfo='Mine color can be used to indicate status (found/unknown/disabled/) tactic etc.' name='color' type='SFColor'/>
      <field accessType='inputOutput' appinfo='Location of mine center in local world coordinates.' name='translation' type='SFVec3f'/>
      <field accessType='inputOutput' appinfo='Scale factor to change spherical mine size default diameter = 1m.' name='scale' type='SFVec3f'/>
      <field accessType='initializeOnly' appinfo='Bounding box for collision detection of mine.' name='bboxCenter' type='SFVec3f'/>
      <field accessType='inputOutput' appinfo='Top and bottom endpoints of line tether that anchors this mine to the bottom.' name='tetherPoints' type='MFVec3f'/>
      <field accessType='outputOnly' appinfo='proximityIsActive can be used to activate information or interaction when the viewer nears the mine.' name='proximityIsActive' type='SFBool'/>
      <field accessType='inputOutput' appinfo='proximitySize provides overall box dimensions for proximity; thus (10 10 10) yields approximate radius 5 to 7 meters.' name='proximitySize' type='SFVec3f'/>
    </ExternProtoDeclare>
    <ProtoDeclare appinfo='Provide icon and contact information for a reported contact. Position ProtoInstances using the depth and location where found.' name='ReportedContact'>
      <ProtoInterface>
        <field accessType='initializeOnly' name='name' type='MFString'/>
        <field accessType='initializeOnly' name='aboveViewpointLabel' type='SFString' value='Reported Contact (100m above)'/>
        <field accessType='initializeOnly' name='closeViewpointLabel' type='SFString' value='Reported Contact (10m closeup)'/>
        <field accessType='inputOutput' name='description' type='MFString'/>
        <field accessType='inputOutput' appinfo='Latitude and longitude (or local coordinates) for display purposes.' name='reportedPosition' type='MFString'/>
        <field accessType='initializeOnly' name='classificationCode' type='SFInt32' value='-1'/>
        <field accessType='inputOutput' appinfo='provide filename and url of contact image as separate quoted strings' name='imageUrl' type='MFString'/>
        <field accessType='inputOutput' appinfo='Aspect-ratio x-y scale of image icon (keep z=1)' name='imageScale' type='SFVec3f' value='1.00 1.00 1'/>
        <field accessType='inputOutput' appinfo='Relative position of image icon' name='imageOffset' type='SFVec3f' value='0 2.5 0'/>
        <field accessType='inputOutput' name='textColor' type='SFColor' value='0.4 0.4 0'/>
        <field accessType='inputOutput' appinfo='Relative position of image icon' name='textOffset' type='SFVec3f' value='0 0 0'/>
      </ProtoInterface>
      <ProtoBody>
        <Group>
          <Viewpoint DEF='SeenFromAboveViewpoint' description='100m above contact (overridden by field viewpointLabel)' orientation='1 0 0 -1.57' position='0 100 0'>
            <IS>
              <connect nodeField='description' protoField='aboveViewpointLabel'/>
            </IS>
          </Viewpoint>
          <Viewpoint DEF='ContactCloseupViewpoint' description='10m next to contact (overridden by closeViewpointLabel)'>
            <IS>
              <connect nodeField='description' protoField='closeViewpointLabel'/>
            </IS>
          </Viewpoint>
          <LOD range='150 10000'>
            <!-- close range -->
            <Group>
              <Transform DEF='TextOffset'>
                <IS>
                  <connect nodeField='translation' protoField='textOffset'/>
                </IS>
                <Billboard>
                  <Transform translation='0 -0.25 0'>
                    <Shape>
                      <Text DEF='PositionText'>
                        <IS>
                          <connect nodeField='string' protoField='reportedPosition'/>
                        </IS>
                        <FontStyle DEF='SmallFont' justify='"MIDDLE" "MIDDLE"' size='0.75'/>
                      </Text>
                      <Appearance DEF='IconAppearance'>
                        <Material DEF='IconMaterial'>
                          <IS>
                            <connect nodeField='diffuseColor' protoField='textColor'/>
                          </IS>
                        </Material>
                      </Appearance>
                    </Shape>
                  </Transform>
                  <Transform translation='0 -1.5 0'>
                    <Shape>
                      <Text DEF='DescriptionText'>
                        <IS>
                          <connect nodeField='string' protoField='description'/>
                        </IS>
                        <FontStyle DEF='SmallerFont' justify='"MIDDLE" "MIDDLE"' size='0.6'/>
                      </Text>
                      <Appearance USE='IconAppearance'/>
                    </Shape>
                  </Transform>
                </Billboard>
              </Transform>
              <Transform DEF='ImageOffset'>
                <IS>
                  <connect nodeField='translation' protoField='imageOffset'/>
                </IS>
                <Billboard axisOfRotation='0 0 0'>
                  <Anchor DEF='BillBoardAnchor' description='click image to popup image viewer' parameter='"target=_blank"'>
                    <IS>
                      <connect nodeField='url' protoField='imageUrl'/>
                    </IS>
                    <Transform DEF='ImageFit'>
                      <IS>
                        <connect nodeField='scale' protoField='imageScale'/>
                      </IS>
                      <Shape>
                        <Appearance>
                          <Material USE='IconMaterial'/>
                          <ImageTexture DEF='ContactImage'>
                            <IS>
                              <connect nodeField='url' protoField='imageUrl'/>
                            </IS>
                          </ImageTexture>
                        </Appearance>
                        <IndexedFaceSet coordIndex='0 1 2 3 0 -1'>
                          <Coordinate DEF='TwoByTwoSquare' point='-1 -1 0 1 -1 0 1 1 0 -1 1 0'/>
                        </IndexedFaceSet>
                      </Shape>
                    </Transform>
                  </Anchor>
                  <!-- Unfortunately the anchor link connects to the viewpoint DEF name, which can't be overridden at runtime. This means that multiple use of the prototype will not resolve properly. -->
                  <Anchor DEF='ViewpointAnchor' description='click text for Contact Closeup Viewpoint' url='"#ContactCloseupViewpoint"'>
                    <!-- TODO Add children nodes here -->
                  </Anchor>
                  <Group>
                    <Transform translation='0 -2 0'>
                      <Shape>
                        <Text DEF='NameText'>
                          <IS>
                            <connect nodeField='string' protoField='name'/>
                          </IS>
                          <FontStyle DEF='LargeFont' justify='"MIDDLE" "MIDDLE"'/>
                        </Text>
                        <Appearance USE='IconAppearance'/>
                      </Shape>
                    </Transform>
                    <TouchSensor DEF='CloseUpTouchSensor' description='bind closeup Viewpoint'/>
                  </Group>
                  <Script DEF='BindViewpointFilter'>
                    <field accessType='inputOnly' name='touched' type='SFBool'/>
                    <field accessType='outputOnly' name='activate' type='SFBool'/>
                    <![CDATA[
ecmascript:

// only activate viewpoint when touched is true, do not unbind when false
function touched (value, timestamp)
{
	if (value == true) activate = true;
}
]]>
                  </Script>
                  <ROUTE fromField='isActive' fromNode='CloseUpTouchSensor' toField='touched' toNode='BindViewpointFilter'/>
                  <ROUTE fromField='activate' fromNode='BindViewpointFilter' toField='set_bind' toNode='ContactCloseupViewpoint'/>
                </Billboard>
              </Transform>
              <Transform translation='0 -3 0'>
                <Switch DEF='MineModelSwitch' whichChoice='-1'>
                  <IS>
                    <connect nodeField='whichChoice' protoField='classificationCode'/>
                  </IS>
                  <!-- Mine code enumerations appear in ADS.src.mil.navy.nps.ads.x3dArchive.DataArchiver.java -->
                  <Shape DEF='UnknownContact'>
                    <Appearance>
                      <Material diffuseColor='0.3 0.8 0'/>
                    </Appearance>
                    <Box size='1 1 1'/>
                  </Shape>
                  <ProtoInstance name='Pdm1BottomMine'/>
                  <ProtoInstance name='MantaMine'>
                    <fieldValue name='viewpointDescription' value='Manta mine 10m'/>
                  </ProtoInstance>
                  <Inline DEF='RockanContact' url='"Rockan.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/Rockan.x3d" "Rockan.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/Rockan.wrl"'/>
                  <ProtoInstance name='SphericalMine'>
                    <fieldValue name='description' value='Spherical Mine'/>
                    <fieldValue name='tetherPoints' value='0 0 0 0 -5 0'/>
                  </ProtoInstance>
                  <Inline DEF='SonarDeflectorDecoyBox' url='"SonarReflectorDecoyBox.x3d" "../../Weapons/UnderwaterMines/SonarReflectorDecoyBox.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/SonarReflectorDecoyBox.x3d" "../../Weapons/UnderwaterMines/SonarReflectorDecoyBox.wrl" "SonarReflectorDecoyBox.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/SonarReflectorDecoyBox.wrl"'/>
                </Switch>
              </Transform>
            </Group>
            <!-- intermediate range -->
            <Transform USE='ImageOffset'/>
            <!-- far range: might place a self-scaling icon billboard here for long-distance map-like appearance -->
            <WorldInfo info='"null node"'/>
          </LOD>
        </Group>
      </ProtoBody>
    </ProtoDeclare>
    <!-- ==================== -->
    <!-- Example scene starts here, in case this prototype is examined. -->
    <Anchor description='ReportedContactExample' parameter='"target=_blank"' url='"ReportedContactExample.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/ReportedContactExample.x3d" "ReportedContactExample.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Weapons/UnderwaterMines/ReportedContactExample.wrl"'>
      <Shape>
        <Text string='"ReportedContactPrototype" "is a prototype definition file" "" "Click this text to see" "ReportedContactExample"'>
          <FontStyle justify='"MIDDLE" "MIDDLE"'/>
        </Text>
        <Appearance>
          <Material diffuseColor='0.6 0.8 0.4'/>
        </Appearance>
      </Shape>
    </Anchor>
  </Scene>
</X3D>