tank.wrl

 tank.wrl  cafe.wrl  stavba.wrl  sibenice.wrl  tw.wrl  tree.wrl  hud.wrl  garaz2.wrl  fence.wrl  table.wrl  u4.wrl 
Zpět Zpět
   1 : #VRML V2.0 utf8
   2 : 
   3 : WorldInfo {
   4 :  info "Author: Martin Petricek"
   5 :  title "Tank"
   6 : }
   7 : 
   8 : PROTO BlackHole[]{
   9 :  Appearance {
  10 :   material Material {
  11 :    diffuseColor 0 0 0
  12 :   }
  13 :  }
  14 : }
  15 : 
  16 : PROTO Red[]{
  17 :  Appearance {
  18 :   material Material {
  19 :    diffuseColor .5 0 0
  20 :    emissiveColor .5 0 0
  21 :   }
  22 :  }
  23 : }
  24 : 
  25 : PROTO TankInside[]{
  26 :  Appearance {
  27 :   material Material {
  28 :    diffuseColor .3 .3 0
  29 :    ambientIntensity .6
  30 :    specularColor 1 1 1
  31 :    shininess .9
  32 :   }
  33 :  }
  34 : }
  35 : 
  36 : PROTO TankSurf[]{
  37 :  Appearance {
  38 :   material Material {
  39 :    diffuseColor .4 .8 .2
  40 :    ambientIntensity .6
  41 :    specularColor .1 .3 .1
  42 :   }
  43 :  }
  44 : }
  45 : 
  46 : PROTO TankPinkSurf[]{
  47 :  Appearance {
  48 :   material Material {
  49 :    diffuseColor .9 .5 .9
  50 :    ambientIntensity .6
  51 :    specularColor .3 .1 .3
  52 :   }
  53 :  }
  54 : }
  55 : 
  56 : PROTO TankTex [
  57 :  field MFString tex "tank2.png"
  58 : ]{
  59 :  Appearance {
  60 :   texture ImageTexture {
  61 :    url IS tex
  62 :   }
  63 :   material Material {
  64 :    ambientIntensity .4
  65 :    diffuseColor .4 .4 .4
  66 :   }
  67 :  }
  68 : }
  69 : 
  70 : 
  71 : PROTO TankWheelSurf [
  72 :  exposedField SFColor wheelColor 0 .4 0
  73 : ]{
  74 :  Appearance {
  75 :   material Material {
  76 :    diffuseColor IS wheelColor
  77 :    ambientIntensity .6
  78 :    specularColor 0 .3 0
  79 :   }
  80 :  }
  81 : }
  82 : 
  83 : PROTO TankWheel [
  84 :  exposedField SFVec3f pos 0 0 0
  85 :  exposedField SFColor wheelColor 0 .4 0
  86 :  exposedField SFColor wheelDarkColor 0 .2 0
  87 : ]{
  88 :  Transform {
  89 :   translation IS pos
  90 :   children Transform {
  91 :    rotation 0 0 1 1.57
  92 :    translation 0 -.9 -3
  93 :    children [
  94 :     Shape {
  95 :      appearance TankWheelSurf {wheelColor IS wheelColor }
  96 :      geometry Cylinder{
  97 :       height .2
  98 :       radius .4
  99 :      }
 100 :     }
 101 :     Shape {
 102 :      appearance TankWheelSurf {wheelColor IS wheelDarkColor }
 103 :      geometry Cylinder{
 104 :       height .25
 105 :       radius .32
 106 :      }
 107 :     }
 108 :    ]
 109 :   }
 110 :  }
 111 : }
 112 : 
 113 : PROTO TankWheelLod0 [
 114 :  exposedField SFVec3f pos 0 0 0
 115 :  exposedField SFColor wheelColor 0 .4 0
 116 :  exposedField SFColor wheelDarkColor 0 .2 0
 117 : ]{
 118 :  Transform {
 119 :   translation IS pos
 120 :   children Transform {
 121 :    rotation 0 0 1 1.57
 122 :    translation 0 -.9 -3
 123 :    children [
 124 :     Shape {
 125 :      appearance TankWheelSurf {wheelColor IS wheelColor }
 126 :      geometry Cylinder{
 127 :       height .23
 128 :       radius .4
 129 :       bottom FALSE
 130 :       top FALSE
 131 :      }
 132 :     }
 133 :     Shape {
 134 :      appearance TankWheelSurf {wheelColor IS wheelDarkColor }
 135 :      geometry Cylinder{
 136 :       height .23
 137 :       radius .4
 138 :       side FALSE
 139 :      }
 140 :     }
 141 :    ]
 142 :   }
 143 :  }
 144 : }
 145 : 
 146 : 
 147 : PROTO TankTexTrans[
 148 :  exposedField SFVec2f trans -.05 0
 149 : ] { TextureTransform {
 150 :   scale 3 128
 151 :   translation IS trans
 152 :  }
 153 : }
 154 : 
 155 : PROTO TankTrack[
 156 :  exposedField SFNode ttrans TankTexTrans{}
 157 : ]{
 158 :  Shape {
 159 :   appearance Appearance {
 160 :    texture ImageTexture {
 161 :     url "trk.png"
 162 :    }
 163 :    textureTransform IS ttrans
 164 :   }
 165 :   geometry Extrusion {
 166 :    creaseAngle 1.3
 167 :    beginCap FALSE
 168 :    endCap FALSE
 169 :    spine [
 170 :     0 -1.3 -3.1,
 171 :     0 -1.2 -3.3,
 172 :     0 -1.1 -3.4,
 173 :     0 -0.4 -3.85,
 174 :     0 -0.2 -3.9,
 175 :     0  0.0 -3.85
 176 :     0  0.1 -3.75
 177 :     0  0.2 -3.6,
 178 :     0  0.2  3.6,
 179 :     0  0.1  3.75
 180 :     0  0.0  3.85
 181 :     0 -0.2  3.9,
 182 :     0 -0.4  3.85,
 183 :     0 -1.1  3.4,
 184 :     0 -1.2  3.3,
 185 :     0 -1.3  3.1,
 186 :     0 -1.3 -3.1
 187 :    ]
 188 :    crossSection [.02 .16,.02 -.16,-.02 -.16,-.02 .16,.02 .16]
 189 :   }
 190 :  }
 191 : }
 192 : 
 193 : PROTO TankWheelSet [
 194 :  exposedField SFColor wheelColor 0 .4 0
 195 :  exposedField SFColor wheelDarkColor 0 .2 0
 196 : ]{
 197 :  Group {
 198 :   children [
 199 :    #upper row
 200 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor }
 201 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 0 1.5 }
 202 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 0 3   }
 203 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 0 4.5 }
 204 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 0 6   }
 205 :    #lower row
 206 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 -.5 }
 207 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 0.9  }
 208 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 2.3  }
 209 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 3.7  }
 210 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 5.1  }
 211 :    TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 6.5  }
 212 :   ]
 213 :  }
 214 : }
 215 : 
 216 : PROTO TankWheelSetLod0 [
 217 :  exposedField SFColor wheelColor 0 .4 0
 218 :  exposedField SFColor wheelDarkColor 0 .2 0
 219 : ]{
 220 :  Group {
 221 :   children [
 222 :    #upper row
 223 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor }
 224 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 0 1.5 }
 225 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 0 3   }
 226 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 0 4.5 }
 227 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 0 6   }
 228 :    #lower row
 229 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 -.5 }
 230 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 0.9  }
 231 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 2.3  }
 232 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 3.7  }
 233 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 5.1  }
 234 :    TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor  pos 0 .7 6.5  }
 235 :   ]
 236 :  }
 237 : }
 238 : 
 239 : 
 240 : PROTO TankTrackComponent [
 241 :  exposedField SFVec3f pos 0 0 0
 242 :  exposedField SFColor wheelColor 0 .4 0
 243 :  exposedField SFColor wheelDarkColor 0 .2 0
 244 :  exposedField SFNode ttrans TankTexTrans{}
 245 : ]{
 246 :  Transform {
 247 :   translation IS pos
 248 :   children [
 249 :    TankTrack { ttrans IS ttrans }
 250 :    TankWheelSet { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
 251 :   ]
 252 :  }
 253 : }
 254 : 
 255 : PROTO TankTrackComponentLod0 [
 256 :  exposedField SFVec3f pos 0 0 0
 257 :  exposedField SFColor wheelColor 0 .4 0
 258 :  exposedField SFColor wheelDarkColor 0 .2 0
 259 :  exposedField SFNode ttrans TankTexTrans{}
 260 : ]{
 261 :  Transform {
 262 :   translation IS pos
 263 :   children [
 264 :    TankTrack {ttrans IS ttrans }
 265 :    TankWheelSetLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
 266 :   ]
 267 :  }
 268 : }
 269 : 
 270 : PROTO TankLight [
 271 :  exposedField SFVec3f pos 0 0 0
 272 :  exposedField SFNode tex TankSurf {}
 273 : ]{
 274 :  Transform {
 275 :   translation IS pos
 276 :   rotation 1 0 0 -1.57
 277 :   children [
 278 :    SpotLight {
 279 :     beamWidth 0.770796
 280 :     radius 8
 281 :     cutOffAngle 0.385398
 282 :     direction 0 1 0
 283 :    }
 284 :    Shape {
 285 :     appearance IS tex
 286 :     geometry Cylinder {
 287 :      bottom FALSE
 288 :      height .2
 289 :      radius .15
 290 :     }
 291 :    }
 292 :    Transform {
 293 :     translation 0 .35 0
 294 :     scale .35 .25 .35
 295 :     children Billboard {
 296 :      children Shape {
 297 :       appearance Appearance {
 298 :        texture ImageTexture {
 299 :         url "lite2.png"
 300 :        }
 301 :       }
 302 :       geometry IndexedFaceSet {
 303 :        coord Coordinate {
 304 :         point [-1 -1 0,-1 1 0,1 1 0 1 -1 0]
 305 :        }
 306 :        coordIndex [3 2 1 0 -1]
 307 :       }
 308 :      }
 309 :     }
 310 :    }
 311 :    Shape {
 312 :     appearance Appearance {
 313 :      material Material {
 314 :       diffuseColor .9 .9 .9
 315 :       emissiveColor 1 1 1
 316 :      }
 317 :     }
 318 :     geometry Cylinder {
 319 :      bottom FALSE
 320 :      side FALSE
 321 :      height .205
 322 :      radius .12
 323 :     }
 324 :    }
 325 :   ]
 326 :  }
 327 : }
 328 : 
 329 : PROTO TankLightBack [
 330 :  exposedField SFVec3f pos 0 0 0
 331 :  exposedField SFNode tex TankSurf {}
 332 : ]{
 333 :  Transform {
 334 :   translation IS pos
 335 :   rotation 1 0 0 -1.57
 336 :   children [
 337 :    Shape {
 338 :     appearance IS tex
 339 :     geometry Cylinder {
 340 :      top FALSE
 341 :      height .2
 342 :      radius .09
 343 :     }
 344 :    }
 345 :    Shape {
 346 :     appearance Appearance {
 347 :      material Material {
 348 :       diffuseColor .9 0 0
 349 :       emissiveColor 1 0 0
 350 :      }
 351 :     }
 352 :     geometry Cylinder {
 353 :      top FALSE
 354 :      side FALSE
 355 :      height .205
 356 :      radius .06
 357 :     }
 358 :    }
 359 :   ]
 360 :  }
 361 : }
 362 : 
 363 : PROTO TankEntranceLod0 [
 364 :  exposedField SFVec3f pos 0 0 0
 365 :  exposedField SFNode tex TankSurf {}
 366 : ]{
 367 :  Transform {
 368 :   translation IS pos
 369 :   children [
 370 :    #cover
 371 :    Transform {
 372 :     translation 0 .04 0
 373 :     children [
 374 :      Shape {
 375 :       appearance IS tex
 376 :       geometry Cylinder {
 377 :        radius .45
 378 :        bottom FALSE
 379 :        height .09
 380 :       }
 381 :      }
 382 :     ]
 383 :    }
 384 :    #rim
 385 :    Shape {
 386 :     appearance IS tex
 387 :     geometry Cylinder {
 388 :      radius .5
 389 :      height .03
 390 :      bottom FALSE
 391 :     }
 392 :    }
 393 :   ]
 394 :  }
 395 : }
 396 : 
 397 : PROTO TankEntranceLod1 [
 398 :  exposedField SFVec3f pos 0 0 0
 399 :  exposedField SFNode tex TankSurf {}
 400 : ]{
 401 :  Transform {
 402 :   translation IS pos
 403 :   children Transform {
 404 :    translation 0 .025 0
 405 :    children Shape {
 406 :     appearance IS tex
 407 :     geometry Cylinder {
 408 :      radius .48
 409 :      bottom FALSE
 410 :      height .12
 411 :     }
 412 :    }
 413 :   }
 414 :  }
 415 : }
 416 : 
 417 : PROTO TankEntrance [
 418 :  exposedField SFVec3f pos 0 0 0
 419 :  exposedField SFNode tex TankSurf {}
 420 : ]{
 421 :  Transform {
 422 :   translation IS pos
 423 :   children [
 424 :    #interior
 425 :    Shape {
 426 :     appearance TankInside {}
 427 :     geometry Cylinder {
 428 :      radius .4
 429 :      height .05
 430 :      bottom FALSE
 431 :     }
 432 :    }
 433 :    TankEntranceLod0 { tex IS tex }
 434 :    #handle
 435 :    Transform {
 436 :     translation 0 .1 -.38
 437 :     children [
 438 :      Shape {
 439 :       appearance IS tex
 440 :       geometry Box {
 441 :        size .08 .03 .25
 442 :       }
 443 :      }
 444 :     ]
 445 :    }
 446 :    #"axis" of rotation
 447 :    Transform {
 448 :     translation 0 .05 .42
 449 :     rotation 0 0 1 1.57
 450 :     children [
 451 :      Shape {
 452 :       appearance IS tex
 453 :       geometry Cylinder {
 454 :        height .25
 455 :        radius .05
 456 :       }
 457 :      }
 458 :     ]
 459 :    }
 460 :   ]
 461 :  }
 462 : }
 463 : 
 464 : PROTO TankMGLodB [
 465 :  exposedField SFNode tex TankSurf {}
 466 : ]{
 467 :  Shape {
 468 :   appearance IS tex
 469 :   geometry Sphere {
 470 :    radius .2
 471 :   }
 472 :  }
 473 : }
 474 : 
 475 : PROTO TankMGLodA [
 476 :  exposedField SFNode tex TankSurf {}
 477 : ]{
 478 :  Group {
 479 :   children [
 480 :    Transform {
 481 :     rotation 1 0 0 -1.57
 482 :     translation 0 0 -.25
 483 :     children [
 484 :      Shape {
 485 :       appearance IS tex
 486 :       geometry Cylinder {
 487 :        radius .03
 488 :        height .5
 489 :        bottom FALSE
 490 :       }
 491 :      }
 492 :      Shape {
 493 :       appearance BlackHole {}
 494 :       geometry Cylinder {
 495 :        radius .02
 496 :        height .502
 497 :        bottom FALSE
 498 :        side FALSE
 499 :       }
 500 :      }
 501 :     ]
 502 :    }
 503 :    TankMGLodB { tex IS tex }
 504 :   ]
 505 :  }
 506 : }
 507 : 
 508 : 
 509 : PROTO TankMG [
 510 :  exposedField SFVec3f pos 0 0 0
 511 :  exposedField SFNode tex TankSurf {}
 512 :  field MFFloat lodRanges [6 14 20 100 500]
 513 : ]{
 514 :  Transform {
 515 :   translation IS pos
 516 :   children [
 517 :    DEF SM CylinderSensor {
 518 :     maxAngle 0.8
 519 :     minAngle -0.8
 520 :    }
 521 :    DEF TM Transform {
 522 :     children LOD {
 523 :      range IS lodRanges
 524 :      level [
 525 :       TankMGLodA { tex IS tex}
 526 :       TankMGLodA { tex IS tex}
 527 :       TankMGLodB { tex IS tex}
 528 :       Group{}
 529 :       Group{}
 530 :       Group{}
 531 :      ]
 532 :     }
 533 :    }
 534 :   ]
 535 :   ROUTE SM.rotation_changed TO TM.rotation
 536 :  }
 537 : }
 538 : 
 539 : PROTO TankEntranceLod [
 540 :  exposedField SFVec3f pos 0 0 0
 541 :  exposedField SFNode tex TankSurf {}
 542 :  field MFFloat lodRanges [6 14 20 100 500]
 543 : ]{
 544 :  LOD {
 545 :       range IS lodRanges
 546 :       level [
 547 :        TankEntrance { pos IS pos tex IS tex}
 548 :        TankEntranceLod0 { pos IS pos tex IS tex}
 549 :        TankEntranceLod1 { pos IS pos tex IS tex}
 550 :        Group{}
 551 :        Group{}
 552 :        Group{}
 553 :       ]
 554 :      }
 555 : }
 556 : 
 557 : PROTO TankCannonHole[]{
 558 :  Transform {
 559 :   translation 0 -1.5 0
 560 :   children [
 561 :    Shape {
 562 :     appearance BlackHole {}
 563 :     geometry Cylinder {
 564 :      radius .10
 565 :      height .001
 566 :      top FALSE
 567 :      side FALSE
 568 :     }
 569 :    }
 570 :   ]
 571 :  }
 572 : }
 573 : 
 574 : PROTO TankCannon [
 575 :  exposedField SFVec3f pos 0 0 0
 576 :  exposedField SFNode tex TankSurf {}
 577 : ]{
 578 :  Transform {
 579 :   rotation 1 0 0 1.57
 580 :   translation IS pos
 581 :   children [
 582 :    TankCannonHole {}
 583 :    Transform {
 584 :     translation 0 -1.4 0
 585 :     children [
 586 :      Shape {
 587 :       appearance IS tex
 588 :       geometry Cylinder {
 589 :        radius .15
 590 :        height .2
 591 :       }
 592 :      }
 593 :     ]
 594 :    }
 595 :    Shape {
 596 :     appearance IS tex
 597 :     geometry Cylinder {
 598 :      radius .12
 599 :      height 3
 600 :      top FALSE
 601 :     }
 602 :    }
 603 :    Shape {
 604 :     appearance IS tex
 605 :     geometry Cylinder {
 606 :      radius .14
 607 :      height 1.1
 608 :     }
 609 :    }
 610 :   ]
 611 :  }
 612 : }
 613 : 
 614 : PROTO TankCannonLod0 [
 615 :  exposedField SFVec3f pos 0 0 0
 616 :  exposedField SFNode tex TankSurf {}
 617 : ]{
 618 :  Transform {
 619 :   rotation 1 0 0 1.57
 620 :   translation IS pos
 621 :   children [
 622 :    TankCannonHole {}
 623 :    Shape {
 624 :     appearance IS tex
 625 :     geometry Cylinder {
 626 :      radius .14
 627 :      height 3
 628 :      top FALSE
 629 :     }
 630 :    }
 631 :   ]
 632 :  }
 633 : }
 634 : 
 635 : PROTO TankWindow [
 636 :  exposedField SFVec3f pos 0 0 0
 637 :  exposedField SFNode tex TankSurf {}
 638 : ]{
 639 :  Transform {
 640 :   translation IS pos
 641 :   children [
 642 :    Shape {
 643 :     appearance IS tex
 644 :     geometry Box {
 645 :      size .6 .3 .3
 646 :     }
 647 :    }
 648 :    Shape {
 649 :     appearance BlackHole {}
 650 :     geometry Box {
 651 :      size .4 .1 .31
 652 :     }
 653 :    }
 654 :   ]
 655 :  }
 656 : }
 657 : 
 658 : PROTO TankWedge [
 659 :  exposedField SFNode tex TankSurf {}
 660 : ]{
 661 :  Shape {
 662 :   appearance IS tex
 663 :   geometry IndexedFaceSet {
 664 :    coord Coordinate {
 665 :     point [
 666 :      -1.2 -.65 -3.4,
 667 :      -1.2 -.65  3.4,
 668 :      -1.2  .65  4.1,
 669 :      -1.2  .65 -4.1,
 670 :      1.2 -.65 -3.4,
 671 :      1.2 -.65  3.4,
 672 :      1.2  .65  4.1
 673 :      1.2  .65 -4.1,
 674 :     ]
 675 :    }
 676 :    coordIndex [
 677 :     0 1 2 3 -1,
 678 :     4 5 1 0 -1,
 679 :     7 6 5 4 -1,
 680 :     6 7 3 2 -1,
 681 :     5 6 2 1 -1,
 682 :     0 3 7 4 -1
 683 :    ]
 684 :    texCoord TextureCoordinate {
 685 :     point [
 686 :      -1 -2,
 687 :      -1  2,
 688 :      1  1.7,
 689 :      1 -1.7,
 690 :     ]
 691 :    }
 692 :    texCoordIndex [
 693 :     0 1 2 3 -1,
 694 :     0 1 2 3 -1,
 695 :     0 1 2 3 -1,
 696 :     0 1 2 3 -1,
 697 :     1 2 3 0 -1,
 698 :     1 2 3 0 -1,
 699 :    ]
 700 :   }
 701 :  }
 702 : }
 703 : 
 704 : PROTO TankWedges [
 705 :  exposedField SFNode tex TankSurf {}
 706 : ]{
 707 :  Transform {
 708 :   translation 0 -.4 0
 709 :   children [
 710 :    TankWedge {tex IS tex }
 711 :    Transform {
 712 :     rotation 1 0 0 3.14
 713 :     scale 1.4 .5 1
 714 :     translation 0 .975 0
 715 :     children TankWedge {tex IS tex }
 716 :    }
 717 :   ]
 718 :  }
 719 : }
 720 : 
 721 : PROTO TankBackBox [
 722 :  exposedField SFVec3f pos 0 0 0
 723 :  exposedField SFNode tex TankSurf {}
 724 : ]{
 725 :  Transform {
 726 :   translation IS pos
 727 :   children Shape {
 728 :    appearance IS tex
 729 :    geometry Box {
 730 :     size 1 .06 1
 731 :    }
 732 :   }
 733 :  }
 734 : }
 735 : 
 736 : PROTO TankGunRack [
 737 :  exposedField SFVec3f pos 0 0 0
 738 :  exposedField SFNode tex TankSurf {}
 739 : ]{
 740 :  Transform {
 741 :   translation IS pos
 742 :   rotation 0 0 1 1.57
 743 :   children [
 744 :    Shape {
 745 :     appearance IS tex
 746 :     geometry Cylinder {
 747 :      radius .4
 748 :      height .3
 749 :     }
 750 :    }
 751 :    Shape {
 752 :     appearance IS tex
 753 :     geometry Box {
 754 :      size .7 .5 .5
 755 :     }
 756 :    }
 757 :   ]
 758 :  }
 759 : }
 760 : 
 761 : PROTO TankGunRackLod0 [
 762 :  exposedField SFVec3f pos 0 0 0
 763 :  exposedField SFNode tex TankSurf {}
 764 : ]{
 765 :  Transform {
 766 :   translation IS pos
 767 :   rotation 0 0 1 1.57
 768 :   children [
 769 :    Shape {
 770 :     appearance IS tex
 771 :     geometry Cylinder {
 772 :      radius .4
 773 :      height .4
 774 :     }
 775 :    }
 776 :   ]
 777 :  }
 778 : }
 779 : 
 780 : 
 781 : PROTO TankHiBox [
 782 :  exposedField SFNode tex TankSurf {}
 783 : ]{
 784 :  Transform {
 785 :   translation 0 .6 .5
 786 :   children [
 787 :    Shape {
 788 :     appearance IS tex
 789 :     geometry Box {
 790 :      size 2.7 .65 6.7
 791 :     }
 792 :    }
 793 :   ]
 794 :  }
 795 : }
 796 : 
 797 : PROTO TankLowerBodyLod0 [
 798 :  exposedField SFNode tex TankSurf {}
 799 : ]{
 800 :  Group {
 801 :   children [
 802 :    TankHiBox {tex IS tex }
 803 :    TankWedges {tex IS tex }
 804 :   ]
 805 :  }
 806 : }
 807 : 
 808 : PROTO TankLowerBody [
 809 :  exposedField SFNode tex TankSurf {}
 810 : ]{
 811 :  Group {
 812 :   children [
 813 :    TankBackBox { pos  .7 .95 3.1 tex IS tex }
 814 :    TankBackBox { pos -.7 .95 3.1 tex IS tex }
 815 :    TankLowerBodyLod0 {tex IS tex }
 816 :   ]
 817 :  }
 818 : }
 819 : 
 820 : PROTO TurretBackWedge [
 821 :  exposedField SFNode tex TankSurf {}
 822 : ]{
 823 :  Transform {
 824 :   rotation 1 1 1 2.09
 825 :   translation 0 .69 1.75
 826 :   children [
 827 :    Shape {
 828 :     appearance IS tex
 829 :     geometry IndexedFaceSet {
 830 :      coord Coordinate {
 831 :       point [
 832 :        -.35 -1.75 -1.45,
 833 :        -.35 -1.75  1.45,
 834 :        -.35   .15   .8,
 835 :        -.35   .15  -.8,
 836 :         .35 -1.75 -1.45,
 837 :         .35 -1.75  1.45,
 838 :         .35   .15   .8
 839 :         .35   .15  -.8,
 840 :       ]
 841 :      }
 842 :      coordIndex [
 843 :       0 1 2 3 -1,
 844 :       4 5 1 0 -1,
 845 :       7 6 5 4 -1,
 846 :       6 7 3 2 -1,
 847 :       5 6 2 1 -1,
 848 :       0 3 7 4 -1
 849 :      ]
 850 :     }
 851 :    }
 852 :   ]
 853 :  }
 854 : }
 855 : 
 856 : PROTO TurretMiddle [
 857 :  exposedField SFNode tex TankSurf {}
 858 : ]{
 859 :  Transform { translation 0 .55 0
 860 :   children [
 861 :    Shape {
 862 :     appearance IS tex
 863 :     geometry Cylinder {
 864 :      radius 1.5
 865 :      height 1
 866 :     }
 867 :    }
 868 :   ]
 869 :  }
 870 : }
 871 : 
 872 : PROTO TurretMiddleLod0 [
 873 :  exposedField SFNode tex TankSurf {}
 874 : ]{
 875 :  Transform { translation 0 .5 0
 876 :   children [
 877 :    Shape {
 878 :     appearance IS tex
 879 :     geometry Cylinder {
 880 :      radius 1.5
 881 :      height 1.1
 882 :      bottom FALSE
 883 :     }
 884 :    }
 885 :   ]
 886 :  }
 887 : }
 888 : 
 889 : PROTO TurretBottom [
 890 :  exposedField SFNode tex TankSurf {}
 891 : ]{
 892 :  Shape {
 893 :   appearance IS tex
 894 :   geometry Cylinder {
 895 :    radius 1.4
 896 :    height .1
 897 :    top FALSE
 898 :    bottom FALSE
 899 :   }
 900 :  }
 901 : }
 902 : 
 903 : PROTO TurretTop [
 904 :  exposedField SFNode tex TankSurf {}
 905 : ]{
 906 :  Transform { translation 0 1.08 0
 907 :   children [
 908 :    Shape {
 909 :     appearance IS tex
 910 :     geometry Cone {
 911 :      bottomRadius 1.5
 912 :      height .1
 913 :      bottom FALSE
 914 :     }
 915 :    }
 916 :   ]
 917 :  }
 918 : }
 919 : 
 920 : PROTO TankTurretCore0 [
 921 :  exposedField SFNode tex TankSurf {}
 922 : ]{
 923 :  Group {
 924 :   children [
 925 :    TurretBackWedge { tex IS tex}
 926 :    TurretMiddle { tex IS tex}
 927 :    TurretBottom { tex IS tex}
 928 :    TurretTop { tex IS tex}
 929 :    TankCannon { pos 0 .5 -2.7 tex IS tex }
 930 :    TankGunRack { pos 0 .5 -1.3 tex IS tex }
 931 :   ]
 932 :  }
 933 : }
 934 : 
 935 : 
 936 : PROTO TankTurretLodB [
 937 :  exposedField SFNode tex TankSurf {}
 938 :  exposedField SFRotation rot 0 0 1 0
 939 : ]{
 940 :  Transform {
 941 :   translation 0 .94 1
 942 :   rotation IS rot
 943 :   children [
 944 :    TankTurretCore0 { tex IS tex }
 945 :    TankEntranceLod0 { pos -.7 1.1 .45 tex IS tex }
 946 :    TankEntranceLod0 { pos  .7 1.1 .45 tex IS tex }
 947 :   ]
 948 :  }
 949 : }
 950 : 
 951 : 
 952 : PROTO TankTurretLod0 [
 953 :  exposedField SFNode tex TankSurf {}
 954 :  exposedField SFRotation rot 0 0 1 0
 955 : ]{
 956 :  Transform {
 957 :   translation 0 .94 1
 958 :   rotation IS rot
 959 :   children [
 960 :    TankTurretCore0 { tex IS tex }
 961 :    TankEntranceLod0 { pos -.7 1.1 .45 tex IS tex }
 962 :    TankEntranceLod0 { pos  .7 1.1 .45 tex IS tex }
 963 :   ]
 964 :  }
 965 : }
 966 : 
 967 : PROTO TankTurretCore1 [
 968 :  exposedField SFNode tex TankSurf {}
 969 : ]{
 970 :  Group {
 971 :   children [
 972 :    TurretBackWedge { tex IS tex}
 973 :    TurretMiddleLod0 { tex IS tex}
 974 :    TankCannonLod0 { pos 0 .5 -2.7 tex IS tex }
 975 :   ]
 976 :  }
 977 : }
 978 : 
 979 : 
 980 : PROTO TankTurretLod2 [
 981 :  exposedField SFNode tex TankSurf {}
 982 :  exposedField SFRotation rot 0 0 1 0
 983 : ]{
 984 :  Transform {
 985 :   translation 0 .94 1
 986 :   rotation IS rot
 987 :   children TankTurretCore1 { tex IS tex }
 988 :  }
 989 : }
 990 : 
 991 : PROTO TankTurretLod1 [
 992 :  exposedField SFNode tex TankSurf {}
 993 :  exposedField SFRotation rot 0 0 1 0
 994 : ]{
 995 :  Transform {
 996 :   translation 0 .94 1
 997 :   rotation IS rot
 998 :   children [
 999 :    TankTurretCore1 { tex IS tex }
1000 :    TankGunRackLod0 { pos 0 .5 -1.3 tex IS tex }
1001 :    TankEntranceLod1 { pos -.7 1.1 .45 tex IS tex }
1002 :    TankEntranceLod1 { pos  .7 1.1 .45 tex IS tex }
1003 :   ]
1004 :  }
1005 : }
1006 : 
1007 : PROTO TankTurretLod [
1008 :  exposedField SFNode tex TankSurf {}
1009 :  field MFFloat lodRanges [6 14 20 100 500]
1010 :  exposedField SFBool rotatable TRUE
1011 : ]{
1012 :  Group {
1013 :   children [
1014 :    DEF S CylinderSensor {enabled IS rotatable}
1015 :    DEF T Transform {
1016 :     center 0 0 1
1017 :     children LOD {
1018 :      range IS lodRanges
1019 :      level [
1020 :       TankTurretLodB { tex IS tex }
1021 :       TankTurretLod0 { tex IS tex }
1022 :       TankTurretLod1 { tex IS tex }
1023 :       TankTurretLod2 { tex IS tex }
1024 :       Group {}
1025 :       Group {}
1026 :      ]
1027 :     }
1028 :    }
1029 :   ]
1030 :   ROUTE S.rotation_changed TO T.rotation
1031 :  }
1032 : }
1033 : 
1034 : PROTO TankFLights [
1035 :  exposedField SFNode tex TankSurf {}
1036 : ]{
1037 :  Group {
1038 :   children [
1039 :    TankLight { pos  1.3 .5 -3.9 tex IS tex }
1040 :    TankLight { pos -1.3 .5 -3.9 tex IS tex }
1041 :   ]
1042 :  }
1043 : }
1044 : 
1045 : PROTO TankLights [
1046 :  exposedField SFNode tex TankSurf {}
1047 : ]{
1048 :  Group {
1049 :   children [
1050 :    TankFLights { tex IS tex }
1051 :    TankLightBack { pos  1.3 .5 3.85 tex IS tex}
1052 :    TankLightBack { pos -1.3 .5 3.85 tex IS tex }
1053 :   ]
1054 :  }
1055 : }
1056 : 
1057 : PROTO TankLod0 [
1058 :  exposedField SFColor wheelColor 0 .4 0
1059 :  exposedField SFColor wheelDarkColor 0 .2 0
1060 :  exposedField SFNode tex TankSurf {}
1061 :  exposedField SFNode ttrans TankTexTrans{}
1062 : ]{
1063 :  Group {
1064 :   children [
1065 :    TankTrackComponent {ttrans IS ttrans pos -1.4 0 0 wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
1066 :    TankTrackComponent {ttrans IS ttrans pos  1.4 0 0 wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
1067 :    TankWindow { pos 0 .7 -3.6 tex IS tex }
1068 :    TankLights { tex IS tex }
1069 :   ]
1070 :  }
1071 : }
1072 : 
1073 : PROTO TankLod1 [
1074 :  exposedField SFColor wheelColor 0 .4 0
1075 :  exposedField SFColor wheelDarkColor 0 .2 0
1076 :  exposedField SFNode tex TankSurf {}
1077 :  exposedField SFNode ttrans TankTexTrans{}
1078 : ]{
1079 :  Group {
1080 :   children [
1081 :    TankTrackComponent {ttrans IS ttrans pos -1.4 0 0 wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
1082 :    TankTrackComponent {ttrans IS ttrans pos  1.4 0 0 wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
1083 :    TankWindow { pos 0 .7 -3.6 tex IS tex }
1084 :    TankLights { tex IS tex }
1085 :   ]
1086 :  }
1087 : }
1088 : 
1089 : PROTO TankLod2 [
1090 :  exposedField SFColor wheelColor 0 .4 0
1091 :  exposedField SFColor wheelDarkColor 0 .2 0
1092 :  exposedField SFNode tex TankSurf {}
1093 :  exposedField SFNode ttrans TankTexTrans{}
1094 : ]{
1095 :  Group {
1096 :   children [
1097 :    TankTrackComponent {ttrans IS ttrans pos -1.4 0 0 wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
1098 :    TankTrackComponent {ttrans IS ttrans pos  1.4 0 0 wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
1099 :    TankWindow { pos 0 .7 -3.6 tex IS tex }
1100 :    TankFLights { tex IS tex }
1101 :   ]
1102 :  }
1103 : }
1104 : 
1105 : PROTO TankLod3 [
1106 :  exposedField SFColor wheelColor 0 .4 0
1107 :  exposedField SFColor wheelDarkColor 0 .2 0
1108 :  exposedField SFNode tex TankSurf {}
1109 :  exposedField SFNode ttrans TankTexTrans{}
1110 : ]{
1111 :  Group {
1112 :   children [
1113 :    TankTrackComponentLod0 {ttrans IS ttrans pos -1.4 0 0 wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
1114 :    TankTrackComponentLod0 {ttrans IS ttrans pos  1.4 0 0 wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
1115 :   ]
1116 :  }
1117 : }
1118 : 
1119 : PROTO TankLod4 [
1120 :  exposedField SFNode tex TankSurf {}
1121 : ]{
1122 :  Group {
1123 :   children [
1124 :    Shape {
1125 :     appearance IS tex
1126 :     geometry Box {
1127 :      size 3.36 2.2 7.5
1128 :     }
1129 :    }
1130 :    Transform {
1131 :     translation 0 1.54 1
1132 :     children Shape {
1133 :      appearance IS tex
1134 :      geometry Box {
1135 :       size 3 1.1 3.4
1136 :      }
1137 :     }
1138 :    }
1139 :   ]
1140 :  }
1141 : }
1142 : 
1143 : PROTO Exhaust [
1144 :  exposedField SFColor color 0 0 0
1145 :  field SFVec3f pos 0 0 0
1146 : ]{
1147 :  Transform {
1148 :   translation IS pos
1149 :   children [
1150 :    Shape {
1151 :     appearance BlackHole {}
1152 :     geometry Cylinder {
1153 :      side FALSE
1154 :      bottom FALSE
1155 :      radius 0.1
1156 :      height 0.5
1157 :     }
1158 :    }
1159 :    Shape {
1160 :     appearance Appearance {
1161 :      material Material {
1162 :       diffuseColor 0.5 0.5 0.5
1163 :       emissiveColor IS color
1164 :      }
1165 :     }
1166 :     geometry Cylinder {
1167 :      top FALSE
1168 :      bottom FALSE
1169 :      radius 0.1
1170 :      height 0.5
1171 :     }
1172 :    }
1173 :   ]
1174 :  }
1175 : }
1176 : 
1177 : PROTO Exhausts [
1178 :  exposedField SFColor color 0.5 0.5 0.5
1179 : ]{
1180 :  Group {
1181 :   children [
1182 :    Exhaust{pos -0.8 1 3.6 color IS color }
1183 :    Exhaust{pos  0.8 1 3.6 color IS color }
1184 :    Exhaust{pos -1.1 1 3.6 color IS color }
1185 :    Exhaust{pos  1.1 1 3.6 color IS color }
1186 :   ]
1187 :  }
1188 : }
1189 : 
1190 : PROTO Arrow [
1191 :  exposedField SFVec3f pos 0 0 0
1192 :  exposedField SFRotation rot 0 0 1 0
1193 : ]{
1194 :  Transform { 
1195 :   translation IS pos
1196 :   rotation IS rot
1197 :   children [
1198 :    Transform {
1199 :     scale 0.25 1 1
1200 :     rotation 1 0 0 -1.54
1201 :     children
1202 :     Shape {
1203 :      appearance Red {}
1204 :      geometry Cone {
1205 :       bottomRadius .2
1206 :       height .2
1207 :      }
1208 :     }
1209 :    }
1210 :    Transform {
1211 :     translation 0 0 .3
1212 :     rotation 1 0 0 -1.54
1213 :     children
1214 :     Shape {
1215 :      appearance Red {}
1216 :      geometry Cylinder {
1217 :       radius .05
1218 :       height .4
1219 :      }
1220 :     }
1221 :    }
1222 :   ]
1223 :  }
1224 : }
1225 : 
1226 : PROTO Tank [
1227 :  exposedField SFVec3f pos 0 0 0              #pozice
1228 :  exposedField SFRotation rot 0 0 1 0         #rotace
1229 :  exposedField SFInt32 lod 1                  #zaputo/vypnuto lOD
1230 :  exposedField SFColor wheelColor 0 .4 0      #barva kolecek
1231 :  exposedField SFColor wheelDarkColor 0 .2 0  #barva vnitrku kolecek
1232 :  exposedField SFNode tex TankSurf {}         #barva ci textura tanku
1233 :  field MFFloat lodRanges [6 14 20 100 500]   #vzdalenosti pro lod
1234 :  exposedField SFColor light 1 1 1            #barva svetla nad strojem
1235 :  exposedField SFFloat lightIntensity 2       #intenzita svetla nad strojem
1236 :  eventIn SFBool lightOn                      #zapnuti svetel
1237 :  exposedField SFTime startRotation 0         #zapnuti rotace
1238 :  exposedField SFTime stopRotation 0          #vypnuti rotace
1239 :  eventIn SFFloat rotSpeed                    #rychlost rotace
1240 : ]{
1241 :  DEF ROT Transform { 
1242 :   center IS pos
1243 :   children
1244 :  Transform { 
1245 :   translation IS pos
1246 :   rotation IS rot
1247 :   children DEF TK Transform {
1248 :    children [
1249 :     DEF P ProximitySensor {
1250 :      size 20 20 20
1251 :      enabled FALSE
1252 :     }
1253 :     DEF L PointLight {
1254 :      color IS light
1255 :      intensity IS lightIntensity
1256 :      location 3 4 3
1257 :      radius 6
1258 :      on FALSE
1259 :     }
1260 :     DEF L2 PointLight {
1261 :      color IS light
1262 :      intensity IS lightIntensity
1263 :      location -3 4 -3
1264 :      radius 6
1265 :      on FALSE
1266 :     }
1267 :     PointLight {
1268 :      color IS light
1269 :      intensity IS lightIntensity
1270 :      location 3 4 3
1271 :      radius 6
1272 :      on IS lightOn
1273 :     }
1274 :     PointLight {
1275 :      color IS light
1276 :      intensity IS lightIntensity
1277 :      location -3 4 -3
1278 :      radius 6
1279 :      on IS lightOn
1280 :     }
1281 :     Switch {
1282 :      whichChoice IS lod
1283 :      choice [
1284 :       TankLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex}
1285 :       Group {
1286 :        children [
1287 :         LOD {
1288 :          range IS lodRanges
1289 :          level [
1290 :           DEF TL0 TankLod0 { ttrans TankTexTrans{} wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex}
1291 :           DEF TL1 TankLod1 { ttrans TankTexTrans{} wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex }
1292 :           DEF TL2 TankLod2 { ttrans TankTexTrans{} wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex }
1293 :           DEF TL3 TankLod3 { ttrans TankTexTrans{} wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex }
1294 :           DEF TL4 TankLod4 { tex IS tex}
1295 :           Group{}
1296 :          ]
1297 :         }
1298 :         LOD {
1299 :          range IS lodRanges
1300 :          level [
1301 :           DEF EX0 Exhausts{ color 0 0 0}
1302 :           USE EX0
1303 :           USE EX0
1304 :           USE EX0
1305 :           USE EX0
1306 :           Group{}
1307 :          ]
1308 :         }
1309 :         Transform {
1310 :          children [
1311 :           DEF T TouchSensor {enabled FALSE}
1312 :           DEF B LOD {
1313 :            range IS lodRanges
1314 :            level [
1315 :             TankLowerBody { tex IS tex}
1316 :             TankLowerBody { tex IS tex}
1317 :             TankLowerBodyLod0 { tex IS tex}
1318 :             TankLowerBodyLod0 { tex IS tex}
1319 :             Group{}
1320 :             Group{}
1321 :            ]
1322 :           }
1323 :           DEF Z PositionInterpolator {
1324 :            key [0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1]
1325 :            keyValue [0 0 9
1326 :             ,0 0 9.005,0 0 8.995
1327 :             ,0 0 9.01 ,0 0 8.99
1328 :             ,0 0 9.015,0 0 8.99 
1329 :             ,0 0 9.01 ,0 0 8.995
1330 :             ,0 0 9.005,0 0 9]
1331 :           }
1332 :           DEF Z2 PositionInterpolator {
1333 :            key [0,.2,.4,.6,.8,1]
1334 :            keyValue [
1335 :             0 0 9,
1336 :             0 0 8,
1337 :             0 0 6,
1338 :             0 0 3,
1339 :             0 0 1,
1340 :             0 0 0]
1341 :           }
1342 :           DEF AU1 Sound {
1343 :            direction 0 0 1
1344 :            maxFront 200
1345 :            minFront 1
1346 :            maxBack 200
1347 :            minBack 1
1348 :            source DEF AC1 AudioClip {
1349 :             url "tstart.wav"
1350 :            }
1351 :           }
1352 :           DEF AU2 Sound {
1353 :            direction 0 0 1
1354 :            maxFront 200
1355 :            minFront 1
1356 :            maxBack 200
1357 :            minBack 1
1358 :            source DEF AC2 AudioClip {
1359 :             url "tstart2.wav"
1360 :            }
1361 :           }
1362 :           DEF AU3 Sound {
1363 :            direction 0 0 1
1364 :            maxFront 200
1365 :            minFront 1
1366 :            maxBack 200
1367 :            minBack 1
1368 :            source DEF AC3 AudioClip {
1369 :             url "tmove.wav"
1370 :            }
1371 :           }
1372 :           DEF AU4 Sound {
1373 :            direction 0 0 1
1374 :            maxFront 200
1375 :            minFront 1
1376 :            maxBack 200
1377 :            minBack 1
1378 :            source DEF AC4 AudioClip {
1379 :             url "tstop.wav"
1380 :            }
1381 :           }
1382 :           DEF TS TimeSensor {
1383 :            cycleInterval 1
1384 :            loop FALSE
1385 :           }
1386 :           DEF TS2 TimeSensor {
1387 :            cycleInterval 3.36
1388 :            loop FALSE
1389 :           }
1390 :           DEF CI1 ColorInterpolator {
1391 :            key [0,1]
1392 :            keyValue [0 0 0,1 0 0]
1393 :           }
1394 :           DEF CI2 ColorInterpolator {
1395 :            key [0,.3,.6,.9,1]
1396 :            keyValue [1 0 0,1 1 0,1 1 1,.3 .3 1,0 0 0]
1397 :           }
1398 :           DEF TIMER Script {
1399 :            eventIn SFTime tick
1400 :            eventIn SFTime flip
1401 :            eventOut SFTime tick1
1402 :            eventOut SFTime tick2
1403 :            eventOut SFTime tick3
1404 :            eventOut SFTime tick4
1405 :            eventIn SFFloat tick5
1406 :            field SFFloat dir 1
1407 :            field SFNode p_I USE Z2
1408 :            field SFNode p_I0 USE Z
1409 :            field SFNode ts USE T
1410 :            field MFNode t [USE TL0 USE TL1 USE TL2 USE TL3]
1411 :            url "javascript:
1412 :             function tick5(x) {
1413 :              if (x>=1) ts.enabled=true;
1414 :              for (j=0;j<3;j++) t[j].ttrans.trans =new SFVec2f (-.05,dir*x/4);
1415 :             }
1416 :             function tick(x) {
1417 :              tick2=x+1;
1418 :              tick3=x+1.88;
1419 :              tick4=x+1.88+1.48;
1420 :             }           
1421 :             function flip(x) {
1422 :              ts.enabled=false;
1423 :              tick1=x;
1424 :              dir=-dir;
1425 :              for (i=0;i<p_I.keyValue.length;i++) {
1426 :               p_I.keyValue[i][2]=9-p_I.keyValue[i][2];
1427 :              }
1428 :              for (i=0;i<p_I0.keyValue.length;i++) {
1429 :               p_I0.keyValue[i][2]=9-p_I0.keyValue[i][2];
1430 :              }
1431 :             }
1432 :            "
1433 :           }
1434 :           DEF TSROT TimeSensor {
1435 :            cycleInterval 10
1436 :            loop TRUE
1437 :           }
1438 :           DEF RI OrientationInterpolator {
1439 :            key [0,0.5,1]
1440 :            keyValue [0 1 0 0,0 1 0 3.14,0 1 0 6.28]
1441 :           }
1442 :           Group{
1443 :            children [
1444 :             DEF MMV Transform {
1445 :              translation 2 2 2
1446 :              children [
1447 :               Shape {
1448 :                appearance Appearance {
1449 :                 material DEF MM Material {
1450 :                  emissiveColor 1 0 0
1451 :                  diffuseColor 1 0 0
1452 :                 }
1453 :                }
1454 :                geometry Box {
1455 :                 size .4 .4 .4
1456 :                }
1457 :               }
1458 :               LOD {
1459 :                range [80]
1460 :                level [
1461 :                 DEF A1 Transform {
1462 :                  children [
1463 :                   Arrow {pos 0 0 .5}
1464 :                   Arrow {pos 0 0 -.5 rot 0 1 0 3.14}
1465 :                  ]
1466 :                 }
1467 :                 Group {}
1468 :                ]
1469 :               }
1470 :              ]
1471 :             }
1472 :             DEF MASTER TouchSensor {}
1473 :             DEF CI3 ColorInterpolator {
1474 :              key [0,.5,1]
1475 :              keyValue [.4 .4 0,0 .4 .2,.4 .4 0]
1476 :             }
1477 :             DEF CI4 ColorInterpolator {
1478 :              key [0,.5,1]
1479 :              keyValue [1 0 0,0 0 1,1 0 0]
1480 :             }
1481 :             DEF TS5 TimeSensor {
1482 :              cycleInterval .7
1483 :              loop TRUE
1484 :             }
1485 :             DEF TS3 TimeSensor {
1486 :              cycleInterval .7
1487 :              loop TRUE
1488 :             }
1489 :             DEF TS4 TimeSensor {
1490 :              cycleInterval .7
1491 :              loop TRUE
1492 :              enabled FALSE
1493 :             }
1494 :             DEF RI2 OrientationInterpolator {
1495 :              key [0,0.5,1]
1496 :              keyValue [0 0 1 0,0 0 1 3.14,0 0 1 6.28]
1497 :             }
1498 :             DEF SC1 PositionInterpolator {
1499 :              key [0,.15,.5,.85,1]
1500 :              keyValue [1 1 1,.9 .9 .9,.7 .7 .7,.9 .9 .9,1 1 1]
1501 :             }
1502 :             DEF PI PositionInterpolator {
1503 :              key [0,1]
1504 :              keyValue [2 2 2,2 2 -2]
1505 :             }
1506 :            ]
1507 :            ROUTE RI2.value_changed TO A1.rotation
1508 :            ROUTE SC1.value_changed TO A1.scale
1509 :            ROUTE TS5.fraction_changed TO RI2.set_fraction
1510 :            ROUTE TS5.fraction_changed TO SC1.set_fraction
1511 :            ROUTE TS3.fraction_changed TO CI3.set_fraction
1512 :            ROUTE TS4.fraction_changed TO CI4.set_fraction
1513 :            ROUTE CI3.value_changed TO MM.emissiveColor
1514 :            ROUTE CI4.value_changed TO MM.emissiveColor
1515 :            ROUTE CI3.value_changed TO MM.diffuseColor
1516 :            ROUTE CI4.value_changed TO MM.diffuseColor
1517 :           }
1518 : 
1519 : 
1520 :           DEF ROTATOR Script {
1521 :            field SFBool rotEnable FALSE
1522 :            field SFFloat rotFracx 0
1523 :            eventOut SFFloat rotFrac
1524 :            field SFFloat rotSpd 0.05
1525 :            eventIn SFTime rotStart
1526 :            eventIn SFTime rotStop
1527 :            eventIn SFFloat rotSpeed IS rotSpeed
1528 :            field SFFloat rotFracLast 0
1529 :            field SFBool t1 FALSE
1530 :            eventIn SFFloat tick
1531 :            url "javascript:
1532 :             function rotStart(qx) {
1533 :              rotEnable=true;
1534 :             }
1535 :             function rotStop (qx) {
1536 :              rotEnable=false;
1537 :             }
1538 :             function rotSpeed(qx) {
1539 :              rotSpd=qx;
1540 :             }
1541 :             function tick(qx) {
1542 :              if (rotEnable) {
1543 :               var diff=qx-rotFracLast;
1544 :               if (diff<0) diff+=1;
1545 :               rotFracx+=diff*rotSpd;
1546 :               while (rotFracx>1) rotFracx-=1;
1547 :               rotFrac=rotFracx;
1548 :              }
1549 :              rotFracLast=qx;
1550 :             }
1551 :            "
1552 :           }         
1553 :           DEF DUMMY TimeSensor {
1554 :            startTime IS startRotation
1555 :            stopTime IS stopRotation
1556 :           }
1557 :           DEF ACTIVATOR Script {
1558 :            eventIn SFTime touch
1559 :            eventOut SFBool active
1560 :            eventOut SFBool activeNot
1561 :            field SFBool isActive FALSE
1562 :            eventOut SFFloat move
1563 :            url "javascript:
1564 :             function touch(x) {
1565 :              isActive=!isActive;
1566 :              active=isActive;
1567 :              activeNot=!isActive;
1568 :              if (isActive) {
1569 :               move=1;
1570 :              } else {
1571 :               move=0;
1572 :              }
1573 :             }
1574 :            "
1575 :           }
1576 :          ]
1577 :          ROUTE T.touchTime TO TIMER.flip
1578 :          ROUTE T.touchTime TO TS.startTime
1579 :          ROUTE T.touchTime TO AC1.startTime
1580 :          ROUTE T.touchTime TO TIMER.tick
1581 :          ROUTE TIMER.tick2 TO AC2.startTime
1582 :          ROUTE TIMER.tick2 TO TS2.startTime
1583 :          ROUTE TIMER.tick3 TO AC3.startTime
1584 :          ROUTE TIMER.tick4 TO AC4.startTime
1585 :          ROUTE TS2.fraction_changed TO TIMER.tick5
1586 :          ROUTE TS.fraction_changed TO Z.set_fraction
1587 :          ROUTE TS2.fraction_changed TO Z2.set_fraction
1588 :          ROUTE TS.fraction_changed TO CI1.set_fraction
1589 :          ROUTE TS2.fraction_changed TO CI2.set_fraction
1590 :          ROUTE Z.value_changed TO TK.translation
1591 :          ROUTE Z2.value_changed TO TK.translation
1592 :          ROUTE CI1.value_changed TO EX0.color
1593 :          ROUTE CI2.value_changed TO EX0.color
1594 :         }
1595 :         TankEntranceLod { pos  .8 .95 -2.2 tex IS tex lodRanges IS lodRanges}
1596 :         TankEntranceLod { pos -.8 .95 -2.2 tex IS tex lodRanges IS lodRanges}
1597 :         DEF TT TankTurretLod { lodRanges IS lodRanges tex IS tex rotatable FALSE }
1598 :         TankMG { pos .7 .65 -3.68 tex IS tex lodRanges IS lodRanges }
1599 :        ]
1600 :       }
1601 :      ]
1602 :      
1603 :      #proximity -> light
1604 :      ROUTE P.isActive TO L.on
1605 :      ROUTE P.isActive TO L2.on
1606 :      #rotator
1607 :      ROUTE TSROT.fraction_changed TO ROTATOR.tick
1608 :      ROUTE ROTATOR.rotFrac TO RI.set_fraction
1609 :      ROUTE RI.value_changed TO ROT.rotation
1610 :      ROUTE ACTIVATOR.activeNot TO TS3.enabled
1611 :      ROUTE ACTIVATOR.active TO TS4.enabled
1612 :      ROUTE ACTIVATOR.move TO PI.set_fraction
1613 :      ROUTE PI.value_changed TO MMV.translation
1614 :      ROUTE DUMMY.startTime TO ROTATOR.rotStart
1615 :      ROUTE DUMMY.stopTime TO ROTATOR.rotStop
1616 :      #master
1617 :      ROUTE MASTER.touchTime TO ACTIVATOR.touch
1618 :      ROUTE ACTIVATOR.active TO T.enabled
1619 :      ROUTE ACTIVATOR.active TO P.enabled
1620 :      ROUTE ACTIVATOR.active TO TT.rotatable
1621 :     }
1622 :    ]
1623 :   }
1624 :  }
1625 :  }
1626 : }