X3D Model Documentation: SideScanSonarPrototype.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
  3  <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'>
  4       <head>
  5            <meta name='title' content='SideScanSonarPrototype.x3d'/>
  6            <meta name='description' content='Produce wireframe or transparent sidescan sonar beams.'/>
  7            <meta name='creator' content='Don Brutzman'/>
  8            <meta name='created' content='15 March 2001'/>
  9            <meta name='modified' content='20 October 2019'/>
 10            <meta name='identifier' content='https://savage.nps.edu/Savage/CommunicationsAndSensors/Sonar/SideScanSonarPrototype.x3d'/>
 11            <meta name='generator' content='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 12            <meta name='license' content='../../license.html'/>
 13       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: BEAM_CALCULATE, BEAM_CONTROL, BeamPatternCoordinatePoints, DETECTION, FaceMaterial, IFS, ILS, LockedDownInterface2D, SOLID_SWITCH, WIREFRAME_SWITCH, WireMaterial

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definition: SideScanSonar
-->
 14       <Scene>
 15            <NavigationInfo DEF='LockedDownInterface2D' type='"NONE"'/>
 16            <Background skyColor='0 0.3 0.5'/>
 17            <WorldInfo info='"Produce wireframe or transparent beam cones."' title='BeamCone Prototyupe'/>
 18            <Viewpoint description='SideScanSonar Prototype' position='0 0 15'/>
 19            <ProtoDeclare name='SideScanSonar' appinfo='Produce wireframe or semi-transparent sonar sidescan beams'>
 20                 <ProtoInterface>
 21                      <field name='altitude' type='SFFloat' accessType='inputOnly'
                     appinfo='vertical distance above bottom in meters along y axis'/>
 22                      <field name='defaultAltitude' type='SFFloat' value='3' accessType='initializeOnly'
                     appinfo='default vertical distance above bottom in meters along y axis'/>
 23                      <field name='maxAltitude' type='SFFloat' value='3' accessType='initializeOnly'
                     appinfo='maximum effective altitude of sidescan sonar above bottom'/>
 24                      <field name='defaultCrossTrackHalfRange' type='SFFloat' value='30' accessType='initializeOnly'
                     appinfo='distance in meters from nadir to rightmost/leftmost edge when operating at defaultAltitude above the bottom'/>
 25                      <field name='defaultTrackWidthMeters' type='SFFloat' value='0.30' accessType='initializeOnly'
                     appinfo='longitudinal width of a single return'/>
 26                      <field name='vehicleWidthMeters' type='SFFloat' value='0.178' accessType='initializeOnly'
                     appinfo='width (or diameter) of vehicle carrying port/starboard sidescan sonar transducers'/>
 27                      <field name='contact' type='SFBool' accessType='inputOnly'
                     appinfo='(communications) whether transmitted signal is in contact with receiver or (sensor) is a target return detected?'/>
 28                      <field name='wireframe' type='SFBool' value='true' accessType='initializeOnly'
                     appinfo='draw lines for tracking shape?'/>
 29                      <field name='solid' type='SFBool' value='true' accessType='initializeOnly'
                     appinfo='draw solid tracking shape?'/>
 30                      <field name='contactColor' type='SFColor' value='.8 .1 .1' accessType='initializeOnly'
                     appinfo='rendering color when contact=true'/>
 31                      <field name='noContactColor' type='SFColor' value='.3 .5 .5' accessType='initializeOnly'
                     appinfo='rendering color when contact=false'/>
 32                      <field name='transparency' type='SFFloat' value='0' accessType='inputOutput'
                     appinfo='1 = fully transparent wireframe only'/>
 33                 </ProtoInterface>
 34                 <ProtoBody>
 35                      <!-- BEAM_CONTROL beam scaling is controlled by range/beamHeightDegrees/beamWidthDegrees/direction inputs -->
 36 
                    <!-- ROUTE information for BEAM_CONTROL node:  [from BEAM_CALCULATE.beamScale to scale ] -->
                    <Transform DEF='BEAM_CONTROL'>
 37 
                         <!-- ROUTE information for WIREFRAME_SWITCH node:  [from DETECTION.wireframeChoice to whichChoice ] -->
                         <Switch DEF='WIREFRAME_SWITCH' whichChoice='1'>
 38                                <!-- TODO refactor index values starting from -1, remove WorldInfo -->
 39                                <WorldInfo info='"initial choice is null node (WorldInfo), meaning no wireframe beam"'/>
 40                                <Shape>
 41                                     <Appearance>
 42 
                                        <!-- ROUTE information for WireMaterial node:  [from DETECTION.beamColor to emissiveColor ] -->
                                        <Material DEF='WireMaterial' diffuseColor='.1 .1 .1' emissiveColor='.1 .1 .1'>
 43                                               <IS>
 44                                                    <connect nodeField='transparency' protoField='transparency'/>
 45                                               </IS>
 46                                          </Material>
 47                                     </Appearance>
 48                                     <IndexedLineSet DEF='ILS' coordIndex='1 2 3 1 -1 5 3 4 5 -1 6 8 7 6 -1 10 9 8 10 -1 6 7 2 1 6 -1 10 5 4 9 10 -1'>
 49 
                                        <!-- Coordinate BeamPatternCoordinatePoints is a DEF node that has 1 USE node: USE_1
                                        <!-- ROUTE information for BeamPatternCoordinatePoints node:  [from BEAM_CALCULATE.coordinatePoints to point ] -->
                                        <Coordinate DEF='BeamPatternCoordinatePoints' point='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'/>
 50                                     </IndexedLineSet>
 51                                </Shape>
 52                           </Switch>
 53 
                         <!-- ROUTE information for SOLID_SWITCH node:  [from DETECTION.solidChoice to whichChoice ] -->
                         <Switch DEF='SOLID_SWITCH' whichChoice='0'>
 54                                <!-- TODO refactor index values starting from -1, remove WorldInfo -->
 55                                <WorldInfo info='"initial choice is null node (WorldInfo), meaning no solid beam"'/>
 56                                <Shape>
 57                                     <Appearance>
 58 
                                        <!-- Material FaceMaterial is a DEF node that has 1 USE node: USE_1
                                        <!-- ROUTE information for FaceMaterial node:  [from DETECTION.beamColor to emissiveColor ] -->
                                        <Material DEF='FaceMaterial' diffuseColor='.1 .1 .1'>
 59                                               <IS>
 60                                                    <connect nodeField='transparency' protoField='transparency'/>
 61                                               </IS>
 62                                          </Material>
 63                                     </Appearance>
 64                                     <IndexedFaceSet DEF='IFS' solid='false' coordIndex='1 2 3 1 -1 5 3 4 5 -1 6 8 7 6 -1 10 9 8 10 -1 6 7 2 1 6 -1 10 5 4 9 10 -1'>
 65                                          <Coordinate USE='BeamPatternCoordinatePoints'/>
 66                                     </IndexedFaceSet>
 67                                </Shape>
 68                           </Switch>
 69                      </Transform>
 70                      <!-- Non-renderable animation controls -->
 71 
                    <!-- ROUTE information for BEAM_CALCULATE node:  [from beamScale to BEAM_CONTROL.scale ] [from coordinatePoints to BeamPatternCoordinatePoints.point ] -->
                    <Script DEF='BEAM_CALCULATE'>
 72                           <field name='altitude' type='SFFloat' accessType='inputOnly'/>
 73                           <field name='defaultAltitude' type='SFFloat' accessType='initializeOnly'/>
 74                           <field name='maxAltitude' type='SFFloat' accessType='initializeOnly'/>
 75                           <field name='defaultCrossTrackHalfRange' type='SFFloat' accessType='initializeOnly'/>
 76                           <field name='defaultTrackWidthMeters' type='SFFloat' accessType='initializeOnly'/>
 77                           <field name='vehicleWidthMeters' type='SFFloat' accessType='initializeOnly'/>
 78                           <field name='beamScale' type='SFVec3f' accessType='outputOnly'/>
 79                           <field name='coordinatePoints' type='MFVec3f' accessType='outputOnly'/>
 80                           <field name='traceEnabled' type='SFBool' value='false' accessType='initializeOnly'
                          appinfo='internal flag to turn on Script tracing'/>
 81                           <IS>
 82                                <connect nodeField='altitude' protoField='altitude'/>
 83                                <connect nodeField='defaultAltitude' protoField='defaultAltitude'/>
 84                                <connect nodeField='maxAltitude' protoField='maxAltitude'/>
 85                                <connect nodeField='defaultCrossTrackHalfRange' protoField='defaultCrossTrackHalfRange'/>
 86                                <connect nodeField='defaultTrackWidthMeters' protoField='defaultTrackWidthMeters'/>
 87                                <connect nodeField='vehicleWidthMeters' protoField='vehicleWidthMeters'/>
 88                           </IS>
  <![CDATA[
          
ecmascript:

function tracePrint (value)
{
	if (traceEnabled) Browser.println ('[SideScanSonar BEAM_CALCULATE] ' + value);
}

function initialize () {
 beamScale = new SFVec3f (1, 1, 1);
 dt2 = defaultTrackWidthMeters/2;

 origin = new SFVec3f (0, 0, 0);
 a  = new SFVec3f (-dt2,  0,               -vehicleWidthMeters/2);
 b  = new SFVec3f (-dt2, -defaultAltitude, -defaultCrossTrackHalfRange);
 c  = new SFVec3f (-dt2, -defaultAltitude,  0);
 d  = new SFVec3f (-dt2, -defaultAltitude,  defaultCrossTrackHalfRange);
 e  = new SFVec3f (-dt2,  0,                vehicleWidthMeters/2);
 aa = new SFVec3f ( dt2,  0,               -vehicleWidthMeters/2);
 bb = new SFVec3f ( dt2, -defaultAltitude, -defaultCrossTrackHalfRange);
 cc = new SFVec3f ( dt2, -defaultAltitude,  0);
 dd = new SFVec3f ( dt2, -defaultAltitude,  defaultCrossTrackHalfRange);
 ee = new SFVec3f ( dt2,  0,                vehicleWidthMeters/2);

 coordinatePoints = new MFVec3f (origin, a, b, c, d, e, aa, bb, cc, dd, ee);

 tracePrint ('coordinatePoints =' + coordinatePoints);
}
function altitude (newAltitude, timeStamp) {
 if (newAltitude <= 0)
 {
   beamHeightFactor= 0.001;
   beamScale = new SFVec3f (1, beamHeightFactor, beamHeightFactor);
 }
 else if (newAltitude < maxAltitude)
 {
   beamHeightFactor= newAltitude / defaultAltitude;
   beamScale = new SFVec3f (1, beamHeightFactor, beamHeightFactor);
 }
 else
 {
   beamHeightFactor= maxAltitude / defaultAltitude;
   beamScale = new SFVec3f (1, beamHeightFactor, beamHeightFactor);
 }
 tracePrint ('newAltitude      =' + newAltitude);
 tracePrint ('beamHeightFactor =' + beamHeightFactor);
 tracePrint ('beamScale        =' + beamScale);
}

        
]]>
 90                      </Script>
 91 
                    <!-- ROUTE information for DETECTION node:  [from beamColor to WireMaterial.emissiveColor ] [from beamColor to FaceMaterial.emissiveColor ] [from wireframeChoice to WIREFRAME_SWITCH.whichChoice ] [from solidChoice to SOLID_SWITCH.whichChoice ] -->
                    <Script DEF='DETECTION' directOutput='true'>
 92                           <field name='contact' type='SFBool' accessType='inputOnly'/>
 93                           <field name='wireframe' type='SFBool' accessType='initializeOnly'/>
 94                           <field name='solid' type='SFBool' accessType='initializeOnly'/>
 95                           <field name='contactColor' type='SFColor' accessType='initializeOnly'/>
 96                           <field name='noContactColor' type='SFColor' accessType='initializeOnly'/>
 97                           <field name='beamColor' type='SFColor' accessType='outputOnly'/>
 98                           <field name='wireframeChoice' type='SFInt32' accessType='outputOnly'/>
 99                           <field name='solidChoice' type='SFInt32' accessType='outputOnly'/>
