X3D Model Documentation: GridXZ_20x20Movable.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=' GridXZ_20x20Movable.x3d '/>
  6            <meta name='creatorcontent='MV4204 class'/>
  7            <meta name='createdcontent='22 November 2000'/>
  8            <meta name='modifiedcontent='28 November 2019'/>
  9            <meta name='descriptioncontent='Line grid authoring tool for precise measurement in 3D space: drag plane to move along Y axis, click numbers to hide grid. Oriented along XZ plane, size 20m by 20m, default block size 1m by 1m.'/>
 10            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridXZ_20x20Movable.x3d '/>
 11            <meta name='generatorcontent='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 12            <meta name='licensecontent='../../license.html'/>
 13       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: CenterText, CenterTextScript, DefaultAppearance, EndPoints, GridLocation, GridOnOffSwitch, GridSensor, LABEL_APPEARANCE, LABEL_FONT, LinesAlignedAlongX, LinesAlignedAlongZ, LineSensorAxisY, NorthEastText, NorthEastTextScript, NorthWestText, NorthWestTextScript, SouthEastText, SouthEastTextScript, SouthWestText, SouthWestTextScript, SwitchTextOnOffScript, TextLabelTouchSensor

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2
-->
 14       <Scene>
 15            <!-- Viewpoint above X axis, rotated left and oriented down to face center -->
 16            <WorldInfo title='GridXZ_20x20Movable.x3d'/>
 17            <Viewpoint description='XZ grid (0 10 25 relative)orientation='1 0 0 -0.4position='0 10 25'/>
 18            <Transform center='25 10 0rotation='0 1 0 1.57079'>
 19                 <Viewpoint description='XZ grid (25 10 0 relative)orientation='1 0 0 -0.4position='25 10 0'/>
 20            </Transform>
 21 
          <!-- ROUTE information for GridLocation node:  [from LineSensorAxisY.translation_changed to set_translation ] -->
          <Transform DEF='GridLocation'>
 22                 <Group>
 23 
                    <!-- ROUTE information for TextLabelTouchSensor node:  [from isActive to SwitchTextOnOffScript.isTouched ] -->
                    <TouchSensor DEF='TextLabelTouchSensordescription='select and hold to hide grid'/>
 24                      <Transform translation='0 -0.5 0'>
 25                           <Billboard>
 26                                <Shape>
 27 
                                   <!-- ROUTE information for CenterText node:  [from CenterTextScript.value to string ] -->
                                   <Text DEF='CenterTextstring='"origin"'>
 28 
                                        <!-- FontStyle LABEL_FONT is a DEF node that has 6 USE nodes: USE_1, USE_2, USE_3, USE_4, USE_5, USE_6 -->
                                        <FontStyle DEF='LABEL_FONTfamily='"SANS"justify='"MIDDLE" "MIDDLE"size='.4'/>
 29                                     </Text>
 30 
                                   <!-- Appearance DefaultAppearance is a DEF node that has 4 USE nodes: USE_1, USE_2, USE_3, USE_4 -->
                                   <Appearance DEF='DefaultAppearance'>
 31                                          <Material/>
 32                                     </Appearance>
 33                                </Shape>
 34                           </Billboard>
 35                      </Transform>
 36                      <Transform translation='10 -0.5 10'>
 37                           <Billboard>
 38                                <Shape>
 39 
                                   <!-- ROUTE information for SouthEastText node:  [from SouthEastTextScript.value to string ] -->
                                   <Text DEF='SouthEastTextstring='"10 0 10"'>
 40                                          <FontStyle USE='LABEL_FONT'/>
 41                                     </Text>
 42                                     <Appearance USE='DefaultAppearance'/>
 43                                </Shape>
 44                           </Billboard>
 45                      </Transform>
 46                      <Transform translation='10 -0.5 -10'>
 47                           <Billboard>
 48                                <Shape>
 49 
                                   <!-- ROUTE information for NorthEastText node:  [from NorthEastTextScript.value to string ] -->
                                   <Text DEF='NorthEastTextstring='"10 0 -10"'>
 50                                          <FontStyle USE='LABEL_FONT'/>
 51                                     </Text>
 52                                     <Appearance USE='DefaultAppearance'/>
 53                                </Shape>
 54                           </Billboard>
 55                      </Transform>
 56                      <Transform translation='-10 -0.5 -10'>
 57                           <Billboard>
 58                                <Shape>
 59 
                                   <!-- ROUTE information for NorthWestText node:  [from NorthWestTextScript.value to string ] -->
                                   <Text DEF='NorthWestTextstring='"-10 0 -10"'>
 60                                          <FontStyle USE='LABEL_FONT'/>
 61                                     </Text>
 62                                     <Appearance USE='DefaultAppearance'/>
 63                                </Shape>
 64                           </Billboard>
 65                      </Transform>
 66                      <Transform translation='-10 -0.5 10'>
 67                           <Billboard>
 68                                <Shape>
 69 
                                   <!-- ROUTE information for SouthWestText node:  [from SouthWestTextScript.value to string ] -->
                                   <Text DEF='SouthWestTextstring='"-10 0 10"'>
 70                                          <FontStyle USE='LABEL_FONT'/>
 71                                     </Text>
 72                                     <Appearance USE='DefaultAppearance'/>
 73                                </Shape>
 74                           </Billboard>
 75                      </Transform>
 76                 </Group>
 77 
               <!-- ROUTE information for GridOnOffSwitch node:  [from SwitchTextOnOffScript.touchChoice to whichChoice ] -->
               <Switch DEF='GridOnOffSwitchwhichChoice='0'>
 78                      <Group>
 79 
                         <!-- ROUTE information for GridSensor node:  [from translation_changed to LineSensorAxisY.set_translation ] -->
                         <PlaneSensor DEF='GridSensordescription='click and drag to move grid'/>
 80 
 81                                <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
 82                                <field name='translation_changedtype='SFVec3faccessType='outputOnly'/>
  <![CDATA[
            
ecmascript:

function set_translation (location, timeStamp)  {
	translation_changed [0] = 0;
	translation_changed [1] = location.y;
	translation_changed [2] = 0;
//	Browser.println ('location=' + location + ', translation_changed=' + translation_changed); 
}

          
]]>
 84                           </Script>
 85 
                         <!-- Shape LinesAlignedAlongZ is a DEF node that has 1 USE node: USE_1 -->
                         <Shape DEF='LinesAlignedAlongZ'>
 86                                <IndexedLineSet colorPerVertex='falsecolorIndex='1 0 0 0 0 2 0 0 0 0 1 0 0 0 0 2 0 0 0 0 1coordIndex='1 22 -1 2 23 -1 3 24 -1 4 25 -1 5 26 -1 6 27 -1 7 28 -1 8 29 -1 9 30 -1 10 31 -1 11 32 -1 12 33 -1 13 34 -1 14 35 -1 15 36 -1 16 37 -1 17 38 -1 18 39 -1 19 40 -1 20 41 -1 21 42 -1'>
 87                                     <Coordinate DEF='EndPointspoint='0 0 0 -10 0 10 -9 0 10 -8 0 10 -7 0 10 -6 0 10 -5 0 10 -4 0 10 -3 0 10 -2 0 10 -1 0 10 0 0 10 1 0 10 2 0 10 3 0 10 4 0 10 5 0 10 6 0 10 7 0 10 8 0 10 9 0 10 10 0 10 -10 0 -10 -9 0 -10 -8 0 -10 -7 0 -10 -6 0 -10 -5 0 -10 -4 0 -10 -3 0 -10 -2 0 -10 -1 0 -10 0 0 -10 1 0 -10 2 0 -10 3 0 -10 4 0 -10 5 0 -10 6 0 -10 7 0 -10 8 0 -10 9 0 -10 10 0 -10'/>
 88                                     <Color color='0.4 0.4 0.4 0.8 0.2 0 0.4 0.1 0.05'/>
 89                                </IndexedLineSet>
 90                           </Shape>
 91                           <Transform DEF='LinesAlignedAlongXrotation='0 1 0 1.57079'>
 92                                <Shape USE='LinesAlignedAlongZ'/>
 93                           </Transform>
 94                           <Transform translation='10.5 0 0'>
 95                                <Billboard>
 96                                     <Shape>
 97                                          <Text string='"X"'>
 98                                               <FontStyle USE='LABEL_FONT'/>
 99                                          </Text>
