| 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=' BeamConePrototype.x3d '/> | 
| 6 | <meta name='creator' content='Don Brutzman'/> | 
| 7 | <meta name='created' content='7 December 2000'/> | 
| 8 | <meta name='modified' content='12 October 2023'/> | 
| 9 | <meta name='description' content='Produce wireframe or transparent beam cones.'/> | 
| 10 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConePrototype.x3d '/> | 
| 11 | <meta name='reference' content=' http://faculty.nps.edu/brutzman/vrtp/demo/auv/BeamConePrototype.x3d '/> | 
| 12 | <meta name='reference' content=' https://www.web3d.org/WorkingGroups/vrtp/demo/auv/BeamConePrototype.x3d '/> | 
| 13 | <meta name='generator' content='X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit'/> | 
| 14 | <meta name='license' content='../../license.html'/> | 
| 15 | </head> | 
 DEF nodes index: 
               
               BEAM_CALCULATE,
BEAM_CONTROL,
CONE_COLOR,
DETECTION,
LockedDownInterface2D,
SOLID_SWITCH,
WIRE_COLOR,
WIREFRAME_SWITCH
               
               
                  DEF nodes index: 
               
               BEAM_CALCULATE,
BEAM_CONTROL,
CONE_COLOR,
DETECTION,
LockedDownInterface2D,
SOLID_SWITCH,
WIRE_COLOR,
WIREFRAME_SWITCH
| 16 | <Scene> | 
| 17 | <NavigationInfo DEF='LockedDownInterface2D' type='"NONE"'/> | 
| 18 | <Background skyColor='0 0.3 0.5'/> | 
| 19 | <WorldInfo info='"Produce wireframe or transparent beam cones"' title='BeamConeProto'/> | 
| 20 | <Viewpoint description='Beam Cone' position='0 0 15'/> | 
| 21 | <ProtoDeclare name='BeamCone' appinfo='Produce wireframe or transparent beam cones. Typical uses include propeller/thruster water flow or line-of-sight sonar/radar/light beams. Negative range values invert base and apex at same relative location. Default: beam with apex at (0 0 0) and base of radius 1 in x-z plane at (1 0 0).'> | 
| 22 | <ProtoInterface> | 
| 23 | <field name='name' type='SFString' value='(unnamed)' accessType='initializeOnly' appinfo='BeamCone name aids in node identification and tracing'/> | 
| 24 | <field name='contact' type='SFBool' accessType='inputOnly' appinfo='(communications) is transmitted signal in contact with receiver or (sensor) is a target return detected?'/> | 
| 25 | <field name='range' type='SFFloat' accessType='inputOnly' appinfo='distance in meters along x axis'/> | 
| 26 | <field name='defaultRange' type='SFFloat' value='1' accessType='initializeOnly' appinfo='distance in meters used until eventIn range sent'/> | 
| 27 | <field name='wireframe' type='SFBool' value='true' accessType='initializeOnly' appinfo='whether wireframe beam is drawn'/> | 
| 28 | <field name='solid' type='SFBool' value='true' accessType='initializeOnly' appinfo='whether solid beam is drawn'/> | 
| 29 | <field name='beamHeightDegrees' type='SFFloat' value='10' accessType='initializeOnly' appinfo='degrees across vertical y axis'/> | 
| 30 | <field name='beamWidthDegrees' type='SFFloat' value='10' accessType='initializeOnly' appinfo='degrees across horizontal z axis'/> | 
| 31 | <field name='contactColor' type='SFColor' value='.8 .1 .1' accessType='initializeOnly' appinfo='rendering color when contact=true'/> | 
| 32 | <field name='noContactColor' type='SFColor' value='.3 .5 .5' accessType='initializeOnly' appinfo='rendering color when contact=false'/> | 
| 33 | <field name='transparency' type='SFFloat' value='0' accessType='inputOutput' appinfo='1 = fully transparent wireframe only'/> | 
| 34 | <field name='traceEnabled' type='SFBool' value='false' accessType='initializeOnly' appinfo='flag to turn on Script tracing'/> | 
| 35 | <!-- BEAM_CONTROL beam scaling is controlled by range/beamHeightDegrees/beamWidthDegrees/direction inputs --> | 
| 36 | </ProtoInterface> | 
| 37 | <ProtoBody> | 
| 38 | 
                    <!-- ROUTE information for BEAM_CONTROL node: 
[from BEAM_CALCULATE.beamScale to scale
                                    ]
[from BEAM_CALCULATE.direction to rotation
                                    ]
