X3D Model Documentation: NetworkedCamera.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            <component level='1name='DIS'/>
  6            <meta name='titlecontent='NetworkedCamera.x3d'/>
  7            <meta name='descriptioncontent='Networked control of master/slave viewpoints using DIS EspduTransform node.'/>
  8            <meta name='creatorcontent='Alan Hudson and Don Brutzman'/>
  9            <meta name='translatorcontent='LT Patrick Sullivan'/>
 10            <meta name='createdcontent='19 April 2005'/>
 11            <meta name='translatedcontent='19 April 2005'/>
 12            <meta name='modifiedcontent='9 October 2023'/>
 13            <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. '/>
 14            <meta name='referencecontent='http://www.xj3d.org/extensions/DIS.html'/>
 15            <meta name='referencecontent='http://www.yumetech.com'/>
 16            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/DistributedInteractiveSimulation/NetworkedCamera.x3d'/>
 17            <meta name='generatorcontent='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/>
 18            <meta name='licensecontent='../license.html'/>
 19       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: CameraEspduTransform, MasterViewpoint, PT, SlavedViewpoint, ViewpointControlScript, WorldProximitySensor

Index for Viewpoint nodes: Viewpoint_1, MasterViewpoint, SlavedViewpoint
-->
 20       <Scene>
 21            <WorldInfo title='NetworkedCamera.x3d'/>
 22            <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'/>
 23            <Viewpoint description='Free Navigationposition='28.85 3.978 -98.85'/>
 24 
          <!-- 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'/>
 25 
          <!-- 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'/>
 26 
          <!-- 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'>
 27 
               <!-- ROUTE information for SlavedViewpoint node:  [from isBound to ViewpointControlScript.bindSlave ] -->
               <Viewpoint DEF='SlavedViewpointdescription='Slaved Viewpointposition='0 0 0'/>
 28            </EspduTransform>
 29 
 30                 <field name='bindMastertype='SFBoolaccessType='inputOnly'/>
 31                 <field name='bindSlavetype='SFBoolaccessType='inputOnly'/>
 32                 <field name='user_translationtype='SFVec3faccessType='inputOnly'/>
 33                 <field name='user_rotationtype='SFRotationaccessType='inputOnly'/>
 34                 <field name='sharedTranslationtype='SFVec3faccessType='outputOnly'/>
 35                 <field name='sharedRotationtype='SFRotationaccessType='outputOnly'/>
 36                 <field name='networkModetype='SFStringaccessType='outputOnly'/>
 37                 <field name='isMastertype='SFBoolvalue='falseaccessType='initializeOnly'/>
 38                 <field name='isSlavetype='SFBoolvalue='falseaccessType='initializeOnly'/>
  <![CDATA[
      
ecmascript:

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

function bindSlave (value)
{
	Browser.println ('[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;
}

    
]]>
 40            </Script>
 41            < ROUTE  fromNode='MasterViewpoint' fromField='isBound' toNode='ViewpointControlScript' toField='bindMaster'/>
 42            < ROUTE  fromNode='MasterViewpoint' fromField='isBound' toNode='WorldProximitySensor' toField='enabled'/>
 43            < ROUTE  fromNode='SlavedViewpoint' fromField='isBound' toNode='ViewpointControlScript' toField='bindSlave'/>
 44            < ROUTE  fromNode='WorldProximitySensor' fromField='position_changed' toNode='ViewpointControlScript' toField='user_translation'/>
 45            < ROUTE  fromNode='WorldProximitySensor' fromField='orientation_changed' toNode='ViewpointControlScript' toField='user_rotation'/>
 46            < ROUTE  fromNode='ViewpointControlScript' fromField='sharedTranslation' toNode='CameraEspduTransform' toField='set_translation'/>
 47            < ROUTE  fromNode='ViewpointControlScript' fromField='sharedRotation' toNode='CameraEspduTransform' toField='set_rotation'/>
 48            < ROUTE  fromNode='ViewpointControlScript' fromField='networkMode' toNode='CameraEspduTransform' toField='networkMode'/>
 49            <!-- ====================================================== -->
 50            <!-- Integrate heads-up display with onscreen networkMode selection and position/orientation tracing -->
 51            <!-- use of HeadsUpDislay and ViewPositionOrientation prototypes will be helpful if Xj3D supports them -->
 52            <!-- consider entity discovery as well -->
 53            <!-- ====================================================== -->
 54            <!-- Example background viewing scene, split out into separate example next -->
 55            <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'/>
 56            <NavigationInfo speed='10type='"WALK" "ANY"'/>
 57            <Transform translation='0 -0.1 0'>
 58                 <Shape>
 59                      <Appearance>
 60                           <PixelTexture DEF='PTimage='2 2 3 0x0 0x00FF00 0x0000FF 0xFF0000'/>
 61                           <TextureTransform scale='100 100'/>
 62                      </Appearance>
 63                      <IndexedFaceSet colorPerVertex='falsecoordIndex='0 1 2 3 0 -1'>
 64                           <Coordinate point='1000 0 1000 1000 0 -1000 -1000 0 -1000 -1000 0 1000'/>
 65                      </IndexedFaceSet>
 66                 </Shape>
 67            </Transform>
 68       </Scene>
 69  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: CameraEspduTransform, MasterViewpoint, PT, SlavedViewpoint, ViewpointControlScript, WorldProximitySensor

Index for Viewpoint nodes: Viewpoint_1, MasterViewpoint, SlavedViewpoint
-->
X3D Tooltips element index: Appearance, Background, component, Coordinate, EspduTransform, field, head, IndexedFaceSet, meta, NavigationInfo, PixelTexture, ProximitySensor, ROUTE, Scene, Script, Shape, TextureTransform, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

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

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/Basic/DistributedInteractiveSimulation/NetworkedCameraIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/DistributedInteractiveSimulation/NetworkedCamera.x3d -->

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

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