100 
                                        <!-- Appearance LABEL_APPEARANCE is a DEF node that has 1 USE node: USE_1 -->
                                        <Appearance DEF='LABEL_APPEARANCE'>
101                                               <Material diffuseColor='1 1 .3emissiveColor='.33 .33 .1'/>
102                                          </Appearance>
103                                     </Shape>
104                                </Billboard>
105                           </Transform>
106                           <Transform translation='0 0 10.5'>
107                                <Billboard>
108                                     <Shape>
109                                          <Text string='"Z"'>
110                                               <FontStyle USE='LABEL_FONT'/>
111                                          </Text>
112                                          <Appearance USE='LABEL_APPEARANCE'/>
113                                     </Shape>
114                                </Billboard>
115                           </Transform>
116                      </Group>
117                 </Switch>
118            </Transform>
119 
          <!-- ROUTE information for CenterTextScript node:  [from LineSensorAxisY.translation_changed to set_translation ] [from value to CenterText.string ] -->
          <Script DEF='CenterTextScript'>
120                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
121                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

// eventOut 'value' is an MFString array to match type of destination Text node string field

function initialize ( ) { 
//	Browser.println ('Grid script initialized, print function works');
//	trace ('Grid script initialized, trace function works');
}

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] = (Math.round (location.x * numberOfPlaces) / numberOfPlaces) + ' '
                 + (Math.round (location.y * numberOfPlaces) / numberOfPlaces) + ' '
                 + (Math.round (location.z * numberOfPlaces) / numberOfPlaces); 