[from BEAM_CALCULATE.reverseOffset to translation
                                    ]
 --> <Transform DEF='BEAM_CONTROL'> | 
| 39 | 
                         <!-- ROUTE information for WIREFRAME_SWITCH node: 
[from DETECTION.wireframeChoice to whichChoice
                                          ]
 --> <Switch DEF='WIREFRAME_SWITCH' whichChoice='0'> | 
| 40 | <WorldInfo info='"initial choice is null node (WorldInfo), meaning no wireframe beam"'/> | 
| 41 | <Shape> | 
| 42 | <Appearance> | 
| 43 | 
                                        <!-- ROUTE information for WIRE_COLOR node: 
[from DETECTION.beamColor to emissiveColor
                                                            ]
 --> <Material DEF='WIRE_COLOR' diffuseColor='.1 .1 .1' emissiveColor='.1 .1 .1'> | 
| 44 | <IS> | 
| 45 | <connect nodeField='transparency' protoField='transparency'/> | 
| 46 | </IS> | 
| 47 | </Material> | 
| 48 | </Appearance> | 
| 49 | <IndexedLineSet coordIndex='0 13 -1 1 2 3 4 5 6 7 8 9 10 11 12 1 -1 0 1 -1 0 2 -1 0 3 -1 0 4 -1 0 5 -1 0 6 -1 0 7 -1 0 8 -1 0 9 -1 0 10 -1 0 11 -1 0 12 -1'> | 
| 50 | <Coordinate point='0 0 0 1 1 0 1 0.86 0.50 1 0.50 0.86 1 0 1.0 1 -0.50 0.86 1 -0.86 0.50 1 -1 0 1 -0.86 -0.50 1 -0.50 -0.86 1 0 -1.0 1 0.50 -0.86 1 0.86 -0.50 1 0 0'/> | 
| 51 | </IndexedLineSet> | 
| 52 | </Shape> | 
| 53 | </Switch> | 
| 54 | 
                         <!-- ROUTE information for SOLID_SWITCH node: 
[from DETECTION.solidChoice to whichChoice
                                          ]
 --> <Switch DEF='SOLID_SWITCH' whichChoice='0'> | 
| 55 | <WorldInfo info='"initial choice is null node (WorldInfo), meaning no solid beam"'/> | 
| 56 | <Transform rotation='0 0 1 1.57079' translation='.5 0 0'> | 
| 57 | <Shape> | 
| 58 | <Appearance> | 
| 59 | 
                                             <!-- ROUTE information for CONE_COLOR node: 
[from DETECTION.beamColor to emissiveColor
                                                                  ]
 --> <Material DEF='CONE_COLOR' diffuseColor='.1 .1 .1'> | 
| 60 | <IS> | 
| 61 | <connect nodeField='transparency' protoField='transparency'/> | 
| 62 | </IS> | 
| 63 | </Material> | 
| 64 | </Appearance> | 
| 65 | <!-- solid='false' is harder to recognize properly, use default solid='true' --> | 
| 66 | <Cone bottom='false' height='1'/> | 
| 67 | </Shape> | 
| 68 | </Transform> | 
| 69 | </Switch> | 
| 70 | </Transform> | 
| 71 | <!-- Non-renderable animation controls --> | 
| 72 | 
                    <!-- ROUTE information for DETECTION node: 
[from beamColor to WIRE_COLOR.emissiveColor
                                    ]
[from beamColor to CONE_COLOR.emissiveColor
                                    ]
[from wireframeChoice to WIREFRAME_SWITCH.whichChoice
                                    ]
[from solidChoice to SOLID_SWITCH.whichChoice
                                    ]
 --> <Script DEF='DETECTION'> | 
