X3D Model Documentation: BeamCylinderPrototype.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='BeamCylinderPrototype.x3d'/>
  6            <meta name='creator' content='Don Brutzman'/>
  7            <meta name='created' content='25 February 2001'/>
  8            <meta name='modified' content='20 October 2019'/>
  9            <meta name='description' content='Produce wireframe or transparent beam cylinders.'/>
 10            <meta name='identifier' content='https://savage.nps.edu/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototype.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, CYLINDER_COLOR, DETECTION, LockedDownInterface2D, SOLID_SWITCH, WIRE_COLOR, WIREFRAME_SWITCH

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definition: BeamCylinder
-->
 14       <Scene>
 15            <NavigationInfo DEF='LockedDownInterface2D' type='"NONE"'/>
 16            <Background skyColor='0 0.3 0.5'/>
 17            <WorldInfo info='"Produce wireframe or transparent beam cylinders."' title='BeamCylinderProto'/>
 18            <Viewpoint description='Beam Cylinder' position='0 0 15'/>
 19            <ProtoDeclare name='BeamCylinder' appinfo='Produce wireframe or transparent beam cylinders. 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).'>
 20                 <ProtoInterface>
 21                      <field name='name' type='SFString' value='(unnamed)' accessType='initializeOnly'
                     appinfo='Assigning a name to a BeamCylinder aids tracing'/>
 22                      <field name='contact' type='SFBool' accessType='inputOnly'
                     appinfo='(communications) is transmitted signal in contact with receiver or (sensor) is a target return detected?'/>
 23                      <field name='range' type='SFFloat' accessType='inputOnly'
                     appinfo='distance in meters along x axis'/>
 24                      <field name='defaultRange' type='SFFloat' value='1' accessType='initializeOnly'
                     appinfo='distance in meters used until eventIn range sent'/>
 25                      <field name='wireframe' type='SFBool' value='true' accessType='initializeOnly'
                     appinfo='whether wireframe beam is drawn'/>
 26                      <field name='solid' type='SFBool' value='true' accessType='initializeOnly'
                     appinfo='whether solid beam is drawn'/>
 27                      <field name='beamHeight' type='SFFloat' value='1' accessType='initializeOnly'
                     appinfo='meters across vertical y axis'/>
 28                      <field name='beamWidth' type='SFFloat' value='1' accessType='initializeOnly'
                     appinfo='meters across horizontal z axis'/>
 29                      <field name='contactColor' type='SFColor' value='.8 .1 .1' accessType='initializeOnly'
                     appinfo='rendering color when contact=true'/>
 30                      <field name='noContactColor' type='SFColor' value='.3 .5 .5' accessType='initializeOnly'
                     appinfo='rendering color when contact=false'/>
 31                      <field name='transparency' type='SFFloat' value='0' accessType='inputOutput'
                     appinfo='1 = fully transparent wireframe only'/>
 32                      <!-- BEAM_CONTROL beam scaling is controlled by range/beamHeightDegrees/beamWidthDegrees/direction inputs -->
 33                 </ProtoInterface>
 34                 <ProtoBody>
 35 
                    <!-- 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'>
 36 
                         <!-- ROUTE information for WIREFRAME_SWITCH node:  [from DETECTION.wireframeChoice to whichChoice ] -->
                         <Switch DEF='WIREFRAME_SWITCH' whichChoice='0'>
 37                                <WorldInfo info='"initial choice is null node (WorldInfo), meaning no wireframe beam"'/>
 38                                <Shape>
 39                                     <Appearance>
 40 
                                        <!-- ROUTE information for WIRE_COLOR node:  [from DETECTION.beamColor to emissiveColor ] -->
                                        <Material DEF='WIRE_COLOR' diffuseColor='.1 .1 .1' emissiveColor='.1 .1 .1'>
 41                                               <IS>
 42                                                    <connect nodeField='transparency' protoField='transparency'/>
 43                                               </IS>
 44                                          </Material>
 45                                     </Appearance>
 46                                     <IndexedLineSet coordIndex='0 13 -1 1 14 -1 2 15 -1 3 16 -1 4 17 -1 5 18 -1 6 19 -1 7 20 -1 8 21 -1 9 22 -1 10 23 -1 11 24 -1 12 25 -1 13 14 15 16 17 18 19 20 21 22 23 24 13 -1 0 1 2 3 4 5 6 7 8 9 10 11 0 -1'>
 47                                          <Coordinate point='0 1 0 0 0.86 0.50 0 0.50 0.86 0 0 1.0 0 -0.50 0.86 0 -0.86 0.50 0 -1 0 0 -0.86 -0.50 0 -0.50 -0.86 0 0 -1.0 0 0.50 -0.86 0 0.86 -0.50 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'/>
 48                                     </IndexedLineSet>
 49                                </Shape>
 50                           </Switch>
 51 
                         <!-- ROUTE information for SOLID_SWITCH node:  [from DETECTION.solidChoice to whichChoice ] -->
                         <Switch DEF='SOLID_SWITCH' whichChoice='0'>
 52                                <WorldInfo info='"initial choice is null node (WorldInfo), meaning no solid beam"'/>
 53                                <Transform rotation='0 0 1 1.57079' translation='.5 0 0'>
 54                                     <Shape>
 55                                          <Appearance>
 56 
                                             <!-- ROUTE information for CYLINDER_COLOR node:  [from DETECTION.beamColor to emissiveColor ] -->
                                             <Material DEF='CYLINDER_COLOR' diffuseColor='.1 .1 .1'>
 57                                                    <IS>
 58                                                         <connect nodeField='transparency' protoField='transparency'/>
 59                                                    </IS>
 60                                               </Material>
 61                                          </Appearance>
 62                                          <!-- solid='false' is harder to recognize properly, use default solid='true' -->
 63                                          <Cylinder height='1'/>
 64                                     </Shape>
 65                                </Transform>
 66                           </Switch>
 67                      </Transform>
 68                      <!-- Non-rendered animation controls -->
 69 
                    <!-- ROUTE information for DETECTION node:  [from beamColor to WIRE_COLOR.emissiveColor ] [from beamColor to CYLINDER_COLOR.emissiveColor ] [from wireframeChoice to WIREFRAME_SWITCH.whichChoice ] [from solidChoice to SOLID_SWITCH.whichChoice ] -->
                    <Script DEF='DETECTION'>
 70                           <field name='name' type='SFString' accessType='initializeOnly'/>
 71                           <field name='contact' type='SFBool' accessType='inputOnly'/>
 72                           <field name='wireframe' type='SFBool' accessType='initializeOnly'/>
 73                           <field name='solid' type='SFBool' accessType='initializeOnly'/>
 74                           <field name='contactColor' type='SFColor' accessType='initializeOnly'/>
 75                           <field name='noContactColor' type='SFColor' accessType='initializeOnly'/>
 76                           <field name='beamColor' type='SFColor' accessType='outputOnly'/>
 77                           <field name='wireframeChoice' type='SFInt32' accessType='outputOnly'/>
 78                           <field name='solidChoice' type='SFInt32' accessType='outputOnly'/>
 79                           <field name='traceEnabled' type='SFBool' value='true' accessType='initializeOnly'
                          appinfo='internal flag to turn on Script tracing'/>
 80                           <IS>
 81                                <connect nodeField='name' protoField='name'/>
 82                                <connect nodeField='contact' protoField='contact'/>
 83                                <connect nodeField='wireframe' protoField='wireframe'/>
 84                                <connect nodeField='solid' protoField='solid'/>
 85                                <connect nodeField='contactColor' protoField='contactColor'/>
 86                                <connect nodeField='noContactColor' protoField='noContactColor'/>
 87                           </IS>
  <![CDATA[
          
ecmascript:
function initialize ()
{
	beamColor = noContactColor;
	if (wireframe == true) wireframeChoice = 1;
	if (solid     == true) solidChoice     = 1;
	if (traceEnabled)
	{
//	Browser.println ('[BeamCylinder.DETECTION ' + name + '] trace=' + trace);
	Browser.println ('[BeamCylinder.DETECTION ' + name + '] wireframeChoice=' + wireframeChoice + ', solidChoice=' + solidChoice);
	Browser.println ('[BeamCylinder.DETECTION ' + name + '] contactColor=' + contactColor.toString() + ', noContactColor=' + noContactColor.toString());
	}
}
function contact (newDetect, timeStamp)
{
	if (newDetect) beamColor = contactColor;
	else           beamColor = noContactColor;
	if (traceEnabled) Browser.println ('[BeamCylinder.DETECTION ' + name + '] contact=' + newDetect + ', beamColor=' + beamColor.toString());
}

        
]]>
 89                      </Script>
 90 
                    <!-- 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'>
 91                           <field name='name' type='SFString' accessType='initializeOnly'/>
 92                           <field name='range' type='SFFloat' accessType='inputOnly'/>
 93                           <field name='defaultRange' type='SFFloat' accessType='initializeOnly'/>
 94                           <field name='beamHeight' type='SFFloat' accessType='initializeOnly'/>
 95                           <field name='beamWidth' type='SFFloat' accessType='initializeOnly'/>
 96                           <field name='beamScale' type='SFVec3f' accessType='outputOnly'/>
 97                           <field name='direction' type='SFRotation' accessType='outputOnly'/>
 98                           <field name='reverseOffset' type='SFVec3f' accessType='outputOnly'/>
 99                           <field name='traceEnabled' type='SFBool' value='true' accessType='initializeOnly'
                          appinfo='internal flag to turn on Script tracing'/>