100                           <field name='MaterialNodeHolder' type='SFNode' accessType='initializeOnly'>
101                                <Material USE='FaceMaterial'/>
102                           </field>
103                           <field name='traceEnabled' type='SFBool' value='false' accessType='initializeOnly'
                          appinfo='internal flag to turn on Script tracing'/>
104                           <IS>
105                                <connect nodeField='contact' protoField='contact'/>
106                                <connect nodeField='wireframe' protoField='wireframe'/>
107                                <connect nodeField='solid' protoField='solid'/>
108                                <connect nodeField='contactColor' protoField='contactColor'/>
109                                <connect nodeField='noContactColor' protoField='noContactColor'/>
110                           </IS>
  <![CDATA[
          
ecmascript:

function tracePrint (value)
{
	if (traceEnabled) Browser.println ('[SideScanSonar DETECTION] ' + value);
}

function initialize ()
{
	beamColor = noContactColor;
	if (wireframe == true) wireframeChoice = 1;
	if (solid     == true) solidChoice     = 1;

	// Debug  statements
	tracePrint ('  wireframe       =' + wireframe);
	tracePrint ('  solid           =' + solid);
	tracePrint ('  contactColor    =' + contactColor);
	tracePrint ('  noContactColor  =' + noContactColor);
	tracePrint ('  beamColor       =' + beamColor);
	tracePrint ('  wireframeChoice =' + wireframeChoice);
	tracePrint ('  solidChoice     =' + solidChoice);
	tracePrint ('  transparency    =' + MaterialNodeHolder.transparency);
}
function contact (newDetect, timeStamp)
{
	tracePrint ('  newDetect       =' + newDetect);
	if (newDetect) beamColor = contactColor;
	else           beamColor = noContactColor;
}

        
]]>
112                      </Script>
113                      < ROUTE  fromNode='BEAM_CALCULATE' fromField='beamScale' toNode='BEAM_CONTROL' toField='scale'/>
114                      < ROUTE  fromNode='BEAM_CALCULATE' fromField='coordinatePoints' toNode='BeamPatternCoordinatePoints' toField='point'/>
115                      < ROUTE  fromNode='DETECTION' fromField='beamColor' toNode='WireMaterial' toField='emissiveColor'/>
116                      < ROUTE  fromNode='DETECTION' fromField='beamColor' toNode='FaceMaterial' toField='emissiveColor'/>
117                      < ROUTE  fromNode='DETECTION' fromField='wireframeChoice' toNode='WIREFRAME_SWITCH' toField='whichChoice'/>
118                      < ROUTE  fromNode='DETECTION' fromField='solidChoice' toNode='SOLID_SWITCH' toField='whichChoice'/>
119                 </ProtoBody>
120            </ProtoDeclare>
121            <!-- Viewable geometry for this scene is anchored text that links to an example showing ExternProtoDeclare usage of BeamCone -->
122            <Anchor description='SideScanSonar Example' parameter='"target=_blank"'   url=' "SideScanSonarExample.x3d" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Sonar/SideScanSonarExample.x3d" "SideScanSonarExample.wrl" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Sonar/SideScanSonarExample.wrl" '>
123                 <Shape>
124                      <Appearance>
125                           <Material diffuseColor='0 1 1' emissiveColor='0 1 1'/>
126                      </Appearance>
127                      <Text string='"SideScanSonarPrototype" "is a Prototype definition file." "" "To see an example scene" "click this text and view" "SideScanSonarExample."'>
128                           <FontStyle justify='"MIDDLE" "MIDDLE"'/>
129                      </Text>
130                 </Shape>
131                 <Shape>
132                      <!-- transparent Box as text-selection assist -->
133                      <Box size='10.5 6 .001'/>
134                      <Appearance>
135                           <Material transparency='1'/>
136                      </Appearance>
137                 </Shape>
138            </Anchor>
139       </Scene>
140  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: BEAM_CALCULATE, BEAM_CONTROL, BeamPatternCoordinatePoints, DETECTION, FaceMaterial, IFS, ILS, LockedDownInterface2D, SOLID_SWITCH, WIREFRAME_SWITCH, WireMaterial

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definition: SideScanSonar
-->
X3D Tooltips element index: Anchor, Appearance, Background, Box, connect, Coordinate, field, FontStyle, head, IndexedFaceSet, IndexedLineSet, IS, Material, meta, NavigationInfo, ProtoBody, ProtoDeclare, ProtoInterface, ROUTE, Scene, Script, Shape, Switch, Text, Transform, Viewpoint, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

