<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://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 =' https://www.web3d.org/specifications/x3d-3.0.xsd '>
<head>
<component level='1name='DIS'/>
<meta name='titlecontent='NetworkedCamera.x3d'/>
<meta name='descriptioncontent='Networked control of master/slave viewpoints using DIS EspduTransform node.'/>
<meta name='creatorcontent='Alan Hudson and Don Brutzman'/>
<meta name='translatorcontent='LT Patrick Sullivan'/>
<meta name='createdcontent='19 April 2005'/>
<meta name='translatedcontent='19 April 2005'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name=' warning content=' under development. will split into simple Inline-capable camera scene and usage example. Xj3D chat-server fallback needs to be checked. '/>
<meta name='referencecontent=' http://www.xj3d.org/extensions/DIS.html '/>
<meta name='referencecontent=' http://www.yumetech.com '/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/DistributedInteractiveSimulation/NetworkedCamera.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!-- -->
<Scene>
<WorldInfo title='NetworkedCamera.x3d'/>
<Background groundAngle='1.45 1.57groundColor='.005 .05 .03 .01 .13 .09 .025 .22 .17skyAngle='.9 1.57skyColor='0 0 .2 .1 .1 .8 .7 .7 1'/>
<Viewpoint description='Free Navigationposition='28.85 3.978 -98.85'/>
<!-- ROUTE information for MasterViewpoint node:  [from isBound to ViewpointControlScript.bindMaster ] [from isBound to WorldProximitySensor.enabled ] -->
<Viewpoint DEF='MasterViewpointdescription='Master Viewpointorientation='0.001188 -1 -0.008389 -2.86position='28.85 3.978 -98.85'/>
<!-- ROUTE information for WorldProximitySensor node:  [from MasterViewpoint.isBound to enabled ] [from position_changed to ViewpointControlScript.user_translation ] [from orientation_changed to ViewpointControlScript.user_rotation ] -->
<ProximitySensor DEF='WorldProximitySensorsize='1000000 1000000 1000000'/>
<!-- ROUTE information for CameraEspduTransform node:  [from ViewpointControlScript.sharedTranslation to set_translation ] [from ViewpointControlScript.sharedRotation to set_rotation ] [from ViewpointControlScript.networkMode to networkMode ] -->
<EspduTransform DEF='CameraEspduTransformaddress='224.2.181.145networkMode='networkWriterport='62040writeInterval='.01containerField='children'>
<!-- ROUTE information for SlavedViewpoint node:  [from isBound to ViewpointControlScript.bindSlave ] -->
<Viewpoint DEF='SlavedViewpointdescription='Slaved Viewpointposition='0 0 0'/>
</EspduTransform>
<!-- ROUTE information for ViewpointControlScript node:  [from MasterViewpoint.isBound to bindMaster ] [from SlavedViewpoint.isBound to bindSlave ] [from WorldProximitySensor.position_changed to user_translation ] [from WorldProximitySensor.orientation_changed to user_rotation ] [from sharedTranslation to CameraEspduTransform.set_translation ] [from sharedRotation to CameraEspduTransform.set_rotation ] [from networkMode to CameraEspduTransform.networkMode ] -->
<Script DEF='ViewpointControlScript'>
<field name='bindMastertype='SFBoolaccessType='inputOnly'/>
<field name='bindSlavetype='SFBoolaccessType='inputOnly'/>
<field name='user_translationtype='SFVec3faccessType='inputOnly'/>
<field name='user_rotationtype='SFRotationaccessType='inputOnly'/>
<field name='sharedTranslationtype='SFVec3faccessType='outputOnly'/>
<field name='sharedRotationtype='SFRotationaccessType='outputOnly'/>
<field name='networkModetype='SFStringaccessType='outputOnly'/>
<field name='isMastertype='SFBoolvalue='falseaccessType='initializeOnly'/>
<field name='isSlavetype='SFBoolvalue='falseaccessType='initializeOnly'/>
<![CDATA[
      
ecmascript:

function bindMaster (value)
{
	Browser.print('[NetworkedCamera] Master viewpoint bound');
	isMaster = value;
	if (isMaster) networkMode ='networkWriter';
}

function bindSlave (value)
{
	Browser.print('[NetworkedCamera] Slave viewpoint bound');
	isSlave = value;
	if (isSlave) networkMode ='networkReader';
}

function user_translation(value)
{
	if (isMaster) sharedTranslation = value;
}

function user_rotation(value)
{
	if (isMaster) sharedRotation = value;
}

    
]]>
</Script>
<ROUTE fromNode='MasterViewpointfromField='isBoundtoNode='ViewpointControlScripttoField='bindMaster'/>
<ROUTE fromNode='MasterViewpointfromField='isBoundtoNode='WorldProximitySensortoField='enabled'/>
<ROUTE fromNode='SlavedViewpointfromField='isBoundtoNode='ViewpointControlScripttoField='bindSlave'/>
<ROUTE fromNode='WorldProximitySensorfromField='position_changedtoNode='ViewpointControlScripttoField='user_translation'/>
<ROUTE fromNode='WorldProximitySensorfromField='orientation_changedtoNode='ViewpointControlScripttoField='user_rotation'/>
<ROUTE fromNode='ViewpointControlScriptfromField='sharedTranslationtoNode='CameraEspduTransformtoField='set_translation'/>
<ROUTE fromNode='ViewpointControlScriptfromField='sharedRotationtoNode='CameraEspduTransformtoField='set_rotation'/>
<ROUTE fromNode='ViewpointControlScriptfromField='networkModetoNode='CameraEspduTransformtoField='networkMode'/>
<!-- ====================================================== -->
<!-- Integrate heads-up display with onscreen networkMode selection and position/orientation tracing -->
<!-- use of HeadsUpDislay and ViewPositionOrientation prototypes will be helpful if Xj3D supports them -->
<!-- consider entity discovery as well -->
<!-- ====================================================== -->
<!-- Example background viewing scene, split out into separate example next -->
<Background groundAngle='1.45 1.57groundColor='.005 .05 .03 .01 .13 .09 .025 .22 .17skyAngle='.9 1.57skyColor='0 0 .2 .1 .1 .8 .7 .7 1'/>
<NavigationInfo speed='10type='"WALK" "ANY"'/>
<Transform translation='0 -0.1 0'>
<Shape>
<Appearance>
<PixelTexture DEF='PTimage='2 2 3 0x0 0x00FF00 0x0000FF 0xFF0000'/>
<TextureTransform scale='100 100'/>
</Appearance>
<IndexedFaceSet colorPerVertex='falsecoordIndex='0 1 2 3 0 -1'>
<Coordinate point='1000 0 1000 1000 0 -1000 -1000 0 -1000 -1000 0 1000'/>
</IndexedFaceSet>
</Shape>
</Transform>
</Scene>
</X3D>
<!--

Index for DEF nodes : CameraEspduTransform, MasterViewpoint, PT, SlavedViewpoint, ViewpointControlScript, WorldProximitySensor

Index for Viewpoint images : Viewpoint_1, MasterViewpoint, SlavedViewpoint
-->

<!-- 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)
-->

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