100                           <IS>
101                                <connect nodeField='name' protoField='name'/>
102                                <connect nodeField='range' protoField='range'/>
103                                <connect nodeField='defaultRange' protoField='defaultRange'/>
104                                <connect nodeField='beamHeight' protoField='beamHeight'/>
105                                <connect nodeField='beamWidth' protoField='beamWidth'/>
106                           </IS>
  <![CDATA[
          
ecmascript:
function initialize () {
 // Note that VRML scale factor triplets all equal to zero are not allowed
 if (defaultRange == 0) defaultRange = .0001;
 if (beamHeight   == 0) beamHeight = .0001;
 if (beamWidth    == 0) beamWidth  = .0001;
 beamScale = new SFVec3f ( defaultRange, beamHeight, beamWidth);
}
function range (newRange, timeStamp) {
 if (newRange < 0)
 {
   direction     = new SFRotation (0, 1, 0, 3.141592653);
   reverseOffset = new SFVec3f (- newRange, 0, 0);
   beamScale = new SFVec3f (-newRange, beamHeight, beamWidth);
 }
 else if (newRange == 0)
 {
   direction     = new SFRotation (0, 1, 0, 0);
   reverseOffset = new SFVec3f (0, 0, 0);
   beamScale = new SFVec3f ( .0001, .0001, .0001 );  // zero scale is illegal
 }
 else
 {
   direction     = new SFRotation (0, 1, 0, 0);
   reverseOffset = new SFVec3f (0, 0, 0);
   beamScale = new SFVec3f (newRange, beamHeight, beamWidth);
 }
 if (traceEnabled)
 {
//	Browser.println ('[BeamCylinder.BEAM_CALCULATE ' + name + '] trace=' + trace);
	Browser.println ('[BeamCylinder.BEAM_CALCULATE ' + name + '] newRange=' + newRange + ', direction=' + direction.toString());
	Browser.println ('[BeamCylinder.BEAM_CALCULATE ' + name + '] reverseOffset=' + reverseOffset.toString() + ', beamScale=' + beamScale.toString());
 }
}

        
]]>
108                      </Script>
109                      < ROUTE  fromNode='DETECTION' fromField='beamColor' toNode='WIRE_COLOR' toField='emissiveColor'/>
110                      < ROUTE  fromNode='DETECTION' fromField='beamColor' toNode='CYLINDER_COLOR' toField='emissiveColor'/>
111                      < ROUTE  fromNode='DETECTION' fromField='wireframeChoice' toNode='WIREFRAME_SWITCH' toField='whichChoice'/>
112                      < ROUTE  fromNode='DETECTION' fromField='solidChoice' toNode='SOLID_SWITCH' toField='whichChoice'/>
113                      < ROUTE  fromNode='BEAM_CALCULATE' fromField='beamScale' toNode='BEAM_CONTROL' toField='scale'/>
114                      < ROUTE  fromNode='BEAM_CALCULATE' fromField='direction' toNode='BEAM_CONTROL' toField='rotation'/>
115                      < ROUTE  fromNode='BEAM_CALCULATE' fromField='reverseOffset' toNode='BEAM_CONTROL' toField='translation'/>
116                 </ProtoBody>
117            </ProtoDeclare>
118            <!-- Viewable geometry for this scene is anchored text that links to an example showing ExternProtoDeclare usage of BeamCylinder -->
119            <Anchor description='Beam Cylinder Example'   url=' "BeamCylinderExample.x3d" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Beam/BeamCylinderExample.x3d" "BeamCylinderExample.wrl" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Beam/BeamCylinderExample.wrl" '>
120                 <Shape>
121                      <Appearance>
122                           <Material diffuseColor='0 1 1' emissiveColor='0 1 1'/>
123                      </Appearance>
124                      <Text string='"BeamCylinderPrototype" "is a Prototype definition file." "" "To see an example scene" "click this text and view" "BeamCylinderExample."'>
125                           <FontStyle justify='"MIDDLE" "MIDDLE"'/>
126                      </Text>
127                 </Shape>
128                 <Shape>
129                      <!-- transparent Box as text-selection assist -->
130                      <Box size='11 6 .001'/>
131                      <Appearance>
132                           <Material transparency='1'/>
133                      </Appearance>
134                 </Shape>
135            </Anchor>
136       </Scene>
137  </X3D>
<!--

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

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definition: BeamCylinder
-->
X3D Tooltips element index: Anchor, Appearance, Background, Box, connect, Coordinate, Cylinder, 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)
CYLINDER_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 119
Anchor
description='Beam Cylinder 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/Beam/BeamCylinderPrototypeIndex.html -->
<!-- Version control at
https://gitlab.nps.edu/Savage/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototype.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. -->