X3D Model Documentation: CrossHairPrototype.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='title' content='CrossHairPrototype.x3d'/>
  6            <meta name='description' content='Prototype for a heads-up display (HUD) crosshair showing center of screen, useful for assessing lookAt point.'/>
  7            <meta name='creator' content='Don Brutzman'/>
  8            <meta name='created' content='1 February 2003'/>
  9            <meta name='modified' content='28 November 2019'/>
 10            <meta name='subject' content='crosshair display'/>
 11            <meta name='identifier' content='https://savage.nps.edu/Savage/Tools/HeadsUpDisplays/CrossHairPrototype.x3d'/>
 12            <meta name='generator' content='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit'/>
 13            <meta name='license' content='../../license.html'/>
 14       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: CameraLocation, CameraOffset, CircleMaterial, EnabledScript, ShowSwitch, TextMenu, WhereSensor

Index for ProtoDeclare definition: CrossHair
-->
 15       <Scene>
 16            <WorldInfo title='CrossHairPrototype.x3d'/>
 17            <ProtoDeclare name='CrossHair' appinfo='CrossHair prototype provides a heads-up display (HUD) crosshair at the view center, which is useful for assessing NavigationInfo lookAt point'>
 18                 <ProtoInterface>
 19                      <field name='enabled' type='SFBool' value='true' accessType='initializeOnly'
                     appinfo='whether CrossHair prototype is enabled or not'/>
 20                      <field name='set_enabled' type='SFBool' accessType='inputOnly'
                     appinfo='control whether enabled/disabled'/>
 21                      <field name='markerColor' type='SFColor' value='0.3 0.3 0.8' accessType='inputOutput'
                     appinfo='color of CrossHair marker'/>
 22                      <field name='scale' type='SFVec3f' value='1 1 1' accessType='inputOutput'
                     appinfo='size of CrossHair in meters'/>
 23                      <field name='positionOffsetFromCamera' type='SFVec3f' value='0 0 -3' accessType='inputOutput'
                     appinfo='distance in front of HUD viewpoint'/>
 24                 </ProtoInterface>
 25                 <ProtoBody>
 26 
                    <!-- ROUTE information for ShowSwitch node:  [from EnabledScript.whichChoice to whichChoice ] -->
                    <Switch DEF='ShowSwitch' whichChoice='-1'>
 27                           <Group>
 28 
                              <!-- ROUTE information for WhereSensor node:  [from isActive to EnabledScript.set_enabled ] [from position_changed to CameraLocation.set_translation ] [from orientation_changed to CameraLocation.set_rotation ] -->
                              <ProximitySensor DEF='WhereSensor' size='1000000000 1000000000 1000000000'>
 29                                     <IS>
 30                                          <connect nodeField='enabled' protoField='enabled'/>
 31                                     </IS>
 32                                </ProximitySensor>
 33 
                              <!-- ROUTE information for CameraLocation node:  [from WhereSensor.position_changed to set_translation ] [from WhereSensor.orientation_changed to set_rotation ] -->
                              <Transform DEF='CameraLocation'>
 34                                     <Transform DEF='CameraOffset'>
 35                                          <IS>
 36                                               <connect nodeField='translation' protoField='positionOffsetFromCamera'/>
 37                                               <connect nodeField='scale' protoField='scale'/>
 38                                          </IS>
 39                                          <Shape>
 40                                               <IndexedLineSet coordIndex='0 1 -1 2 3 -1'>
 41                                                    <Coordinate point='0 1 0 0 -1 0 1 0 0 -1 0 0'/>
 42                                               </IndexedLineSet>
 43                                               <Appearance>
 44                                                    <Material DEF='CircleMaterial' diffuseColor='0 0 0'>
 45                                                         <IS>
 46                                                              <connect nodeField='emissiveColor' protoField='markerColor'/>
 47                                                         </IS>
 48                                                    </Material>
 49                                               </Appearance>
 50                                          </Shape>
 51                                     </Transform>
 52                                     <Group>
 53 
                                        <!-- ROUTE information for EnabledScript node:  [from WhereSensor.isActive to set_enabled ] [from whichChoice to ShowSwitch.whichChoice ] -->
                                        <Script DEF='EnabledScript'>
 54                                               <field name='enabled' type='SFBool' accessType='initializeOnly'/>
 55                                               <field name='set_enabled' type='SFBool' accessType='inputOnly'/>
 56                                               <field name='whichChoice' type='SFInt32' accessType='outputOnly'/>
 57                                               <IS>
 58                                                    <connect nodeField='enabled' protoField='enabled'/>
 59                                                    <connect nodeField='set_enabled' protoField='set_enabled'/>
 60                                               </IS>
  <![CDATA[
                  
ecmascript:

function initialize ()
{
	if (enabled) whichChoice =  0;
	else                        whichChoice = -1;
//	Browser.println ('enabled=' + enabled + ', whichChoice=' + whichChoice);
}

function set_enabled (value, timestamp)
{
	if (value) whichChoice =  0;
	else       whichChoice = -1;
//	Browser.println ('set_enabled=' + value + ', whichChoice=' + whichChoice);
}

                
]]>
 62                                          </Script>
 63                                          < ROUTE  fromNode='WhereSensor' fromField='isActive' toNode='EnabledScript' toField='set_enabled'/>
 64                                          < ROUTE  fromNode='EnabledScript' fromField='whichChoice' toNode='ShowSwitch' toField='whichChoice'/>
 65                                     </Group>
 66                                </Transform>
 67                           </Group>
 68                      </Switch>
 69                      < ROUTE  fromNode='WhereSensor' fromField='position_changed' toNode='CameraLocation' toField='set_translation'/>
 70                      < ROUTE  fromNode='WhereSensor' fromField='orientation_changed' toNode='CameraLocation' toField='set_rotation'/>
 71                 </ProtoBody>
 72            </ProtoDeclare>
 73            <!-- ======================== -->
 74            <NavigationInfo speed='10' type='"FLY" "ANY"'/>
 75            <ProtoInstance name='CrossHair'>
 76                 <fieldValue name='enabled' value='true'/>
 77                 <fieldValue name='markerColor' value='1 0.5 0'/>
 78                 <fieldValue name='scale' value='1 1 1'/>
 79                 <fieldValue name='positionOffsetFromCamera' value='0 0 -3'/>
 80            </ProtoInstance>
 81            <Group DEF='TextMenu'>
 82                 <Transform>
 83                      <Anchor description='CrossHair Example' parameter='"target=_blank"'   url=' "CrossHairExample.x3d" "https://savage.nps.edu/Savage/Tools/HeadsUpDisplays/CrossHairExample.x3d" "CrossHairExample.wrl" "https://savage.nps.edu/Savage/Tools/HeadsUpDisplays/CrossHairExample.wrl" '>
 84                           <Shape>
 85                                <Text string='"CrossHairPrototype is a" "prototype definition file." "Click text to see" "CrossHairExample"'>
 86                                     <FontStyle justify='"MIDDLE" "MIDDLE"' size='0.8'/>
 87                                </Text>
 88                                <Appearance>
 89                                     <Material diffuseColor='0.8 0.8 0.4'/>
 90                                </Appearance>
 91                           </Shape>
 92                      </Anchor>
 93                 </Transform>
 94            </Group>
 95       </Scene>
 96  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: CameraLocation, CameraOffset, CircleMaterial, EnabledScript, ShowSwitch, TextMenu, WhereSensor

