X3D Model Documentation: WaypointInterpolatorExample.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN" "https://www.web3d.org/specifications/x3d-3.2.dtd">
  3  <X3D profile='Immersive' version='3.2 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.2.xsd'>
  4       <head>
  5            <meta name='titlecontent=' WaypointInterpolatorExample.x3d '/>
  6            <meta name='descriptioncontent='Example set of waypoints, plus either leg durations or speed(s), which demonstrates resulting position/orientation interpolation. Motion can be stopped/started by placing mouse over orange TouchSensor Box. A HiddenViewpoint also exists under the coordinate axes. Trace values are printed in the browser console.'/>
  7            <meta name='creatorcontent='Don Brutzman, Curtis Blais, Jeff Weekley, Jane Wu'/>
  8            <meta name='createdcontent='6 April 2001'/>
  9            <meta name='modifiedcontent='23 August 2023'/>
 10            <meta name='Imagecontent='WaypointInterpolatorExample.png'/>
 11            <meta name=' warning content=' Cortona bug: TimeSensor set_cycleInterval has no effect, effectively ignoring routed totalDuration. Workaround: view calculated value for totalDuration, then set it in TimeSensor manually. '/>
 12            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorExample.x3d '/>
 13            <meta name='referencecontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d '/>
 14            <meta name='generatorcontent='X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 15            <meta name='licensecontent='../../license.html'/>
 16       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: Clock, ConeAppearance, CoordinateAxes, FloorAndToggleMarker, FloorAppearance, OrangeAppearance, TestHiddenViewpointPrototype, TogglePlayback, TouchBox, TrackBuilder, TrackingTransform

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2, Viewpoint_3, Viewpoint_4, Viewpoint_5

