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=' PointTrackGeneratorPrototype5.x3d '/> |
6 | <meta name='description' content='Generator of randomized colored points using script nodes. The data arrays for coordinates and colors are generated in realtime or everyting is displayed, depending on your choice. This is still experimental, it is very difficult to get good contrast even despite trying different backgrounds.'/> |
7 | <meta name='creator' content='Frederic Roussille'/> |
8 | <meta name='created' content='14 May 2001'/> |
9 | <meta name='modified' content='28 November 2019'/> |
10 | <meta name=' warning ' content=' some debugging remains necessary. '/> |
11 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/PointTrackGeneratorPrototype5.x3d '/> |
12 | <meta name='generator' content='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
13 | <meta name='license' content='../../license.html'/> |
14 | </head> |
15 | <Scene> |
16 | <WorldInfo title='PointTrackGeneratorPrototype5.x3d'/> |
17 | <ProtoDeclare name='PointTrackGenerator' appinfo='Sequentially display track points. Both points and times are initially provided as a full set of values.'> |
18 | <ProtoInterface> |
19 |
<field name='pointPositionsArray' type='MFVec3f' value='0 0 0 10 -4 0 25 -6 0 30 -8 5 38 -15 5 45 -18 5 55 -22 5 60 -25 15 60 -27 22 55 -30 35 48 -35 35 35 -35 35 25 -45 35 20 -55 35 15 -70 35 3 -70 35 -5 -72 40 -5 -75 50 0 -80 55 15 -75 55 30 -70 55 35 -60 55 40 -50 55 50 -34 55 65 -23 70' accessType='initializeOnly'
appinfo='Point coordinates in meters referenced to local coordinate system origin.'/> |
20 |
<field name='pointTimesArray' type='MFTime' value='1 3 6 8 10 12 14 15 17 18 23 28 35 37 39 43 45 47 48 53 58 60 61 65 70' accessType='initializeOnly'
appinfo='Point times in seconds for local exercise clock. (Each time is clock time in seconds not in interval durations.)'/> |
21 |
<field name='totalDuration' type='SFTime' accessType='outputOnly'
appinfo='totalDuration is derived from the pointTimesArray and used to set cycleInterval on a controlling TimeSensor clock outside the PointTrackGenerator ProtoInstance.'/> |
22 |
<field name='displaypointsMode' type='SFInt32' value='2' accessType='inputOutput'
appinfo='displaypointsMode settings: -1=none 0=some (active interval) 1=all 2=IndexedLineSet.'/> |
23 |
<field name='durationActivePoints' type='SFTime' accessType='inputOnly'
appinfo='durationActivePoints is in seconds default initialization value is totalDuration.'/> |
24 |
<field name='timeLatestActivePoint' type='SFTime' accessType='inputOnly'
appinfo='timeLatestActivePoint is in seconds default initialization value is final point time.'/> |
25 | <field name='getStartTime' type='SFTime' accessType='outputOnly'/> |
26 | <field name='getStopTime' type='SFTime' accessType='outputOnly'/> |
27 | <field name='mappedColorPointCreator' type='SFTime' accessType='inputOnly'/> |
28 | <field name='auvName' type='MFString' value=' "../../Robots/UnmannedUnderwaterVehicles/AriesExample.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Robots/UnmannedUnderwaterVehicles/AriesExample.wrl"' accessType='inputOutput'/> |
29 | </ProtoInterface> |
30 | <ProtoBody> |
31 | <Group> |
32 | <Switch DEF='PointsGeometrySwitch' whichChoice='-1'> |
33 | <IS> |
34 | <connect nodeField='whichChoice' protoField='displaypointsMode'/> |
35 | </IS> |
36 | <Shape DEF='displaypointsMode_0'> |
37 | <PointSet DEF='ActivePointSet'> |
38 |
<!-- Coordinate
ActivePointSetCoordinateNode is a DEF node that has 1 USE node: USE_1
<!-- ROUTE information for ActivePointSetCoordinateNode node: [from point_changed to Debugger.set_debugcoordinate ] --> <Coordinate DEF='ActivePointSetCoordinateNode'/> |
39 |
<!-- Color
ActivePointSetColorNode is a DEF node that has 1 USE node: USE_1
<!-- ROUTE information for ActivePointSetColorNode node: [from color_changed to Debugger.set_debugcolor ] --> <Color DEF='ActivePointSetColorNode'/> |
40 | </PointSet> |
41 | </Shape> |
42 | <Shape DEF='displaypointsMode_1'> |
43 | <PointSet DEF='CompletePointSet'> |
44 |
<!-- Coordinate
CompletePointSetCoordinateNode is a DEF node that has 1 USE node: USE_1
<!-- ROUTE information for CompletePointSetCoordinateNode node: [from point_changed to Debugger.set_debugcoordinateC ] --> <Coordinate DEF='CompletePointSetCoordinateNode'/> |
45 |
<!-- Color
CompletePointSetColorNode is a DEF node that has 1 USE node: USE_1
<!-- ROUTE information for CompletePointSetColorNode node: [from color_changed to Debugger.set_debugcolorC ] --> <Color DEF='CompletePointSetColorNode'/> |
46 | </PointSet> |
47 | </Shape> |
48 | <Group DEF='displaypointsMode_2'> |
49 | <Shape> |
50 |
<!-- ROUTE information for ActiveLineSet node:
[from DrawPointScript.coordIndex_changed to set_coordIndex
]
-->
<IndexedLineSet DEF='ActiveLineSet'> |
51 |
<!-- Coordinate
ActiveLineSetCoordinateNode is a DEF node that has 1 USE node: USE_1
<!-- ROUTE information for ActiveLineSetCoordinateNode node: [from point to Debugger.set_debugcoord ] --> <Coordinate DEF='ActiveLineSetCoordinateNode'/> |
52 |
<!-- Color
ActiveLineSetColorNode is a DEF node that has 1 USE node: USE_1 --> <Color DEF='ActiveLineSetColorNode'/> |
53 | </IndexedLineSet> |
54 | </Shape> |
55 |
<!-- Transform
auvTransform is a DEF node that has 1 USE node: USE_1 -->
<Transform DEF='auvTransform' scale='4 4 4'> |
56 | <Inline DEF='AuvNameInline'> |
57 | <IS> |
58 | <connect nodeField='url' protoField='auvName'/> |
59 | </IS> |
60 | </Inline> |
61 | </Transform> |
62 | </Group> |
63 | </Switch> |
64 | <!-- work on color mapping later... --> |
65 |
<!-- ColorInterpolator
ColorMapInterpolator is a DEF node that has 1 USE node: USE_1 --> <ColorInterpolator DEF='ColorMapInterpolator' key='0 0.12 0.48 0.7 1' keyValue='1 1 1 1 0 0 0 1 0 0 0 1 0 0 0'/> |
66 |
<!-- ColorInterpolator
ColorMapInterpolatorForCompletePointsSet is a DEF node that has 1 USE node: USE_1
<!-- ROUTE information for ColorMapInterpolatorForCompletePointsSet node: [from value_changed to DrawPointScript.set_completePointSetColorArray ] --> <ColorInterpolator DEF='ColorMapInterpolatorForCompletePointsSet' key='0 0.12 0.48 0.7 1' keyValue='1 1 1 1 0 0 0 1 0 0 0 1 0 0 0'/> |
67 |
<!-- ROUTE information for CompletePointSetTimeSensor node:
[from cycleTime to DrawPointScript.completePointSetValue_changed
]
-->
<TimeSensor DEF='CompletePointSetTimeSensor' cycleInterval='0.01' loop='true'/> |
68 |
<!-- ROUTE information for DrawPointScript node:
[from CompletePointSetTimeSensor.cycleTime to completePointSetValue_changed
]
[from ColorMapInterpolatorForCompletePointsSet.value_changed to set_completePointSetColorArray
]
[from coordIndex_changed to ActiveLineSet.set_coordIndex
]
[from coordIndex_changed to Debugger.set_debugcoordIndex_changed
]
-->
<Script DEF='DrawPointScript' directOutput='true'> |
69 | <!-- For proper operation, first insert newPoint and then newPointTimeStamp --> |
70 | <field name='pointPositionsArray' type='MFVec3f' accessType='initializeOnly'> |
71 | <!-- no default initialization value --> |
72 | </field> |
73 | <field name='pointTimesArray' type='MFTime' accessType='initializeOnly'> |
74 | <!-- no default initialization value --> |
75 | </field> |
76 | <field name='newPointPositionsArray' type='MFVec3f' accessType='initializeOnly'> |
77 | <!-- no default initialization value --> |
78 | </field> |
79 | <field name='newPointTimesArray' type='MFTime' accessType='initializeOnly'> |
80 | <!-- no default initialization value --> |
81 | </field> |
82 | <field name='lineIndex' type='SFInt32' value='1' accessType='initializeOnly'/> |
83 | <field name='mappedColorPointCreator' type='SFTime' accessType='inputOnly'/> |
84 | <field name='index' type='SFInt32' value='0' accessType='initializeOnly'/> |
85 | <field name='completeIndex' type='SFInt32' value='0' accessType='initializeOnly'/> |
86 | <field name='ConditionComplete' type='SFBool' accessType='outputOnly'/> |
87 | <field name='ActivePointSetCoordinateNode' type='SFNode' accessType='initializeOnly'> |
88 | <Coordinate USE='ActivePointSetCoordinateNode'/> |
89 | </field> |
90 | <field name='ActivePointSetColorNode' type='SFNode' accessType='initializeOnly'> |
91 | <Color USE='ActivePointSetColorNode'/> |
92 | </field> |
93 | <field name='CompletePointSetCoordinateNode' type='SFNode' accessType='initializeOnly'> |
94 | <Coordinate USE='CompletePointSetCoordinateNode'/> |
95 | </field> |
96 | <field name='CompletePointSetColorNode' type='SFNode' accessType='initializeOnly'> |
97 | <Color USE='CompletePointSetColorNode'/> |
98 | </field> |
99 | <field name='ColorMapInterpolator' type='SFNode' accessType='initializeOnly'> |
100 | <ColorInterpolator USE='ColorMapInterpolator'/> |
101 | </field> |
102 | <field name='ColorMapInterpolatorForCompletePointsSet' type='SFNode' accessType='initializeOnly'> |
103 | <ColorInterpolator USE='ColorMapInterpolatorForCompletePointsSet'/> |
104 | </field> |
105 | <field name='ActiveLineSetCoordinateNode' type='SFNode' accessType='initializeOnly'> |
106 | <Coordinate USE='ActiveLineSetCoordinateNode'/> |
107 | </field> |
108 | <field name='ActiveLineSetColorNode' type='SFNode' accessType='initializeOnly'> |
109 | <Color USE='ActiveLineSetColorNode'/> |
110 | </field> |
111 | <field name='auvTransform' type='SFNode' accessType='initializeOnly'> |
112 | <Transform USE='auvTransform'/> |
113 | </field> |
114 | <field name='totalDuration' type='SFTime' accessType='outputOnly'/> |
115 | <field name='getStartTime' type='SFTime' accessType='outputOnly'/> |
116 | <field name='getStopTime' type='SFTime' accessType='outputOnly'/> |
117 | <field name='coordIndex_changed' type='MFInt32' accessType='outputOnly'/> |
118 | <field name='durationActivePoints' type='SFTime' accessType='inputOnly'/> |
119 | <field name='timeLatestActivePoint' type='SFTime' accessType='inputOnly'/> |
120 | <field name='completePointSetValue_changed' type='SFTime' accessType='inputOnly'/> |
121 | <field name='set_completePointSetColorArray' type='SFColor' accessType='inputOnly'/> |
122 | <IS> |
123 | <connect nodeField='pointPositionsArray' protoField='pointPositionsArray'/> |
124 | <connect nodeField='pointTimesArray' protoField='pointTimesArray'/> |
125 | <connect nodeField='totalDuration' protoField='totalDuration'/> |
126 | <connect nodeField='durationActivePoints' protoField='durationActivePoints'/> |
127 | <connect nodeField='timeLatestActivePoint' protoField='timeLatestActivePoint'/> |
128 | <connect nodeField='getStartTime' protoField='getStartTime'/> |
129 | <connect nodeField='getStopTime' protoField='getStopTime'/> |
130 | <connect nodeField='mappedColorPointCreator' protoField='mappedColorPointCreator'/> |
131 | </IS> |
<![CDATA[
ecmascript: function initialize() { totalDuration = pointTimesArray[pointTimesArray.length-1]; var today = new Date(); getStartTime = Math.round(today.getTime() / 1000); getStopTime = getStartTime + totalDuration; var m = 1; //default values for durationActivePoint and timeLatestActivePoint durationActivePoint = totalDuration; timeLatestActivePoint = pointTimesArray[pointTimesArray.length-1]; if(timeLatestActivePoint == durationActivePoint) { newPointTimesArray = pointTimesArray; newPointPositionsArray = pointPositionsArray; Browser.println ('newPointTimesArray = ' + newPointTimesArray); } if(timeLatestActivePoint > durationActivePoint) { var firstTime = latestTime = k = 0; while((timeLatestActivePoint - durationActivePoint) != pointTimesArray[firstTime]) { firstTime++; } while(timeLatestActivePoint != pointTimesArray[latestTime]) { latestTime++; } for(var j = firstTime ; j <= latestTime ; j++) { newPointTimesArray[k] = pointTimesArray[j] - pointTimesArray[firstTime] + 1; newPointPositionsArray[k] = pointPositionsArray[j]; k++; } Browser.println ('newPointTimesArray = ' + newPointTimesArray); } if(timeLatestActivePoint < durationActivePoint) { Browser.println ('Fatal error : timeLatestActivePoint < durationActivePoint !'); } ConditionComplete = false; } function completePointSetValue_changed() { if(ConditionComplete == false && completeIndex <= (pointPositionsArray.length-1)) { ColorMapInterpolatorForCompletePointsSet.set_fraction = - pointPositionsArray[completeIndex][1] / 100; Browser.println ('ColorMapInterpolatorForCompletePointsSet.set_fraction['+completeIndex+ '] = ' + ColorMapInterpolatorForCompletePointsSet.set_fraction); //need to initialize ColorMapInterpolator.set_fraction with the first point color otherwise the value is shifted ConditionComplete = true; } } function set_completePointSetColorArray(Value) { CompletePointSetColorNode.color[completeIndex] = Value; CompletePointSetCoordinateNode.point[completeIndex] = pointPositionsArray[completeIndex]; completeIndex++; ConditionComplete = false; } function mappedColorPointCreator(fractionValue) { ColorMapInterpolator.set_fraction = - newPointPositionsArray[index][1] / 100; //need to initialize ColorMapInterpolator.set_fraction with the first point color otherwise the value is shifted if(Math.floor(fractionValue) == (newPointTimesArray[index] + getStartTime)) { ActivePointSetColorNode.color[index] = ColorMapInterpolator.value_changed; ActivePointSetCoordinateNode.point[index] = newPointPositionsArray[index]; auvTransform.translation = newPointPositionsArray[index]; if(index <= 1) { ActiveLineSetCoordinateNode.point[index] = newPointPositionsArray[index]; coordIndex_changed[index] = index; ActiveLineSetColorNode.color[index][0] = 1; ActiveLineSetColorNode.color[index][1] = 1; ActiveLineSetColorNode.color[index][2] = 1; auvTransform.translation = newPointPositionsArray[index]; if(index == 1) { ActiveLineSetCoordinateNode.point[index] = newPointPositionsArray[index]; coordIndex_changed[index] = index; coordIndex_changed[index+1] = -1; ActiveLineSetColorNode.color[index-1][0] = 1; ActiveLineSetColorNode.color[index-1][1] = 0; ActiveLineSetColorNode.color[index-1][2] = 0; ActiveLineSetColorNode.color[index][0] = 1; ActiveLineSetColorNode.color[index][1] = 1; ActiveLineSetColorNode.color[index][2] = 1; } } else { ActiveLineSetCoordinateNode.point[index] = newPointPositionsArray[index]; coordIndex_changed[index+lineIndex] = coordIndex_changed[index+lineIndex-2]; coordIndex_changed[index+lineIndex+1] = index; coordIndex_changed[index+lineIndex+2] = -1; ActiveLineSetColorNode.color[index-1][0] = 1; ActiveLineSetColorNode.color[index-1][1] = 0; ActiveLineSetColorNode.color[index-1][2] = 0; ActiveLineSetColorNode.color[index][0] = 1; ActiveLineSetColorNode.color[index][1] = 1; ActiveLineSetColorNode.color[index][2] = 1; lineIndex += 2; } //print ('ActivePointSetCoordinateNode.point[' +index + '][0]=' + ActivePointSetCoordinateNode.point[index][0]); //print ('ActivePointSetCoordinateNode.point[' +index + '][1]=' + ActivePointSetCoordinateNode.point[index][1]); //print ('ActivePointSetCoordinateNode.point[' +index + '][2]=' + ActivePointSetCoordinateNode.point[index][2]); index ++; } }
]]>
|
|
133 | </Script> |
134 |
<!-- ROUTE information for Debugger node:
[from ActivePointSetCoordinateNode.point_changed to set_debugcoordinate
]
[from ActivePointSetColorNode.color_changed to set_debugcolor
]
[from ActiveLineSetCoordinateNode.point to set_debugcoord
]
[from DrawPointScript.coordIndex_changed to set_debugcoordIndex_changed
]
[from CompletePointSetCoordinateNode.point_changed to set_debugcoordinateC
]
[from CompletePointSetColorNode.color_changed to set_debugcolorC
]
-->
<Script DEF='Debugger'> |
135 | <field name='set_debugcoordinate' type='MFVec3f' accessType='inputOnly'/> |
136 | <field name='set_debugcolor' type='MFColor' accessType='inputOnly'/> |
137 | <field name='set_debugcoordinateC' type='MFVec3f' accessType='inputOnly'/> |
138 | <field name='set_debugcolorC' type='MFColor' accessType='inputOnly'/> |
139 | <field name='set_debugcoord' type='MFVec3f' accessType='inputOnly'/> |
140 | <field name='set_debugcoordIndex_changed' type='MFInt32' accessType='inputOnly'/> |
<![CDATA[
ecmascript: function set_debugcoordinate(Value) { Browser.println ('ActivePointSet : CoordinatePointArrray = ' + Value); } function set_debugcolor(Valeur) { Browser.println ('ActivePointSet : ColorPointArray = ' + Valeur); } function set_debugcoordinateC(Value) { Browser.println ('CompletePointSet : CoordinatePointArrray = ' + Value); Browser.println (' '); } function set_debugcolorC(Valeur) { Browser.println ('CompletePointSet : ColorPointArray = ' + Valeur); } function set_debugcoord(Valeur) { Browser.println ('ActiveLineSet : Coordinate.point = ' + Valeur); Browser.println (' '); } function set_debugcoordIndex_changed(Valeur) { Browser.println ('DrawPointScript : coordIndex_changed = ' + Valeur); }
]]>
|
|
142 | </Script> |
143 | </Group> |
144 | < ROUTE fromNode='CompletePointSetTimeSensor' fromField='cycleTime' toNode='DrawPointScript' toField='completePointSetValue_changed'/> |
145 | < ROUTE fromNode='ColorMapInterpolatorForCompletePointsSet' fromField='value_changed' toNode='DrawPointScript' toField='set_completePointSetColorArray'/> |
146 | < ROUTE fromNode='DrawPointScript' fromField='coordIndex_changed' toNode='ActiveLineSet' toField='set_coordIndex'/> |
147 | < ROUTE fromNode='ActivePointSetCoordinateNode' fromField='point_changed' toNode='Debugger' toField='set_debugcoordinate'/> |
148 | < ROUTE fromNode='ActivePointSetColorNode' fromField='color_changed' toNode='Debugger' toField='set_debugcolor'/> |
149 | < ROUTE fromNode='ActiveLineSetCoordinateNode' fromField='point' toNode='Debugger' toField='set_debugcoord'/> |
150 | < ROUTE fromNode='DrawPointScript' fromField='coordIndex_changed' toNode='Debugger' toField='set_debugcoordIndex_changed'/> |
151 | < ROUTE fromNode='CompletePointSetCoordinateNode' fromField='point_changed' toNode='Debugger' toField='set_debugcoordinateC'/> |
152 | < ROUTE fromNode='CompletePointSetColorNode' fromField='color_changed' toNode='Debugger' toField='set_debugcolorC'/> |
153 | </ProtoBody> |
154 | </ProtoDeclare> |
155 | <!-- =================== --> |
156 | <!-- Example scene goes here --> |
157 | <Viewpoint description='MainView' position='0 -50 200'/> |
158 |
<!-- ROUTE information for TrackGeneratorInstance node:
[from DisplayingTimer.fraction_changed to mappedColorPointCreator
]
[from getStartTime to DisplayingTimer.set_startTime
]
[from getStopTime to DisplayingTimer.set_stopTime
]
[from totalDuration to DisplayingTimer.set_cycleInterval
]
-->
<ProtoInstance name='PointTrackGenerator' DEF='TrackGeneratorInstance'> |
159 | <fieldValue name='displaypointsMode' value='2'/> |
160 | </ProtoInstance> |
161 |
<!-- ROUTE information for DisplayingTimer node:
[from TrackGeneratorInstance.getStartTime to set_startTime
]
[from TrackGeneratorInstance.getStopTime to set_stopTime
]
[from TrackGeneratorInstance.totalDuration to set_cycleInterval
]
[from fraction_changed to TrackGeneratorInstance.mappedColorPointCreator
]
-->
<TimeSensor DEF='DisplayingTimer'/> |
162 | < ROUTE fromNode='TrackGeneratorInstance' fromField='getStartTime' toNode='DisplayingTimer' toField='set_startTime'/> |
163 | < ROUTE fromNode='TrackGeneratorInstance' fromField='getStopTime' toNode='DisplayingTimer' toField='set_stopTime'/> |
164 | < ROUTE fromNode='TrackGeneratorInstance' fromField='totalDuration' toNode='DisplayingTimer' toField='set_cycleInterval'/> |
165 | < ROUTE fromNode='DisplayingTimer' fromField='fraction_changed' toNode='TrackGeneratorInstance' toField='mappedColorPointCreator'/> |
166 | </Scene> |
167 | </X3D> |
Event Graph ROUTE Table entries with 13 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.
CompletePointSetTimeSensor
TimeSensor cycleTime SFTime |
DrawPointScript
Script completePointSetValue_changed SFTime |
then
|
DrawPointScript
Script coordIndex_changed MFInt32 |
ActiveLineSet
IndexedLineSet set_coordIndex MFInt32 |
||
then
|
DrawPointScript
Script coordIndex_changed MFInt32 |
Debugger
Script set_debugcoordIndex_changed MFInt32 |
DrawPointScript
Script coordIndex_changed MFInt32 |
ActiveLineSet
IndexedLineSet set_coordIndex MFInt32 |
|
DrawPointScript
Script coordIndex_changed MFInt32 |
Debugger
Script set_debugcoordIndex_changed MFInt32 |
<!--
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.
-->