//	Browser.println ('location=' + location); 
}

    
]]>
123            </Script>
124 
          <!-- ROUTE information for SouthEastTextScript node:  [from LineSensorAxisY.translation_changed to set_translation ] [from value to SouthEastText.string ] -->
          <Script DEF='SouthEastTextScript'>
125                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
126                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] =  10 + ' '
                 + (Math.round (location.y * numberOfPlaces) / numberOfPlaces) + ' '
                 +  10; 
}

    
]]>
128            </Script>
129 
          <!-- ROUTE information for NorthEastTextScript node:  [from LineSensorAxisY.translation_changed to set_translation ] [from value to NorthEastText.string ] -->
          <Script DEF='NorthEastTextScript'>
130                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
131                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] =  10 + ' '
                 + (Math.round (location.y * numberOfPlaces) / numberOfPlaces) + ' '
                 + -10; 
}

    
]]>
133            </Script>
134 
          <!-- ROUTE information for NorthWestTextScript node:  [from LineSensorAxisY.translation_changed to set_translation ] [from value to NorthWestText.string ] -->
          <Script DEF='NorthWestTextScript'>
135                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
136                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] = -10 + ' '
                 + (Math.round (location.y * numberOfPlaces) / numberOfPlaces) + ' '
                 + -10; 
}

    
]]>
138            </Script>
139 
          <!-- ROUTE information for SouthWestTextScript node:  [from LineSensorAxisY.translation_changed to set_translation ] [from value to SouthWestText.string ] -->
          <Script DEF='SouthWestTextScript'>
140                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
141                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] = -10 + ' '
                 + (Math.round (location.y * numberOfPlaces) / numberOfPlaces) + ' '
                 +  10; 
}

    
]]>
143            </Script>
144 
          <!-- ROUTE information for SwitchTextOnOffScript node:  [from TextLabelTouchSensor.isActive to isTouched ] [from touchChoice to GridOnOffSwitch.whichChoice ] -->
          <Script DEF='SwitchTextOnOffScript'>