| 73 | <field name='name' type='SFString' accessType='initializeOnly' appinfo='BeamCone name aids tracing'/> | 
| 74 | <field name='contact' type='SFBool' accessType='inputOnly'/> | 
| 75 | <field name='wireframe' type='SFBool' accessType='initializeOnly'/> | 
| 76 | <field name='solid' type='SFBool' accessType='initializeOnly'/> | 
| 77 | <field name='contactColor' type='SFColor' accessType='initializeOnly'/> | 
| 78 | <field name='noContactColor' type='SFColor' accessType='initializeOnly'/> | 
| 79 | <field name='beamColor' type='SFColor' accessType='outputOnly'/> | 
| 80 | <field name='wireframeChoice' type='SFInt32' accessType='outputOnly'/> | 
| 81 | <field name='solidChoice' type='SFInt32' accessType='outputOnly'/> | 
| 82 | <field name='traceEnabled' type='SFBool' accessType='initializeOnly' appinfo='internal flag to turn on Script tracing'/> | 
| 83 | <IS> | 
| 84 | <connect nodeField='name' protoField='name'/> | 
| 85 | <connect nodeField='contact' protoField='contact'/> | 
| 86 | <connect nodeField='wireframe' protoField='wireframe'/> | 
| 87 | <connect nodeField='solid' protoField='solid'/> | 
| 88 | <connect nodeField='contactColor' protoField='contactColor'/> | 
| 89 | <connect nodeField='noContactColor' protoField='noContactColor'/> | 
| 90 | <connect nodeField='traceEnabled' protoField='traceEnabled'/> | 
| 91 | </IS> | 
| 
                                             <![CDATA[
                                          
          
ecmascript:
function initialize ()
{
	beamColor = noContactColor;
	if (wireframe == true) wireframeChoice = 1;
	if (solid     == true) solidChoice     = 1;
	if (traceEnabled)
	{
//		Browser.println ('[BeamCone ' + name + '] trace=' + trace);
		Browser.println ('[BeamCone ' + name + '] wireframeChoice=' + wireframeChoice + ', solidChoice=' + solidChoice);
		Browser.println ('[BeamCone ' + name + '] contactColor=' + contactColor.toString() + ', noContactColor=' + noContactColor.toString());
	}
}
function contact (newDetect, timeStamp)
{
	if (newDetect) beamColor = contactColor;
	else           beamColor = noContactColor;
	if (traceEnabled) Browser.println ('[BeamCone ' + name + '] contact=' + newDetect + ', beamColor=' + beamColor.toString());
}
        
                                             ]]>
                                           | |
| 93 | </Script> | 
| 94 | 
                    <!-- ROUTE information for BEAM_CALCULATE node: 
[from beamScale to BEAM_CONTROL.scale
                                    ]
[from direction to BEAM_CONTROL.rotation
                                    ]
[from reverseOffset to BEAM_CONTROL.translation
                                    ]
 --> <Script DEF='BEAM_CALCULATE'> | 
| 95 | <field name='range' type='SFFloat' accessType='inputOnly'/> | 
| 96 | <field name='defaultRange' type='SFFloat' accessType='initializeOnly'/> | 
| 97 | <field name='beamHeightDegrees' type='SFFloat' accessType='initializeOnly'/> | 
| 98 | <field name='beamWidthDegrees' type='SFFloat' accessType='initializeOnly'/> | 
| 99 | <field name='beamScale' type='SFVec3f' accessType='outputOnly'/> | 
| 100 | <field name='direction' type='SFRotation' accessType='outputOnly'/> | 
| 101 | <field name='reverseOffset' type='SFVec3f' accessType='outputOnly'/> | 
| 102 | <IS> | 
| 103 | <connect nodeField='range' protoField='range'/> | 
| 104 | <connect nodeField='defaultRange' protoField='defaultRange'/> | 
| 105 | <connect nodeField='beamHeightDegrees' protoField='beamHeightDegrees'/> | 
| 106 | <connect nodeField='beamWidthDegrees' protoField='beamWidthDegrees'/> | 
| 107 | </IS> | 
| 
                                             <![CDATA[
                                          
          
ecmascript:
function initialize () {
 // Note that X3D scale factor triplets all equal to zero are not allowed
 if (defaultRange == 0)      defaultRange = .0001;
 if (beamHeightDegrees == 0) beamHeightDegrees = .0001;
 if (beamWidthDegrees  == 0) beamWidthDegrees  = .0001;
 beamHeightFactor= Math.sin ((beamHeightDegrees * 3.141592653 / 180.0) / 2.0);
 beamWidthFactor = Math.sin ((beamWidthDegrees  * 3.141592653 / 180.0) / 2.0);
 beamScale = new SFVec3f ( defaultRange, defaultRange * beamHeightFactor, defaultRange * beamWidthFactor);
}
function range (newRange, timeStamp) {
 beamHeightFactor= Math.sin ((beamHeightDegrees * 3.141592653 / 180.0) / 2.0);
 beamWidthFactor = Math.sin ((beamWidthDegrees  * 3.141592653 / 180.0) / 2.0);
 if (newRange < 0)
 {
   direction     = new SFRotation (0, 1, 0, 3.141592653);
   reverseOffset = new SFVec3f (- newRange, 0, 0);
   beamScale = new SFVec3f (-newRange, -newRange * beamHeightFactor, -newRange * beamWidthFactor);
 }
 else if (newRange == 0)
 {
   direction     = new SFRotation (0, 1, 0, 0);
   reverseOffset = new SFVec3f (0, 0, 0);
   beamScale = new SFVec3f ( .0001, .0001, .0001 );
 }
 else
 {
   direction     = new SFRotation (0, 1, 0, 0);
   reverseOffset = new SFVec3f (0, 0, 0);
   beamScale = new SFVec3f (newRange, newRange * beamHeightFactor, newRange * beamWidthFactor);
 }
}
        
                                             ]]>
                                           | |
