X3D Model Documentation: ArbitraryAxisCylinderSensorPrototype.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=' ArbitraryAxisCylinderSensorPrototype.x3d '/>
  6            <meta name='descriptioncontent="Modified CylinderSensor oriented about an arbitrary axis, relative to peer/child geometry that remains oriented to its original axis. Originally authored by Don Brutzman's MV4204 class, with modifications by Maj James Breitinger USMC to include min/max angles of rotation and object center. Motivation: Modify example shown by Chapter 9 Figure 7 to build a PROTO for a CylinderSensor oriented about an arbitrary axis."/>
  7            <meta name='infocontent='ArbitraryAxisCylinderSensor operates on its children, NOT on its peers. This variation is necessary in order to accomplish the desired Transform rotation to a new orientation axis.'/>
  8            <meta name='creatorcontent='Don Brutzman'/>
  9            <meta name='createdcontent='1 October 1998'/>
 10            <meta name='modifiedcontent='28 November 2019'/>
 11            <meta name='referencecontent=' ArbitraryAxisCylinderSensorExamples.x3d '/>
 12            <meta name='referencecontent='ArbitraryAxisCylinderSensorPrototypeOriginal.wrl'/>
 13            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/ArbitraryAxisCylinderSensorPrototype.x3d '/>
 14            <meta name='referencecontent='The VRML 2.0 Sourcebook (Copyright 1997 By Andrea L. Ames, David R. Nadeau, and John L. Moreland)'/>
 15            <meta name='generatorcontent='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 16            <meta name='licensecontent='../../license.html'/>
 17       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: ArbitraryAxisTransform, CylinderSensorRotationTransform, HideSensorShapeScript, NegationScript, RestorationTransform, RotatedCylinderSensor, ScaleSensorShape, ScaleSensorSwitch, SelectionAssist, SensorShapeAppearance, SensorShapeMaterial

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definition: ArbitraryAxisCylinderSensor
-->
 18       <Scene>
 19            <WorldInfo title='ArbitraryAxisCylinderSensorPrototype.x3d'/>
 20            <ProtoDeclare name='ArbitraryAxisCylinderSensorappinfo='Modified CylinderSensor with children nodes oriented about an arbitrary axis. Warning: ArbitraryAxisCylinderSensor affects children, not peers.'>
 21                 <ProtoInterface>
 22                      <!-- All default fields and events of a regular CylinderSensor are exposed without modification. -->
 23                      <!-- Transparent viewing-assist geometry shows orientation and cylindrical mapping of mouse movements by sensor. Since viewCylinderSensorShape connects to a Script, it is a initialize-time field instead of a run-time exposedField. -->
 24                      <field name='shiftRotationAxistype='SFRotationvalue='1 0 0 0accessType='initializeOnly'
                     appinfo='shifted axis of rotation from local vertical, default 1 0 0 0'/>
 25                      <field name='centertype='SFVec3fvalue='0 0 0accessType='initializeOnly'
                     appinfo='local center for axis of rotation, default 0 0 0'/>
 26                      <field name='showCylinderSensorShapetype='SFBoolvalue='trueaccessType='initializeOnly'
                     appinfo='whether to show visualization shape to show orientation and cylindrical mapping of mouse movements by sensor, default true'/>
 27                      <field name='scaleCylinderSensorShapetype='SFVec3fvalue='1 1 1accessType='inputOutput'
                     appinfo='scale for visualization shape, default 1 1 1'/>
 28                      <field name='colorCylinderSensorShapetype='SFColorvalue='0.9 0.9 0.4accessType='inputOutput'
                     appinfo='color for visualization shape, default 0.9 0.9 0.4'/>
 29                      <field name='transparencyCylinderSensorShapetype='SFFloatvalue='0.8accessType='inputOutput'
                     appinfo='transparency for visualization shape'/>
 30                      <field name='childrentype='MFNodeaccessType='inputOutput'
                     appinfo='children nodes affected by ArbitraryAxisCylinderSensor'>
 31                           <!-- initialization nodes (if any) go here -->
 32                      </field>
 33                      <field name='autoOffsettype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='determines whether previous offset values are remembered/accumulated, default true'/>
 34                      <field name='descriptiontype='SFStringvalue='Select and drag to rotate ArbitraryAxisCylinderSensoraccessType='inputOutput'
                     appinfo='Text tooltip displayed for user interaction'/>
 35                      <field name='diskAngletype='SFFloatvalue='0.262accessType='inputOutput'
                     appinfo='diskAngle 0 forces disk-like behavior, diskAngle 1.57 (90 degrees) forces cylinder-like behavior, default 0.262, range [0,pi/2]'/>
 36                      <field name='enabledtype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='enables/disables node operation, default true'/>
 37                      <field name='minAngletype='SFFloatvalue='0accessType='inputOutput'
                     appinfo='clamps rotation_changed events, default 0, range [-2pi,2pi]'/>
 38                      <field name='maxAngletype='SFFloatvalue='-1accessType='inputOutput'
                     appinfo='clamps rotation_changed events, default -1, range [-2pi,2pi]'/>
 39                      <field name='offsettype='SFFloatvalue='0accessType='initializeOnly'
                     appinfo='sends event and remembers last value sensed, default 0, range (-infinity,infinity)'/>
 40                      <field name='isActivetype='SFBoolaccessType='outputOnly'
                     appinfo='output event isActive=true when primary mouse button is pressed, output event isActive=false when released.'/>
 41                      <field name='rotation_changedtype='SFRotationaccessType='outputOnly'
                     appinfo='rotation_changed events equal sum of relative bearing changes plus offset value about Y-axis in local coordinate system'/>
 42                      <field name='trackPoint_changedtype='SFVec3faccessType='outputOnly'
                     appinfo="trackPoint_changed events give intersection point of bearing with sensor's virtual geometry"/>
 43                 </ProtoInterface>
 44                 <ProtoBody>
 45                      <!-- Prototype body follows. First rotate local frame about center to axis of interest, then perform the rotation about the desired center. -->
 46                      <Transform DEF='ArbitraryAxisTransform'>
 47                           <IS>
 48                                <connect nodeField='rotationprotoField='shiftRotationAxis'/>
 49                                <connect nodeField='centerprotoField='center'/>
 50                           </IS>
 51 
                         <!-- ROUTE information for RotatedCylinderSensor node:  [from rotation_changed to CylinderSensorRotationTransform.set_rotation ] -->
                         <CylinderSensor DEF='RotatedCylinderSensor'>
 52                                <IS>
 53                                     <connect nodeField='autoOffsetprotoField='autoOffset'/>
 54                                     <connect nodeField='descriptionprotoField='description'/>
 55                                     <connect nodeField='diskAngleprotoField='diskAngle'/>
 56                                     <connect nodeField='enabledprotoField='enabled'/>
 57                                     <connect nodeField='minAngleprotoField='minAngle'/>
 58                                     <connect nodeField='maxAngleprotoField='maxAngle'/>
 59                                     <connect nodeField='offsetprotoField='offset'/>
 60                                     <connect nodeField='isActiveprotoField='isActive'/>
 61                                     <connect nodeField='rotation_changedprotoField='rotation_changed'/>
 62                                     <connect nodeField='trackPoint_changedprotoField='trackPoint_changed'/>
 63                                </IS>
 64                           </CylinderSensor>
 65                           <!-- CylinderSensorRotationTransform rotation value is overridden by RotatedCylinderSensor, so leave it alone! -->
 66 
                         <!-- Transform CylinderSensorRotationTransform is a DEF node that has 1 USE node: USE_1
                         <!-- ROUTE information for CylinderSensorRotationTransform node:  [from RotatedCylinderSensor.rotation_changed to set_rotation ] -->
                         <Transform DEF='CylinderSensorRotationTransform'>
 67                                <!-- ROUTEd rotation to RestorationTransform negates (and offsets) arbitrary-axis rotation in RestorationTransform, so children geometry is returned to original orientation. -->
 68                                <!-- Perform the rotation about the same center. -->
 69 
                              <!-- ROUTE information for RestorationTransform node:  [from NegationScript.rotationRestore to rotation ] -->
                              <Transform DEF='RestorationTransform'>
 70                                     <IS>
 71                                          <connect nodeField='centerprotoField='center'/>
 72                                          <connect nodeField='childrenprotoField='children'/>
 73                                     </IS>
 74                                </Transform>
 75                                <!-- Prototype children field finally appears above... -->
 76 
                              <!-- ROUTE information for ScaleSensorSwitch node:  [from HideSensorShapeScript.choiceScaleSensor to whichChoice ] -->
                              <Switch DEF='ScaleSensorSwitchwhichChoice='0'>
 77                                     <Transform DEF='ScaleSensorShape'>
 78                                          <IS>
 79                                               <connect nodeField='scaleprotoField='scaleCylinderSensorShape'/>
 80                                          </IS>
 81                                          <Shape>
 82                                               <Cylinder height='2.5radius='0.1'/>
 83 
                                             <!-- Appearance SensorShapeAppearance is a DEF node that has 1 USE node: USE_1 -->
                                             <Appearance DEF='SensorShapeAppearance'>
 84                                                    <Material DEF='SensorShapeMaterial'>
 85                                                         <IS>
 86                                                              <connect nodeField='diffuseColorprotoField='colorCylinderSensorShape'/>
 87                                                              <connect nodeField='transparencyprotoField='transparencyCylinderSensorShape'/>
 88                                                         </IS>
 89                                                    </Material>
 90                                               </Appearance>
 91                                          </Shape>
 92                                          <Shape>
 93                                               <Cylinder height='0.2radius='1.5'/>
 94                                               <Appearance USE='SensorShapeAppearance'/>
 95                                          </Shape>
 96                                     </Transform>
 97                                </Switch>
 98                           </Transform>
 99 
                         <!-- ROUTE information for NegationScript node:  [from rotationRestore to RestorationTransform.rotation ] -->
                         <Script DEF='NegationScriptdirectOutput='true'>
