| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "https://www.web3d.org/specifications/x3d-3.1.dtd">
|
| 3 | <X3D profile='Immersive' version='3.1' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.1.xsd'> |
| 4 | <head> |
| 5 | <meta name='title' content=' NetworkSensorConnectionPrototypes.x3d '/> |
| 6 | <meta name='description' content='Prototypes for NetworkSensor and Connection nodes'/> |
| 7 | <meta name='creator' content='Don Brutzman, Chris Thorne, Don McGregor, Shun-Yun Hu'/> |
| 8 | <meta name='created' content='14 March 2008'/> |
| 9 | <meta name='modified' content='2 January 2025'/> |
| 10 | <meta name=' warning ' content=' under development '/> |
| 11 | <meta name='reference' content=' NetworkSensorConnectionNodes.html '/> |
| 12 | <meta name='reference' content=' http://www.xj3d.org/tutorials/general_sai.html '/> |
| 13 | <meta name='reference' content=' https://www.web3d.org/x3d/specifications/ISO-IEC-CD-19775-2.2/Part02/X3D_SAI.html '/> |
| 14 | <meta name='reference' content=' https://www.web3d.org/x3d/specifications/ISO-IEC-19777-2-X3DLanguageBindings-Java/Part2/X3D_Java.html '/> |
| 15 | <meta name='subject' content='Prototypes for NetworkSensor and Connection nodes'/> |
| 16 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Basic/Networking/NetworkSensorConnectionPrototypes.x3d '/> |
| 17 | <meta name='generator' content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
| 18 | <meta name='license' content='../license.html'/> |
| 19 | </head> |
| 20 | <Scene> |
| 21 | <WorldInfo title='NetworkSensorConnectionPrototypes.x3d'/> |
| 22 | <ProtoDeclare name='NetworkSensor'> |
| 23 | <ProtoInterface> |
| 24 | <field name='enabled' type='SFBool' value='true' accessType='inputOutput'/> |
| 25 |
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='X3DMetadataObject node type only'> |
| 26 | <!-- Metadata initialization node is NULL --> |
| 27 | </field> |
| 28 | <field name='isActive' type='SFBool' accessType='outputOnly'/> |
| 29 |
<field name='connection' type='SFNode' accessType='initializeOnly'
appinfo='Connection node only'> |
| 30 | <!-- Default Connection node goes here --> |
| 31 | </field> |
| 32 | <field name='httpRequest' type='SFString' accessType='inputOnly'/> |
| 33 | <field name='httpResponse' type='MFString' accessType='outputOnly'/> |
| 34 | <field name='channelId' type='SFString' value='true' accessType='initializeOnly'/> |
| 35 | <!-- TODO: how to handle user-defined fields? --> |
| 36 | <!-- perhaps corresponding MFString arrays for fieldName, fieldType, fieldAccessType, fieldInitialValues --> |
| 37 | <!-- for now we'll simply try to get a MFString field to work --> |
| 38 |
<field name='textInput' type='SFString' accessType='inputOnly'
appinfo='ROUTE StringSensor output here'/> |
| 39 |
<field name='textOutput' type='MFString' accessType='outputOnly'
appinfo='ROUTE this output to Text node string field'/> |
| 40 | <!-- TODO: can we get consistent type for textInput? --> |
| 41 | </ProtoInterface> |
| 42 | <ProtoBody> |
| 43 | <!-- First node determines node type of prototype --> |
| 44 | <Script DEF='NetworkSensorScript' url=' "NetworkSensorScript.class" "https://www.web3d.org/x3d/content/examples/Networking/NetworkSensorScript.class" '> |
| 45 | <field name='enabled' type='SFBool' accessType='inputOutput'/> |
| 46 | <field name='metadata' type='SFNode' accessType='inputOutput'/> |
| 47 | <field name='isActive' type='SFBool' accessType='outputOnly'/> |
| 48 |
<field name='connection' type='SFNode' accessType='initializeOnly'
appinfo='Connection node only'/> |
| 49 | <field name='httpRequest' type='SFString' accessType='inputOnly'/> |
| 50 | <field name='httpResponse' type='MFString' accessType='outputOnly'/> |
| 51 | <field name='channelId' type='SFString' accessType='initializeOnly'/> |
| 52 | <IS> |
| 53 | <connect nodeField='enabled' protoField='enabled'/> |
| 54 | <connect nodeField='metadata' protoField='metadata'/> |
| 55 | <connect nodeField='isActive' protoField='isActive'/> |
| 56 | <connect nodeField='connection' protoField='connection'/> |
| 57 | <connect nodeField='httpRequest' protoField='httpRequest'/> |
| 58 | <connect nodeField='httpResponse' protoField='httpResponse'/> |
| 59 | <connect nodeField='channelId' protoField='channelId'/> |
| 60 | </IS> |
| 61 | </Script> |
| 62 | <!-- Subsequent nodes do not render, but still must be a valid X3D subgraph --> |
| 63 | </ProtoBody> |
| 64 | </ProtoDeclare> |
| 65 | <ProtoDeclare name='Connection'> |
| 66 | <ProtoInterface> |
| 67 | <field name='enabled' type='SFBool' value='true' accessType='inputOutput'/> |
| 68 | <field name='metadata' type='SFNode' accessType='inputOutput'> |
| 69 | <!-- Metadata initialization node is NULL --> |
| 70 | </field> |
| 71 | <field name='isActive' type='SFBool' accessType='outputOnly'/> |
| 72 | <field name='url' type='MFString' value='"x3dp://localhost:80"' accessType='inputOutput'/> |
| 73 | <!-- 1 for HTTP, 2 for HTTP 1.1, 3 for TCP/IP, 4 for UDP, 5 for multicast --> |
| 74 | <!-- spec TODO: change these code numbers to string enumerations instead --> |
| 75 | <field name='protocol' type='SFInt32' value='0' accessType='initializeOnly'/> |
| 76 | <field name='timeOut' type='SFTime' value='0' accessType='inputOutput'/> |
| 77 | <field name='secure' type='SFBool' accessType='inputOnly'/> |
| 78 | </ProtoInterface> |
| 79 | <ProtoBody> |
| 80 | <!-- First node determines node type of prototype --> |
| 81 | <Script DEF='ConnectionScript' url=' "ConnectionScript.class" "https://www.web3d.org/x3d/content/examples/Networking/ConnectionScript.class" '> |
| 82 | <field name='enabled' type='SFBool' accessType='inputOutput'/> |
| 83 | <field name='isActive' type='SFBool' accessType='outputOnly'/> |
| 84 | <field name='url' type='MFString' accessType='inputOutput'/> |
| 85 | <field name='protocol' type='SFInt32' accessType='initializeOnly'/> |
| 86 | <field name='timeOut' type='SFTime' accessType='inputOutput'/> |
| 87 | <field name='secure' type='SFBool' accessType='inputOnly'/> |
| 88 | <IS> |
| 89 | <connect nodeField='enabled' protoField='enabled'/> |
| 90 | <connect nodeField='isActive' protoField='isActive'/> |
| 91 | <connect nodeField='url' protoField='url'/> |
| 92 | <connect nodeField='protocol' protoField='protocol'/> |
| 93 | <connect nodeField='timeOut' protoField='timeOut'/> |
| 94 | <connect nodeField='secure' protoField='secure'/> |
| 95 | </IS> |
| 96 | </Script> |
| 97 | <!-- Subsequent nodes do not render, but still must be a valid X3D subgraph --> |
| 98 | </ProtoBody> |
| 99 | </ProtoDeclare> |
| 100 | <!-- We'll put our initial example next. First the listener will output networked messages to a Text node --> |
| 101 | <Shape> |
| 102 |
<!-- ROUTE information for MessageOutput node:
[from TextListener.textOutput to string
]
-->
<Text DEF='MessageOutput' string='"NetworkSensor messages will appear here"'> |
| 103 | <FontStyle justify='"MIDDLE" "MIDDLE"'/> |
| 104 | </Text> |
| 105 | <Appearance> |
| 106 | <Material ambientIntensity='0.25' diffuseColor='0.374008 0 0.748016' shininess='0.4' specularColor='0.909091 0.909091 0.909091' transparency='0.35'/> |
| 107 | </Appearance> |
| 108 | </Shape> |
| 109 | <!-- Only need a single Connection definition for this example --> |
| 110 |
<!-- ProtoInstance
OurNetworkChannel is a DEF node that has 2 USE nodes: USE_1, USE_2 -->
<ProtoInstance name='Connection' DEF='OurNetworkChannel'> |
| 111 | <fieldValue name='url' value='"x3dp://localhost:80"'/> |
| 112 | <!-- protocol 1=http --> |
| 113 | <fieldValue name='protocol' value='1'/> |
| 114 | <fieldValue name='timeOut' value='10'/> |
| 115 | </ProtoInstance> |
| 116 | <!-- Here is the listener that connects and sends strings to the Text node --> |
| 117 |
<!-- ROUTE information for TextListener node:
[from textOutput to MessageOutput.string
]
-->
<ProtoInstance name='NetworkSensor' DEF='TextListener'> |
| 118 | <fieldValue name='connection'> |
| 119 | <ProtoInstance USE='OurNetworkChannel'/> |
| 120 | </fieldValue> |
| 121 | <fieldValue name='channelId' value='78'/> |
| 122 | </ProtoInstance> |
| 123 | <!-- TODO: once a single string can successfully be sent, insert an intermediate Script to remember last 10 strings --> |
| 124 | < ROUTE fromNode='TextListener' fromField='textOutput' toNode='MessageOutput' toField='string'/> |
| 125 | <!-- Now capture text from local keyboard, send to scenes listening to this network connection --> |
| 126 |
<!-- ROUTE information for TextSender node:
[from KeyboardDetector.finalText to textInput
]
-->
<ProtoInstance name='NetworkSensor' DEF='TextSender'> |
| 127 | <fieldValue name='connection'> |
| 128 | <ProtoInstance USE='OurNetworkChannel'/> |
| 129 | </fieldValue> |
| 130 | <fieldValue name='channelId' value='78'/> |
| 131 | </ProtoInstance> |
| 132 |
<!-- ROUTE information for KeyboardDetector node:
[from finalText to TextSender.textInput
]
-->
<StringSensor DEF='KeyboardDetector'/> |
| 133 | < ROUTE fromNode='KeyboardDetector' fromField='finalText' toNode='TextSender' toField='textInput'/> |
| 134 | <!-- done. we should now be able to type text and have it appear in the output for whoever's using the same scene. --> |
| 135 | </Scene> |
| 136 | </X3D> |
Event Graph ROUTE Table entries with 2 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.
|
KeyboardDetector
StringSensor finalText SFString |
TextSender
ProtoInstance textInput SFString |
|
OurNetworkChannel
ProtoInstance Connection |
No direct ROUTE connection found for events to/from this node. This ProtoInstance contains SFNode/MFNode fieldValue declarations with direct access to other nodes, and thus has potential to produce run-time animation. |
|
TextListener
ProtoInstance textOutput MFString |
MessageOutput
Text string MFString |
|
TextSender
ProtoInstance NetworkSensor |
No direct ROUTE connection found for events to/from this node. This ProtoInstance contains SFNode/MFNode fieldValue declaration with direct access to other nodes, and thus has potential to produce run-time animation. |
<!--
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.
-->