X3D Model Documentation: BeamConePrototype.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='titlecontent=' BeamConePrototype.x3d '/>
  6            <meta name='creatorcontent='Don Brutzman'/>
  7            <meta name='createdcontent='7 December 2000'/>
  8            <meta name='modifiedcontent='12 October 2023'/>
  9            <meta name='descriptioncontent='Produce wireframe or transparent beam cones.'/>
 10            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConePrototype.x3d '/>
 11            <meta name='referencecontent=' http://faculty.nps.edu/brutzman/vrtp/demo/auv/BeamConePrototype.x3d '/>
 12            <meta name='referencecontent=' https://www.web3d.org/WorkingGroups/vrtp/demo/auv/BeamConePrototype.x3d '/>
 13            <meta name='generatorcontent='X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 14            <meta name='licensecontent='../../license.html'/>
 15       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: BEAM_CALCULATE, BEAM_CONTROL, CONE_COLOR, DETECTION, LockedDownInterface2D, SOLID_SWITCH, WIRE_COLOR, WIREFRAME_SWITCH

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definition: BeamCone
-->
 16       <Scene>
 17            <NavigationInfo DEF='LockedDownInterface2Dtype='"NONE"'/>
 18            <Background skyColor='0 0.3 0.5'/>
 19            <WorldInfo info='"Produce wireframe or transparent beam cones"title='BeamConeProto'/>
 20            <Viewpoint description='Beam Coneposition='0 0 15'/>
 21            <ProtoDeclare name='BeamConeappinfo='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='nametype='SFStringvalue='(unnamed)accessType='initializeOnly'
                     appinfo='BeamCone name aids in node identification and tracing'/>
 24                      <field name='contacttype='SFBoolaccessType='inputOnly'
                     appinfo='(communications) is transmitted signal in contact with receiver or (sensor) is a target return detected?'/>
 25                      <field name='rangetype='SFFloataccessType='inputOnly'
                     appinfo='distance in meters along x axis'/>
 26                      <field name='defaultRangetype='SFFloatvalue='1accessType='initializeOnly'
                     appinfo='distance in meters used until eventIn range sent'/>
 27                      <field name='wireframetype='SFBoolvalue='trueaccessType='initializeOnly'
                     appinfo='whether wireframe beam is drawn'/>
 28                      <field name='solidtype='SFBoolvalue='trueaccessType='initializeOnly'
                     appinfo='whether solid beam is drawn'/>
 29                      <field name='beamHeightDegreestype='SFFloatvalue='10accessType='initializeOnly'
                     appinfo='degrees across vertical y axis'/>
 30                      <field name='beamWidthDegreestype='SFFloatvalue='10accessType='initializeOnly'
                     appinfo='degrees across horizontal z axis'/>
 31                      <field name='contactColortype='SFColorvalue='.8 .1 .1accessType='initializeOnly'
                     appinfo='rendering color when contact=true'/>
 32                      <field name='noContactColortype='SFColorvalue='.3 .5 .5accessType='initializeOnly'
                     appinfo='rendering color when contact=false'/>
 33                      <field name='transparencytype='SFFloatvalue='0accessType='inputOutput'
                     appinfo='1 = fully transparent wireframe only'/>
 34                      <field name='traceEnabledtype='SFBoolvalue='falseaccessType='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_SWITCHwhichChoice='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_COLORdiffuseColor='.1 .1 .1emissiveColor='.1 .1 .1'>
 44                                               <IS>
 45                                                    <connect nodeField='transparencyprotoField='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_SWITCHwhichChoice='0'>
 55                                <WorldInfo info='"initial choice is null node (WorldInfo), meaning no solid beam"'/>
 56                                <Transform rotation='0 0 1 1.57079translation='.5 0 0'>
 57                                     <Shape>
 58                                          <Appearance>
 59 
                                             <!-- ROUTE information for CONE_COLOR node:  [from DETECTION.beamColor to emissiveColor ] -->
                                             <Material DEF='CONE_COLORdiffuseColor='.1 .1 .1'>
 60                                                    <IS>
 61                                                         <connect nodeField='transparencyprotoField='transparency'/>
 62                                                    </IS>
 63                                               </Material>
 64                                          </Appearance>
 65                                          <!-- solid='false' is harder to recognize properly, use default solid='true' -->
 66                                          <Cone bottom='falseheight='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='nametype='SFStringaccessType='initializeOnly'
                          appinfo='BeamCone name aids tracing'/>
 74                           <field name='contacttype='SFBoolaccessType='inputOnly'/>
 75                           <field name='wireframetype='SFBoolaccessType='initializeOnly'/>
 76                           <field name='solidtype='SFBoolaccessType='initializeOnly'/>
 77                           <field name='contactColortype='SFColoraccessType='initializeOnly'/>
 78                           <field name='noContactColortype='SFColoraccessType='initializeOnly'/>
 79                           <field name='beamColortype='SFColoraccessType='outputOnly'/>
 80                           <field name='wireframeChoicetype='SFInt32accessType='outputOnly'/>
 81                           <field name='solidChoicetype='SFInt32accessType='outputOnly'/>
 82                           <field name='traceEnabledtype='SFBoolaccessType='initializeOnly'
                          appinfo='internal flag to turn on Script tracing'/>
 83                           <IS>
 84                                <connect nodeField='nameprotoField='name'/>
 85                                <connect nodeField='contactprotoField='contact'/>
 86                                <connect nodeField='wireframeprotoField='wireframe'/>
 87                                <connect nodeField='solidprotoField='solid'/>
 88                                <connect nodeField='contactColorprotoField='contactColor'/>
 89                                <connect nodeField='noContactColorprotoField='noContactColor'/>
 90                                <connect nodeField='traceEnabledprotoField='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='rangetype='SFFloataccessType='inputOnly'/>
 96                           <field name='defaultRangetype='SFFloataccessType='initializeOnly'/>
 97                           <field name='beamHeightDegreestype='SFFloataccessType='initializeOnly'/>
 98                           <field name='beamWidthDegreestype='SFFloataccessType='initializeOnly'/>
 99                           <field name='beamScaletype='SFVec3faccessType='outputOnly'/>