100                                <field name='shiftRotationAxistype='SFRotationaccessType='initializeOnly'/>
101                                <field name='offsettype='SFFloataccessType='initializeOnly'/>
102                                <field name='rotationRestoretype='SFRotationaccessType='outputOnly'/>
103                                <field name='CylinderSensorRotationTransformtype='SFNodeaccessType='initializeOnly'>
104                                     <Transform USE='CylinderSensorRotationTransform'/>
105                                </field>
106                                <!-- local variables -->
107                                <field name='rotationOffsettype='SFRotationvalue='0 1 0 0accessType='initializeOnly'/>
108                                <field name='rotationIntermediatetype='SFRotationvalue='0 1 0 0accessType='initializeOnly'/>
109                                <IS>
110                                     <connect nodeField='offsetprotoField='offset'/>
111                                     <connect nodeField='shiftRotationAxisprotoField='shiftRotationAxis'/>
112                                </IS>
  <![CDATA[
            
ecmascript:

function initialize () {
	rotationOffset = new SFRotation (0, 1, 0, offset);  // establish initial angle
	CylinderSensorRotationTransform.rotation =
	   CylinderSensorRotationTransform.rotation.multiply (rotationOffset);
	rotationIntermediate = shiftRotationAxis;
	rotationIntermediate = rotationIntermediate.inverse ();
	rotationRestore = rotationIntermediate;
	Browser.println ('   rotationOffset=' +    rotationOffset.toString());
	Browser.println ('shiftRotationAxis=' + shiftRotationAxis.toString());
	Browser.println ('  rotationRestore=' +   rotationRestore.toString());
}

          
]]>
114                           </Script>
115 
                         <!-- ROUTE information for HideSensorShapeScript node:  [from choiceScaleSensor to ScaleSensorSwitch.whichChoice ] -->
                         <Script DEF='HideSensorShapeScript'>
