#X3D V3.3 utf8 PROFILE Immersive # [X3D] version=3.3 # [X3D] noNamespaceSchemaLocation=https://www.web3d.org/specifications/x3d-3.3.xsd # X3D-to-ClassicVRML XSL translation autogenerated by X3dToClassicVrmlEncoding.xslt and X3dToVrml97.xslt # https://www.web3d.org/x3d/content/X3dToClassicVrmlEncoding.xslt # https://www.web3d.org/x3d/content/X3dToVrml97.xslt # Transformation using XSLT processor: Saxonica # head META "title" "BeamConePrototype.x3d" META "creator" "Don Brutzman" META "created" "7 December 2000" META "modified" "12 October 2023" META "description" "Produce wireframe or transparent beam cones." META "identifier" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Beam/BeamConePrototype.x3d" META "reference" "http://faculty.nps.edu/brutzman/vrtp/demo/auv/BeamConePrototype.x3d" META "reference" "https://www.web3d.org/WorkingGroups/vrtp/demo/auv/BeamConePrototype.x3d" META "generator" "X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit" META "license" "../../license.html" # [Scene] ========== ========== ========== DEF LockedDownInterface2D NavigationInfo { type [ "NONE" ] } Background { skyColor [ 0 0.3 0.5 ] } WorldInfo { info [ "Produce wireframe or transparent beam cones" ] title "BeamConeProto" } Viewpoint { description "Beam Cone" position 0 0 15 } PROTO 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). initializeOnly SFString name "(unnamed)" # [appinfo] BeamCone name aids in node identification and tracing inputOnly SFBool contact # [appinfo] (communications) is transmitted signal in contact with receiver or (sensor) is a target return detected? inputOnly SFFloat range # [appinfo] distance in meters along x axis initializeOnly SFFloat defaultRange 1 # [appinfo] distance in meters used until eventIn range sent initializeOnly SFBool wireframe TRUE # [appinfo] whether wireframe beam is drawn initializeOnly SFBool solid TRUE # [appinfo] whether solid beam is drawn initializeOnly SFFloat beamHeightDegrees 10 # [appinfo] degrees across vertical y axis initializeOnly SFFloat beamWidthDegrees 10 # [appinfo] degrees across horizontal z axis initializeOnly SFColor contactColor .8 .1 .1 # [appinfo] rendering color when contact=true initializeOnly SFColor noContactColor .3 .5 .5 # [appinfo] rendering color when contact=false inputOutput SFFloat transparency 0 # [appinfo] 1 = fully transparent wireframe only initializeOnly SFBool traceEnabled FALSE # [appinfo] flag to turn on Script tracing # BEAM_CONTROL beam scaling is controlled by range/beamHeightDegrees/beamWidthDegrees/direction inputs ] { DEF BEAM_CONTROL Transform { children [ DEF WIREFRAME_SWITCH Switch { whichChoice 0 children [ ### children3 WorldInfo { info [ "initial choice is null node (WorldInfo), meaning no wireframe beam" ] } Shape { appearance Appearance { material DEF WIRE_COLOR Material { diffuseColor .1 .1 .1 emissiveColor .1 .1 .1 transparency IS transparency } } geometry 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 ] coord 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 ] } } } ] } DEF SOLID_SWITCH Switch { whichChoice 0 children [ ### children3 WorldInfo { info [ "initial choice is null node (WorldInfo), meaning no solid beam" ] } Transform { rotation 0 0 1 1.57079 translation .5 0 0 children [ Shape { appearance Appearance { material DEF CONE_COLOR Material { diffuseColor .1 .1 .1 transparency IS transparency } } # solid='false' is harder to recognize properly, use default solid='true' geometry Cone { bottom FALSE height 1 } } ] } ] } ] } DEF DETECTION Script { initializeOnly SFString name IS name # [appinfo] BeamCone name aids tracing inputOnly SFBool contact IS contact initializeOnly SFBool wireframe IS wireframe initializeOnly SFBool solid IS solid initializeOnly SFColor contactColor IS contactColor initializeOnly SFColor noContactColor IS noContactColor outputOnly SFColor beamColor outputOnly SFInt32 wireframeChoice outputOnly SFInt32 solidChoice initializeOnly SFBool traceEnabled IS traceEnabled # [appinfo] internal flag to turn on Script tracing url [ "ecmascript: // ### X3D Browser.print() not supported by all VRML97 viewers, instead simply using print() 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()); } " ] } DEF BEAM_CALCULATE Script { inputOnly SFFloat range IS range initializeOnly SFFloat defaultRange IS defaultRange initializeOnly SFFloat beamHeightDegrees IS beamHeightDegrees initializeOnly SFFloat beamWidthDegrees IS beamWidthDegrees outputOnly SFVec3f beamScale outputOnly SFRotation direction outputOnly SFVec3f reverseOffset url [ "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); } } " ] } ROUTE DETECTION.beamColor TO WIRE_COLOR.emissiveColor ROUTE DETECTION.beamColor TO CONE_COLOR.emissiveColor ROUTE DETECTION.wireframeChoice TO WIREFRAME_SWITCH.whichChoice ROUTE DETECTION.solidChoice TO SOLID_SWITCH.whichChoice ROUTE BEAM_CALCULATE.beamScale TO BEAM_CONTROL.scale ROUTE BEAM_CALCULATE.direction TO BEAM_CONTROL.rotation ROUTE BEAM_CALCULATE.reverseOffset TO BEAM_CONTROL.translation } # Viewable geometry for this scene is anchored text that links to an example showing ExternProtoDeclare usage of BeamCone Anchor { description "Beam Cone Example" url [ "BeamConeExample.x3d" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Beam/BeamConeExample.x3d" "BeamConeExample.wrl" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Beam/BeamConeExample.wrl" ] children [ Shape { appearance Appearance { material Material { diffuseColor 0 1 1 emissiveColor 0 1 1 } } geometry Text { string [ "BeamConePrototype" "is a Prototype definition file." "" "To see an example scene" "click this text and view" "BeamConeExample." ] fontStyle FontStyle { justify [ "MIDDLE" "MIDDLE" ] } } } Shape { # transparent Box as text-selection assist geometry Box { size 11 6 .001 } appearance Appearance { material Material { transparency 1 } } } ] }