Index for ExternProtoDeclare definitions: HiddenViewpoint, WaypointInterpolator
-->
 17       <Scene>
 18            <!-- ====================================== -->
 19            <!-- To use WaypointInterpolator in your scene, copy/paste this definition verbatim first. -->
 20            <WorldInfo title='WaypointInterpolatorExample.x3d'/>
 21            <ExternProtoDeclare name='WaypointInterpolatorappinfo='Reads waypoints and legSpeeds/legDurations/defaultSpeed to provide a customizable position/orientation interpolator.'   url=' "../../../Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d#WaypointInterpolator" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d#WaypointInterpolator" "../../../Savage/Tools/Animation/WaypointInterpolatorPrototype.wrl#WaypointInterpolator" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.wrl#WaypointInterpolator" '>
 22                 <!-- Priority of use: legSpeeds (m/sec), legDurations (seconds), defaultSpeed (m/sec) -->
 23                 <field name='descriptiontype='SFStringaccessType='initializeOnly'
                appinfo='Short description of what is animated by this WaypointInterpolator.'/>
 24                 <field name='waypointstype='MFVec3faccessType='initializeOnly'
                appinfo='Waypoints being traversed with interpolation of intermediate positions and orientations.'/>
 25                 <field name='add_waypointtype='SFVec3faccessType='inputOnly'
                appinfo='Add another single waypoint to array of waypoints recalculate interpolator values.'/>
 26                 <field name='set_waypointstype='MFVec3faccessType='inputOnly'
                appinfo='Replace all waypoints recalculate interpolator values.'/>
 27                 <field name='pitchUpDownForVerticalWaypointstype='SFBoolaccessType='initializeOnly'
                appinfo='Whether to pitch child geometry (such as a vehicle) up or down to match vertical slope'/>
 28                 <field name='legSpeedstype='MFFloataccessType='initializeOnly'
                appinfo='Units m/sec. If used, array lengths for legSpeeds and legDurations must be one less than number of waypoints.'/>
 29                 <field name='legDurationstype='MFTimeaccessType='initializeOnly'
                appinfo='Units in seconds. If used, array lengths for legSpeeds and legDurations must be one less than number of waypoints.'/>
 30                 <field name='defaultSpeedtype='SFFloataccessType='initializeOnly'
                appinfo='Units m/sec.'/>
 31                 <field name='turningRatetype='SFFloataccessType='initializeOnly'
                appinfo='turningRate (degrees/second) also determines standoff distance prior to waypoint where turn commences. If 0 turns are instantaneous.'/>
 32                 <field name='totalDurationtype='SFTimeaccessType='outputOnly'
                appinfo='Output calculation summing all leg durations, useful for setting TimeSensor cycleInterval. Units in seconds.'/>
 33                 <!-- interpolation fields -->
 34                 <field name='set_fractiontype='SFFloataccessType='inputOnly'
                appinfo='exposed PositionInterpolator and OrientationInterpolator setting'/>
 35                 <field name='position_changedtype='SFVec3faccessType='outputOnly'
                appinfo='exposed PositionInterpolator setting'/>
 36                 <field name='orientation_changedtype='SFRotationaccessType='outputOnly'
                appinfo='exposed OrientationInterpolator setting'/>
 37                 <!-- display-related fields -->
 38                 <field name='lineColortype='SFColoraccessType='inputOutput'
                appinfo='default color for non-active line segments'/>
 39                 <field name='highlightSegmentColortype='SFColoraccessType='inputOutput'
                appinfo='active segment highlight color'/>
 40                 <field name='transparencytype='SFFloataccessType='inputOutput'
                appinfo='1.0 is completely transparent, 0.0 is completely opaque.'/>
 41                 <field name='labelDisplayModetype='SFStringaccessType='initializeOnly'
                appinfo='allowed values: none; waypoints (produce labels at each waypoint); or interpolation (produce single moving label at interpolator time course speed location)'/>
 42                 <field name='heightLabeltype='SFStringaccessType='initializeOnly'
                appinfo='allowed values: altitude depth (negate Y value) none'/>
 43                 <field name='labelOffsettype='SFVec3faccessType='initializeOnly'
                appinfo='heightLabel relative location'/>
 44                 <field name='labelFontSizetype='SFFloataccessType='initializeOnly'
                appinfo='heightLabel text size'/>
 45                 <field name='labelColortype='SFColoraccessType='initializeOnly'
                appinfo='heightLabel text color'/>
 46                 <field name='traceEnabledtype='SFBoolaccessType='initializeOnly'
                appinfo='enable console output to trace script computations and prototype progress'/>
 47                 <field name='outputInitializationComputationstype='SFBoolaccessType='initializeOnly'
                appinfo='Output the number of waypoints totalDistance and totalDuration to console upon initialization'/>
 48                 <field name='verticalDropLineColortype='SFColoraccessType='inputOutput'
                appinfo='default color for vertical drop-line segments'/>
 49                 <field name='verticalDropLineTransparencytype='SFFloataccessType='inputOutput'
                appinfo='1.0 is completely transparent, 0.0 is completely opaque.'/>
 50            </ExternProtoDeclare>
 51            <!-- ====================================== -->
 52            <!-- Here is another interesting prototype authoring tool. -->
 53            <ExternProtoDeclare name='HiddenViewpointappinfo='Hidden viewpoint becomes active (binds) upon pointer selection to reveal an interesting view with an optionally label'   url=' "../../../Savage/Tools/Animation/HiddenViewpointPrototype.x3d#HiddenViewpoint" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/HiddenViewpointPrototype.x3d#HiddenViewpoint" "../../../Savage/Tools/Animation/HiddenViewpointPrototype.wrl#HiddenViewpoint" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/HiddenViewpointPrototype.wrl#HiddenViewpoint" '>
 54                 <field name='positiontype='SFVec3faccessType='inputOutput'/>
 55                 <field name='rotationtype='SFRotationaccessType='inputOutput'/>
 56                 <field name='sensorRadiustype='SFFloataccessType='initializeOnly'/>
 57                 <field name='activatetype='SFBoolaccessType='inputOnly'/>
 58                 <field name='labeltype='MFStringaccessType='inputOutput'/>
 59                 <field name='labelOffsettype='SFVec3faccessType='inputOutput'/>
 60                 <field name='labelFontSizetype='SFFloataccessType='initializeOnly'/>
 61                 <field name='labelColortype='SFColoraccessType='inputOutput'/>
 62            </ExternProtoDeclare>
 63            <!-- ====================================== -->
 64            <!-- Example instance follows prototype declaration -->
 65            <Viewpoint description='WaypointInterpolator exampleorientation='1 0 0 -0.3position='-1 5 13'/>
 66            <Viewpoint description='Above, looking downorientation='1 0 0 -1.57position='0 15 -5'/>
 67            <Inline DEF='CoordinateAxes'   url=' "../../../Savage/Tools/Authoring/CoordinateAxes.x3d" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/CoordinateAxes.x3d" "../../../Savage/Tools/Authoring/CoordinateAxes.wrl" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/CoordinateAxes.wrl" '/>
 68            <!-- 10 second default cycleInterval should get overridden by 25.3 second computed totalDuration. -->
 69 
          <!-- ROUTE information for Clock node:  [from TrackBuilder.totalDuration to set_cycleInterval ] [from TouchBox.isOver to enabled ] [from fraction_changed to TrackBuilder.set_fraction ] -->
          <TimeSensor DEF='ClockcycleInterval='10.0loop='true'/>
 70 
 71                 <fieldValue name='descriptionvalue='TrackBuilder'/>
 72                 <!-- Priority of use: legSpeeds (m/sec), legDurations (seconds), defaultSpeed (m/sec) -->
 73                 <fieldValue name='waypointsvalue='-5 0 0 5 2 0 5 5 -10 4.9 2 -10 -5 0 -10 -5 0 0 -5.5 0 1.5 -7 0.5 2 -8 0 0 -5 0 0'/>
 74                 <fieldValue name='pitchUpDownForVerticalWaypointsvalue='false'/>
 75                 <fieldValue name='legDurationsvalue='1 2 3 1 2 3 1 2 3'/>
 76                 <fieldValue name='legSpeedsvalue='2 4 2 2 4 1 1 1 1'/>
 77                 <fieldValue name='defaultSpeedvalue='5'/>
 78                 <fieldValue name='turningRatevalue='90'/>
 79                 <fieldValue name='lineColorvalue='1 0 0'/>
 80                 <fieldValue name='highlightSegmentColorvalue='0.2 0.2 1'/>
 81                 <fieldValue name='transparencyvalue='0'/>
 82                 <fieldValue name='labelDisplayModevalue='interpolation'/>
 83                 <fieldValue name='heightLabelvalue='altitude'/>
 84                 <fieldValue name='labelOffsetvalue='0 1.2 0'/>
 85                 <fieldValue name='labelFontSizevalue='0.5'/>
 86                 <fieldValue name='labelColorvalue='0.3 0.9 0.3'/>
 87                 <fieldValue name='traceEnabledvalue='false'/>
 88                 <fieldValue name='outputInitializationComputationsvalue='true'/>
 89            </ProtoInstance>
 90            < ROUTE  fromNode='Clock' fromField='fraction_changed' toNode='TrackBuilder' toField='set_fraction'/>
 91            < ROUTE  fromNode='TrackBuilder' fromField='totalDuration' toNode='Clock' toField='set_cycleInterval'/>
 92 
          <!-- ROUTE information for TrackingTransform node:  [from TrackBuilder.position_changed to translation ] [from TrackBuilder.orientation_changed to rotation ] -->
          <Transform DEF='TrackingTransform'>
 93                 <!-- Always align initial geometry with X axis -->
 94                 <Group>
 95                      <!-- Point cone along X-axis -->
 96                      <Transform rotation='0 0 1 -1.57'>
 97                           <Shape>
 98                                <Cone bottomRadius='0.4'/>
 99 
                              <!-- Appearance ConeAppearance is a DEF node that has 1 USE node: USE_1 -->
                              <Appearance DEF='ConeAppearance'>
