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='titlecontent=' CrossHairPrototype.x3d '/>
  6            <meta name='descriptioncontent='Prototype for a heads-up display (HUD) crosshair showing center of screen, useful for assessing lookAt point.'/>
  7            <meta name='creatorcontent='Don Brutzman'/>
  8            <meta name='createdcontent='1 February 2003'/>
  9            <meta name='modifiedcontent='28 November 2019'/>
 10            <meta name='subjectcontent='crosshair display'/>
 11            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/CrossHairPrototype.x3d '/>
 12            <meta name='generatorcontent='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 13            <meta name='licensecontent='../../license.html'/>
 14       </head>
<!--

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

Index for ProtoDeclare definition: CrossHair
-->
 15       <Scene>
 16            <WorldInfo title='CrossHairPrototype.x3d'/>
 17            <ProtoDeclare name='CrossHairappinfo='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='enabledtype='SFBoolvalue='trueaccessType='initializeOnly'
                     appinfo='whether CrossHair prototype is enabled or not'/>
 20                      <field name='set_enabledtype='SFBoolaccessType='inputOnly'
                     appinfo='control whether enabled/disabled'/>
 21                      <field name='markerColortype='SFColorvalue='0.3 0.3 0.8accessType='inputOutput'
                     appinfo='color of CrossHair marker'/>
 22                      <field name='scaletype='SFVec3fvalue='1 1 1accessType='inputOutput'
                     appinfo='size of CrossHair in meters'/>
 23                      <field name='positionOffsetFromCameratype='SFVec3fvalue='0 0 -3accessType='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='ShowSwitchwhichChoice='-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='WhereSensorsize='1000000000 1000000000 1000000000'>
 29                                     <IS>
 30                                          <connect nodeField='enabledprotoField='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='translationprotoField='positionOffsetFromCamera'/>
 37                                               <connect nodeField='scaleprotoField='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='CircleMaterialdiffuseColor='0 0 0'>
 45                                                         <IS>
 46                                                              <connect nodeField='emissiveColorprotoField='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='enabledtype='SFBoolaccessType='initializeOnly'/>
 55                                               <field name='set_enabledtype='SFBoolaccessType='inputOnly'/>
 56                                               <field name='whichChoicetype='SFInt32accessType='outputOnly'/>
 57                                               <IS>
 58                                                    <connect nodeField='enabledprotoField='enabled'/>
 59                                                    <connect nodeField='set_enabledprotoField='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='10type='"FLY" "ANY"'/>
 75            <ProtoInstance name='CrossHair'>
 76                 <fieldValue name='enabledvalue='true'/>
 77                 <fieldValue name='markerColorvalue='1 0.5 0'/>
 78                 <fieldValue name='scalevalue='1 1 1'/>
 79                 <fieldValue name='positionOffsetFromCameravalue='0 0 -3'/>
 80            </ProtoInstance>
 81            <Group DEF='TextMenu'>
 82                 <Transform>
 83                      <Anchor description='CrossHair Exampleparameter='"target=_blank"'   url=' "CrossHairExample.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/CrossHairExample.x3d" "CrossHairExample.wrl" "https://www.web3d.org/x3d/content/examples/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 DEF nodes index: 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 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. 

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://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/CrossHairPrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/CrossHairPrototype.x3d -->

<!-- Color-coding legend: X3D terminology <X3dNode  DEF='idNamefield='value'/> matches XML terminology <XmlElement  DEF='idNameattribute='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. -->