| 109 | </Script> | 
| 110 | < ROUTE fromNode='DETECTION' fromField='beamColor' toNode='WIRE_COLOR' toField='emissiveColor'/> | 
| 111 | < ROUTE fromNode='DETECTION' fromField='beamColor' toNode='CONE_COLOR' toField='emissiveColor'/> | 
| 112 | < ROUTE fromNode='DETECTION' fromField='wireframeChoice' toNode='WIREFRAME_SWITCH' toField='whichChoice'/> | 
| 113 | < ROUTE fromNode='DETECTION' fromField='solidChoice' toNode='SOLID_SWITCH' toField='whichChoice'/> | 
| 114 | < ROUTE fromNode='BEAM_CALCULATE' fromField='beamScale' toNode='BEAM_CONTROL' toField='scale'/> | 
| 115 | < ROUTE fromNode='BEAM_CALCULATE' fromField='direction' toNode='BEAM_CONTROL' toField='rotation'/> | 
| 116 | < ROUTE fromNode='BEAM_CALCULATE' fromField='reverseOffset' toNode='BEAM_CONTROL' toField='translation'/> | 
| 117 | </ProtoBody> | 
| 118 | </ProtoDeclare> | 
| 119 | <!-- Viewable geometry for this scene is anchored text that links to an example showing ExternProtoDeclare usage of BeamCone --> | 
| 120 | <Anchor description='Beam Cone Example' url=' "BeamConeExample.x3d" "https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConeExample.x3d" "BeamConeExample.wrl" "https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConeExample.wrl" '> | 
| 121 | <Shape> | 
| 122 | <Appearance> | 
| 123 | <Material diffuseColor='0 1 1' emissiveColor='0 1 1'/> | 
| 124 | </Appearance> | 
| 125 | <Text string='"BeamConePrototype" "is a Prototype definition file." "" "To see an example scene" "click this text and view" "BeamConeExample."'> | 
| 126 | <FontStyle justify='"MIDDLE" "MIDDLE"'/> | 
| 127 | </Text> | 
| 128 | </Shape> | 
| 129 | <Shape> | 
| 130 | <!-- transparent Box as text-selection assist --> | 
| 131 | <Box size='11 6 .001'/> | 
| 132 | <Appearance> | 
| 133 | <Material transparency='1'/> | 
| 134 | </Appearance> | 
| 135 | </Shape> | 
| 136 | </Anchor> | 
| 137 | </Scene> | 
| 138 | </X3D> | 
 DEF nodes index: 
         
         BEAM_CALCULATE,
BEAM_CONTROL,
CONE_COLOR,
DETECTION,
LockedDownInterface2D,
SOLID_SWITCH,
WIRE_COLOR,
WIREFRAME_SWITCH
         
         
            DEF nodes index: 
         
         BEAM_CALCULATE,
BEAM_CONTROL,
CONE_COLOR,
DETECTION,
LockedDownInterface2D,
SOLID_SWITCH,
WIRE_COLOR,
WIREFRAME_SWITCH
Event Graph ROUTE Table entries with 7 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 | BEAM_CONTROL Transform scale SFVec3f | |
| BEAM_CALCULATE Script direction SFRotation | BEAM_CONTROL Transform rotation SFRotation | |
| BEAM_CALCULATE Script reverseOffset SFVec3f | BEAM_CONTROL Transform translation SFVec3f | 
| DETECTION Script beamColor SFColor | WIRE_COLOR Material emissiveColor SFColor | |
| DETECTION Script beamColor SFColor | CONE_COLOR Material emissiveColor SFColor | |
| DETECTION Script wireframeChoice SFInt32 | WIREFRAME_SWITCH Switch whichChoice SFInt32 | |
| DETECTION Script solidChoice SFInt32 | SOLID_SWITCH Switch whichChoice SFInt32 | 
| line 120 Anchor | description='Beam Cone Example' User-interaction hint for this node. | 
         <!--
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>
 -->
      
         
             <!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->
         
         <!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->