100                                     <Material diffuseColor='0.8 0.8 0.2'/>
101                                </Appearance>
102                           </Shape>
103                      </Transform>
104                      <Transform translation='0 0.1 0'>
105                           <Shape>
106                                <Cone bottomRadius='0.1height='0.8'/>
107                                <Appearance USE='ConeAppearance'/>
108                           </Shape>
109                      </Transform>
110                      <Viewpoint description='Ride onorientation='0 1 0 -1.57position='-4 1 0'/>
111                      <Viewpoint description='Ride alongsideposition='0 0 5'/>
112                      <Viewpoint description='Ride in frontorientation='0 1 0 1.57position='4 1 0'/>
113                 </Group>
114            </Transform>
115            < ROUTE  fromNode='TrackBuilder' fromField='position_changed' toNode='TrackingTransform' toField='translation'/>
116            < ROUTE  fromNode='TrackBuilder' fromField='orientation_changed' toNode='TrackingTransform' toField='rotation'/>
117            <!-- floor employs TouchSensor.isOver to stop/start animation -->
118            <Group DEF='FloorAndToggleMarker'>
119                 <Transform translation='0 -0.1 -5'>
120                      <Shape>
121                           <Box size='10 0.1 10'/>
122                           <Appearance DEF='FloorAppearance'>
123                                <Material diffuseColor='0.1 0.8 0.9'/>
124                           </Appearance>
125                      </Shape>
126                 </Transform>
127                 <!-- starting point marker toggles playback -->
128                 <Transform translation='-5 0 0'>
129 
                    <!-- ROUTE information for TouchBox node:  [from isOver to Clock.enabled ] -->
                    <TouchSensor DEF='TouchBoxdescription='Touch box to toggle playback'/>
