Viewpoint {
position 0 20 5
orientation 1 0 0 -1
}
NavigationInfo {
type "NONE"
}
DEF UFO-Tf Transform {
children [
Transform {
scale 1 0.5 0.5
children [
Shape {
appearance Appearance {
material DEF UFO-Mt0 Material {
diffuseColor 0.8 0.8 0.9
}
}
geometry Sphere {}
}
]
}
Transform {
translation 1 0 0.2
scale 0.3 0.3 1
children [
Shape {
appearance DEF UFO-Ap Appearance {
material DEF UFO-Mt1 Material {
diffuseColor 0.8 0.9 0.8
}
}
geometry Sphere {}
}
]
}
Transform {
translation -1 0 0.2
scale 0.3 0.3 1
children [
Shape {
appearance USE UFO-Ap
geometry Sphere {}
}
]
}
]
}
DEF UFOOI-TiS TimeSensor {
loop TRUE
cycleInterval 1
}
DEF UFO-OI OrientationInterpolator {
key [ 0.0 0.25 0.5 0.75 1.0 ]
keyValue [
0 0 1 0
0 0 1 1.5708
0 0 1 3.1416
0 0 1 4.7124
0 0 1 6.2832
]
}
ROUTE UFOOI-TiS.fraction_changed TO UFO-OI.set_fraction
ROUTE UFO-OI.value_changed TO UFO-Tf.rotation
DEF UFOPI-TiS TimeSensor {
loop TRUE
cycleInterval 10
}
DEF UFO-PI PositionInterpolator {
key [ 0.0 0.5 1.0 ]
keyValue [
-10 0 -20
10 0 -20
-10 0 -20
]
}
ROUTE UFOPI-TiS.fraction_changed TO UFO-PI.set_fraction
ROUTE UFO-PI.value_changed TO UFO-Tf.translation
DEF Meteo0-Tf Transform {
children [
DEF Meteo-Sp Shape {
appearance Appearance {
material Material {
diffuseColor 0.8 0 0
}
}
geometry Sphere {}
}
]
}
DEF Meteo0-TiS TimeSensor {
loop TRUE
cycleInterval 5
}
DEF Meteo0-PI PositionInterpolator {
key [ 0.0 1.0 ]
keyValue [
-12 0 -17
12 0 -17
]
}
ROUTE Meteo0-TiS.fraction_changed TO Meteo0-PI.set_fraction
ROUTE Meteo0-PI.value_changed TO Meteo0-Tf.translation
DEF Meteo1-Tf Transform {
children USE Meteo-Sp
}
DEF Meteo1-TiS TimeSensor {
loop TRUE
cycleInterval 7
}
DEF Meteo1-PI PositionInterpolator {
key [ 0.0 1.0 ]
keyValue [
12 0 -14
-12 0 -14
]
}
ROUTE Meteo1-TiS.fraction_changed TO Meteo1-PI.set_fraction
ROUTE Meteo1-PI.value_changed TO Meteo1-Tf.translation
DEF Meteo2-Tf Transform {
children USE Meteo-Sp
}
DEF Meteo2-TiS TimeSensor {
loop TRUE
cycleInterval 8
}
DEF Meteo2-PI PositionInterpolator {
key [ 0.0 1.0 ]
keyValue [
-12 0 -11
12 0 -11
]
}
ROUTE Meteo2-TiS.fraction_changed TO Meteo2-PI.set_fraction
ROUTE Meteo2-PI.value_changed TO Meteo2-Tf.translation
DEF Missile-Tf Transform {
children [
DEF Missile-Sw Switch {
whichChoice 0
choice [
Transform {
rotation 1 0 0 -1.5708
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0.9 0.5
}
}
geometry Cone {
bottomRadius 0.5
height 2
}
}
]
}
DEF Expl-Tf Transform {
children [
Shape {
appearance Appearance {
material DEF Expl-Mt Material {
diffuseColor 1 0.5 0
}
}
geometry Sphere {
radius 0.7
}
}
]
}
]
}
]
}
DEF Missile-TiS TimeSensor {
cycleInterval 20
}
DEF Expl-TiS TimeSensor {
cycleInterval 0.5
}
DEF Expl-PI PositionInterpolator {
key [ 0.0 1.0 ]
keyValue [
1 1 1
2 2 2
]
}
ROUTE Expl-TiS.fraction_changed TO Expl-PI.set_fraction
ROUTE Expl-PI.value_changed TO Expl-Tf.scale
DEF Expl-CI ColorInterpolator {
key [ 0.0 0.5 1.0 ]
keyValue [
1 1 0.5
0.6 0 0
0.2 0 0
]
}
ROUTE Expl-TiS.fraction_changed TO Expl-CI.set_fraction
ROUTE Expl-CI.value_changed TO Expl-Mt.diffuseColor
DEF Console-Tf Transform {
children [
Transform {
translation 0 -1.5 -5
children [
DEF Slider-Tf Transform {
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0 0.8 0
}
}
geometry Sphere {
radius 0.2
}
}
]
}
Shape {
appearance Appearance {
material Material {
diffuseColor 0.5 0 0
}
}
geometry Box {
size 2 0.1 0.1
}
}
DEF Slider-PlS PlaneSensor {
minPosition -1 0
maxPosition 1 0
}
]
}
Transform {
translation 1.5 -1.5 -5
rotation 1 0 0 -1.5708
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0.5 0
}
}
geometry Cylinder {
radius 0.3
height 0.1
}
}
DEF Button-ThS TouchSensor {}
]
}
Transform {
translation -1.5 -1.7 -5
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 1 0.999
}
}
geometry DEF Score-Tx Text {
string "0"
fontStyle FontStyle {
justify "MIDDLE"
size 0.5
}
}
}
]
}
]
}
ROUTE Slider-PlS.translation_changed TO Slider-Tf.translation
ROUTE Button-ThS.touchTime TO Missile-TiS.startTime
DEF PrS ProximitySensor {
size 1000 1000 1000
}
ROUTE PrS.position_changed TO Console-Tf.set_translation
ROUTE PrS.orientation_changed TO Console-Tf.set_rotation
DEF Sc Script {
eventIn SFVec3f set_translationPlS
eventIn SFFloat set_fraction
eventIn SFBool settingMissile
eventOut SFVec3f missilePos
eventOut SFTime stopTimeMissile
eventOut SFTime startTimeExpl
eventOut SFInt32 whichChoice
eventOut MFString scStr
eventOut SFColor emiColorUfo
field SFNode UFO USE UFO-Tf
field MFNode Meteos [
USE Meteo0-Tf USE Meteo1-Tf USE Meteo2-Tf ]
field SFInt32 score 0
field MFColor ufoColors [ 0 0 0, 1 0 0 ]
url "javascript:
function set_translationPlS (val) {
missilePos.x = val.x * 5;
}
function set_fraction (f,et) {
missilePos.z = f * -20;
if ( f >= 1 )
missilePos.z = 0;
if ( isHit(
missilePos,
UFO.translation ) ) {
stopTimeMissile = et;
startTimeExpl = et;
whichChoice = 1;
emiColorUfo = ufoColors[1];
score += 10;
scStr[0] = score;
}
for ( var i = 0; i <
Meteos.length; i++ ) {
if ( isHit(
missilePos,
Meteos[i].translation ) ) {
stopTimeMissile = et;
startTimeExpl = et;
whichChoice = 1;
}
}
}
function isHit (va,vb) {
return ( va.subtract(vb).length() <= 1.5 );
}
function settingMissile (val) {
if (!val) {
whichChoice = 0;
missilePos.z = 0;
emiColorUfo = ufoColors[0];
}
}
"
}
ROUTE Slider-PlS.translation_changed TO Sc.set_translationPlS
ROUTE Missile-TiS.fraction_changed TO Sc.set_fraction
ROUTE Expl-TiS.isActive TO Sc.settingMissile
ROUTE Sc.missilePos TO Missile-Tf.translation
ROUTE Sc.stopTimeMissile TO Missile-TiS.stopTime
ROUTE Sc.startTimeExpl TO Expl-TiS.startTime
ROUTE Sc.whichChoice TO Missile-Sw.whichChoice
ROUTE Sc.scStr TO Score-Tx.string
ROUTE Sc.emiColorUfo TO UFO-Mt0.emissiveColor
ROUTE Sc.emiColorUfo TO UFO-Mt1.emissiveColor