X3D Model Documentation: RelativeProximitySensorExample.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2 
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
  3  <X3D profile='Immersive' version='3.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'>
  4       <head>
  5            <meta name='titlecontent=' RelativeProximitySensorExample.x3d '/>
  6            <meta name='descriptioncontent='RelativeProximitySensor design pattern: example use for paired object-to-object collision detection.'/>
  7            <meta name='creatorcontent='Don Brutzman and MV4204 class'/>
  8            <meta name='createdcontent='7 September 2004'/>
  9            <meta name='modifiedcontent='28 November 2019'/>
 10            <meta name='referencecontent=' RelativeProximitySensorPrototype.x3d '/>
 11            <meta name='subjectcontent='Object-to-object collision detection'/>
 12            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/RelativeProximitySensorExample.x3d '/>
 13            <meta name='generatorcontent='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 14            <meta name='licensecontent='../../license.html'/>
 15       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: AnimationClock, BoxMover, LeftHandBoxTransform, RightHandSphereTransform, RPS, ShapeAnimationGroup, SphereMover, TextColor, TextTouchGroup, TouchSensorActive

Index for Viewpoint node: Viewpoint_1

Index for ExternProtoDeclare definition: RelativeProximitySensor
-->
 16       <Scene>
 17            <WorldInfo title='RelativeProximitySensorExample.x3d'/>
 18            <ExternProtoDeclare name='RelativeProximitySensorappinfo='RelativeProximitySensor measures paired object-to-object collision detection'   url=' "RelativeProximitySensorPrototype.x3d#RelativeProximitySensor" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/RelativeProximitySensorPrototype.x3d#RelativeProximitySensor" "RelativeProximitySensorPrototype.wrl#RelativeProximitySensor" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/RelativeProximitySensorPrototype.wrl#RelativeProximitySensor" '>
 19                 <field name='descriptiontype='SFStringaccessType='inputOutput'
                appinfo='describe the purpose of this sensor'/>
 20                 <field name='locationPrimarytype='SFVec3faccessType='initializeOnly'
                appinfo='where is the primary object'/>
 21                 <field name='set_locationPrimarytype='SFVec3faccessType='inputOnly'
                appinfo='update location of the primary object'/>
 22                 <field name='locationSecondarytype='SFVec3faccessType='initializeOnly'
                appinfo='where is the secondary object'/>
 23                 <field name='set_locationSecondarytype='SFVec3faccessType='inputOnly'
                appinfo='update location of the secondary object'/>
 24                 <field name='proximityRangeThresholdtype='SFFloataccessType='initializeOnly'
                appinfo='distance for detecting object-to-object collision'/>
 25                 <field name='set_proximityRangeThresholdtype='SFFloataccessType='inputOnly'
                appinfo='change threshold distance for detecting collision'/>
 26                 <field name='isInRangetype='SFBoolaccessType='outputOnly'
                appinfo='is object-to-object distance less than proximityRangeThreshold?'/>
 27                 <field name='isInRangeTimetype='SFTimeaccessType='outputOnly'
                appinfo='when did object-to-object range meet detection criteria?'/>
 28                 <field name='enabledtype='SFBoolaccessType='initializeOnly'
                appinfo='whether sensor is active'/>
 29                 <field name='set_enabledtype='SFBoolaccessType='inputOnly'/>
 30            </ExternProtoDeclare>
 31            <Viewpoint description='RelativeProximitySensor testposition='0 2 25'/>
 32            <!-- ==================== -->
 33            <Group DEF='TextTouchGroup'>
 34                 <Transform translation='0 5 0'>
 35                      <Shape>
 36                           <Text string='"click text to watch object motion and" "RelativeProximitySensor console alerts"'>
 37                                <FontStyle justify='"MIDDLE" "MIDDLE"size='1.8'/>
 38                           </Text>
 39                           <Appearance>
 40                                <Material DEF='TextColordiffuseColor='0.8 0.1 0.1'/>
 41                           </Appearance>
 42                      </Shape>
 43                      <Shape>
 44                           <Box size='25 4 0.01'/>
 45                           <Appearance>
 46                                <Material transparency='1'/>
 47                           </Appearance>
 48                      </Shape>
 49                 </Transform>
 50 
               <!-- ROUTE information for TouchSensorActive node:  [from touchTime to AnimationClock.set_startTime ] -->
               <TouchSensor DEF='TouchSensorActivedescription='click to initiate time delay and color change'/>
 51            </Group>
 52            <!-- ==================== -->
 53            <Group DEF='ShapeAnimationGroup'>
 54 
               <!-- 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'/>
 55                 < ROUTE  fromNode='TouchSensorActive' fromField='touchTime' toNode='AnimationClock' toField='set_startTime'/>
 56 
               <!-- ROUTE information for LeftHandBoxTransform node:  [from BoxMover.value_changed to set_translation ] -->
               <Transform DEF='LeftHandBoxTransformtranslation='-10 0 0'>
 57                      <Shape>
 58                           <Box/>
 59                           <Appearance>
 60                                <Material diffuseColor='0.1 0.8 0.1'/>
 61                           </Appearance>
 62                      </Shape>
 63 
                    <!-- 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'/>
 64                      < ROUTE  fromNode='AnimationClock' fromField='fraction_changed' toNode='BoxMover' toField='set_fraction'/>
 65                      < ROUTE  fromNode='BoxMover' fromField='value_changed' toNode='LeftHandBoxTransform' toField='set_translation'/>
 66                 </Transform>
 67 
               <!-- 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'>
 68                      <Shape>
 69                           <Sphere/>
 70                           <Appearance>
 71                                <Material diffuseColor='0.1 0.1 0.8'/>
 72                           </Appearance>
 73                      </Shape>
 74 
                    <!-- 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'/>
 75                      < ROUTE  fromNode='AnimationClock' fromField='fraction_changed' toNode='SphereMover' toField='set_fraction'/>
 76                      < ROUTE  fromNode='SphereMover' fromField='value_changed' toNode='RightHandSphereTransform' toField='set_translation'/>
 77                 </Transform>
 78            </Group>
 79 
          <!-- ROUTE information for RPS node:  [from BoxMover.value_changed to set_locationPrimary ] [from RightHandSphereTransform.translation_changed to set_locationSecondary ] -->
          <ProtoInstance name='RelativeProximitySensorDEF='RPS'>
 80                 <fieldValue name='descriptionvalue='test case'/>
 81                 <fieldValue name='enabledvalue='true'/>
 82                 <fieldValue name='locationPrimaryvalue='-10 0 0'/>
 83                 <fieldValue name='locationSecondaryvalue='10 0 0'/>
 84            </ProtoInstance>
 85            <!-- Connect interpolator output to monitor movement of first object. -->
 86            < ROUTE  fromNode='BoxMover' fromField='value_changed' toNode='RPS' toField='set_locationPrimary'/>
 87            <!-- Test use of Transform output, which means that this sensor could be used to monitor other nodes that might have multiple movers. -->
 88            < ROUTE  fromNode='RightHandSphereTransform' fromField='translation_changed' toNode='RPS' toField='set_locationSecondary'/>
 89       </Scene>
 90  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: AnimationClock, BoxMover, LeftHandBoxTransform, RightHandSphereTransform, RPS, ShapeAnimationGroup, SphereMover, TextColor, TextTouchGroup, TouchSensorActive