130                      < ROUTE  fromNode='TouchBox' fromField='isOver' toNode='Clock' toField='enabled'/>
131                      <Shape>
132                           <Box DEF='TogglePlaybacksize='0.1 0.8 0.1'/>
133 
                         <!-- Appearance OrangeAppearance is a DEF node that has 1 USE node: USE_1 -->
                         <Appearance DEF='OrangeAppearance'>
134                                <Material diffuseColor='0.8 0.5 0.2'/>
135                           </Appearance>
136                      </Shape>
137                      <Transform translation='0 1.4 0'>
138                           <Billboard>
139                                <Shape>
140                                     <Text string=' "isOver" "toggles" "motion" "off/on" '>
141                                          <FontStyle justify='"MIDDLE" "MIDDLE"size='0.3'/>
142                                     </Text>
143                                     <Appearance USE='OrangeAppearance'/>
144                                </Shape>
145                           </Billboard>
146                      </Transform>
147                      <!-- Illuminate bottom of floor for HiddenViewpoint clarity -->
148                      <PointLight location='0 -6 0radius='10'/>
149                 </Transform>
150            </Group>
151            <!-- Example instance of clickable viewpoint prototype -->
152            <ProtoInstance name='HiddenViewpointDEF='TestHiddenViewpointPrototype'>
153                 <fieldValue name='positionvalue='0 -0.5 0'/>
154                 <fieldValue name='rotationvalue='0 1 0 2.5'/>
155                 <fieldValue name='sensorRadiusvalue='1'/>
156                 <fieldValue name='labelvalue='"HiddenViewpoint" "test works!"'/>
157                 <fieldValue name='labelOffsetvalue='1 -1.25 0'/>
158                 <fieldValue name='labelFontSizevalue='0.4'/>
159                 <fieldValue name='labelColorvalue='1 0 0'/>
160            </ProtoInstance>
161       </Scene>
162  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: Clock, ConeAppearance, CoordinateAxes, FloorAndToggleMarker, FloorAppearance, OrangeAppearance, TestHiddenViewpointPrototype, TogglePlayback, TouchBox, TrackBuilder, TrackingTransform

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2, Viewpoint_3, Viewpoint_4, Viewpoint_5