145                 <field name='isTouchedtype='SFBoolaccessType='inputOnly'/>
146                 <field name='touchChoicetype='SFInt32accessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function isTouched (value, timeStamp)  {
	if (value == true)
		touchChoice = -1;
	else	touchChoice =  0; 
}

    
]]>
148            </Script>
149            < ROUTE  fromNode='GridSensor' fromField='translation_changed' toNode='LineSensorAxisY' toField='set_translation'/>
150            <!-- Send changed position to text-construction scripts -->
151            < ROUTE  fromNode='LineSensorAxisY' fromField='translation_changed' toNode='GridLocation' toField='set_translation'/>
152            < ROUTE  fromNode='LineSensorAxisY' fromField='translation_changed' toNode='CenterTextScript' toField='set_translation'/>
153            < ROUTE  fromNode='LineSensorAxisY' fromField='translation_changed' toNode='SouthEastTextScript' toField='set_translation'/>
154            < ROUTE  fromNode='LineSensorAxisY' fromField='translation_changed' toNode='NorthEastTextScript' toField='set_translation'/>
155            < ROUTE  fromNode='LineSensorAxisY' fromField='translation_changed' toNode='NorthWestTextScript' toField='set_translation'/>
156            < ROUTE  fromNode='LineSensorAxisY' fromField='translation_changed' toNode='SouthWestTextScript' toField='set_translation'/>
157            <!-- Send text showing changed position to output Text nodes -->
158            < ROUTE  fromNode='CenterTextScript' fromField='value' toNode='CenterText' toField='string'/>
159            < ROUTE  fromNode='SouthEastTextScript' fromField='value' toNode='SouthEastText' toField='string'/>
160            < ROUTE  fromNode='NorthEastTextScript' fromField='value' toNode='NorthEastText' toField='string'/>
161            < ROUTE  fromNode='NorthWestTextScript' fromField='value' toNode='NorthWestText' toField='string'/>
162            < ROUTE  fromNode='SouthWestTextScript' fromField='value' toNode='SouthWestText' toField='string'/>
163            <!-- Enable/disable grid visibility based on user touching coordinate labels -->
164            < ROUTE  fromNode='TextLabelTouchSensor' fromField='isActive' toNode='SwitchTextOnOffScript' toField='isTouched'/>
165            < ROUTE  fromNode='SwitchTextOnOffScript' fromField='touchChoice' toNode='GridOnOffSwitch' toField='whichChoice'/>
166       </Scene>
167  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: CenterText, CenterTextScript, DefaultAppearance, EndPoints, GridLocation, GridOnOffSwitch, GridSensor, LABEL_APPEARANCE, LABEL_FONT, LinesAlignedAlongX, LinesAlignedAlongZ, LineSensorAxisY, NorthEastText, NorthEastTextScript, NorthWestText, NorthWestTextScript, SouthEastText, SouthEastTextScript, SouthWestText, SouthWestTextScript, SwitchTextOnOffScript, TextLabelTouchSensor

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2
-->
X3D Tooltips element index: Appearance, Billboard, Color, Coordinate, field, FontStyle, Group, head, IndexedLineSet, Material, meta, PlaneSensor, ROUTE, Scene, Script, Shape, Switch, Text, TouchSensor, Transform, Viewpoint, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

Event Graph ROUTE Table entries with 14 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.

TextLabelTouchSensor
TouchSensor
isActive
SFBool

ROUTE
event to
(1)
SwitchTextOnOffScript
Script
isTouched
SFBool
then
 
 
 
SwitchTextOnOffScript
Script
touchChoice
SFInt32

ROUTE
event to
(2)
GridOnOffSwitch
Switch
whichChoice
SFInt32

GridSensor
PlaneSensor
translation_changed
SFVec3f

ROUTE
event to
(1)
LineSensorAxisY
Script
set_translation
SFVec3f
then
 
 
 
LineSensorAxisY
Script
translation_changed
SFVec3f

ROUTE
event to
(2)
GridLocation
Transform
set_translation
SFVec3f
  then
 
 
 
LineSensorAxisY
Script
translation_changed
SFVec3f

ROUTE
event to
(2)
CenterTextScript
Script
set_translation
SFVec3f
then
 
 
 
CenterTextScript
Script
value
MFString

ROUTE
event to
(3)
CenterText
Text
string
MFString
  then
 
 
 
LineSensorAxisY
Script
translation_changed
SFVec3f

ROUTE
event to
(2)
SouthEastTextScript
Script
set_translation
SFVec3f
then
 
 
 
SouthEastTextScript
Script
value
MFString

ROUTE
event to
(3)
SouthEastText
Text
string
MFString
  then
 
 
 
LineSensorAxisY
Script
translation_changed
SFVec3f

ROUTE
event to
(2)
NorthEastTextScript
Script
set_translation
SFVec3f
then
 
 
 
NorthEastTextScript
Script
value
MFString

ROUTE
event to
(3)
NorthEastText
Text
string
MFString
  then
 
 
 
LineSensorAxisY
Script
translation_changed
SFVec3f

ROUTE
event to
(2)
NorthWestTextScript
Script
set_translation
SFVec3f
then
 
 
 
NorthWestTextScript
Script
value
MFString

ROUTE
event to
(3)
NorthWestText
Text
string
MFString
  then
 
 
 
LineSensorAxisY
Script
translation_changed
SFVec3f

ROUTE
event to
(2)
SouthWestTextScript
Script
set_translation
SFVec3f
then
 
 
 
SouthWestTextScript
Script
value
MFString

ROUTE
event to
(3)
SouthWestText
Text
string
MFString

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

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