#X3D V3.0 utf8 PROFILE Immersive # [X3D] version=3.0 # [X3D] noNamespaceSchemaLocation=https://www.web3d.org/specifications/x3d-3.0.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" "TSSRPairPrototype.x3d" META "description" "A pair of Tropo Satellite Support Radios (TSSR) used for short-range (< 20 miles) point-to-point SHF communication. The system designed to support remote equipment and users by replacing long cable runs." META "creator" "Mike Hunsberger" META "created" "1 May 2001" META "modified" "20 October 2019" META "identifier" "https://savage.nps.edu/Savage/CommunicationsAndSensors/TSSR/TSSRPairPrototype.x3d" META "reference" "https://savage.nps.edu/Savage/CommunicationsAndSensors/TSSR/TSSRPairExample.x3d" META "generator" "X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit" META "license" "../../license.html" # [Scene] ========== ========== ========== EXTERNPROTO 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). initializeOnly SFString name # [appinfo] Assigning a name to a BeamCylinder aids 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 # [appinfo] distance in meters used until eventIn range sent initializeOnly SFBool wireframe # [appinfo] whether wireframe beam is drawn initializeOnly SFBool solid # [appinfo] whether solid beam is drawn initializeOnly SFFloat beamHeight # [appinfo] meters across vertical y axis initializeOnly SFFloat beamWidth # [appinfo] meters across horizontal z axis initializeOnly SFColor contactColor # [appinfo] rendering color when contact=true initializeOnly SFColor noContactColor # [appinfo] rendering color when contact=false inputOutput SFFloat transparency # [appinfo] 1 = fully transparent wireframe only ][ "../../CommunicationsAndSensors/Beam/BeamCylinderPrototype.x3d#BeamCylinder" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototype.x3d#BeamCylinder" "../../CommunicationsAndSensors/Beam/BeamCylinderPrototype.wrl#BeamCylinder" "https://savage.nps.edu/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototype.wrl#BeamCylinder" ] # ExternProtoDeclare definitions must be included verbatim # PROTO consists of two TSSRs for short range (< 5 mile) point-to-point communication. TSSRs eliminate the need for long cable runs. This PROTO allow specification for the initial placement of each TSSR. It automatically calculates the correct angle to complete the link. PROTO TSSRPair [ initializeOnly SFVec3f TSSR1Location 1 1 1 initializeOnly SFVec3f TSSR2Location 0 0 0 ] { Group { children [ DEF TSSRPairViewpoint Viewpoint { description "TSSR Pair Viewpoint" } LOD { range [ 40000 ] children [ ### children2 # TSSR 1 Two Transforms. One in the XZ plane, the second in the XY plane. Inlines for the TSSR body, stand, and the dome pattern. DEF TSSR1_TRANSFORM Transform { translation IS TSSR1Location children [ DEF TSSR1_XY_TRANSFORM Transform { children [ DEF TSSRBody Inline { url [ "../../CommunicationsAndSensors/TSSR/TSSRBody.x3d" "https://savage.nps.edu/Savage/CommunicationsAndSensors/TSSR/TSSRBody.x3d" "../../CommunicationsAndSensors/TSSR/TSSRBody.wrl" "https://savage.nps.edu/Savage/CommunicationsAndSensors/TSSR/TSSRBody.wrl" ] } DEF TSSR1Cone Transform { translation 1 0 0 children [ DEF TSSR1_BEAMCYLINDER BeamCylinder { defaultRange 10 beamHeight 1 beamWidth 1 transparency 0.2 wireframe TRUE solid TRUE contactColor .3 .5 .5 noContactColor .8 .1 .1 } LOD { range [ 100 ] children [ ### children2 Transform { children [ Viewpoint { description "TSSR1 side view" } ### Warning: Viewpoint behavior not guaranteed as child (or descendant) of LOD node ] } WorldInfo { info [ "null node for no rendering when distant" ] } ] } ] } ] } Transform { children [ DEF TSSRStand Inline { url [ "../../CommunicationsAndSensors/TSSR/TSSRTripod.x3d" "https://savage.nps.edu/Savage/CommunicationsAndSensors/TSSR/TSSRTripod.x3d" "../../CommunicationsAndSensors/TSSR/TSSRTripod.wrl" "https://savage.nps.edu/Savage/CommunicationsAndSensors/TSSR/TSSRTripod.wrl" ] } ] } ] } WorldInfo { info [ "null node for no rendering when distant" ] } ] } LOD { range [ 40000 ] children [ ### children2 # TSSR 2 Two Transforms. One in the XZ plane, the second in the XY plane. Inlines for the TSSR body, stand, and the dome pattern. DEF TSSR2_TRANSFORM Transform { translation IS TSSR2Location children [ DEF TSSR2_XY_TRANSFORM Transform { children [ USE TSSRBody DEF TSSR2Cone Transform { translation 1 0 0 children [ DEF TSSR2_BEAMCYLINDER BeamCylinder { defaultRange 10 beamHeight 1 beamWidth 1 transparency 0.2 wireframe TRUE solid TRUE contactColor .3 .5 .5 noContactColor .8 .1 .1 } LOD { range [ 100 ] children [ ### children2 Transform { children [ Viewpoint { description "TSSR2 side view" orientation 0 1 0 3.14 position 0 0 -10 } ### Warning: Viewpoint behavior not guaranteed as child (or descendant) of LOD node ] } WorldInfo { info [ "null node for no rendering when distant" ] } ] } ] } ] } Transform { children [ USE TSSRStand ] } ] } WorldInfo { info [ "null node for no rendering when distant" ] } ] } DEF TransmitScript Script { inputOnly SFInt32 transState outputOnly SFVec3f size url [ "ecmascript: // ### X3D Browser.print() not supported by all VRML97 viewers, instead simply using print() function initialize () { size = new SFVec3f(100, 100, 100) ; Browser.println ('TransmitScript initialize() complete') ; } // function name matches eventIn variable name ('hour') // hourValue captures the new value of the ROUTE hour event // minutes is just the current field value function transState (newValue, timestamp) { transmitState = newValue ; if (transmitState == 3) { size = new SFVec3f(10, 10, 10) ; } else { size = new SFVec3f(100, 100, 100) ; } Browser.println ('size = ' + size) ; } " ] } DEF TransmitScript2 Script { inputOnly SFInt32 transState outputOnly SFVec3f size url [ "ecmascript: // ### X3D Browser.print() not supported by all VRML97 viewers, instead simply using print() function initialize () { size = new SFVec3f(100, 100, 100) ; Browser.println ('TransmitScript initialize() complete') ; } // function name matches eventIn variable name ('hour') // hourValue captures the new value of the ROUTE hour event // minutes is just the current field value function transState (newValue, timestamp) { transmitState = newValue ; if (transmitState == 3) { size = new SFVec3f(10, 10, 10) ; } else { size = new SFVec3f(100, 100, 100) ; } Browser.println ('size = ' + size) ; } " ] } # This script is used to calculate the corresponding rotation angles so the TSSRs will be pointed at each other DEF CalculateAngleScript Script { initializeOnly SFVec3f TSSR1Location IS TSSR1Location initializeOnly SFVec3f TSSR2Location IS TSSR2Location outputOnly SFRotation TSSR1_XZangle outputOnly SFRotation TSSR2_XZangle outputOnly SFVec3f beamScale outputOnly SFFloat beamLength outputOnly SFRotation TSSR1_XYangle outputOnly SFRotation TSSR2_XYangle outputOnly SFBool LinkEstablished outputOnly SFVec3f ViewpointLocation outputOnly SFRotation ViewpointAngle url [ "ecmascript: // ### X3D Browser.print() not supported by all VRML97 viewers, instead simply using print() function initialize () { Browser.println ('TSSR1 =' + TSSR1Location) ; Browser.println ('TSSR2 =' + TSSR2Location) ; Browser.println ('TransmitScript initialize() complete') ; active = true ; TSSR1_XZangle = new SFRotation(0, 1, 0, 0) ; TSSR2_XZangle = new SFRotation(0, 1, 0, 0) ; TSSR1_XYangle = new SFRotation(0, 0, 1, 0) ; TSSR2_XYangle = new SFRotation(0, 0, 1, 0) ; beamScale = new SFVec3f ( ) ; ViewpointLocation = new SFVec3f ( ) ; ViewpointAngle = new SFRotation(0, 1, 0, 0) ; LinkEstablished = true; compute(active) ; } function compute ( ) { computeDistance( ) ; computeXZangle( ); ViewpointLocation[0] = TSSR1Location[0] ; ViewpointLocation[1] = TSSR1Location[1] + 4; ViewpointLocation[2] = TSSR1Location[2] ; Browser.println ('ViewpointLocation =' + ViewpointLocation) ; ViewpointAngle[3] = TSSR1_XZangle[3] - Math.PI/2; Browser.println ('ViewpointAngle =' + ViewpointAngle) ; computeXYangle( ) ; } function computeDistance( ) { Browser.println ('TSSR1 =' + TSSR1Location) ; Browser.println ('TSSR2 =' + TSSR2Location) ; deltaX = (TSSR2Location[0] - TSSR1Location[0]) ; deltaY = (TSSR2Location[1] - TSSR1Location[1]) ; deltaZ = (TSSR2Location[2] - TSSR1Location[2]) ; distanceSquared = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ ; Browser.println ('Distance Squared =' + distanceSquared) ; distance = Math.sqrt(distanceSquared) ; Browser.println ('Distance =' + distance) ; beamScale[0] = distance/10; beamScale[1] = 5; beamScale[2] = 5; Browser.println ('BeamScale =' + beamScale) ; beamLength = distance - 2 ; if (distance > 5000/.6) { LinkEstablished = false; beamLength = 5000; } } function computeXZangle( ) { if (deltaZ == 0) { deltaZ = .00000001 ; } angle = Math.atan(deltaX/deltaZ) ; if (deltaZ < 0) { TSSR1_XZangle[3] = angle + Math.PI/2; } else { TSSR1_XZangle[3] = angle - Math.PI/2; } TSSR2_XZangle[3] = TSSR1_XZangle[3] + Math.PI; Browser.println ('Angle =' + TSSR1_XZangle[3]) ; Browser.println ('Angle2 =' + TSSR2_XZangle[3]) ; } function computeXYangle( ) { angle = Math.asin(deltaY/distance) ; TSSR1_XYangle[3] = angle ; TSSR2_XYangle[3] = - TSSR1_XYangle[3]; Browser.println ('AngleXY =' + TSSR1_XYangle[3]) ; Browser.println ('Angle2XY =' + TSSR2_XYangle[3]) ; } " ] } ] } ROUTE CalculateAngleScript.TSSR1_XZangle TO TSSR1_TRANSFORM.rotation ROUTE CalculateAngleScript.TSSR2_XZangle TO TSSR2_TRANSFORM.rotation ROUTE CalculateAngleScript.beamLength TO TSSR1_BEAMCYLINDER.range ROUTE CalculateAngleScript.beamLength TO TSSR2_BEAMCYLINDER.range ROUTE CalculateAngleScript.TSSR1_XYangle TO TSSR1_XY_TRANSFORM.rotation ROUTE CalculateAngleScript.TSSR2_XYangle TO TSSR2_XY_TRANSFORM.rotation ROUTE CalculateAngleScript.LinkEstablished TO TSSR1_BEAMCYLINDER.contact ROUTE CalculateAngleScript.LinkEstablished TO TSSR2_BEAMCYLINDER.contact ROUTE CalculateAngleScript.ViewpointLocation TO TSSRPairViewpoint.position ROUTE CalculateAngleScript.ViewpointAngle TO TSSRPairViewpoint.orientation } # ==================== WorldInfo { info [ "Author: Mike Hunsberger" "Revised: 30 April 2001" "Purpose: Pair of TSSRs" "Browser: CosmoPlayer" ] title "AntennaWorld" } TSSRPair { TSSR1Location 0 0 0 TSSR2Location 50 0 50 } Background { groundAngle [ 1.57079 ] groundColor [ 1 0.8 0.6 0.6 0.4 0.2 ] skyAngle [ 0.2 ] skyColor [ 1 1 1 0.2 0.2 1 ] }