Event Graph ROUTE Table entries with 6 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

BEAM_CALCULATE
Script
beamScale
SFVec3f
→
ROUTE
event to
(1)
BEAM_CONTROL
Transform
scale
SFVec3f
BEAM_CALCULATE
Script
coordinatePoints
MFVec3f
→
ROUTE
event to
(1)
BeamPatternCoordinatePoints
Coordinate
point
MFVec3f

DETECTION
Script
beamColor
SFColor
→
ROUTE
event to
(1)
WireMaterial
Material
emissiveColor
SFColor
DETECTION
Script
beamColor
SFColor
→
ROUTE
event to
(1)
FaceMaterial
Material
emissiveColor
SFColor
DETECTION
Script
wireframeChoice
SFInt32
→
ROUTE
event to
(1)
WIREFRAME_SWITCH
Switch
whichChoice
SFInt32
DETECTION
Script
solidChoice
SFInt32
→
ROUTE
event to
(1)
SOLID_SWITCH
Switch
whichChoice
SFInt32

line 122
Anchor
description='SideScanSonar Example' 
User-interaction hint for this node. 

Additional guidance on X3D animation can be found in the 10-Step Animation Design Process and Event Tracing hint sheets. Have fun with X3D! 😀

-->
<!-- Online at
https://savage.nps.edu/Savage/CommunicationsAndSensors/Sonar/SideScanSonarPrototypeIndex.html -->
<!-- Version control at
https://gitlab.nps.edu/Savage/Savage/CommunicationsAndSensors/Sonar/SideScanSonarPrototype.x3d -->

<!-- Color-coding legend: X3D terminology <X3dNode  DEF='idName' field='value'/> matches XML terminology <XmlElement  DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
    <ProtoDeclare name='ProtoName'> <field name='fieldName'/> </ProtoDeclare> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->