<head>
</head>
<!--
Index for DEF nodes
:
ButtonRotInter,
ChScale,
DescSensor,
Disk,
ElevDescUpdater,
ElevSensor,
FireCone,
FireSensor,
FireSound,
fireTimer,
FireTransform,
GunAp,
GunBase,
GunControl,
GunMount,
HoleNamlu,
InNamlu,
InnerFireCone,
LRotSensor,
MenuB,
MountBody,
MountCap,
Namlu,
NamluDondur,
NamluGROUP,
NamluSensor,
OutNamlu,
PortSideTimer,
RotUpdater,
RRotSensor,
TopDondur,
TopSensor
-->
<Scene>
<!-- Script Node to update the rotation of the gun. -->
<!-- ROUTE information for RotUpdater node:
[from LRotSensor.isActive to set_LRotation
]
[from RRotSensor.isActive to set_RRotation
]
[from TopDondur.rotation to get_CurRotation
]
[from newRotation to TopDondur.set_rotation
]
-->
<Script DEF='RotUpdater'>
<!-- Variables and methods of the RotUpdater script -->
<field name='set_LRotation' type='SFBool' accessType='inputOnly'/>
<field name='set_RRotation' type='SFBool' accessType='inputOnly'/>
<field name='get_CurRotation' type='SFRotation' accessType='inputOnly'/>
<field name='isLeft' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='isRight' type='SFBool' value='false' accessType='initializeOnly'/>
<field name='CurRot' type='SFRotation' value='0 1 0 0' accessType='initializeOnly'/>
<field name='newRotation' type='SFRotation' accessType='outputOnly'/>
<![CDATA[
ecmascript:
function initialize() {
CurRot[0] = 0.0;
CurRot[1] = 1.0;
CurRot[2] = 0.0;
CurRot[3] = 0.0;
}
function set_LRotation(bool,time) {
isLeft = bool;
isRight = !bool;
if(isLeft) {
generate_Rotation();
}
}
function set_RRotation(bool,time) {
isRight = bool;
isLeft = !bool;
if(isRight) {
generate_Rotation();
}
}
function get_CurRotation(cR,time) {
CurRot = cR;
}
function generate_Rotation() {
newRotation = CurRot;
if(isLeft) {
if(CurRot[3] < 1.7) {
newRotation[3] = CurRot[3] + 0.2;
}
}
else if(isRight) {
if(CurRot[3] > -1.7) {
newRotation[3] = CurRot[3] - 0.2;
}
}
}
]]>
</Script>
<!-- Script node to update elevation of the gun. -->
<!-- ROUTE information for ElevDescUpdater node:
[from ElevSensor.isActive to set_Elevation
]
[from DescSensor.isActive to set_Descendance
]
[from NamluDondur.rotation to get_CurOrientation
]
[from newOrientation to NamluDondur.set_rotation
]
-->
<Script DEF='ElevDescUpdater'>
<!-- Variables and methods of the ElevDescUpdater script script -->
<field name='set_Elevation' type='SFBool' accessType='inputOnly'/>
<field name='set_Descendance' type='SFBool' accessType='inputOnly'/>
<field name='get_CurOrientation' type='SFRotation' accessType='inputOnly'/>
<field name='isUp' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='isDown' type='SFBool' value='false' accessType='initializeOnly'/>
<field name='CurOr' type='SFRotation' value='0 1 0 0' accessType='initializeOnly'/>
<field name='newOrientation' type='SFRotation' accessType='outputOnly'/>
<![CDATA[
ecmascript:
function initialize() {
CurOr[0] = 0.0;
CurOr[1] = 1.0;
CurOr[2] = 0.0;
CurOr[3] = 0.0;
}
function set_Elevation(bool,time) {
isUp = bool;
isDown = !bool;
if(isUp) {
generate_Rotation();
}
}
function set_Descendance(bool,time) {
isDown = bool;
isUp = !bool;
if(isDown) {
generate_Rotation();
}
}
function get_CurOrientation(cR,time) {
CurOr = cR;
}
function generate_Rotation() {
newOrientation = CurOr;
if(isUp) {
if(CurOr[3] < 0.45) {
newOrientation[3] = CurOr[3] + 0.05;
}
}
else if(isDown) {
if(CurOr[3] > 0.05) {
newOrientation[3] = CurOr[3] - 0.05;
}
}
}
]]>
</Script>
<!-- Gun Controller - Heads up displays and touch sensors -->
<Background skyColor='0.1 0.1 0.6'/>
<!-- Fire sound effect. -->
<Sound maxBack='35' maxFront='35'>
</Sound>
<!-- Modeling the gun -->
<Transform rotation='0 1 0 3.14' scale='1.2 1.2 1.2' translation='0.0 -1.5 0.0'>
<Group DEF='GunBase'>
<Shape>
<Cylinder height='1.0'/>
<Appearance DEF='GunAp'>
<Material diffuseColor='.7 .7 .8' shininess='.4'/>
</Appearance>
</Shape>
<Transform translation='0.0 0.4 0.0'>
<Shape DEF='Disk'>
<Cylinder height='0.1' radius='1.05'/>
<Appearance USE='GunAp'/>
</Shape>
</Transform>
</Group>
<!-- Mobile part of the gun (DEFLECTION) -->
<!-- ROUTE information for TopDondur node:
[from TopSensor.rotation_changed to set_rotation
]
[from RotUpdater.newRotation to set_rotation
]
[from rotation to RotUpdater.get_CurRotation
]
-->
<Transform DEF='TopDondur'>
<Group DEF='GunMount'>
<Transform rotation='0.0 0.0 1.0 0.3' scale='1.1 1.0 1.5' translation='-0.385 1.8 0.0'>
<Shape DEF='MountBody'>
<Cylinder radius='0.9'/>
<Appearance USE='GunAp'/>
</Shape>
<Transform scale='1.0 0.8 1.0' translation='0.0 1.0 0.0'>
<Shape DEF='MountCap'>
<Sphere radius='0.9'/>
<Appearance USE='GunAp'/>
</Shape>
</Transform>
<Transform translation='0.65 0.0 0.0'>
<Shape>
<Box size='0.5 1.8 0.7'/>
<Appearance USE='GunAp'/>
</Shape>
<Transform translation='0.25 0.0 0.0'>
<Shape>
<Box size='0.1 1.8 0.5'/>
<Appearance>
<Material diffuseColor='0.1 0.1 0.1'/>
</Appearance>
</Shape>
</Transform>
</Transform>
</Transform>
<Transform rotation='1.0 0.0 0.0 1.57'>
<!-- ROUTE information for NamluSensor node:
[from rotation_changed to NamluDondur.set_rotation
]
-->
<CylinderSensor DEF='NamluSensor' description='click and drag to rotate' maxAngle='0.45'/>
<!-- Mobile part of the gun (ELEVATION) -->
<!-- ROUTE information for NamluDondur node:
[from NamluSensor.rotation_changed to set_rotation
]
[from ElevDescUpdater.newOrientation to set_rotation
]
[from rotation to ElevDescUpdater.get_CurOrientation
]
-->
<Transform DEF='NamluDondur'>
<Transform rotation='1.0 0.0 0.0 -1.57'>
<Group DEF='NamluGROUP'>
<Transform rotation='0.0 0.0 1.0 1.57' translation='1.0 2.2 0.2'>
<Group DEF='Namlu'>
<Shape DEF='InNamlu'>
<Cylinder radius='0.08'/>
<Appearance>
<Material diffuseColor='.3 .3 .3' shininess='0.6'/>
</Appearance>
</Shape>
<Shape DEF='HoleNamlu'>
<Cylinder height='2.02' radius='0.06'/>
<Appearance>
<Material diffuseColor='.0 .0 .0' shininess='0.6'/>
</Appearance>
</Shape>
<Shape DEF='OutNamlu'>
<Cylinder height='1.2' radius='0.1'/>
<Appearance>
<Material diffuseColor='.4 .4 .4' shininess='.6'/>
</Appearance>
</Shape>
<!-- ROUTE information for FireTransform node:
[from ChScale.value_changed to set_scale
]
-->
<Transform DEF='FireTransform' rotation='0.0 0.0 1.0 -3.14' scale='0.0001 0.0001 0.00001' translation='0.0 -1.35 0.0'>
<Shape DEF='FireCone'>
<Cone bottomRadius='0.05' height='0.5'/>
<Appearance>
<Material diffuseColor='0.8 0.3 0.0' shininess='0.7' specularColor='0.8 0.3 0.0'/>
</Appearance>
</Shape>
<Transform translation='0.0 -0.2 0.0'>
<Shape DEF='InnerFireCone'>
<Cone bottomRadius='0.051' height='0.2'/>
<Appearance>
<Material diffuseColor='1.0 0.6 0.0' shininess='0.7' specularColor='1.0 0.6 0.0'/>
</Appearance>
</Shape>
<!-- ROUTE information for ChScale node:
[from fireTimer.fraction_changed to set_fraction
]
[from value_changed to FireTransform.set_scale
]
-->
<PositionInterpolator DEF='ChScale' key='0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44 0.48 0.52 0.56 0.6 0.64 0.68 0.72 0.76 0.8 0.84 0.86 0.9 0.94 1.0' keyValue='0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001 1.0 1.0 1.0 0.00001 0.00001 0.00001'/>
<!-- ROUTE information for fireTimer node:
[from FireSensor.touchTime to set_startTime
]
[from fraction_changed to ChScale.set_fraction
]
-->
<TimeSensor DEF='fireTimer' cycleInterval='1.5'/>
</Transform>
</Transform>
</Group>
</Transform>
<Transform rotation='0.0 0.0 1.0 1.57' translation='1.0 2.2 -0.2'>
</Transform>
<Transform rotation='0.0 0.0 1.0 1.57' translation='1.0 1.8 -0.2'>
</Transform>
<Transform rotation='0.0 0.0 1.0 1.57' translation='1.0 1.8 0.2'>
</Transform>
</Group>
</Transform>
</Transform>
</Transform>
<!-- ROUTE information for TopSensor node:
[from rotation_changed to TopDondur.set_rotation
]
-->
<CylinderSensor DEF='TopSensor' description='click and drag to rotate' maxAngle='1.7' minAngle='-1.7'/>
<!-- missing ROUTE for OrientationInterpolator, likely due to use of CylinderSensor -->
<!-- ROUTE information for ButtonRotInter node:
[from PortSideTimer.fraction_changed to set_fraction
]
-->
<OrientationInterpolator DEF='ButtonRotInter' key='0.0 1.0' keyValue='0.0 1.0 0.0 0.0 0.0 1.0 0.0 1.7'/>
<!-- ROUTE information for PortSideTimer node:
[from FireSensor.isActive to set_enabled
]
[from fraction_changed to ButtonRotInter.set_fraction
]
-->
<TimeSensor DEF='PortSideTimer' cycleInterval='3.0' enabled='false' loop='true'/>
<Transform rotation='0.0 0.0 1.0 0.3' translation='-0.1 1.0 0.0'>
<Shape>
<Cylinder height='1.5' radius='0.7'/>
<Appearance USE='GunAp'/>
</Shape>
</Transform>
</Group>
</Transform>
</Transform>
<Transform rotation='0 1 0 1.57'>
<Transform rotation='1 0 0 -1.4' scale='1.4 1.4 1.4' translation='0 0 0.5'>
<Group DEF='GunControl'>
<Transform translation='0 0 3'>
</Transform>
<Transform translation='-0.25 -0.2 3'>
<Group>
<Shape USE='MenuB'/>
<Transform translation='-0.2 -0.05 0.005'>
<Shape>
<Text string='"LROT"'>
<FontStyle size='0.18' spacing='0.1' style='BOLD'/>
</Text>
<Appearance>
<Material diffuseColor='1.0 0.0 0.0'/>
</Appearance>
</Shape>
</Transform>
<!-- ROUTE information for LRotSensor node:
[from isActive to RotUpdater.set_LRotation
]
-->
<TouchSensor DEF='LRotSensor' description='touch to rotate left'/>
</Group>
</Transform>
<Transform translation='0.25 -0.2 3'>
<Group>
<Shape USE='MenuB'/>
<Transform translation='-0.2 -0.05 0.005'>
<Shape>
<Text string='"RROT"'>
<FontStyle size='0.18' spacing='0.1' style='BOLD'/>
</Text>
<Appearance>
<Material diffuseColor='1.0 0.0 0.0'/>
</Appearance>
</Shape>
</Transform>
<!-- ROUTE information for RRotSensor node:
[from isActive to RotUpdater.set_RRotation
]
-->
<TouchSensor DEF='RRotSensor' description='touch to rotate right'/>
</Group>
</Transform>
<Transform translation='-0.25 -0.4 3'>
<Group>
<Shape USE='MenuB'/>
<Transform translation='-0.2 -0.05 0.005'>
<Shape>
<Text string='"ELEV"'>
<FontStyle size='0.18' spacing='0.1' style='BOLD'/>
</Text>
<Appearance>
<Material diffuseColor='1.0 0.0 0.0'/>
</Appearance>
</Shape>
</Transform>
<!-- ROUTE information for ElevSensor node:
[from isActive to ElevDescUpdater.set_Elevation
]
-->
<TouchSensor DEF='ElevSensor' description='touch to elevate'/>
</Group>
</Transform>
<Transform translation='0.25 -0.4 3'>
<Group>
<Shape USE='MenuB'/>
<Transform translation='-0.2 -0.05 0.005'>
<Shape>
<Text string='"DESC"'>
<FontStyle size='0.18' spacing='0.1' style='BOLD'/>
</Text>
<Appearance>
<Material diffuseColor='1.0 0.0 0.0'/>
</Appearance>
</Shape>
</Transform>
<!-- ROUTE information for DescSensor node:
[from isActive to ElevDescUpdater.set_Descendance
]
-->
<TouchSensor DEF='DescSensor' description='touch to depress downward'/>
</Group>
</Transform>
</Group>
</Transform>
</Transform>
<ROUTE fromNode='TopSensor' fromField='rotation_changed' toNode='TopDondur' toField='set_rotation'/>
<ROUTE fromNode='NamluSensor' fromField='rotation_changed' toNode='NamluDondur' toField='set_rotation'/>
<ROUTE fromNode='fireTimer' fromField='fraction_changed' toNode='ChScale' toField='set_fraction'/>
<ROUTE fromNode='ChScale' fromField='value_changed' toNode='FireTransform' toField='set_scale'/>
<ROUTE fromNode='FireSensor' fromField='touchTime' toNode='fireTimer' toField='set_startTime'/>
<ROUTE fromNode='FireSensor' fromField='touchTime' toNode='FireSound' toField='set_startTime'/>
<ROUTE fromNode='PortSideTimer' fromField='fraction_changed' toNode='ButtonRotInter' toField='set_fraction'/>
<ROUTE fromNode='FireSensor' fromField='isActive' toNode='PortSideTimer' toField='set_enabled'/>
<ROUTE fromNode='LRotSensor' fromField='isActive' toNode='RotUpdater' toField='set_LRotation'/>
<ROUTE fromNode='RRotSensor' fromField='isActive' toNode='RotUpdater' toField='set_RRotation'/>
<ROUTE fromNode='TopDondur' fromField='rotation' toNode='RotUpdater' toField='get_CurRotation'/>
<ROUTE fromNode='RotUpdater' fromField='newRotation' toNode='TopDondur' toField='set_rotation'/>
<ROUTE fromNode='ElevSensor' fromField='isActive' toNode='ElevDescUpdater' toField='set_Elevation'/>
<ROUTE fromNode='DescSensor' fromField='isActive' toNode='ElevDescUpdater' toField='set_Descendance'/>
<ROUTE fromNode='NamluDondur' fromField='rotation' toNode='ElevDescUpdater' toField='get_CurOrientation'/>
<ROUTE fromNode='ElevDescUpdater' fromField='newOrientation' toNode='NamluDondur' toField='set_rotation'/>
</Scene>