<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersive' version='3.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' http://www.web3d.org/specifications/x3d-3.0.xsd '>
<head>
<meta name='titlecontent='RelativeProximitySensorExample.x3d'/>
<meta name='descriptioncontent='RelativeProximitySensor design pattern: example use for paired object-to-object collision detection.'/>
<meta name='creatorcontent='Don Brutzman and MV4204 class'/>
<meta name='createdcontent='7 September 2004'/>
<meta name='modifiedcontent='14 January 2014'/>
<meta name='referencecontent='RelativeProximitySensorPrototype.x3d'/>
<meta name='subjectcontent='Object-to-object collision detection'/>
<meta name='identifiercontent=' https://savage.nps.edu/Savage/Tools/Animation/RelativeProximitySensorExample.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../../license.html'/>
</head>
<!-- -->
<Scene>
<ExternProtoDeclare name='RelativeProximitySensorappinfo='RelativeProximitySensor measures paired object-to-object collision detection'
  url=' "RelativeProximitySensorPrototype.x3d#RelativeProximitySensor" "https://savage.nps.edu/Savage/Tools/Animation/RelativeProximitySensorPrototype.x3d#RelativeProximitySensor" "RelativeProximitySensorPrototype.wrl#RelativeProximitySensor" "https://savage.nps.edu/Savage/Tools/Animation/RelativeProximitySensorPrototype.wrl#RelativeProximitySensor" '>
<field name='descriptiontype='SFStringaccessType='inputOutput'
 appinfo='describe the purpose of this sensor'/>

<field name='locationPrimarytype='SFVec3faccessType='initializeOnly'
 appinfo='where is the primary object'/>

<field name='set_locationPrimarytype='SFVec3faccessType='inputOnly'
 appinfo='update location of the primary object'/>

<field name='locationSecondarytype='SFVec3faccessType='initializeOnly'
 appinfo='where is the secondary object'/>

<field name='set_locationSecondarytype='SFVec3faccessType='inputOnly'
 appinfo='update location of the secondary object'/>

<field name='proximityRangeThresholdtype='SFFloataccessType='initializeOnly'
 appinfo='distance for detecting object-to-object collision'/>

<field name='set_proximityRangeThresholdtype='SFFloataccessType='inputOnly'
 appinfo='change threshold distance for detecting collision'/>

<field name='isInRangetype='SFBoolaccessType='outputOnly'
 appinfo='is object-to-object distance less than proximityRangeThreshold?'/>

<field name='isInRangeTimetype='SFTimeaccessType='outputOnly'
 appinfo='when did object-to-object range meet detection criteria?'/>

<field name='enabledtype='SFBoolaccessType='initializeOnly'
 appinfo='whether sensor is active'/>

<field name='set_enabledtype='SFBoolaccessType='inputOnly'/>
</ExternProtoDeclare>
<Viewpoint description='RelativeProximitySensor testposition='0 2 25'/>
<!-- ==================== -->
<Group DEF='TextTouchGroup'>
<Transform translation='0 5 0'>
<Shape>
<Text string='"click text to watch object motion and" "RelativeProximitySensor console alerts"'>
<FontStyle justify='"MIDDLE" "MIDDLE"size='1.8'/>
</Text>
<Appearance>
<Material DEF='TextColordiffuseColor='0.8 0.1 0.1'/>
</Appearance>
</Shape>
<Shape>
<Box size='25 4 0.01'/>
<Appearance>
<Material transparency='1'/>
</Appearance>
</Shape>
</Transform>
<!-- ROUTE information for TouchSensorActive node:  [from touchTime to AnimationClock.set_startTime ] -->
<TouchSensor DEF='TouchSensorActivedescription='click to initiate time delay and color change'/>
</Group>
<!-- ==================== -->
<Group DEF='ShapeAnimationGroup'>
<!-- ROUTE information for AnimationClock node:  [from TouchSensorActive.touchTime to set_startTime ] [from fraction_changed to BoxMover.set_fraction ] [from fraction_changed to SphereMover.set_fraction ] -->
<TimeSensor DEF='AnimationClockcycleInterval='4'/>
<ROUTE fromNode='TouchSensorActivefromField='touchTimetoNode='AnimationClocktoField='set_startTime'/>
<!-- ROUTE information for LeftHandBoxTransform node:  [from BoxMover.value_changed to set_translation ] -->
<Transform DEF='LeftHandBoxTransformtranslation='-10 0 0'>
<Shape>
<Box/>
<Appearance>
<Material diffuseColor='0.1 0.8 0.1'/>
</Appearance>
</Shape>
<!-- ROUTE information for BoxMover node:  [from AnimationClock.fraction_changed to set_fraction ] [from value_changed to LeftHandBoxTransform.set_translation ] [from value_changed to RPS.set_locationPrimary ] -->
<PositionInterpolator DEF='BoxMoverkey='0 0.5 1keyValue='-10 0 0 -3 0 0 -10 0 0'/>
<ROUTE fromNode='AnimationClockfromField='fraction_changedtoNode='BoxMovertoField='set_fraction'/>
<ROUTE fromNode='BoxMoverfromField='value_changedtoNode='LeftHandBoxTransformtoField='set_translation'/>
</Transform>
<!-- ROUTE information for RightHandSphereTransform node:  [from SphereMover.value_changed to set_translation ] [from translation_changed to RPS.set_locationSecondary ] -->
<Transform DEF='RightHandSphereTransformtranslation='10 0 0'>
<Shape>
<Sphere/>
<Appearance>
<Material diffuseColor='0.1 0.1 0.8'/>
</Appearance>
</Shape>
<!-- ROUTE information for SphereMover node:  [from AnimationClock.fraction_changed to set_fraction ] [from value_changed to RightHandSphereTransform.set_translation ] -->
<PositionInterpolator DEF='SphereMoverkey='0 0.5 1keyValue='10 0 0 2 0 0 10 0 0'/>
<ROUTE fromNode='AnimationClockfromField='fraction_changedtoNode='SphereMovertoField='set_fraction'/>
<ROUTE fromNode='SphereMoverfromField='value_changedtoNode='RightHandSphereTransformtoField='set_translation'/>
</Transform>
</Group>
<!-- ROUTE information for RPS node:  [from BoxMover.value_changed to set_locationPrimary ] [from RightHandSphereTransform.translation_changed to set_locationSecondary ] -->
<ProtoInstance name='RelativeProximitySensorDEF='RPS'>
<fieldValue name='descriptionvalue='test case'/>
<fieldValue name='enabledvalue='true'/>
<fieldValue name='locationPrimaryvalue='-10 0 0'/>
<fieldValue name='locationSecondaryvalue='10 0 0'/>
</ProtoInstance>
<!-- Connect interpolator output to monitor movement of first object. -->
<ROUTE fromNode='BoxMoverfromField='value_changedtoNode='RPStoField='set_locationPrimary'/>
<!-- Test use of Transform output, which means that this sensor could be used to monitor other nodes that might have multiple movers. -->
<ROUTE fromNode='RightHandSphereTransformfromField='translation_changedtoNode='RPStoField='set_locationSecondary'/>
</Scene>
</X3D>
<!--

Index for ExternProtoDeclare definition : RelativeProximitySensor

Index for DEF nodes : AnimationClock, BoxMover, LeftHandBoxTransform, RightHandSphereTransform, RPS, ShapeAnimationGroup, SphereMover, TextColor, TextTouchGroup, TouchSensorActive

Index for Viewpoint image : Viewpoint_1
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
    <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->