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='title' content=' RelativeProximitySensorExample.x3d '/> |
6 | <meta name='description' content='RelativeProximitySensor design pattern: example use for paired object-to-object collision detection.'/> |
7 | <meta name='creator' content='Don Brutzman and MV4204 class'/> |
8 | <meta name='created' content='7 September 2004'/> |
9 | <meta name='modified' content='28 November 2019'/> |
10 | <meta name='reference' content=' RelativeProximitySensorPrototype.x3d '/> |
11 | <meta name='subject' content='Object-to-object collision detection'/> |
12 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/RelativeProximitySensorExample.x3d '/> |
13 | <meta name='generator' content='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
14 | <meta name='license' content='../../license.html'/> |
15 | </head> |
16 | <Scene> |
17 | <WorldInfo title='RelativeProximitySensorExample.x3d'/> |
18 | <ExternProtoDeclare name='RelativeProximitySensor' appinfo='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='description' type='SFString' accessType='inputOutput'
appinfo='describe the purpose of this sensor'/> |
20 |
<field name='locationPrimary' type='SFVec3f' accessType='initializeOnly'
appinfo='where is the primary object'/> |
21 |
<field name='set_locationPrimary' type='SFVec3f' accessType='inputOnly'
appinfo='update location of the primary object'/> |
22 |
<field name='locationSecondary' type='SFVec3f' accessType='initializeOnly'
appinfo='where is the secondary object'/> |
23 |
<field name='set_locationSecondary' type='SFVec3f' accessType='inputOnly'
appinfo='update location of the secondary object'/> |
24 |
<field name='proximityRangeThreshold' type='SFFloat' accessType='initializeOnly'
appinfo='distance for detecting object-to-object collision'/> |
25 |
<field name='set_proximityRangeThreshold' type='SFFloat' accessType='inputOnly'
appinfo='change threshold distance for detecting collision'/> |
26 |
<field name='isInRange' type='SFBool' accessType='outputOnly'
appinfo='is object-to-object distance less than proximityRangeThreshold?'/> |
27 |
<field name='isInRangeTime' type='SFTime' accessType='outputOnly'
appinfo='when did object-to-object range meet detection criteria?'/> |
28 |
<field name='enabled' type='SFBool' accessType='initializeOnly'
appinfo='whether sensor is active'/> |
29 | <field name='set_enabled' type='SFBool' accessType='inputOnly'/> |
30 | </ExternProtoDeclare> |
31 | <Viewpoint description='RelativeProximitySensor test' position='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='TextColor' diffuseColor='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='TouchSensorActive' description='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='AnimationClock' cycleInterval='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='LeftHandBoxTransform' translation='-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='BoxMover' key='0 0.5 1' keyValue='-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='RightHandSphereTransform' translation='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='SphereMover' key='0 0.5 1' keyValue='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='RelativeProximitySensor' DEF='RPS'> |
80 | <fieldValue name='description' value='test case'/> |
81 | <fieldValue name='enabled' value='true'/> |
82 | <fieldValue name='locationPrimary' value='-10 0 0'/> |
83 | <fieldValue name='locationSecondary' value='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 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 |
AnimationClock
TimeSensor set_startTime SFTime |
then
|
AnimationClock
TimeSensor fraction_changed SFFloat |
BoxMover
PositionInterpolator set_fraction SFFloat |
then
|
BoxMover
PositionInterpolator value_changed SFVec3f |
LeftHandBoxTransform
Transform set_translation SFVec3f |
|||||||
then
|
BoxMover
PositionInterpolator value_changed SFVec3f |
RPS
ProtoInstance set_locationPrimary SFVec3f |
||||||||||||
then
|
AnimationClock
TimeSensor fraction_changed SFFloat |
SphereMover
PositionInterpolator set_fraction SFFloat |
then
|
SphereMover
PositionInterpolator value_changed SFVec3f |
RightHandSphereTransform
Transform set_translation SFVec3f |
then
|
RightHandSphereTransform
Transform translation_changed SFVec3f |
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. |
<!--
Color-coding legend: X3D terminology
<X3dNode
DEF='idName' field='value'/>
matches XML terminology
<XmlElement
DEF='idName' attribute='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>
-->
<!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->