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 TankInside[]{
17 : Appearance {
18 : material Material {
19 : diffuseColor .3 .3 0
20 : ambientIntensity .6
21 : specularColor 1 1 1
22 : shininess .9
23 : }
24 : }
25 : }
26 :
27 : PROTO TankSurf[]{
28 : Appearance {
29 : material Material {
30 : diffuseColor .4 .8 .2
31 : ambientIntensity .6
32 : specularColor .1 .3 .1
33 : }
34 : }
35 : }
36 :
37 : PROTO TankPinkSurf[]{
38 : Appearance {
39 : material Material {
40 : diffuseColor .9 .5 .9
41 : ambientIntensity .6
42 : specularColor .3 .1 .3
43 : }
44 : }
45 : }
46 :
47 : PROTO TankTex [
48 : field MFString tex "tank2.png"
49 : ]{
50 : Appearance {
51 : texture ImageTexture {
52 : url IS tex
53 : }
54 : material Material {
55 : ambientIntensity .4
56 : diffuseColor .4 .4 .4
57 : }
58 : }
59 : }
60 :
61 :
62 : PROTO TankWheelSurf [
63 : exposedField SFColor wheelColor 0 .4 0
64 : ]{
65 : Appearance {
66 : material Material {
67 : diffuseColor IS wheelColor
68 : ambientIntensity .6
69 : specularColor 0 .3 0
70 : }
71 : }
72 : }
73 :
74 : PROTO TankWheel [
75 : exposedField SFVec3f pos 0 0 0
76 : exposedField SFColor wheelColor 0 .4 0
77 : exposedField SFColor wheelDarkColor 0 .2 0
78 : ]{
79 : Transform {
80 : translation IS pos
81 : children Transform {
82 : rotation 0 0 1 1.57
83 : translation 0 -.9 -3
84 : children [
85 : Shape {
86 : appearance TankWheelSurf {wheelColor IS wheelColor }
87 : geometry Cylinder{
88 : height .2
89 : radius .4
90 : }
91 : }
92 : Shape {
93 : appearance TankWheelSurf {wheelColor IS wheelDarkColor }
94 : geometry Cylinder{
95 : height .25
96 : radius .32
97 : }
98 : }
99 : ]
100 : }
101 : }
102 : }
103 :
104 : PROTO TankWheelLod0 [
105 : exposedField SFVec3f pos 0 0 0
106 : exposedField SFColor wheelColor 0 .4 0
107 : exposedField SFColor wheelDarkColor 0 .2 0
108 : ]{
109 : Transform {
110 : translation IS pos
111 : children Transform {
112 : rotation 0 0 1 1.57
113 : translation 0 -.9 -3
114 : children [
115 : Shape {
116 : appearance TankWheelSurf {wheelColor IS wheelColor }
117 : geometry Cylinder{
118 : height .23
119 : radius .4
120 : bottom FALSE
121 : top FALSE
122 : }
123 : }
124 : Shape {
125 : appearance TankWheelSurf {wheelColor IS wheelDarkColor }
126 : geometry Cylinder{
127 : height .23
128 : radius .4
129 : side FALSE
130 : }
131 : }
132 : ]
133 : }
134 : }
135 : }
136 :
137 :
138 : PROTO TankTexTrans[
139 : exposedField SFVec2f trans -.05 0
140 : ] { TextureTransform {
141 : scale 3 128
142 : translation IS trans
143 : }
144 : }
145 :
146 : PROTO TankTrack[
147 : exposedField SFNode ttrans TankTexTrans{}
148 : ]{
149 : Shape {
150 : appearance Appearance {
151 : texture ImageTexture {
152 : url "trk.png"
153 : }
154 : textureTransform IS ttrans
155 : }
156 : geometry Extrusion {
157 : creaseAngle 1.3
158 : beginCap FALSE
159 : endCap FALSE
160 : spine [
161 : 0 -1.3 -3.1,
162 : 0 -1.2 -3.3,
163 : 0 -1.1 -3.4,
164 : 0 -0.4 -3.85,
165 : 0 -0.2 -3.9,
166 : 0 0.0 -3.85
167 : 0 0.1 -3.75
168 : 0 0.2 -3.6,
169 : 0 0.2 3.6,
170 : 0 0.1 3.75
171 : 0 0.0 3.85
172 : 0 -0.2 3.9,
173 : 0 -0.4 3.85,
174 : 0 -1.1 3.4,
175 : 0 -1.2 3.3,
176 : 0 -1.3 3.1,
177 : 0 -1.3 -3.1
178 : ]
179 : crossSection [.02 .16,.02 -.16,-.02 -.16,-.02 .16,.02 .16]
180 : }
181 : }
182 : }
183 :
184 : PROTO TankWheelSet [
185 : exposedField SFColor wheelColor 0 .4 0
186 : exposedField SFColor wheelDarkColor 0 .2 0
187 : ]{
188 : Group {
189 : children [
190 : #upper row
191 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor }
192 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 0 1.5 }
193 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 0 3 }
194 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 0 4.5 }
195 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 0 6 }
196 : #lower row
197 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 -.5 }
198 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 0.9 }
199 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 2.3 }
200 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 3.7 }
201 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 5.1 }
202 : TankWheel { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 6.5 }
203 : ]
204 : }
205 : }
206 :
207 : PROTO TankWheelSetLod0 [
208 : exposedField SFColor wheelColor 0 .4 0
209 : exposedField SFColor wheelDarkColor 0 .2 0
210 : ]{
211 : Group {
212 : children [
213 : #upper row
214 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor }
215 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 0 1.5 }
216 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 0 3 }
217 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 0 4.5 }
218 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 0 6 }
219 : #lower row
220 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 -.5 }
221 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 0.9 }
222 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 2.3 }
223 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 3.7 }
224 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 5.1 }
225 : TankWheelLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor pos 0 .7 6.5 }
226 : ]
227 : }
228 : }
229 :
230 :
231 : PROTO TankTrackComponent [
232 : exposedField SFVec3f pos 0 0 0
233 : exposedField SFColor wheelColor 0 .4 0
234 : exposedField SFColor wheelDarkColor 0 .2 0
235 : exposedField SFNode ttrans TankTexTrans{}
236 : ]{
237 : Transform {
238 : translation IS pos
239 : children [
240 : TankTrack { ttrans IS ttrans }
241 : TankWheelSet { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
242 : ]
243 : }
244 : }
245 :
246 : PROTO TankTrackComponentLod0 [
247 : exposedField SFVec3f pos 0 0 0
248 : exposedField SFColor wheelColor 0 .4 0
249 : exposedField SFColor wheelDarkColor 0 .2 0
250 : exposedField SFNode ttrans TankTexTrans{}
251 : ]{
252 : Transform {
253 : translation IS pos
254 : children [
255 : TankTrack {ttrans IS ttrans }
256 : TankWheelSetLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor}
257 : ]
258 : }
259 : }
260 :
261 : PROTO TankLight [
262 : exposedField SFVec3f pos 0 0 0
263 : exposedField SFNode tex TankSurf {}
264 : ]{
265 : Transform {
266 : translation IS pos
267 : rotation 1 0 0 -1.57
268 : children [
269 : SpotLight {
270 : beamWidth 0.770796
271 : intensity 1
272 : radius 8
273 : cutOffAngle 0.385398
274 : direction 0 1 0
275 : }
276 : Shape {
277 : appearance IS tex
278 : geometry Cylinder {
279 : bottom FALSE
280 : height .2
281 : radius .15
282 : }
283 : }
284 : Transform {
285 : translation 0 .35 0
286 : scale .35 .25 .35
287 : children Billboard {
288 : axisOfRotation 0 1 0
289 : children Shape {
290 : appearance Appearance {
291 : texture ImageTexture {
292 : url "lite2.png"
293 : }
294 : }
295 : geometry IndexedFaceSet {
296 : coord Coordinate {
297 : point [-1 -1 0,-1 1 0,1 1 0 1 -1 0]
298 : }
299 : coordIndex [3 2 1 0 -1]
300 : }
301 : }
302 : }
303 : }
304 : Shape {
305 : appearance Appearance {
306 : material Material {
307 : diffuseColor .9 .9 .9
308 : emissiveColor 1 1 1
309 : }
310 : }
311 : geometry Cylinder {
312 : bottom FALSE
313 : side FALSE
314 : height .205
315 : radius .12
316 : }
317 : }
318 : ]
319 : }
320 : }
321 :
322 : PROTO TankLightBack [
323 : exposedField SFVec3f pos 0 0 0
324 : exposedField SFNode tex TankSurf {}
325 : ]{
326 : Transform {
327 : translation IS pos
328 : rotation 1 0 0 -1.57
329 : children [
330 : Shape {
331 : appearance IS tex
332 : geometry Cylinder {
333 : top FALSE
334 : height .2
335 : radius .09
336 : }
337 : }
338 : Shape {
339 : appearance Appearance {
340 : material Material {
341 : diffuseColor .9 0 0
342 : emissiveColor 1 0 0
343 : }
344 : }
345 : geometry Cylinder {
346 : top FALSE
347 : side FALSE
348 : height .205
349 : radius .06
350 : }
351 : }
352 : ]
353 : }
354 : }
355 :
356 : PROTO TankEntranceLod0 [
357 : exposedField SFVec3f pos 0 0 0
358 : exposedField SFNode tex TankSurf {}
359 : ]{
360 : Transform {
361 : translation IS pos
362 : children [
363 : #cover
364 : Transform {
365 : translation 0 .04 0
366 : children [
367 : Shape {
368 : appearance IS tex
369 : geometry Cylinder {
370 : radius .45
371 : top TRUE
372 : bottom FALSE
373 : height .09
374 : }
375 : }
376 : ]
377 : }
378 : #rim
379 : Shape {
380 : appearance IS tex
381 : geometry Cylinder {
382 : radius .5
383 : top TRUE
384 : height .03
385 : bottom FALSE
386 : }
387 : }
388 : ]
389 : }
390 : }
391 :
392 : PROTO TankEntranceLod1 [
393 : exposedField SFVec3f pos 0 0 0
394 : exposedField SFNode tex TankSurf {}
395 : ]{
396 : Transform {
397 : translation IS pos
398 : children Transform {
399 : translation 0 .025 0
400 : children Shape {
401 : appearance IS tex
402 : geometry Cylinder {
403 : radius .48
404 : top TRUE
405 : bottom FALSE
406 : height .12
407 : }
408 : }
409 : }
410 : }
411 : }
412 :
413 : PROTO TankEntrance [
414 : exposedField SFVec3f pos 0 0 0
415 : exposedField SFNode tex TankSurf {}
416 : ]{
417 : Transform {
418 : translation IS pos
419 : children [
420 : #interior
421 : Shape {
422 : appearance TankInside {}
423 : geometry Cylinder {
424 : radius .4
425 : top TRUE
426 : height .05
427 : bottom FALSE
428 : }
429 : }
430 : TankEntranceLod0 { tex IS tex }
431 : #handle
432 : Transform {
433 : translation 0 .1 -.38
434 : children [
435 : Shape {
436 : appearance IS tex
437 : geometry Box {
438 : size .08 .03 .25
439 : }
440 : }
441 : ]
442 : }
443 : #"axis" of rotation
444 : Transform {
445 : translation 0 .05 .42
446 : rotation 0 0 1 1.57
447 : children [
448 : Shape {
449 : appearance IS tex
450 : geometry Cylinder {
451 : height .25
452 : radius .05
453 : }
454 : }
455 : ]
456 : }
457 : ]
458 : }
459 : }
460 :
461 : PROTO TankMGLodB [
462 : exposedField SFNode tex TankSurf {}
463 : ]{
464 : Shape {
465 : appearance IS tex
466 : geometry Sphere {
467 : radius .2
468 : }
469 : }
470 : }
471 :
472 : PROTO TankMGLodA [
473 : exposedField SFNode tex TankSurf {}
474 : ]{
475 : Group {
476 : children [
477 : Transform {
478 : rotation 1 0 0 -1.57
479 : translation 0 0 -.25
480 : children [
481 : Shape {
482 : appearance IS tex
483 : geometry Cylinder {
484 : radius .03
485 : height .5
486 : bottom FALSE
487 : }
488 : }
489 : Shape {
490 : appearance BlackHole {}
491 : geometry Cylinder {
492 : radius .02
493 : height .502
494 : bottom FALSE
495 : side FALSE
496 : }
497 : }
498 : ]
499 : }
500 : TankMGLodB { tex IS tex }
501 : ]
502 : }
503 : }
504 :
505 :
506 : PROTO TankMG [
507 : exposedField SFVec3f pos 0 0 0
508 : exposedField SFNode tex TankSurf {}
509 : field MFFloat lodRanges [6 14 20 100 500]
510 : ]{
511 : Transform {
512 : translation IS pos
513 : children [
514 : DEF SM CylinderSensor {
515 : maxAngle 0.8
516 : minAngle -0.8
517 : }
518 : DEF TM Transform {
519 : children LOD {
520 : range IS lodRanges
521 : level [
522 : TankMGLodA { tex IS tex}
523 : TankMGLodA { tex IS tex}
524 : TankMGLodB { tex IS tex}
525 : Group{}
526 : Group{}
527 : Group{}
528 : ]
529 : }
530 : }
531 : ]
532 : ROUTE SM.rotation_changed TO TM.rotation
533 : }
534 : }
535 :
536 : PROTO TankEntranceLod [
537 : exposedField SFVec3f pos 0 0 0
538 : exposedField SFNode tex TankSurf {}
539 : field MFFloat lodRanges [6 14 20 100 500]
540 : ]{
541 : LOD {
542 : range IS lodRanges
543 : level [
544 : TankEntrance { pos IS pos tex IS tex}
545 : TankEntranceLod0 { pos IS pos tex IS tex}
546 : TankEntranceLod1 { pos IS pos tex IS tex}
547 : Group{}
548 : Group{}
549 : Group{}
550 : ]
551 : }
552 : }
553 :
554 : PROTO TankCannonHole[]{
555 : Transform {
556 : translation 0 -1.5 0
557 : children [
558 : Shape {
559 : appearance BlackHole {}
560 : geometry Cylinder {
561 : radius .10
562 : height .001
563 : top FALSE
564 : side FALSE
565 : }
566 : }
567 : ]
568 : }
569 : }
570 :
571 : PROTO TankCannon [
572 : exposedField SFVec3f pos 0 0 0
573 : exposedField SFNode tex TankSurf {}
574 : ]{
575 : Transform {
576 : rotation 1 0 0 1.57
577 : translation IS pos
578 : children [
579 : TankCannonHole {}
580 : Transform {
581 : translation 0 -1.4 0
582 : children [
583 : Shape {
584 : appearance IS tex
585 : geometry Cylinder {
586 : radius .15
587 : height .2
588 : }
589 : }
590 : ]
591 : }
592 : Shape {
593 : appearance IS tex
594 : geometry Cylinder {
595 : radius .12
596 : height 3
597 : top FALSE
598 : }
599 : }
600 : Shape {
601 : appearance IS tex
602 : geometry Cylinder {
603 : radius .14
604 : height 1.1
605 : }
606 : }
607 : ]
608 : }
609 : }
610 :
611 : PROTO TankCannonLod0 [
612 : exposedField SFVec3f pos 0 0 0
613 : exposedField SFNode tex TankSurf {}
614 : ]{
615 : Transform {
616 : rotation 1 0 0 1.57
617 : translation IS pos
618 : children [
619 : TankCannonHole {}
620 : Shape {
621 : appearance IS tex
622 : geometry Cylinder {
623 : radius .14
624 : height 3
625 : top FALSE
626 : }
627 : }
628 : ]
629 : }
630 : }
631 :
632 : PROTO TankWindow [
633 : exposedField SFVec3f pos 0 0 0
634 : exposedField SFNode tex TankSurf {}
635 : ]{
636 : Transform {
637 : translation IS pos
638 : children [
639 : Shape {
640 : appearance IS tex
641 : geometry Box {
642 : size .6 .3 .3
643 : }
644 : }
645 : Shape {
646 : appearance BlackHole {}
647 : geometry Box {
648 : size .4 .1 .31
649 : }
650 : }
651 : ]
652 : }
653 : }
654 :
655 : PROTO TankWedge [
656 : exposedField SFNode tex TankSurf {}
657 : ]{
658 : Shape {
659 : appearance IS tex
660 : geometry IndexedFaceSet {
661 : coord Coordinate {
662 : point [
663 : -1.2 -.65 -3.4,
664 : -1.2 -.65 3.4,
665 : -1.2 .65 4.1,
666 : -1.2 .65 -4.1,
667 : 1.2 -.65 -3.4,
668 : 1.2 -.65 3.4,
669 : 1.2 .65 4.1
670 : 1.2 .65 -4.1,
671 : ]
672 : }
673 : coordIndex [
674 : 0 1 2 3 -1,
675 : 4 5 1 0 -1,
676 : 7 6 5 4 -1,
677 : 6 7 3 2 -1,
678 : 5 6 2 1 -1,
679 : 0 3 7 4 -1
680 : ]
681 : texCoord TextureCoordinate {
682 : point [
683 : -1 -2,
684 : -1 2,
685 : 1 1.7,
686 : 1 -1.7,
687 : ]
688 : }
689 : texCoordIndex [
690 : 0 1 2 3 -1,
691 : 0 1 2 3 -1,
692 : 0 1 2 3 -1,
693 : 0 1 2 3 -1,
694 : 1 2 3 0 -1,
695 : 1 2 3 0 -1,
696 : ]
697 : }
698 : }
699 : }
700 :
701 : PROTO TankWedges [
702 : exposedField SFNode tex TankSurf {}
703 : ]{
704 : Transform {
705 : translation 0 -.4 0
706 : children [
707 : TankWedge {tex IS tex }
708 : Transform {
709 : rotation 1 0 0 3.14
710 : scale 1.4 .5 1
711 : translation 0 .975 0
712 : children TankWedge {tex IS tex }
713 : }
714 : ]
715 : }
716 : }
717 :
718 : PROTO TankBackBox [
719 : exposedField SFVec3f pos 0 0 0
720 : exposedField SFNode tex TankSurf {}
721 : ]{
722 : Transform {
723 : translation IS pos
724 : children DEF TankBackBox Shape {
725 : appearance IS tex
726 : geometry Box {
727 : size 1 .06 1
728 : }
729 : }
730 : }
731 : }
732 :
733 : PROTO TankGunRack [
734 : exposedField SFVec3f pos 0 0 0
735 : exposedField SFNode tex TankSurf {}
736 : ]{
737 : Transform {
738 : translation IS pos
739 : rotation 0 0 1 1.57
740 : children [
741 : Shape {
742 : appearance IS tex
743 : geometry Cylinder {
744 : radius .4
745 : height .3
746 : bottom TRUE
747 : top TRUE
748 : }
749 : }
750 : Shape {
751 : appearance IS tex
752 : geometry Box {
753 : size .7 .5 .5
754 : }
755 : }
756 : ]
757 : }
758 : }
759 :
760 : PROTO TankGunRackLod0 [
761 : exposedField SFVec3f pos 0 0 0
762 : exposedField SFNode tex TankSurf {}
763 : ]{
764 : Transform {
765 : translation IS pos
766 : rotation 0 0 1 1.57
767 : children [
768 : Shape {
769 : appearance IS tex
770 : geometry Cylinder {
771 : radius .4
772 : height .4
773 : bottom TRUE
774 : top TRUE
775 : }
776 : }
777 : ]
778 : }
779 : }
780 :
781 :
782 : PROTO TankHiBox [
783 : exposedField SFNode tex TankSurf {}
784 : ]{
785 : Transform {
786 : translation 0 .6 .5
787 : children [
788 : Shape {
789 : appearance IS tex
790 : geometry Box {
791 : size 2.7 .65 6.7
792 : }
793 : }
794 : ]
795 : }
796 : }
797 :
798 : PROTO TankLowerBodyLod0 [
799 : exposedField SFNode tex TankSurf {}
800 : ]{
801 : Group {
802 : children [
803 : TankHiBox {tex IS tex }
804 : TankWedges {tex IS tex }
805 : ]
806 : }
807 : }
808 :
809 : PROTO TankLowerBody [
810 : exposedField SFNode tex TankSurf {}
811 : ]{
812 : Group {
813 : children [
814 : TankBackBox { pos .7 .95 3.1 tex IS tex }
815 : TankBackBox { pos -.7 .95 3.1 tex IS tex }
816 : TankLowerBodyLod0 {tex IS tex }
817 : ]
818 : }
819 : }
820 :
821 : PROTO TurretBackWedge [
822 : exposedField SFNode tex TankSurf {}
823 : ]{
824 : Transform {
825 : rotation 1 1 1 2.09
826 : translation 0 .69 1.75
827 : children [
828 : Shape {
829 : appearance IS tex
830 : geometry IndexedFaceSet {
831 : coord Coordinate {
832 : point [
833 : -.35 -1.75 -1.45,
834 : -.35 -1.75 1.45,
835 : -.35 .15 .8,
836 : -.35 .15 -.8,
837 : .35 -1.75 -1.45,
838 : .35 -1.75 1.45,
839 : .35 .15 .8
840 : .35 .15 -.8,
841 : ]
842 : }
843 : coordIndex [
844 : 0 1 2 3 -1,
845 : 4 5 1 0 -1,
846 : 7 6 5 4 -1,
847 : 6 7 3 2 -1,
848 : 5 6 2 1 -1,
849 : 0 3 7 4 -1
850 : ]
851 : }
852 : }
853 : ]
854 : }
855 : }
856 :
857 : PROTO TurretMiddle [
858 : exposedField SFNode tex TankSurf {}
859 : ]{
860 : Transform { translation 0 .55 0
861 : children [
862 : Shape {
863 : appearance IS tex
864 : geometry Cylinder {
865 : radius 1.5
866 : height 1
867 : }
868 : }
869 : ]
870 : }
871 : }
872 :
873 : PROTO TurretMiddleLod0 [
874 : exposedField SFNode tex TankSurf {}
875 : ]{
876 : Transform { translation 0 .5 0
877 : children [
878 : Shape {
879 : appearance IS tex
880 : geometry Cylinder {
881 : radius 1.5
882 : height 1.1
883 : bottom FALSE
884 : }
885 : }
886 : ]
887 : }
888 : }
889 :
890 : PROTO TurretBottom [
891 : exposedField SFNode tex TankSurf {}
892 : ]{
893 : Shape {
894 : appearance IS tex
895 : geometry Cylinder {
896 : radius 1.4
897 : height .1
898 : top FALSE
899 : bottom FALSE
900 : }
901 : }
902 : }
903 :
904 : PROTO TurretTop [
905 : exposedField SFNode tex TankSurf {}
906 : ]{
907 : Transform { translation 0 1.08 0
908 : children [
909 : Shape {
910 : appearance IS tex
911 : geometry Cone {
912 : bottomRadius 1.5
913 : height .1
914 : bottom FALSE
915 : }
916 : }
917 : ]
918 : }
919 : }
920 :
921 : PROTO TankTurretCore0 [
922 : exposedField SFNode tex TankSurf {}
923 : ]{
924 : Group {
925 : children [
926 : TurretBackWedge { tex IS tex}
927 : TurretMiddle { tex IS tex}
928 : TurretBottom { tex IS tex}
929 : TurretTop { tex IS tex}
930 : TankCannon { pos 0 .5 -2.7 tex IS tex }
931 : TankGunRack { pos 0 .5 -1.3 tex IS tex }
932 : ]
933 : }
934 : }
935 :
936 :
937 : PROTO TankTurretLodB [
938 : exposedField SFNode tex TankSurf {}
939 : exposedField SFRotation rot 0 0 1 0
940 : ]{
941 : Transform {
942 : translation 0 .94 1
943 : rotation IS rot
944 : children [
945 : TankTurretCore0 { tex IS tex }
946 : TankEntranceLod0 { pos -.7 1.1 .45 tex IS tex }
947 : TankEntranceLod0 { pos .7 1.1 .45 tex IS tex }
948 : ]
949 : }
950 : }
951 :
952 :
953 : PROTO TankTurretLod0 [
954 : exposedField SFNode tex TankSurf {}
955 : exposedField SFRotation rot 0 0 1 0
956 : ]{
957 : Transform {
958 : translation 0 .94 1
959 : rotation IS rot
960 : children [
961 : TankTurretCore0 { tex IS tex }
962 : TankEntranceLod0 { pos -.7 1.1 .45 tex IS tex }
963 : TankEntranceLod0 { pos .7 1.1 .45 tex IS tex }
964 : ]
965 : }
966 : }
967 :
968 : PROTO TankTurretCore1 [
969 : exposedField SFNode tex TankSurf {}
970 : ]{
971 : Group {
972 : children [
973 : TurretBackWedge { tex IS tex}
974 : TurretMiddleLod0 { tex IS tex}
975 : TankCannonLod0 { pos 0 .5 -2.7 tex IS tex }
976 : ]
977 : }
978 : }
979 :
980 :
981 : PROTO TankTurretLod2 [
982 : exposedField SFNode tex TankSurf {}
983 : exposedField SFRotation rot 0 0 1 0
984 : ]{
985 : Transform {
986 : translation 0 .94 1
987 : rotation IS rot
988 : children TankTurretCore1 { tex IS tex }
989 : }
990 : }
991 :
992 : PROTO TankTurretLod1 [
993 : exposedField SFNode tex TankSurf {}
994 : exposedField SFRotation rot 0 0 1 0
995 : ]{
996 : Transform {
997 : translation 0 .94 1
998 : rotation IS rot
999 : children [
1000 : TankTurretCore1 { tex IS tex }
1001 : TankGunRackLod0 { pos 0 .5 -1.3 tex IS tex }
1002 : TankEntranceLod1 { pos -.7 1.1 .45 tex IS tex }
1003 : TankEntranceLod1 { pos .7 1.1 .45 tex IS tex }
1004 : ]
1005 : }
1006 : }
1007 :
1008 : PROTO TankTurretLod [
1009 : exposedField SFNode tex TankSurf {}
1010 : field MFFloat lodRanges [6 14 20 100 500]
1011 : ]{
1012 : Group {
1013 : children [
1014 : DEF S CylinderSensor {}
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 Tank [
1191 : exposedField SFVec3f pos 0 0 0 #pozice
1192 : exposedField SFRotation rot 0 0 1 0 #rotace
1193 : exposedField SFInt32 lod 1 #zaputo/vypnuto lOD
1194 : exposedField SFColor wheelColor 0 .4 0 #barva kolecek
1195 : exposedField SFColor wheelDarkColor 0 .2 0 #barva vnitrku kolecek
1196 : exposedField SFNode tex TankSurf {} #barva ci textura tanku
1197 : field MFFloat lodRanges [6 14 20 100 500] #vzdalenosti pro lod
1198 : exposedField SFColor light 1 1 1 #barva svetla nad strojem
1199 : exposedField SFFloat lightIntensity 2 #intenzita svetla nad strojem
1200 : ]{
1201 : Transform {
1202 : translation IS pos
1203 : rotation IS rot
1204 : children DEF TK Transform {
1205 : children [
1206 : DEF P ProximitySensor {
1207 : size 20 20 20
1208 : }
1209 : DEF L PointLight {
1210 : color IS light
1211 : intensity IS lightIntensity
1212 : location 3 4 3
1213 : radius 8
1214 : on FALSE
1215 : }
1216 : DEF L2 PointLight {
1217 : color IS light
1218 : intensity IS lightIntensity
1219 : location -3 4 -3
1220 : radius 8
1221 : on FALSE
1222 : }
1223 : Switch {
1224 : whichChoice IS lod
1225 : choice [
1226 : TankLod0 { wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex}
1227 : Group {
1228 : children [
1229 : LOD {
1230 : range IS lodRanges
1231 : level [
1232 : DEF TL0 TankLod0 { ttrans TankTexTrans{} wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex}
1233 : DEF TL1 TankLod1 { ttrans TankTexTrans{} wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex }
1234 : DEF TL2 TankLod2 { ttrans TankTexTrans{} wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex }
1235 : DEF TL3 TankLod3 { ttrans TankTexTrans{} wheelColor IS wheelColor wheelDarkColor IS wheelDarkColor tex IS tex }
1236 : DEF TL4 TankLod4 { tex IS tex}
1237 : Group{}
1238 : ]
1239 : }
1240 : LOD {
1241 : range IS lodRanges
1242 : level [
1243 : DEF EX0 Exhausts{ color 0 0 0}
1244 : USE EX0
1245 : USE EX0
1246 : USE EX0
1247 : USE EX0
1248 : Group{}
1249 : ]
1250 : }
1251 : Transform {
1252 : children [
1253 : DEF T TouchSensor {}
1254 : DEF B LOD {
1255 : range IS lodRanges
1256 : level [
1257 : TankLowerBody { tex IS tex}
1258 : TankLowerBody { tex IS tex}
1259 : TankLowerBodyLod0 { tex IS tex}
1260 : TankLowerBodyLod0 { tex IS tex}
1261 : Group{}
1262 : Group{}
1263 : ]
1264 : }
1265 : DEF Z PositionInterpolator {
1266 : key [0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1]
1267 : keyValue [0 0 9
1268 : ,0 0 9.005,0 0 8.995
1269 : ,0 0 9.01 ,0 0 8.99
1270 : ,0 0 9.015,0 0 8.99
1271 : ,0 0 9.01 ,0 0 8.995
1272 : ,0 0 9.005,0 0 9]
1273 : }
1274 : DEF Z2 PositionInterpolator {
1275 : key [0,.2,.4,.6,.8,1]
1276 : keyValue [
1277 : 0 0 9,
1278 : 0 0 8,
1279 : 0 0 6,
1280 : 0 0 3,
1281 : 0 0 1,
1282 : 0 0 0]
1283 : }
1284 : DEF AU1 Sound {
1285 : direction 0 0 1
1286 : maxFront 200
1287 : minFront 1
1288 : maxBack 200
1289 : minBack 1
1290 : source DEF AC1 AudioClip {
1291 : url "tstart.wav"
1292 : }
1293 : }
1294 : DEF AU2 Sound {
1295 : direction 0 0 1
1296 : maxFront 200
1297 : minFront 1
1298 : maxBack 200
1299 : minBack 1
1300 : source DEF AC2 AudioClip {
1301 : url "tstart2.wav"
1302 : }
1303 : }
1304 : DEF AU3 Sound {
1305 : direction 0 0 1
1306 : maxFront 200
1307 : minFront 1
1308 : maxBack 200
1309 : minBack 1
1310 : source DEF AC3 AudioClip {
1311 : url "tmove.wav"
1312 : }
1313 : }
1314 : DEF AU4 Sound {
1315 : direction 0 0 1
1316 : maxFront 200
1317 : minFront 1
1318 : maxBack 200
1319 : minBack 1
1320 : source DEF AC4 AudioClip {
1321 : url "tstop.wav"
1322 : }
1323 : }
1324 : DEF TS TimeSensor {
1325 : cycleInterval 1
1326 : loop FALSE
1327 : }
1328 : DEF TS2 TimeSensor {
1329 : cycleInterval 3.36
1330 : loop FALSE
1331 : }
1332 : DEF CI1 ColorInterpolator {
1333 : key [0,1]
1334 : keyValue [0 0 0,1 0 0]
1335 : }
1336 : DEF CI2 ColorInterpolator {
1337 : key [0,.3,.6,.9,1]
1338 : keyValue [1 0 0,1 1 0,1 1 1,.3 .3 1,0 0 0]
1339 : }
1340 : DEF TIMER Script {
1341 : eventIn SFTime tick
1342 : eventIn SFTime flip
1343 : eventOut SFTime tick1
1344 : eventOut SFTime tick2
1345 : eventOut SFTime tick3
1346 : eventOut SFTime tick4
1347 : eventIn SFFloat tick5
1348 : field SFFloat dir 1
1349 : field SFNode p_I USE Z2
1350 : field SFNode p_I0 USE Z
1351 : field SFNode ts USE T
1352 : field MFNode t [USE TL0 USE TL1 USE TL2 USE TL3]
1353 : url "javascript:
1354 : function tick5(x) {
1355 : if (x>=1) ts.enabled=true;
1356 : for (j=0;j<3;j++) t[j].ttrans.trans =new SFVec2f (-.05,dir*x/4);
1357 : }
1358 : function tick(x) {
1359 : tick2=x+1;
1360 : tick3=x+1.88;
1361 : tick4=x+1.88+1.48;
1362 : }
1363 : function flip(x) {
1364 : ts.enabled=false;
1365 : tick1=x;
1366 : dir=-dir;
1367 : for (i=0;i<p_I.keyValue.length;i++) {
1368 : p_I.keyValue[i][2]=9-p_I.keyValue[i][2];
1369 : }
1370 : for (i=0;i<p_I0.keyValue.length;i++) {
1371 : p_I0.keyValue[i][2]=9-p_I0.keyValue[i][2];
1372 : }
1373 : }
1374 : "
1375 : }
1376 : ]
1377 : ROUTE T.touchTime TO TIMER.flip
1378 : ROUTE T.touchTime TO TS.startTime
1379 : ROUTE T.touchTime TO AC1.startTime
1380 : ROUTE T.touchTime TO TIMER.tick
1381 : ROUTE TIMER.tick2 TO AC2.startTime
1382 : ROUTE TIMER.tick2 TO TS2.startTime
1383 : ROUTE TIMER.tick3 TO AC3.startTime
1384 : ROUTE TIMER.tick4 TO AC4.startTime
1385 : ROUTE TS2.fraction_changed TO TIMER.tick5
1386 : ROUTE TS.fraction_changed TO Z.set_fraction
1387 : ROUTE TS2.fraction_changed TO Z2.set_fraction
1388 : ROUTE TS.fraction_changed TO CI1.set_fraction
1389 : ROUTE TS2.fraction_changed TO CI2.set_fraction
1390 : ROUTE Z.value_changed TO TK.translation
1391 : ROUTE Z2.value_changed TO TK.translation
1392 : ROUTE CI1.value_changed TO EX0.color
1393 : ROUTE CI2.value_changed TO EX0.color
1394 : }
1395 : TankEntranceLod { pos .8 .95 -2.2 tex IS tex lodRanges IS lodRanges}
1396 : TankEntranceLod { pos -.8 .95 -2.2 tex IS tex lodRanges IS lodRanges}
1397 : TankTurretLod { lodRanges IS lodRanges tex IS tex }
1398 : TankMG { pos .7 .65 -3.68 tex IS tex lodRanges IS lodRanges }
1399 : ]
1400 : }
1401 : ]
1402 : ROUTE P.isActive TO L.on
1403 : ROUTE P.isActive TO L2.on
1404 : }
1405 : ]
1406 : }
1407 : }
1408 : }