Index for ExternProtoDeclare definitions: HiddenViewpoint, WaypointInterpolator
-->
X3D Tooltips element index: Appearance, Billboard, Box, Cone, ExternProtoDeclare, field, fieldValue, FontStyle, Group, head, Inline, Material, meta, PointLight, ProtoInstance, ROUTE, Scene, Shape, 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 5 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.

The following ROUTE chain begins an event-routing loop! Loop occurs at nodeDepth=4.
 
ROUTE Clock.fraction_changed TO TrackBuilder.set_fraction
TouchBox
TouchSensor
isOver
SFBool

ROUTE
event to
(1)
Clock
TimeSensor
enabled
SFBool
then
 
 
 
Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(2)
TrackBuilder
ProtoInstance
set_fraction
SFFloat
then
 
 
 
TrackBuilder
ProtoInstance
orientation_changed
SFRotation

ROUTE
event to
(3)
TrackingTransform
Transform
rotation
SFRotation
  then
 
 
 
TrackBuilder
ProtoInstance
position_changed
SFVec3f

ROUTE
event to
(3)
TrackingTransform
Transform
translation
SFVec3f
  then
 
 
 
TrackBuilder
ProtoInstance
totalDuration
SFTime

ROUTE
event to
(3)
Clock
TimeSensor
set_cycleInterval
SFTime
then
 
 
 
Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(4)
TrackBuilder
ProtoInstance
set_fraction
SFFloat
then
 
 
 
TrackBuilder
ProtoInstance
orientation_changed
SFRotation

ROUTE
event to
(5)
TrackingTransform
Transform
rotation
SFRotation
  then
 
 
 
TrackBuilder
ProtoInstance
position_changed
SFVec3f

ROUTE
event to
(5)
TrackingTransform
Transform
translation
SFVec3f
  then
 
 
 
TrackBuilder
ProtoInstance
totalDuration
SFTime

ROUTE
event to
(5)
Clock
TimeSensor
set_cycleInterval
SFTime

TestHiddenViewpointPrototype
ProtoInstance
HiddenViewpoint
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. 

     
The following ROUTE chain begins an event-routing loop! Loop occurs at nodeDepth=3.
 
ROUTE TrackBuilder.totalDuration TO Clock.set_cycleInterval
TrackBuilder
ProtoInstance
totalDuration
SFTime

ROUTE
event to
(1)
Clock
TimeSensor
set_cycleInterval
SFTime
then
 
 
 
Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(2)
TrackBuilder
ProtoInstance
set_fraction
SFFloat
then
 
 
 
TrackBuilder
ProtoInstance
orientation_changed
SFRotation

ROUTE
event to
(3)
TrackingTransform
Transform
rotation
SFRotation
  then
 
 
 
TrackBuilder
ProtoInstance
position_changed
SFVec3f

ROUTE
event to
(3)
TrackingTransform
Transform
translation
SFVec3f
  then
 
 
 
TrackBuilder
ProtoInstance
totalDuration
SFTime

ROUTE
event to
(3)
Clock
TimeSensor
set_cycleInterval
SFTime
then
 
 
 
Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(4)
TrackBuilder
ProtoInstance
set_fraction
SFFloat
then
 
 
 
TrackBuilder
ProtoInstance
orientation_changed
SFRotation

ROUTE
event to
(5)
TrackingTransform
Transform
rotation
SFRotation
  then
 
 
 
TrackBuilder
ProtoInstance
position_changed
SFVec3f

ROUTE
event to
(5)
TrackingTransform
Transform
translation
SFVec3f
  then
 
 
 
TrackBuilder
ProtoInstance
totalDuration
SFTime

ROUTE
event to
(5)
Clock
TimeSensor
set_cycleInterval
SFTime
TrackBuilder
ProtoInstance
position_changed
SFVec3f

ROUTE
event to
(1)
TrackingTransform
Transform
translation
SFVec3f
TrackBuilder
ProtoInstance
orientation_changed
SFRotation

ROUTE
event to
(1)
TrackingTransform
Transform
rotation
SFRotation

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/WaypointInterpolatorExampleIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorExample.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. -->