Index for ProtoDeclare definition: CrossHair
-->
X3D Tooltips element index: Anchor, Appearance, connect, Coordinate, field, fieldValue, FontStyle, Group, head, IndexedLineSet, IS, Material, meta, NavigationInfo, ProtoBody, ProtoDeclare, ProtoInstance, ProtoInterface, ProximitySensor, ROUTE, Scene, Script, Shape, Switch, Text, Transform, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

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

      EnabledScript
Script
whichChoice
SFInt32
→
ROUTE
event to
(1)
ShowSwitch
Switch
whichChoice
SFInt32

WhereSensor
ProximitySensor
isActive
SFBool
→
ROUTE
event to
(1)
EnabledScript
Script
set_enabled
SFBool
then
 
 
 
EnabledScript
Script
whichChoice
SFInt32
→
ROUTE
event to
(2)
ShowSwitch
Switch
whichChoice
SFInt32
WhereSensor
ProximitySensor
position_changed
SFVec3f
→
ROUTE
event to
(1)
CameraLocation
Transform
set_translation
SFVec3f
WhereSensor
ProximitySensor
orientation_changed
SFRotation
→
ROUTE
event to
(1)
CameraLocation
Transform
set_rotation
SFRotation

line 75
ProtoInstance
CrossHair
No ROUTE connection found for output events 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. 

line 83
Anchor
description='CrossHair Example' 
User-interaction hint for this node. 

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://savage.nps.edu/Savage/Tools/HeadsUpDisplays/CrossHairPrototypeIndex.html -->
<!-- Version control at
https://gitlab.nps.edu/Savage/Savage/Tools/HeadsUpDisplays/CrossHairPrototype.x3d -->

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

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