116                                <field name='showCylinderSensorShapetype='SFBoolaccessType='initializeOnly'/>
117                                <field name='choiceScaleSensortype='SFInt32accessType='outputOnly'/>
118                                <IS>
119                                     <connect nodeField='showCylinderSensorShapeprotoField='showCylinderSensorShape'/>
120                                </IS>
  <![CDATA[
            
ecmascript:

function initialize () {
	if (showCylinderSensorShape == true)
		choiceScaleSensor =  0;
	else	choiceScaleSensor = -1;
}

          
]]>
122                           </Script>
123                      </Transform>
124                      < ROUTE  fromNode='RotatedCylinderSensor' fromField='rotation_changed' toNode='CylinderSensorRotationTransform' toField='set_rotation'/>
125                      < ROUTE  fromNode='NegationScript' fromField='rotationRestore' toNode='RestorationTransform' toField='rotation'/>
126                      < ROUTE  fromNode='HideSensorShapeScript' fromField='choiceScaleSensor' toNode='ScaleSensorSwitch' toField='whichChoice'/>
127                      <!-- Add any ROUTEs here, going from Script to other nodes in ProtoBody -->
128                 </ProtoBody>
129            </ProtoDeclare>
130            <!-- Example use of this prototype is in ArbitraryAxisCylinderSensorExample.x3d, .wrl -->
131            <Viewpoint description='click message to view exampleposition='0 0 8'/>
132            <!-- Redirection text in case a user examines this PROTO file via a 3D browser: -->
133            <Anchor description='Touch text for example'   url=' "ArbitraryAxisCylinderSensorExamples.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/ArbitraryAxisCylinderSensorExamples.x3d" "ArbitraryAxisCylinderSensorExamples.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/ArbitraryAxisCylinderSensorExamples.wrl" '>
134                 <Shape>
135                      <Appearance>
136                           <Material diffuseColor='0 1 1emissiveColor='0 1 1'/>
137                      </Appearance>
138                      <Text string='"ArbitraryAxisCylinderSensorPrototype" "is a Prototype (PROTO) definition file." "" "To see an example scene using this new node" "click this text and view" "ArbitraryAxisCylinderSensorExample"'>
139                           <FontStyle justify='"MIDDLE" "MIDDLE"size='0.5'/>
140                      </Text>
141                 </Shape>
142                 <Shape DEF='SelectionAssist'>
143                      <Box size='9 4 .001'/>
144                      <Appearance>
145                           <Material transparency='0.9'/>
146                      </Appearance>
147                 </Shape>
148            </Anchor>
149       </Scene>
150  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: ArbitraryAxisTransform, CylinderSensorRotationTransform, HideSensorShapeScript, NegationScript, RestorationTransform, RotatedCylinderSensor, ScaleSensorShape, ScaleSensorSwitch, SelectionAssist, SensorShapeAppearance, SensorShapeMaterial

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definition: ArbitraryAxisCylinderSensor
-->
X3D Tooltips element index: Anchor, Appearance, Box, connect, Cylinder, CylinderSensor, field, FontStyle, head, IS, Material, meta, ProtoBody, ProtoDeclare, ProtoInterface, ROUTE, Scene, Script, Shape, Switch, Text, Transform, Viewpoint, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

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

HideSensorShapeScript
Script
choiceScaleSensor
SFInt32

ROUTE
event to
(1)
ScaleSensorSwitch
Switch
whichChoice
SFInt32

NegationScript
Script
rotationRestore
SFRotation

ROUTE
event to
(1)
RestorationTransform
Transform
rotation
SFRotation

RotatedCylinderSensor
CylinderSensor
rotation_changed
SFRotation

ROUTE
event to
(1)
CylinderSensorRotationTransform
Transform
set_rotation
SFRotation

line 133
Anchor
description='Touch text for 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/Animation/ArbitraryAxisCylinderSensorPrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/Tools/Animation/ArbitraryAxisCylinderSensorPrototype.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)
    <ProtoDeclare name='ProtoName'> <field name='fieldName'/> </ProtoDeclare> -->

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