1 : #VRML V2.0 utf8
2 :
3 : # "All work and no play makes Jack a dull boy."
4 :
5 : WorldInfo {
6 : info "Author: Tomash Kazmar"
7 : title "Old 'Underwood Noiseless' Typwriter"
8 : }
9 :
10 : PROTO TWPlastic []
11 : {
12 : Appearance {
13 : material Material {
14 : diffuseColor .15 .15 .15
15 : specularColor .5 .5 .5
16 : ambientIntensity 0
17 : emissiveColor .14 .14 .14
18 : }
19 : }
20 : }
21 :
22 : PROTO TWSteel []
23 : {
24 : Appearance {
25 : material Material {
26 : diffuseColor .373 .31 .251
27 : specularColor .475 .475 .373
28 : ambientIntensity .122
29 : shininess .1
30 : emissiveColor .129 .129 .129
31 : }
32 : }
33 : }
34 :
35 : PROTO TWKey [exposedField MFString char [""],
36 : exposedField SFNode steel TWSteel {}]
37 : {
38 : LOD {
39 : range [1 20]
40 : level [
41 : Group { # full detail
42 : children [
43 : DEF Inner Shape {
44 : geometry Cylinder {
45 : bottom FALSE
46 : top TRUE
47 : side FALSE
48 : radius 0.00798
49 : height 0.001
50 : }
51 : appearance Appearance {
52 : material Material {
53 : diffuseColor .76 .66 .38
54 : shininess .1
55 : emissiveColor .2 .18 .1
56 : ambientIntensity 0
57 : specularColor .15 .15 .15
58 : }
59 : }
60 : }
61 : DEF Outer Shape {
62 : geometry Cylinder {
63 : bottom FALSE
64 : top FALSE
65 : side TRUE
66 : radius 0.008
67 : height 0.002
68 : }
69 : appearance IS steel
70 : }
71 : DEF Letter Shape {
72 : geometry IndexedFaceSet {
73 : coord Coordinate {
74 : point [-0.01 0.0011 0.01, 0.01 0.0011 0.01, 0.01 0.0011 -0.01, -0.01 0.0011 -0.01]
75 : }
76 : coordIndex [0 1 2 3 -1]
77 : texCoord TextureCoordinate {
78 : point [0.05 0, 1 0, 1 1, 0.05 1]
79 : }
80 : }
81 : appearance Appearance {
82 : texture ImageTexture {
83 : url IS char
84 : repeatS FALSE
85 : repeatT FALSE
86 : }
87 :
88 : }
89 : }
90 : Shape {
91 : geometry Extrusion {
92 : beginCap FALSE
93 : endCap FALSE
94 : creaseAngle 1.0
95 : scale 0.001 0.0015
96 : spine [0 0 0, 0 -0.01 0, 0 0 -0.18]
97 : crossSection [0.7 0.7, 1.0 0, 0.7 -0.7, 0 -1.0,
98 : -0.7 -0.7, -1.0 0, -0.7 0.7, 0 1.0
99 : 0.7 0.7]
100 : }
101 : appearance IS steel
102 : }
103 : ]
104 : }
105 : Group { # from distance
106 : children [
107 : USE Inner
108 : USE Outer
109 : Transform {
110 : children Shape {
111 : geometry Box {
112 : size 0.002 0.003 0.18
113 : }
114 : appearance IS steel
115 : }
116 : translation -0.001 -0.005 -0.09
117 : }
118 : ]
119 : }
120 : Shape {} # far away
121 : ]
122 : }
123 : }
124 :
125 : PROTO TWScrew [exposedField SFNode steel TWSteel {}]
126 : {
127 : Group {
128 : children [
129 : Shape {
130 : geometry Cylinder {
131 : bottom FALSE
132 : height 0.001
133 : radius 0.005
134 : }
135 : appearance IS steel
136 : }
137 : Shape {
138 : geometry IndexedFaceSet {
139 : coord Coordinate {
140 : point [
141 : -0.005 0.00051 0.0005,
142 : -0.005 0.00051 -0.0005,
143 : 0.005 0.00051 0.0005,
144 : 0.005 0.00051 -0.0005
145 : ]
146 : }
147 : coordIndex [0 2 3 1 -1]
148 : }
149 : appearance Appearance { # cut simulation
150 : material Material {
151 : diffuseColor 0 0 0
152 : specularColor .29 .298 .29
153 : ambientIntensity 0
154 : shininess .063
155 : transparency .224 # <<-
156 : }
157 : }
158 : }
159 : ]
160 : }
161 : }
162 :
163 : PROTO TWSpacebar [exposedField SFNode steel TWSteel {}]
164 : {
165 : LOD {
166 : range [1 20]
167 : level [
168 : Group { # full detail
169 : children [
170 : DEF CBox Shape {
171 : geometry Box {
172 : size 0.18 0.008 0.01
173 : }
174 : appearance TWPlastic {}
175 : }
176 : DEF LeftPart Shape {
177 : geometry Extrusion {
178 : beginCap TRUE
179 : endCap TRUE
180 : solid TRUE
181 : creaseAngle 0.3
182 : spine [-0.09 -0.004 -0.005, -0.09 -0.004 0.005]
183 : scale 0.01 0.01
184 : crossSection [-1 0, 0 0, 0 -0.8, -0.1 -0.7, -0.2 -0.6,
185 : -0.3 -0.53, -0.4 -0.47, -0.5 -0.41,
186 : -0.6 -0.36, -0.7 -0.32, -0.8 -0.28,
187 : -0.9 -0.26, -1 -0.20, -1 0]
188 : }
189 : appearance TWPlastic {}
190 : }
191 : Transform {
192 : children USE LeftPart
193 : rotation 0 1 0 3.14
194 : translation 0 0 0
195 : }
196 : DEF LeftStick Shape {
197 : geometry Extrusion {
198 : beginCap FALSE
199 : endCap FALSE
200 : creaseAngle 1.0
201 : scale 0.001 0.0015
202 : spine [-0.07 0 0, -0.07 -0.01 0, -0.07 0 -0.22]
203 : crossSection [0.7 0.7, 1.0 0, 0.7 -0.7, 0 -1.0,
204 : -0.7 -0.7, -1.0 0, -0.7 0.7, 0 1.0
205 : 0.7 0.7]
206 : }
207 : appearance IS steel
208 : }
209 : Transform {
210 : children USE LeftStick
211 : translation 0.14 0 0
212 : }
213 :
214 : ]
215 : }
216 : Group { # from distance
217 : children [
218 : USE CBox
219 : Transform {
220 : children DEF LeftSimple Shape {
221 : geometry Box {
222 : size 0.002 0.003 0.20
223 : }
224 : appearance IS steel
225 : }
226 : translation -0.071 -0.005 -0.10
227 : }
228 : Transform {
229 : children USE LeftSimple
230 : translation 0.071 -0.005 -0.10
231 : }
232 : ]
233 : }
234 : Shape {} # far away
235 : ]
236 : }
237 : }
238 :
239 : PROTO TWTopBox [exposedField SFNode plastic TWPlastic {}]
240 : {
241 : LOD {
242 : range [1 5 20]
243 : level [
244 : Transform { # full detail
245 : scale 0.012 0.009 0.011
246 : children [
247 : Shape {
248 : geometry Extrusion {
249 : spine [ 0.97 0 0.26, 0.87 0 0.50, 0.70 0 0.70, 0.50 0 0.87,
250 : 0.26 0 0.97, 0.00 0 1.00, -0.26 0 0.97, -0.50 0 0.87,
251 : -0.70 0 0.70, -0.87 0 0.50, -0.97 0 0.26]
252 : creaseAngle 1.5
253 : scale 1 0.5
254 : solid TRUE
255 : ccw FALSE
256 : crossSection [0 0, 0 -6, 3.6 -6, 3.8 -6.2, 4 -7.8, 4.2 -8, 8.5 -8,
257 : 9.5 -5, 10 -2, 10.3 -2, 10.5 0, 0 0]
258 : }
259 : appearance IS plastic
260 : }
261 : ]
262 : }
263 : Transform { # detail
264 : scale 0.012 0.009 0.011
265 : children [
266 : Shape {
267 : geometry Extrusion {
268 : spine [ 0.97 0 0.26, 0.87 0 0.50, 0.50 0 0.87, 0.00 0 1.00,
269 : -0.50 0 0.87, -0.87 0 0.50, -0.97 0 0.26]
270 : creaseAngle 1.5
271 : scale 1 0.5
272 : solid TRUE
273 : ccw FALSE
274 : crossSection [0 0, 0 -6, 4 -6, 4 -8, 8.5 -8, 10 -2, 10.5 0, 0 0]
275 : }
276 : appearance IS plastic
277 : }
278 : ]
279 : }
280 : Transform { # from distance
281 : scale 0.012 0.009 0.011
282 : children [
283 : Shape {
284 : geometry Extrusion {
285 : spine [ 0.97 0 0.26, 0.70 0 0.70, -0.70 0 0.70, -0.97 0 0.26]
286 : creaseAngle 1.5
287 : scale 1 0.5
288 : solid TRUE
289 : ccw FALSE
290 : crossSection [0 0, 0 -6, 4 -6, 4 -8, 8.5 -8, 10 -2, 10.5 0, 0 0]
291 : }
292 : appearance IS plastic
293 : }
294 : ]
295 : }
296 : Shape {} # far away
297 : ]
298 : }
299 : }
300 :
301 : PROTO TWTape [exposedField SFNode steel TWSteel {}]
302 : {
303 : Group {
304 : children [
305 : Shape {
306 : geometry Cylinder {
307 : height 0.015
308 : radius 0.03
309 : }
310 : appearance TWPlastic {}
311 : }
312 : LOD {
313 : range [1]
314 : level [
315 : Transform { # tiny topie
316 : children Shape {
317 : geometry Cylinder {
318 : bottom FALSE
319 : height 0.01
320 : radius 0.005
321 : }
322 : appearance IS steel
323 : }
324 : translation 0 0.008 0
325 : }
326 : Shape {} # no tiny topie
327 : ]
328 : }
329 : ]
330 : }
331 : }
332 :
333 : PROTO TWRoller [exposedField SFNode steel TWSteel {}]
334 : {
335 : Group {
336 : children [
337 : Shape { # cylinder
338 : geometry Cylinder {
339 : height 0.249
340 : radius 0.015
341 : }
342 : appearance Appearance {
343 : material Material {
344 : diffuseColor 0 0 0
345 : specularColor .631 .69 1
346 : ambientIntensity 0
347 : }
348 : }
349 : }
350 : LOD {
351 : range [5]
352 : level [
353 : Group {
354 : children [
355 : Transform {
356 : children DEF LeftStick Shape { # left steel stick to cap
357 : geometry Cylinder {
358 : top FALSE
359 : bottom FALSE
360 : height 0.02
361 : radius 0.004
362 : }
363 : appearance IS steel
364 : }
365 : translation 0 0.135 0
366 : }
367 : Transform { # right ...
368 : children USE LeftStick
369 : translation 0 -0.135 0
370 : }
371 : ]
372 : }
373 : Shape {}
374 : ]
375 : }
376 : Transform {
377 : children DEF LeftCap Shape { # left handle of cylinder
378 : geometry Cylinder {
379 : height 0.008
380 : radius 0.017
381 : }
382 : appearance TWPlastic {}
383 : }
384 : translation 0 0.15 0
385 : }
386 : Transform { # right ...
387 : children USE LeftCap
388 : translation 0 -0.15 0
389 : }
390 : ]
391 : }
392 : }
393 :
394 : PROTO TWReturn [exposedField SFNode steel TWSteel {}]
395 : {
396 : LOD {
397 : range [1 5]
398 : level [
399 : DEF Full Group {
400 : children Shape {
401 : geometry Extrusion {
402 : creaseAngle 2
403 : spine [0 0 0, 0 0.01 0.01, 0 0.015 0.02, 0 0.018 0.03, 0 0.02 0.04, 0 0.016 0.075,
404 : 0.0001 0.018 0.082, 0.0003 0.023 0.089, 0.00031 0.025 0.09, 0.00035 0.03 0.092,
405 : 0.001 0.045 0.094, 0 0.060 0.0942, -0.004 0.065 0.0942, -0.012 0.066 0.0942]
406 : scale 0.002 0.006
407 : crossSection [1 1, 1 -1, -1 -1, -1 1, 1 1]
408 : }
409 : appearance IS steel
410 : }
411 : }
412 : Shape {
413 : geometry Extrusion {
414 : creaseAngle 2
415 : spine [0 0 0, 0 0.02 0.04, 0 0.016 0.075, 0.0003 0.023 0.089,
416 : 0.001 0.045 0.094, -0.012 0.066 0.0942]
417 : scale 0.002 0.006
418 : crossSection [1 1, 1 -1, -1 -1, -1 1, 1 1]
419 : }
420 : appearance IS steel
421 : }
422 : Shape {}
423 : ]
424 : }
425 : }
426 :
427 : PROTO TWRearScale [exposedField SFNode steel TWSteel {}]
428 : {
429 : Group {
430 : children [
431 : Shape {
432 : geometry Box {
433 : size 0.25 0.01 0.002
434 : }
435 : appearance TWPlastic {}
436 : }
437 : Transform {
438 : children DEF LeftStuff Shape {
439 : geometry Extrusion {
440 : solid TRUE
441 : creaseAngle 1
442 : spine [0 -0.033 0.043, 0 -0.001 0.007, 0 0 0, 0 0.001 -0.007]
443 : scale 0.005 0.002
444 : crossSection [-1 0, -1 1, 1 1, 1 -1, -1 0, -1 0]
445 : }
446 : appearance IS steel
447 : }
448 : translation -0.127 0 0
449 : }
450 : Transform {
451 : children USE LeftStuff
452 : translation 0.127 0 0
453 : }
454 : ]
455 : }
456 : }
457 :
458 : PROTO TWWindow [exposedField SFNode steel TWSteel {}]
459 : {
460 : Group {
461 : children [
462 : Transform {
463 : children Shape {
464 : geometry Extrusion {
465 : beginCap FALSE
466 : endCap FALSE
467 : creaseAngle 0.3
468 : scale 0.001 0.001
469 : spine [-0.005 0 0, 0.005 0 0, 0.005 0.01 0, -0.005 0.01 0, -0.005 0 0]
470 : crossSection [1 1, 1 -1, -1 -1, -1 1, 1 1]
471 : }
472 : appearance IS steel
473 : }
474 : translation 0 0 0.001
475 : }
476 : Transform {
477 : children DEF LeftStick Shape {
478 : geometry Box {
479 : size 0.119 0.008 0.001
480 : }
481 : appearance IS steel
482 : }
483 : translation -0.065 0.004 0.0005
484 : }
485 : Transform {
486 : children USE LeftStick
487 : translation 0.065 0.004 0.0005
488 : }
489 : ]
490 : }
491 : }
492 :
493 : PROTO TWFrontHandle [exposedField SFNode plastic TWPlastic {}]
494 : {
495 : LOD {
496 : range [1]
497 : level [
498 : Group { # full detail
499 : children Shape {
500 : geometry Extrusion {
501 : beginCap FALSE
502 : endCap FALSE
503 : solid TRUE
504 : ccw FALSE
505 : creaseAngle 0.3
506 : spine [-0.1225 0 0.00, -0.1225 0 0.07, -0.1225 0 0.140,
507 : -0.1170 0 0.147,
508 : -0.1125 0 0.15, -0.080 0 0.15, -0.056 0 0.15, -0.025 0 0.15
509 : 0 0 0.15,
510 : 0.025 0 0.15, 0.056 0 0.15, 0.080 0 0.15, 0.1125 0 0.15,
511 : 0.1170 0 0.147,
512 : 0.1225 0 0.140, 0.1225 0 0.07, 0.1225 0 0.00]
513 : crossSection [-0.0025 0, 0.0025 0, 0.0025 0.01, -0.0025 0.01, -0.0025 0]
514 : }
515 : appearance IS plastic
516 : }
517 : }
518 : Group { # detail
519 : children Shape {
520 : geometry Extrusion {
521 : beginCap FALSE
522 : endCap FALSE
523 : solid TRUE
524 : ccw FALSE
525 : creaseAngle 0.3
526 : spine [-0.1225 0 0.00, -0.1225 0 0.150, 0.1225 0 0.150, 0.1225 0 0.00]
527 : crossSection [-0.0025 0, 0.0025 0, 0.0025 0.01, -0.0025 0.01, -0.0025 0]
528 : }
529 : appearance IS plastic
530 : }
531 : }
532 : ]
533 : }
534 : }
535 :
536 : PROTO TWMiddleBox [exposedField SFNode plastic TWPlastic {}
537 : exposedField SFNode steel TWSteel {}]
538 : {
539 : Group {
540 : children [
541 : Transform {
542 : children TWTopBox { plastic IS plastic }
543 : translation 0 0.18 -0.11
544 : }
545 : LOD {
546 : range [1 5 20]
547 : level [
548 : Group {
549 : children [
550 : DEF TMBottom Transform { # middle bottom
551 : children DEF MBottom Shape {
552 : geometry Box {
553 : size 0.248 0.004 0.10
554 : }
555 : appearance IS plastic
556 : }
557 : translation 0 0.002 -0.05
558 : }
559 : DEF TLMSide Transform { # left middle side
560 : children DEF LMSide Shape {
561 : geometry Box {
562 : size 0.004 0.18 0.10
563 : }
564 : appearance IS plastic
565 : }
566 : translation -0.123 0.09 -0.05
567 : }
568 : DEF TRMSide Transform { # right middle side
569 : children USE LMSide
570 : translation 0.123 0.09 -0.05
571 : }
572 : Transform { # middle top
573 : children [
574 : USE MBottom
575 : Transform {
576 : children TWScrew {steel IS steel}
577 : translation -0.115 0.002 0.04
578 : }
579 : Transform {
580 : children TWScrew {steel IS steel}
581 : translation 0.115 0.002 0.04
582 : }
583 : ]
584 : translation 0 0.178 -0.06
585 : scale 1 1 1.2
586 : }
587 : Transform { # front
588 : children [
589 : Shape {
590 : geometry Box {
591 : size 0.248 0.108 0.004
592 : }
593 : appearance IS plastic
594 : }
595 : Transform {
596 : children TWScrew {steel IS steel}
597 : rotation 1 0 0 1.57
598 : translation -0.11 0.04 0.002
599 : scale 0.5 1.5 0.5
600 : }
601 : Transform {
602 : children TWScrew {steel IS steel}
603 : rotation 1 0 0 1.57
604 : translation -0.11 -0.04 0.002
605 : scale 0.5 1.5 0.5
606 : }
607 : Transform {
608 : children TWScrew {steel IS steel}
609 : rotation 1 0 0 1.57
610 : translation 0.11 0.04 0.002
611 : scale 0.5 1.5 0.5
612 : }
613 : Transform {
614 : children TWScrew {steel IS steel}
615 : rotation 1 0 0 1.57
616 : translation 0.11 -0.04 0.002
617 : scale 0.5 1.5 0.5
618 : }
619 : ]
620 : translation 0 0.125 -0.007
621 : }
622 : ]
623 : }
624 : Group {
625 : children [
626 : USE TMBottom
627 : USE TLMSide
628 : USE TRMSide
629 : Transform { # middle top
630 : children USE MBottom
631 : translation 0 0.178 -0.06
632 : scale 1 1 1.2
633 : }
634 : Transform { # front
635 : children Shape {
636 : geometry Box {
637 : size 0.248 0.108 0.004
638 : }
639 : appearance IS plastic
640 : }
641 : translation 0 0.125 -0.007
642 : }
643 : ]
644 : }
645 : Transform {
646 : children Shape {
647 : geometry Box {
648 : size 0.25 0.18 0.10
649 : }
650 : appearance IS plastic
651 : }
652 : translation 0 0.09 -0.05
653 : }
654 : Shape {}
655 : ]
656 : }
657 : ]
658 : }
659 : }
660 :
661 : PROTO TWRearBoxMoveable [exposedField SFNode plastic TWPlastic {},
662 : exposedField SFNode steel TWSteel {},
663 : eventIn SFBool SpaceTouched,
664 : eventIn SFBool active]
665 : {
666 : DEF Cyl Transform {
667 : children [
668 : LOD {
669 : range [1 5]
670 : level [
671 : Group {
672 : children [
673 : DEF TCylinder Transform {
674 : children TWRoller {steel IS steel} # cylinder
675 : translation 0 0.18 -0.17
676 : rotation 0 0 1 1.57
677 : }
678 : DEF TRScale Transform {
679 : children TWRearScale {steel IS steel} # rearest scale
680 : translation 0 0.21 -0.21
681 : }
682 : DEF TReturn Transform {
683 : children [
684 : Transform {
685 : children [
686 : TWReturn {steel IS steel}
687 : DEF SR CylinderSensor {
688 : enabled IS active
689 : maxAngle 0.5
690 : minAngle 0
691 : diskAngle 0.262
692 : autoOffset FALSE
693 : }
694 : ]
695 : rotation 1 0 0 -0.15
696 : }
697 : ]
698 : translation -0.135 0.184 -0.172
699 : }
700 : ]
701 : }
702 : Group {
703 : children [
704 : USE TCylinder
705 : USE TRScale
706 : USE TReturn
707 : ]
708 : }
709 : Group {
710 : children [
711 : USE TCylinder
712 : USE TRScale
713 : ]
714 : }
715 : ]
716 : }
717 : DEF SP PlaneSensor {
718 : enabled IS active
719 : minPosition -0.15 0
720 : maxPosition 0.15 0
721 :
722 : }
723 : DEF OBack OrientationInterpolator {
724 : key [0, 1]
725 : keyValue [0 1 0 0.5, 0 1 0 0]
726 : }
727 : DEF TBack TimeSensor {
728 : cycleInterval 0.05
729 : loop FALSE
730 : enabled FALSE
731 : }
732 : DEF ScrCyl Script {
733 : field SFNode manip USE SP
734 : field SFNode rotmanip USE SR
735 : field SFNode valec USE Cyl
736 : field SFNode cas USE TBack
737 : field SFVec3f vec 0 0 0
738 : field SFRotation rotvec 0 1 0 0
739 : field SFBool wasback FALSE
740 : eventIn SFBool back
741 : eventIn SFBool space IS SpaceTouched
742 : eventIn SFRotation rot
743 : url "javascript:
744 : function rot(val)
745 : {
746 : if (val.angle >= 0.5)
747 : {
748 : vec = valec.translation;
749 : vec[0] = vec[0] + 0.002;
750 : if (vec[0] >= 0.15)
751 : vec[0] = 0.15;
752 : manip.offset = vec;
753 : valec.translation = vec;
754 : }
755 :
756 : }
757 : function back(val, time)
758 : {
759 : if (!val) {
760 : if (!wasback) {
761 : wasback = true;
762 : cas.startTime = time;
763 : cas.enabled = true;
764 : rotmanip.offset = rotvec;
765 : }
766 : } else {
767 : wasback = false;
768 : }
769 : }
770 : function space(val)
771 : {
772 : if (val) {
773 : vec = valec.translation;
774 : vec[0] = vec[0] - 0.01;
775 : if (vec[0] <= -0.15)
776 : vec[0] = -0.15;
777 : manip.offset = vec;
778 : valec.translation = vec;
779 : }
780 : }
781 : "
782 : }
783 : ]
784 : }
785 :
786 : ROUTE SP.translation_changed TO Cyl.translation
787 : ROUTE SR.rotation_changed TO TReturn.rotation
788 : ROUTE SR.rotation_changed TO ScrCyl.rot
789 : ROUTE SR.isActive TO ScrCyl.back
790 : ROUTE TBack.fraction_changed TO OBack.set_fraction
791 : ROUTE OBack.value_changed TO TReturn.rotation
792 : }
793 :
794 : PROTO TWRearBox [exposedField SFNode plastic TWPlastic {},
795 : exposedField SFNode steel TWSteel {},
796 : eventIn SFBool SpaceTouched,
797 : eventIn SFBool active]
798 : {
799 : LOD {
800 : range [1 5 20]
801 : level [
802 : DEF Full Group {
803 : children [
804 : DEF TLRSide Transform { # left rear side
805 : children DEF LRSide Shape {
806 : geometry Box {
807 : size 0.004 0.16 0.096
808 : }
809 : appearance IS plastic
810 : }
811 : translation -0.123 0.08 -0.148
812 : }
813 : DEF TRRSide Transform { # right rear side
814 : children USE LRSide
815 : translation 0.123 0.08 -0.148
816 : }
817 : DEF TRSide Transform { # rear side
818 : children Shape {
819 : geometry Box {
820 : size 0.25 0.18 0.004
821 : }
822 : appearance IS plastic
823 : }
824 : translation 0 0.09 -0.198
825 : }
826 : DEF TRBottom Transform { # rear bottom
827 : children Shape {
828 : geometry Box {
829 : size 0.242 0.004 0.096
830 : }
831 : appearance IS plastic
832 : }
833 : translation 0 0.002 -0.148
834 : }
835 : DEF TLTape Transform {
836 : children TWTape {steel IS steel} # left tape box
837 : translation -0.10 0.1875 -0.11
838 : }
839 : DEF TRTape Transform {
840 : children TWTape {steel IS steel} # right tape box
841 : translation 0.10 0.1875 -0.11
842 : }
843 : DEF TWindow Transform {
844 : children TWWindow {steel IS steel}
845 : translation 0 0.175 -0.15
846 : }
847 : DEF RMove TWRearBoxMoveable {plastic IS plastic, steel IS steel, SpaceTouched IS SpaceTouched, active IS active}
848 : ]
849 : }
850 : Group {
851 : children [
852 : USE TRSide
853 : USE TLRSide
854 : USE TRRSide
855 : USE TRBottom
856 : USE TLTape
857 : USE TRTape
858 : USE RMove
859 : ]
860 : }
861 : Group {
862 : children [
863 : Transform {
864 : children Shape {
865 : geometry Box {
866 : size 0.25 0.18 0.10
867 : }
868 : appearance IS plastic
869 : }
870 : translation 0 0.09 -0.15
871 : }
872 : USE RMove
873 : ]
874 : }
875 : Shape {}
876 : ]
877 : }
878 : }
879 :
880 : PROTO TWKeyboard [exposedField SFNode steel TWSteel {}, eventOut SFBool SpaceTouched, eventIn SFBool active]
881 : {
882 : LOD {
883 : range [1 5 20]
884 : level [
885 : DEF Keys Group { # keys with letters
886 : children [
887 : DEF Space Transform { # spacebar key
888 : children [
889 : TWSpacebar {steel IS steel}
890 : DEF TouchSpace TouchSensor {
891 : enabled IS active
892 : }
893 : ]
894 : translation 0 0.02 0.135
895 : }
896 : DEF TimeSpace TimeSensor {
897 : cycleInterval 0.5
898 : }
899 : DEF AniSpace PositionInterpolator {
900 : key [0, 0.3, 1]
901 : keyValue [0 0.02 0.135, 0 0.01 0.135, 0 0.02 0.135]
902 : }
903 : Sound {
904 : source DEF SoundSpace AudioClip { url "key_wav/char_e.wav"}
905 : }
906 :
907 : Transform { ### first row - debugging
908 : children [
909 : Transform { # z
910 : children TWKey {char ["key_img/z.png"], steel IS steel}
911 : translation -0.10 0.025 0.110
912 : }
913 : Transform { # x
914 : children TWKey {char ["key_img/x.png"], steel IS steel}
915 : translation -0.08 0.025 0.110
916 : }
917 : Transform { # c
918 : children TWKey {char ["key_img/c.png"], steel IS steel}
919 : translation -0.06 0.025 0.110
920 : }
921 : Transform { # v
922 : children TWKey {char ["key_img/v.png"], steel IS steel}
923 : translation -0.04 0.025 0.110
924 : }
925 : Transform { # b
926 : children TWKey {char ["key_img/b.png"], steel IS steel}
927 : translation -0.02 0.025 0.110
928 : }
929 : Transform { # n
930 : children TWKey {char ["key_img/n.png"], steel IS steel}
931 : translation -0.00 0.025 0.110
932 : }
933 : Transform { # m
934 : children TWKey {char ["key_img/m.png"], steel IS steel}
935 : translation 0.02 0.025 0.110
936 : }
937 : Transform { # ,
938 : children TWKey {char ["key_img/qmark_comma.png"], steel IS steel}
939 : translation 0.04 0.025 0.110
940 : }
941 : Transform { # .
942 : children TWKey {char ["key_img/slash_period.png"], steel IS steel}
943 : translation 0.06 0.025 0.110
944 : }
945 : Transform { # /
946 : children TWKey {char ["key_img/colon_hyphen.png"], steel IS steel}
947 : translation 0.08 0.025 0.110
948 : }
949 : ]
950 : translation 0.01 0.005 0
951 : }
952 :
953 : Transform { ### second row - debugging
954 : children [
955 : Transform { # a
956 : children TWKey {char ["key_img/a.png"], steel IS steel}
957 : translation -0.10 0.025 0.110
958 : }
959 : Transform { # s
960 : children TWKey {char ["key_img/s.png"], steel IS steel}
961 : translation -0.08 0.025 0.110
962 : }
963 : Transform { # d
964 : children TWKey {char ["key_img/d.png"], steel IS steel}
965 : translation -0.06 0.025 0.110
966 : }
967 : Transform { # f
968 : children TWKey {char ["key_img/f.png"], steel IS steel}
969 : translation -0.04 0.025 0.110
970 : }
971 : Transform { # g
972 : children TWKey {char ["key_img/g.png"], steel IS steel}
973 : translation -0.02 0.025 0.110
974 : }
975 : Transform { # h
976 : children TWKey {char ["key_img/h.png"], steel IS steel}
977 : translation -0.00 0.025 0.110
978 : }
979 : Transform { # j
980 : children TWKey {char ["key_img/j.png"], steel IS steel}
981 : translation 0.02 0.025 0.110
982 : }
983 : Transform { # k
984 : children TWKey {char ["key_img/k.png"], steel IS steel}
985 : translation 0.04 0.025 0.110
986 : }
987 : Transform { # l
988 : children TWKey {char ["key_img/l.png"], steel IS steel}
989 : translation 0.06 0.025 0.110
990 : }
991 : Transform { # ;
992 : children TWKey {char ["key_img/percent_o.png"], steel IS steel}
993 : translation 0.08 0.025 0.110
994 : }
995 : Transform { # ;
996 : children TWKey {char ["key_img/ampersand_a.png"], steel IS steel}
997 : translation 0.10 0.025 0.110
998 : }
999 : ]
1000 : translation 0.00 0.015 -0.025
1001 : }
1002 :
1003 : Transform { ### third row - debugging
1004 : children [
1005 : Transform { # q
1006 : children TWKey {char ["key_img/q.png"], steel IS steel}
1007 : translation -0.10 0.025 0.110
1008 : }
1009 : Transform { # w
1010 : children TWKey {char ["key_img/w.png"], steel IS steel}
1011 : translation -0.08 0.025 0.110
1012 : }
1013 : Transform { # e
1014 : children TWKey {char ["key_img/e.png"], steel IS steel}
1015 : translation -0.06 0.025 0.110
1016 : }
1017 : Transform { # r
1018 : children TWKey {char ["key_img/r.png"], steel IS steel}
1019 : translation -0.04 0.025 0.110
1020 : }
1021 : Transform { # t
1022 : children TWKey {char ["key_img/t.png"], steel IS steel}
1023 : translation -0.02 0.025 0.110
1024 : }
1025 : Transform { # y
1026 : children TWKey {char ["key_img/y.png"], steel IS steel}
1027 : translation -0.00 0.025 0.110
1028 : }
1029 : Transform { # u
1030 : children TWKey {char ["key_img/u.png"], steel IS steel}
1031 : translation 0.02 0.025 0.110
1032 : }
1033 : Transform { # i
1034 : children TWKey {char ["key_img/i.png"], steel IS steel}
1035 : translation 0.04 0.025 0.110
1036 : }
1037 : Transform { # o
1038 : children TWKey {char ["key_img/o.png"], steel IS steel}
1039 : translation 0.06 0.025 0.110
1040 : }
1041 : Transform { # p
1042 : children TWKey {char ["key_img/p.png"], steel IS steel}
1043 : translation 0.08 0.025 0.110
1044 : }
1045 : Transform { # (
1046 : children TWKey {char ["key_img/paragraph_u.png"], steel IS steel}
1047 : translation 0.10 0.025 0.110
1048 : }
1049 : ]
1050 : translation -0.003 0.025 -0.050
1051 : }
1052 :
1053 : Transform { ### fourth row - debugging
1054 : children [
1055 : Transform { # 1
1056 : children TWKey {char ["key_img/2.png"], steel IS steel}
1057 : translation -0.10 0.025 0.110
1058 : }
1059 : Transform { # 2
1060 : children TWKey {char ["key_img/3.png"], steel IS steel}
1061 : translation -0.08 0.025 0.110
1062 : }
1063 : Transform { # 3
1064 : children TWKey {char ["key_img/4.png"], steel IS steel}
1065 : translation -0.06 0.025 0.110
1066 : }
1067 : Transform { # 4
1068 : children TWKey {char ["key_img/5.png"], steel IS steel}
1069 : translation -0.04 0.025 0.110
1070 : }
1071 : Transform { # 5
1072 : children TWKey {char ["key_img/6.png"], steel IS steel}
1073 : translation -0.02 0.025 0.110
1074 : }
1075 : Transform { # 6
1076 : children TWKey {char ["key_img/7.png"], steel IS steel}
1077 : translation -0.00 0.025 0.110
1078 : }
1079 : Transform { # 7
1080 : children TWKey {char ["key_img/8.png"], steel IS steel}
1081 : translation 0.02 0.025 0.110
1082 : }
1083 : Transform { # 8
1084 : children TWKey {char ["key_img/9.png"], steel IS steel}
1085 : translation 0.04 0.025 0.110
1086 : }
1087 : Transform { # 9
1088 : children TWKey {char ["key_img/u_i.png"], steel IS steel}
1089 : translation 0.06 0.025 0.110
1090 : }
1091 : Transform { # 0
1092 : children TWKey {char ["key_img/u_Kc.png"], steel IS steel}
1093 : translation 0.08 0.025 0.110
1094 : }
1095 : Transform { # 0
1096 : children TWKey {char ["key_img/exclamation_underscore.png"], steel IS steel}
1097 : translation 0.10 0.025 0.110
1098 : }
1099 : ]
1100 : translation 0.005 0.035 -0.075
1101 : }
1102 : ]
1103 : }
1104 : USE Keys # keys
1105 : Group {
1106 : children Shape { # image of keyboard
1107 : geometry IndexedFaceSet {
1108 : coord Coordinate {
1109 : point [-0.116 0.025 0.145, 0.116 0.025 0.145,
1110 : 0.1225 0.060 0.015, -0.1225 0.060 0.015]
1111 : }
1112 : coordIndex [0 1 2 3 -1]
1113 : texCoord TextureCoordinate {
1114 : point [0 0, 1 0, 1 1, 0 1]
1115 : }
1116 : texCoordIndex [0 1 2 3 -1]
1117 : }
1118 : appearance Appearance {
1119 : texture ImageTexture {
1120 : url ["keyboard.png"]
1121 : }
1122 : material Material {
1123 : }
1124 : }
1125 : }
1126 : }
1127 : Shape {} # nothing at all
1128 : ]
1129 : }
1130 :
1131 : DEF ScrSpace Script {
1132 : eventIn SFFloat set_fraction
1133 : eventOut SFBool space IS SpaceTouched
1134 : field SFBool msgsent FALSE
1135 : url "javascript:
1136 : function set_fraction(value)
1137 : {
1138 : if (value < 0.5) {
1139 : msgsent = false;
1140 : }
1141 : if (value >= 0.5 && !msgsent)
1142 : {
1143 : msgsent = true;
1144 : space = true;
1145 : }
1146 : }
1147 : "
1148 : }
1149 :
1150 : ROUTE TouchSpace.touchTime TO TimeSpace.startTime
1151 : ROUTE TimeSpace.fraction_changed TO AniSpace.set_fraction
1152 : ROUTE TimeSpace.fraction_changed TO ScrSpace.set_fraction
1153 : ROUTE AniSpace.value_changed TO Space.translation
1154 : ROUTE TouchSpace.touchTime TO SoundSpace.startTime
1155 : }
1156 :
1157 : PROTO TW [exposedField SFNode plastic TWPlastic {}
1158 : exposedField SFNode steel TWSteel {}
1159 : exposedField SFColor light 0 0 1
1160 : eventIn SFBool lightOn
1161 : eventIn SFFloat rotSpeed
1162 : field SFTime startTime 0
1163 : exposedField SFTime stopTime 0
1164 : eventIn SFBool lightOn
1165 : exposedField SFTime startRotation -1
1166 : exposedField SFTime stopRotation 0
1167 : eventIn SFFloat rotSpeed
1168 : ]
1169 : {
1170 : Group {
1171 : children [
1172 : # LOD [1 5 12 20]
1173 : # d < 1 - full detail
1174 : # 1 < d < 5 - detail
1175 : # 5 < d < 12 - nicely shaped
1176 : # 12 < d < 20 - just a box
1177 : # d > 20 - nothing at all
1178 : DEF TWT Transform {
1179 : children [
1180 : LOD {
1181 : range [12 20]
1182 : level [
1183 : Group {
1184 : children [
1185 : TWFrontHandle { plastic IS plastic }
1186 : DEF RBox TWRearBox { plastic IS plastic, steel IS steel }
1187 : TWMiddleBox { plastic IS plastic, steel IS steel }
1188 : DEF Keyb TWKeyboard { steel IS steel }
1189 : ]
1190 : }
1191 : Transform {
1192 : children Shape {
1193 : geometry Box {
1194 : size 0.25 0.20 0.20
1195 : }
1196 : appearance IS plastic
1197 : }
1198 : translation 0 0.10 -0.10
1199 : }
1200 : Shape {}
1201 : ]
1202 : }
1203 : DEF Btn Transform {
1204 : children [
1205 : Transform {
1206 : children Shape {
1207 : geometry Cylinder {
1208 : bottom FALSE
1209 : top FALSE
1210 : height 0.10
1211 : radius 0.008
1212 : }
1213 : appearance IS plastic
1214 : }
1215 : rotation 0 0 1 1.57
1216 : translation -0.05 0.05 0
1217 : }
1218 : Transform {
1219 : children Shape {
1220 : geometry Cylinder {
1221 : bottom FALSE
1222 : top FALSE
1223 : height 0.20
1224 : radius 0.008
1225 : }
1226 : appearance IS plastic
1227 : }
1228 : translation 0 0.15 0
1229 : }
1230 : DEF BtnHandle Transform {
1231 : children Shape {
1232 : geometry Sphere {
1233 : radius 0.025
1234 : }
1235 : appearance Appearance {
1236 : material DEF BtnMat Material {
1237 : diffuseColor 1 .85 0
1238 : specularColor .87 .25 .25
1239 : ambientIntensity .157
1240 : shininess 1
1241 : }
1242 : }
1243 : }
1244 : translation 0 0.23 0
1245 : scale 1 1 1
1246 : }
1247 : DEF BtnTouch TouchSensor {}
1248 : ]
1249 : translation 0.18 0.05 0
1250 : rotation 1 0 0 -1.2
1251 : center 0 0.05 0
1252 : scale 0.5 0.5 0.5
1253 : }
1254 : ]
1255 : }
1256 : DEF BtnCol ColorInterpolator {
1257 : key [0,0.5,1.0]
1258 : keyValue [0.1 0.8 0.2, 0 0.2 0.8, 0.1 0.8 0.2]
1259 : }
1260 : DEF BtnSize PositionInterpolator {
1261 : key [0, 0.05, 0.45, 0.5, 0.55, 0.95, 1.0]
1262 : keyValue [1 1 1, 1.1 1.1 1.1, 1.45 1.45 1.45, 1.5 1.5 1.5,
1263 : 1.45 1.45 1.45, 1.1 1.1 1.1, 1 1 1]
1264 : }
1265 : DEF BtnTime TimeSensor {
1266 : cycleInterval 2
1267 : enabled TRUE
1268 : loop TRUE
1269 : }
1270 : DEF BtnScr Script {
1271 : field SFNode btnOn USE Btn
1272 : eventIn SFTime touch
1273 : eventOut SFBool active
1274 : field SFBool on TRUE
1275 : url "javascript:
1276 : function initialize()
1277 : {
1278 : active = on;
1279 : }
1280 : function touch(x)
1281 : {
1282 : if (on) {
1283 : btnOn.rotation = new SFRotation(1, 0, 0, 0);
1284 : } else {
1285 : btnOn.rotation = new SFRotation(1, 0, 0, -1.2);
1286 : }
1287 : on = !on;
1288 : active = on;
1289 : }
1290 :
1291 : "
1292 : }
1293 : DEF PS ProximitySensor {
1294 : center 0 0 0
1295 : size 4 4 4
1296 : enabled TRUE
1297 : }
1298 : DEF SLProx SpotLight {
1299 : ambientIntensity 1
1300 : beamWidth 1.570796
1301 : color IS light
1302 : cutOffAngle 0.55
1303 : direction 0 -1 0
1304 : intensity 1
1305 : location 0 0.5 -0.1
1306 : on FALSE
1307 : radius 1
1308 : }
1309 : DEF SLHUD SpotLight {
1310 : ambientIntensity 1
1311 : beamWidth 1.570796
1312 : color IS light
1313 : cutOffAngle 0.55
1314 : direction 0 -1 0
1315 : intensity 1
1316 : location 0 0.5 -0.1
1317 : on IS lightOn
1318 : radius 1
1319 : }
1320 : DEF ORot OrientationInterpolator {
1321 : key [0, 0.5, 1.0]
1322 : keyValue [0 1 0 0, 0 1 0 3.14, 0 1 0 6.28]
1323 : }
1324 : DEF TRot TimeSensor {
1325 : cycleInterval 10
1326 : loop TRUE
1327 : }
1328 : # rotation
1329 : DEF DUMMY TimeSensor {
1330 : startTime IS startRotation
1331 : stopTime IS stopRotation
1332 : }
1333 : DEF ROTATOR Script {
1334 : field SFBool rotEnable FALSE
1335 : field SFFloat rotFracx 0
1336 : eventOut SFFloat rotFrac
1337 : field SFFloat rotSpd 0.05
1338 : eventIn SFTime rotStart
1339 : eventIn SFTime rotStop
1340 : eventIn SFFloat rotSpeed IS rotSpeed
1341 : field SFFloat rotFracLast 0
1342 : field SFBool t1 FALSE
1343 : eventIn SFFloat tick
1344 : url "javascript:
1345 : function rotStart(qx) {
1346 : rotEnable=true;
1347 : }
1348 : function rotStop (qx) {
1349 : rotEnable=false;
1350 : }
1351 : function rotSpeed(qx) {
1352 : rotSpd=qx;
1353 : }
1354 : function tick(qx) {
1355 : if (rotEnable) {
1356 : var diff=qx-rotFracLast;
1357 : if (diff<0) diff+=1;
1358 : rotFracx+=diff*rotSpd;
1359 : while (rotFracx>1) rotFracx-=1;
1360 : rotFrac=rotFracx;
1361 : }
1362 : rotFracLast=qx;
1363 : }
1364 : "
1365 : }
1366 : ]
1367 : }
1368 : ROUTE BtnScr.active TO Keyb.active
1369 : ROUTE BtnScr.active TO RBox.active
1370 : ROUTE BtnTime.fraction_changed TO BtnSize.set_fraction
1371 : ROUTE BtnSize.value_changed TO BtnHandle.scale
1372 : ROUTE BtnTouch.touchTime TO BtnScr.touch
1373 :
1374 : ROUTE TRot.fraction_changed TO ROTATOR.tick
1375 : ROUTE ROTATOR.rotFrac TO ORot.set_fraction
1376 : ROUTE ORot.value_changed TO TWT.rotation
1377 : ROUTE DUMMY.startTime TO ROTATOR.rotStart
1378 : ROUTE DUMMY.stopTime TO ROTATOR.rotStop
1379 :
1380 : ROUTE PS.isActive TO SLProx.on
1381 : ROUTE Keyb.SpaceTouched TO RBox.SpaceTouched
1382 : ROUTE BtnTime.fraction_changed TO BtnCol.set_fraction
1383 : ROUTE BtnCol.value_changed TO BtnMat.emissiveColor
1384 : }