<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersive' version='3.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' http://www.web3d.org/specifications/x3d-3.0.xsd '>
<head>
<meta name='titlecontent='GridXZ_20x20Movable.x3d'/>
<meta name='creatorcontent='MV4204 class'/>
<meta name='createdcontent='22 November 2000'/>
<meta name='modifiedcontent='30 March 2016'/>
<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.'/>
<meta name='identifiercontent=' https://savage.nps.edu/Savage/Tools/Authoring/GridXZ_20x20Movable.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../../license.html'/>
</head>
<!-- -->
<Scene>
<!-- Viewpoint above X axis, rotated left and oriented down to face center -->
<Viewpoint description='XZ grid (0 10 25 relative)orientation='1 0 0 -0.4position='0 10 25'/>
<Transform center='25 10 0rotation='0 1 0 1.57079'>
<Viewpoint description='XZ grid (25 10 0 relative)orientation='1 0 0 -0.4position='25 10 0'/>
</Transform>
<!-- ROUTE information for GridLocation node:  [from LineSensorAxisY.translation_changed to set_translation ] -->
<Transform DEF='GridLocation'>
<Group>
<!-- ROUTE information for TextLabelTouchSensor node:  [from isActive to SwitchTextOnOffScript.isTouched ] -->
<TouchSensor DEF='TextLabelTouchSensordescription='select and hold to hide grid'/>
<Transform translation='0 -0.5 0'>
<Billboard>
<Shape>
<!-- ROUTE information for CenterText node:  [from CenterTextScript.value to string ] -->
<Text DEF='CenterTextstring='"origin"'>
<FontStyle DEF='LABEL_FONTfamily='"SANS"justify='"MIDDLE" "MIDDLE"size='.4'/>
</Text>
<Appearance DEF='DefaultAppearance'>
<Material/>
</Appearance>
</Shape>
</Billboard>
</Transform>
<Transform translation='10 -0.5 10'>
<Billboard>
<Shape>
<!-- ROUTE information for SouthEastText node:  [from SouthEastTextScript.value to string ] -->
<Text DEF='SouthEastTextstring='"10 0 10"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='DefaultAppearance'/>
</Shape>
</Billboard>
</Transform>
<Transform translation='10 -0.5 -10'>
<Billboard>
<Shape>
<!-- ROUTE information for NorthEastText node:  [from NorthEastTextScript.value to string ] -->
<Text DEF='NorthEastTextstring='"10 0 -10"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='DefaultAppearance'/>
</Shape>
</Billboard>
</Transform>
<Transform translation='-10 -0.5 -10'>
<Billboard>
<Shape>
<!-- ROUTE information for NorthWestText node:  [from NorthWestTextScript.value to string ] -->
<Text DEF='NorthWestTextstring='"-10 0 -10"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='DefaultAppearance'/>
</Shape>
</Billboard>
</Transform>
<Transform translation='-10 -0.5 10'>
<Billboard>
<Shape>
<!-- ROUTE information for SouthWestText node:  [from SouthWestTextScript.value to string ] -->
<Text DEF='SouthWestTextstring='"-10 0 10"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='DefaultAppearance'/>
</Shape>
</Billboard>
</Transform>
</Group>
<!-- ROUTE information for GridOnOffSwitch node:  [from SwitchTextOnOffScript.touchChoice to whichChoice ] -->
<Switch DEF='GridOnOffSwitchwhichChoice='0'>
<Group>
<!-- ROUTE information for GridSensor node:  [from translation_changed to LineSensorAxisY.set_translation ] -->
<PlaneSensor DEF='GridSensordescription='click and drag to move grid'/>
<!-- ROUTE information for LineSensorAxisY node:  [from GridSensor.translation_changed to set_translation ] [from translation_changed to GridLocation.set_translation ] [from translation_changed to CenterTextScript.set_translation ] [from translation_changed to SouthEastTextScript.set_translation ] [from translation_changed to NorthEastTextScript.set_translation ] [from translation_changed to NorthWestTextScript.set_translation ] [from translation_changed to SouthWestTextScript.set_translation ] -->
<Script DEF='LineSensorAxisY'>
<field name='set_translationtype='SFVec3faccessType='inputOnly'/>
<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.print ('location=' + location + ', translation_changed=' + translation_changed); 
}

          
]]>
</Script>
<Shape DEF='LinesAlignedAlongZ'>
<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'>
<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'/>
<Color color='0.4 0.4 0.4 0.8 0.2 0 0.4 0.1 0.05'/>
</IndexedLineSet>
</Shape>
<Transform DEF='LinesAlignedAlongXrotation='0 1 0 1.57079'>
<Shape USE='LinesAlignedAlongZ'/>
</Transform>
<Transform translation='10.5 0 0'>
<Billboard>
<Shape>
<Text string='"X"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance DEF='LABEL_APPEARANCE'>
<Material diffuseColor='1 1 .3emissiveColor='.33 .33 .1'/>
</Appearance>
</Shape>
</Billboard>
</Transform>
<Transform translation='0 0 10.5'>
<Billboard>
<Shape>
<Text string='"Z"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='LABEL_APPEARANCE'/>
</Shape>
</Billboard>
</Transform>
</Group>
</Switch>
</Transform>
<!-- ROUTE information for CenterTextScript node:  [from LineSensorAxisY.translation_changed to set_translation ] [from value to CenterText.string ] -->
<Script DEF='CenterTextScript'>
<field name='set_translationtype='SFVec3faccessType='inputOnly'/>
<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.print ('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.print ('location=' + location); 
}

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

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

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

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

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

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

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

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

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

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

    
]]>
</Script>
<ROUTE fromNode='GridSensorfromField='translation_changedtoNode='LineSensorAxisYtoField='set_translation'/>
<!-- Send changed position to text-construction scripts -->
<ROUTE fromNode='LineSensorAxisYfromField='translation_changedtoNode='GridLocationtoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisYfromField='translation_changedtoNode='CenterTextScripttoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisYfromField='translation_changedtoNode='SouthEastTextScripttoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisYfromField='translation_changedtoNode='NorthEastTextScripttoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisYfromField='translation_changedtoNode='NorthWestTextScripttoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisYfromField='translation_changedtoNode='SouthWestTextScripttoField='set_translation'/>
<!-- Send text showing changed position to output Text nodes -->
<ROUTE fromNode='CenterTextScriptfromField='valuetoNode='CenterTexttoField='string'/>
<ROUTE fromNode='SouthEastTextScriptfromField='valuetoNode='SouthEastTexttoField='string'/>
<ROUTE fromNode='NorthEastTextScriptfromField='valuetoNode='NorthEastTexttoField='string'/>
<ROUTE fromNode='NorthWestTextScriptfromField='valuetoNode='NorthWestTexttoField='string'/>
<ROUTE fromNode='SouthWestTextScriptfromField='valuetoNode='SouthWestTexttoField='string'/>
<!-- Enable/disable grid visibility based on user touching coordinate labels -->
<ROUTE fromNode='TextLabelTouchSensorfromField='isActivetoNode='SwitchTextOnOffScripttoField='isTouched'/>
<ROUTE fromNode='SwitchTextOnOffScriptfromField='touchChoicetoNode='GridOnOffSwitchtoField='whichChoice'/>
</Scene>
</X3D>
<!--

Index for DEF nodes : 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 images : Viewpoint_1, Viewpoint_2
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
-->

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->