Index for Viewpoint node: Viewpoint_1

Index for ExternProtoDeclare definition: RelativeProximitySensor
-->
X3D Tooltips element index: Appearance, Box, ExternProtoDeclare, field, fieldValue, FontStyle, Group, head, Material, meta, PositionInterpolator, ProtoInstance, ROUTE, Scene, Shape, Sphere, Text, TimeSensor, TouchSensor, 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.

TouchSensorActive
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
AnimationClock
TimeSensor
set_startTime
SFTime
then
 
 
 
AnimationClock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(2)
BoxMover
PositionInterpolator
set_fraction
SFFloat
then
 
 
 
BoxMover
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(3)
LeftHandBoxTransform
Transform
set_translation
SFVec3f
  then
 
 
 
BoxMover
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(3)
RPS
ProtoInstance
set_locationPrimary
SFVec3f
  then
 
 
 
AnimationClock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(2)
SphereMover
PositionInterpolator
set_fraction
SFFloat
then
 
 
 
SphereMover
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(3)
RightHandSphereTransform
Transform
set_translation
SFVec3f
then
 
 
 
RightHandSphereTransform
Transform
translation_changed
SFVec3f

ROUTE
event to
(4)
RPS
ProtoInstance
set_locationSecondary
SFVec3f

      RPS
ProtoInstance
RelativeProximitySensor
No direct ROUTE connection found for events to/from this node.
This ProtoInstance contains SFNode/MFNode fieldValue declarations with
direct access to other nodes, and thus has potential to produce run-time animation. 

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/Tools/Animation/RelativeProximitySensorExampleIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/Tools/Animation/RelativeProximitySensorExample.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)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->