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='titlecontent=' BeamCylinderPrototype.x3d '/>
  6            <meta name='creatorcontent='Don Brutzman'/>
  7            <meta name='createdcontent='25 February 2001'/>
  8            <meta name='modifiedcontent='20 October 2019'/>
  9            <meta name='descriptioncontent='Produce wireframe or transparent beam cylinders.'/>
 10            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototype.x3d '/>
 11            <meta name='generatorcontent='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 12            <meta name='licensecontent='../../license.html'/>
 13       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: 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='LockedDownInterface2Dtype='"NONE"'/>
 16            <Background skyColor='0 0.3 0.5'/>
 17            <WorldInfo info='"Produce wireframe or transparent beam cylinders."title='BeamCylinderProto'/>
 18            <Viewpoint description='Beam Cylinderposition='0 0 15'/>
 19            <ProtoDeclare name='BeamCylinderappinfo='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='nametype='SFStringvalue='(unnamed)accessType='initializeOnly'
                     appinfo='Assigning a name to a BeamCylinder aids tracing'/>
 22                      <field name='contacttype='SFBoolaccessType='inputOnly'
                     appinfo='(communications) is transmitted signal in contact with receiver or (sensor) is a target return detected?'/>
 23                      <field name='rangetype='SFFloataccessType='inputOnly'
                     appinfo='distance in meters along x axis'/>
 24                      <field name='defaultRangetype='SFFloatvalue='1accessType='initializeOnly'
                     appinfo='distance in meters used until eventIn range sent'/>
 25                      <field name='wireframetype='SFBoolvalue='trueaccessType='initializeOnly'
                     appinfo='whether wireframe beam is drawn'/>
 26                      <field name='solidtype='SFBoolvalue='trueaccessType='initializeOnly'
                     appinfo='whether solid beam is drawn'/>
 27                      <field name='beamHeighttype='SFFloatvalue='1accessType='initializeOnly'
                     appinfo='meters across vertical y axis'/>
 28                      <field name='beamWidthtype='SFFloatvalue='1accessType='initializeOnly'
                     appinfo='meters across horizontal z axis'/>
 29                      <field name='contactColortype='SFColorvalue='.8 .1 .1accessType='initializeOnly'
                     appinfo='rendering color when contact=true'/>
 30                      <field name='noContactColortype='SFColorvalue='.3 .5 .5accessType='initializeOnly'
                     appinfo='rendering color when contact=false'/>
 31                      <field name='transparencytype='SFFloatvalue='0accessType='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_SWITCHwhichChoice='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_COLORdiffuseColor='.1 .1 .1emissiveColor='.1 .1 .1'>
 41                                               <IS>
 42                                                    <connect nodeField='transparencyprotoField='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_SWITCHwhichChoice='0'>
 52                                <WorldInfo info='"initial choice is null node (WorldInfo), meaning no solid beam"'/>
 53                                <Transform rotation='0 0 1 1.57079translation='.5 0 0'>
 54                                     <Shape>
 55                                          <Appearance>
 56 
                                             <!-- ROUTE information for CYLINDER_COLOR node:  [from DETECTION.beamColor to emissiveColor ] -->
                                             <Material DEF='CYLINDER_COLORdiffuseColor='.1 .1 .1'>
 57                                                    <IS>
 58                                                         <connect nodeField='transparencyprotoField='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='nametype='SFStringaccessType='initializeOnly'/>
 71                           <field name='contacttype='SFBoolaccessType='inputOnly'/>
 72                           <field name='wireframetype='SFBoolaccessType='initializeOnly'/>
 73                           <field name='solidtype='SFBoolaccessType='initializeOnly'/>
 74                           <field name='contactColortype='SFColoraccessType='initializeOnly'/>
 75                           <field name='noContactColortype='SFColoraccessType='initializeOnly'/>
 76                           <field name='beamColortype='SFColoraccessType='outputOnly'/>
 77                           <field name='wireframeChoicetype='SFInt32accessType='outputOnly'/>
 78                           <field name='solidChoicetype='SFInt32accessType='outputOnly'/>
 79                           <field name='traceEnabledtype='SFBoolvalue='trueaccessType='initializeOnly'
                          appinfo='internal flag to turn on Script tracing'/>
 80                           <IS>
 81                                <connect nodeField='nameprotoField='name'/>
 82                                <connect nodeField='contactprotoField='contact'/>
 83                                <connect nodeField='wireframeprotoField='wireframe'/>
 84                                <connect nodeField='solidprotoField='solid'/>
 85                                <connect nodeField='contactColorprotoField='contactColor'/>
 86                                <connect nodeField='noContactColorprotoField='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='nametype='SFStringaccessType='initializeOnly'/>
 92                           <field name='rangetype='SFFloataccessType='inputOnly'/>
 93                           <field name='defaultRangetype='SFFloataccessType='initializeOnly'/>
 94                           <field name='beamHeighttype='SFFloataccessType='initializeOnly'/>
 95                           <field name='beamWidthtype='SFFloataccessType='initializeOnly'/>
 96                           <field name='beamScaletype='SFVec3faccessType='outputOnly'/>
 97                           <field name='directiontype='SFRotationaccessType='outputOnly'/>
 98                           <field name='reverseOffsettype='SFVec3faccessType='outputOnly'/>
 99                           <field name='traceEnabledtype='SFBoolvalue='trueaccessType='initializeOnly'
                          appinfo='internal flag to turn on Script tracing'/>
100                           <IS>
101                                <connect nodeField='nameprotoField='name'/>
102                                <connect nodeField='rangeprotoField='range'/>
103                                <connect nodeField='defaultRangeprotoField='defaultRange'/>
104                                <connect nodeField='beamHeightprotoField='beamHeight'/>
105                                <connect nodeField='beamWidthprotoField='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://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamCylinderExample.x3d" "BeamCylinderExample.wrl" "https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamCylinderExample.wrl" '>
120                 <Shape>
121                      <Appearance>
122                           <Material diffuseColor='0 1 1emissiveColor='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 DEF nodes index: 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://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototype.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. -->