100                           <field name='directiontype='SFRotationaccessType='outputOnly'/>
101                           <field name='reverseOffsettype='SFVec3faccessType='outputOnly'/>
102                           <IS>
103                                <connect nodeField='rangeprotoField='range'/>
104                                <connect nodeField='defaultRangeprotoField='defaultRange'/>
105                                <connect nodeField='beamHeightDegreesprotoField='beamHeightDegrees'/>
106                                <connect nodeField='beamWidthDegreesprotoField='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 1emissiveColor='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>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: BEAM_CALCULATE, BEAM_CONTROL, CONE_COLOR, DETECTION, LockedDownInterface2D, SOLID_SWITCH, WIRE_COLOR, WIREFRAME_SWITCH

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definition: BeamCone
-->
X3D Tooltips element index: Anchor, Appearance, Background, Box, Cone, connect, Coordinate, field, FontStyle, head, 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 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

ROUTE
event to
(1)
BEAM_CONTROL
Transform
scale
SFVec3f
BEAM_CALCULATE
Script
direction
SFRotation

ROUTE
event to
(1)
BEAM_CONTROL
Transform
rotation
SFRotation
BEAM_CALCULATE
Script
reverseOffset
SFVec3f

ROUTE
event to
(1)
BEAM_CONTROL
Transform
translation
SFVec3f

DETECTION
Script
beamColor
SFColor

ROUTE
event to
(1)
WIRE_COLOR
Material
emissiveColor
SFColor
DETECTION
Script
beamColor
SFColor

ROUTE
event to
(1)
CONE_COLOR
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 120
Anchor
description='Beam Cone 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://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConePrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConePrototype.x3d -->

<!-- Color-coding legend: X3D terminology <X3dNode  DEF='idNamefield='value'/> matches XML terminology <XmlElement  DEF='idNameattribute='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. -->