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 : {
665 : DEF Cyl Transform {
666 : children [
667 : LOD {
668 : range [1 5]
669 : level [
670 : Group {
671 : children [
672 : DEF TCylinder Transform {
673 : children TWRoller {steel IS steel} # cylinder
674 : translation 0 0.18 -0.17
675 : rotation 0 0 1 1.57
676 : }
677 : DEF TRScale Transform {
678 : children TWRearScale {steel IS steel} # rearest scale
679 : translation 0 0.21 -0.21
680 : }
681 : DEF TReturn Transform {
682 : children [
683 : Transform {
684 : children [
685 : TWReturn {steel IS steel}
686 : DEF SR CylinderSensor {
687 : enabled TRUE
688 : maxAngle 0.5
689 : minAngle 0
690 : diskAngle 0.262
691 : autoOffset FALSE
692 : }
693 : ]
694 : rotation 1 0 0 -0.15
695 : }
696 : ]
697 : translation -0.135 0.184 -0.172
698 : }
699 : ]
700 : }
701 : Group {
702 : children [
703 : USE TCylinder
704 : USE TRScale
705 : USE TReturn
706 : ]
707 : }
708 : Group {
709 : children [
710 : USE TCylinder
711 : USE TRScale
712 : ]
713 : }
714 : ]
715 : }
716 : DEF SP PlaneSensor {
717 : enabled TRUE
718 : minPosition -0.15 0
719 : maxPosition 0.15 0
720 :
721 : }
722 : DEF OBack OrientationInterpolator {
723 : key [0, 1]
724 : keyValue [0 1 0 0.5, 0 1 0 0]
725 : }
726 : DEF TBack TimeSensor {
727 : cycleInterval 0.05
728 : loop FALSE
729 : enabled FALSE
730 : }
731 : DEF ScrCyl Script {
732 : field SFNode manip USE SP
733 : field SFNode rotmanip USE SR
734 : field SFNode valec USE Cyl
735 : field SFNode cas USE TBack
736 : field SFVec3f vec 0 0 0
737 : field SFRotation rotvec 0 1 0 0
738 : field SFBool wasback FALSE
739 : eventIn SFBool back
740 : eventIn SFBool space IS SpaceTouched
741 : eventIn SFRotation rot
742 : url "javascript:
743 : function rot(val)
744 : {
745 : if (val.angle >= 0.5)
746 : {
747 : vec = valec.translation;
748 : vec[0] = vec[0] + 0.002;
749 : if (vec[0] >= 0.15)
750 : vec[0] = 0.15;
751 : manip.offset = vec;
752 : valec.translation = vec;
753 : }
754 :
755 : }
756 : function back(val, time)
757 : {
758 : if (!val) {
759 : if (!wasback) {
760 : wasback = true;
761 : cas.startTime = time;
762 : cas.enabled = true;
763 : rotmanip.offset = rotvec;
764 : }
765 : } else {
766 : wasback = false;
767 : }
768 : }
769 : function space(val)
770 : {
771 : if (val) {
772 : vec = valec.translation;
773 : vec[0] = vec[0] - 0.01;
774 : if (vec[0] <= -0.15)
775 : vec[0] = -0.15;
776 : manip.offset = vec;
777 : valec.translation = vec;
778 : }
779 : }
780 : "
781 : }
782 : ]
783 : }
784 :
785 : ROUTE SP.translation_changed TO Cyl.translation
786 : ROUTE SR.rotation_changed TO TReturn.rotation
787 : ROUTE SR.rotation_changed TO ScrCyl.rot
788 : ROUTE SR.isActive TO ScrCyl.back
789 : ROUTE TBack.fraction_changed TO OBack.set_fraction
790 : ROUTE OBack.value_changed TO TReturn.rotation
791 : }
792 :
793 : PROTO TWRearBox [exposedField SFNode plastic TWPlastic {},
794 : exposedField SFNode steel TWSteel {},
795 : eventIn SFBool SpaceTouched]
796 : {
797 : LOD {
798 : range [1 5 20]
799 : level [
800 : DEF Full Group {
801 : children [
802 : DEF TLRSide Transform { # left rear side
803 : children DEF LRSide Shape {
804 : geometry Box {
805 : size 0.004 0.16 0.096
806 : }
807 : appearance IS plastic
808 : }
809 : translation -0.123 0.08 -0.148
810 : }
811 : DEF TRRSide Transform { # right rear side
812 : children USE LRSide
813 : translation 0.123 0.08 -0.148
814 : }
815 : DEF TRSide Transform { # rear side
816 : children Shape {
817 : geometry Box {
818 : size 0.25 0.18 0.004
819 : }
820 : appearance IS plastic
821 : }
822 : translation 0 0.09 -0.198
823 : }
824 : DEF TRBottom Transform { # rear bottom
825 : children Shape {
826 : geometry Box {
827 : size 0.242 0.004 0.096
828 : }
829 : appearance IS plastic
830 : }
831 : translation 0 0.002 -0.148
832 : }
833 : DEF TLTape Transform {
834 : children TWTape {steel IS steel} # left tape box
835 : translation -0.10 0.1875 -0.11
836 : }
837 : DEF TRTape Transform {
838 : children TWTape {steel IS steel} # right tape box
839 : translation 0.10 0.1875 -0.11
840 : }
841 : DEF TWindow Transform {
842 : children TWWindow {steel IS steel}
843 : translation 0 0.175 -0.15
844 : }
845 : DEF RMove TWRearBoxMoveable {plastic IS plastic, steel IS steel, SpaceTouched IS SpaceTouched}
846 : ]
847 : }
848 : Group {
849 : children [
850 : USE TRSide
851 : USE TLRSide
852 : USE TRRSide
853 : USE TRBottom
854 : USE TLTape
855 : USE TRTape
856 : USE RMove
857 : ]
858 : }
859 : Group {
860 : children [
861 : Transform {
862 : children Shape {
863 : geometry Box {
864 : size 0.25 0.18 0.10
865 : }
866 : appearance IS plastic
867 : }
868 : translation 0 0.09 -0.15
869 : }
870 : USE RMove
871 : ]
872 : }
873 : Shape {}
874 : ]
875 : }
876 : }
877 :
878 : PROTO TWKeyboard [exposedField SFNode steel TWSteel {}, eventOut SFBool SpaceTouched]
879 : {
880 : LOD {
881 : range [1 5 20]
882 : level [
883 : DEF Keys Group { # keys with letters
884 : children [
885 : DEF Space Transform { # spacebar key
886 : children [
887 : TWSpacebar {steel IS steel}
888 : DEF TouchSpace TouchSensor {
889 : enabled TRUE
890 : }
891 : ]
892 : translation 0 0.02 0.135
893 : }
894 : DEF TimeSpace TimeSensor {
895 : cycleInterval 0.5
896 : }
897 : DEF AniSpace PositionInterpolator {
898 : key [0, 0.3, 1]
899 : keyValue [0 0.02 0.135, 0 0.01 0.135, 0 0.02 0.135]
900 : }
901 : Sound {
902 : source DEF SoundSpace AudioClip { url "key_wav/char_e.wav"}
903 : }
904 :
905 : Transform { ### first row - debugging
906 : children [
907 : Transform { # z
908 : children TWKey {char ["key_img/z.png"], steel IS steel}
909 : translation -0.10 0.025 0.110
910 : }
911 : Transform { # x
912 : children TWKey {char ["key_img/x.png"], steel IS steel}
913 : translation -0.08 0.025 0.110
914 : }
915 : Transform { # c
916 : children TWKey {char ["key_img/c.png"], steel IS steel}
917 : translation -0.06 0.025 0.110
918 : }
919 : Transform { # v
920 : children TWKey {char ["key_img/v.png"], steel IS steel}
921 : translation -0.04 0.025 0.110
922 : }
923 : Transform { # b
924 : children TWKey {char ["key_img/b.png"], steel IS steel}
925 : translation -0.02 0.025 0.110
926 : }
927 : Transform { # n
928 : children TWKey {char ["key_img/n.png"], steel IS steel}
929 : translation -0.00 0.025 0.110
930 : }
931 : Transform { # m
932 : children TWKey {char ["key_img/m.png"], steel IS steel}
933 : translation 0.02 0.025 0.110
934 : }
935 : Transform { # ,
936 : children TWKey {char ["key_img/qmark_comma.png"], steel IS steel}
937 : translation 0.04 0.025 0.110
938 : }
939 : Transform { # .
940 : children TWKey {char ["key_img/slash_period.png"], steel IS steel}
941 : translation 0.06 0.025 0.110
942 : }
943 : Transform { # /
944 : children TWKey {char ["key_img/colon_hyphen.png"], steel IS steel}
945 : translation 0.08 0.025 0.110
946 : }
947 : ]
948 : translation 0.01 0.005 0
949 : }
950 :
951 : Transform { ### second row - debugging
952 : children [
953 : Transform { # a
954 : children TWKey {char ["key_img/a.png"], steel IS steel}
955 : translation -0.10 0.025 0.110
956 : }
957 : Transform { # s
958 : children TWKey {char ["key_img/s.png"], steel IS steel}
959 : translation -0.08 0.025 0.110
960 : }
961 : Transform { # d
962 : children TWKey {char ["key_img/d.png"], steel IS steel}
963 : translation -0.06 0.025 0.110
964 : }
965 : Transform { # f
966 : children TWKey {char ["key_img/f.png"], steel IS steel}
967 : translation -0.04 0.025 0.110
968 : }
969 : Transform { # g
970 : children TWKey {char ["key_img/g.png"], steel IS steel}
971 : translation -0.02 0.025 0.110
972 : }
973 : Transform { # h
974 : children TWKey {char ["key_img/h.png"], steel IS steel}
975 : translation -0.00 0.025 0.110
976 : }
977 : Transform { # j
978 : children TWKey {char ["key_img/j.png"], steel IS steel}
979 : translation 0.02 0.025 0.110
980 : }
981 : Transform { # k
982 : children TWKey {char ["key_img/k.png"], steel IS steel}
983 : translation 0.04 0.025 0.110
984 : }
985 : Transform { # l
986 : children TWKey {char ["key_img/l.png"], steel IS steel}
987 : translation 0.06 0.025 0.110
988 : }
989 : Transform { # ;
990 : children TWKey {char ["key_img/percent_o.png"], steel IS steel}
991 : translation 0.08 0.025 0.110
992 : }
993 : Transform { # ;
994 : children TWKey {char ["key_img/ampersand_a.png"], steel IS steel}
995 : translation 0.10 0.025 0.110
996 : }
997 : ]
998 : translation 0.00 0.015 -0.025
999 : }
1000 :
1001 : Transform { ### third row - debugging
1002 : children [
1003 : Transform { # q
1004 : children TWKey {char ["key_img/q.png"], steel IS steel}
1005 : translation -0.10 0.025 0.110
1006 : }
1007 : Transform { # w
1008 : children TWKey {char ["key_img/w.png"], steel IS steel}
1009 : translation -0.08 0.025 0.110
1010 : }
1011 : Transform { # e
1012 : children TWKey {char ["key_img/e.png"], steel IS steel}
1013 : translation -0.06 0.025 0.110
1014 : }
1015 : Transform { # r
1016 : children TWKey {char ["key_img/r.png"], steel IS steel}
1017 : translation -0.04 0.025 0.110
1018 : }
1019 : Transform { # t
1020 : children TWKey {char ["key_img/t.png"], steel IS steel}
1021 : translation -0.02 0.025 0.110
1022 : }
1023 : Transform { # y
1024 : children TWKey {char ["key_img/y.png"], steel IS steel}
1025 : translation -0.00 0.025 0.110
1026 : }
1027 : Transform { # u
1028 : children TWKey {char ["key_img/u.png"], steel IS steel}
1029 : translation 0.02 0.025 0.110
1030 : }
1031 : Transform { # i
1032 : children TWKey {char ["key_img/i.png"], steel IS steel}
1033 : translation 0.04 0.025 0.110
1034 : }
1035 : Transform { # o
1036 : children TWKey {char ["key_img/o.png"], steel IS steel}
1037 : translation 0.06 0.025 0.110
1038 : }
1039 : Transform { # p
1040 : children TWKey {char ["key_img/p.png"], steel IS steel}
1041 : translation 0.08 0.025 0.110
1042 : }
1043 : Transform { # (
1044 : children TWKey {char ["key_img/paragraph_u.png"], steel IS steel}
1045 : translation 0.10 0.025 0.110
1046 : }
1047 : ]
1048 : translation -0.003 0.025 -0.050
1049 : }
1050 :
1051 : Transform { ### fourth row - debugging
1052 : children [
1053 : Transform { # 1
1054 : children TWKey {char ["key_img/2.png"], steel IS steel}
1055 : translation -0.10 0.025 0.110
1056 : }
1057 : Transform { # 2
1058 : children TWKey {char ["key_img/3.png"], steel IS steel}
1059 : translation -0.08 0.025 0.110
1060 : }
1061 : Transform { # 3
1062 : children TWKey {char ["key_img/4.png"], steel IS steel}
1063 : translation -0.06 0.025 0.110
1064 : }
1065 : Transform { # 4
1066 : children TWKey {char ["key_img/5.png"], steel IS steel}
1067 : translation -0.04 0.025 0.110
1068 : }
1069 : Transform { # 5
1070 : children TWKey {char ["key_img/6.png"], steel IS steel}
1071 : translation -0.02 0.025 0.110
1072 : }
1073 : Transform { # 6
1074 : children TWKey {char ["key_img/7.png"], steel IS steel}
1075 : translation -0.00 0.025 0.110
1076 : }
1077 : Transform { # 7
1078 : children TWKey {char ["key_img/8.png"], steel IS steel}
1079 : translation 0.02 0.025 0.110
1080 : }
1081 : Transform { # 8
1082 : children TWKey {char ["key_img/9.png"], steel IS steel}
1083 : translation 0.04 0.025 0.110
1084 : }
1085 : Transform { # 9
1086 : children TWKey {char ["key_img/u_i.png"], steel IS steel}
1087 : translation 0.06 0.025 0.110
1088 : }
1089 : Transform { # 0
1090 : children TWKey {char ["key_img/u_Kc.png"], steel IS steel}
1091 : translation 0.08 0.025 0.110
1092 : }
1093 : Transform { # 0
1094 : children TWKey {char ["key_img/exclamation_underscore.png"], steel IS steel}
1095 : translation 0.10 0.025 0.110
1096 : }
1097 : ]
1098 : translation 0.005 0.035 -0.075
1099 : }
1100 : ]
1101 : }
1102 : USE Keys # keys
1103 : Group {
1104 : children Shape { # image of keyboard
1105 : geometry IndexedFaceSet {
1106 : coord Coordinate {
1107 : point [-0.116 0.025 0.145, 0.116 0.025 0.145,
1108 : 0.1225 0.060 0.015, -0.1225 0.060 0.015]
1109 : }
1110 : coordIndex [0 1 2 3 -1]
1111 : texCoord TextureCoordinate {
1112 : point [0 0, 1 0, 1 1, 0 1]
1113 : }
1114 : texCoordIndex [0 1 2 3 -1]
1115 : }
1116 : appearance Appearance {
1117 : texture ImageTexture {
1118 : url ["keyboard.png"]
1119 : }
1120 : material Material {
1121 : }
1122 : }
1123 : }
1124 : }
1125 : Shape {} # nothing at all
1126 : ]
1127 : }
1128 :
1129 : DEF ScrSpace Script {
1130 : eventIn SFFloat set_fraction
1131 : eventOut SFBool space IS SpaceTouched
1132 : field SFBool msgsent FALSE
1133 : url "javascript:
1134 : function set_fraction(value)
1135 : {
1136 : if (value < 0.1)
1137 : msgsent = false;
1138 : if (value >= 0.5 && !msgsent)
1139 : {
1140 : msgsent = true;
1141 : space = true;
1142 : }
1143 : }
1144 : "
1145 : }
1146 :
1147 : ROUTE TouchSpace.touchTime TO TimeSpace.startTime
1148 : ROUTE TimeSpace.fraction_changed TO AniSpace.set_fraction
1149 : ROUTE TimeSpace.fraction_changed TO ScrSpace.set_fraction
1150 : ROUTE AniSpace.value_changed TO Space.translation
1151 : ROUTE TouchSpace.touchTime TO SoundSpace.startTime
1152 : }
1153 :
1154 : PROTO TW [exposedField SFNode plastic TWPlastic {}
1155 : exposedField SFNode steel TWSteel {}
1156 : exposedField SFColor light 0 0 1]
1157 : {
1158 : Group {
1159 : children [
1160 : # LOD [1 5 12 20]
1161 : # d < 1 - full detail
1162 : # 1 < d < 5 - detail
1163 : # 5 < d < 12 - nicely shaped
1164 : # 12 < d < 20 - just a box
1165 : # d > 20 - nothing at all
1166 : LOD {
1167 : range [12 20]
1168 : level [
1169 : Group {
1170 : children [
1171 : TWFrontHandle { plastic IS plastic }
1172 : DEF RBox TWRearBox { plastic IS plastic, steel IS steel }
1173 : TWMiddleBox { plastic IS plastic, steel IS steel }
1174 : DEF Keyb TWKeyboard { steel IS steel }
1175 : ]
1176 : }
1177 : Transform {
1178 : children Shape {
1179 : geometry Box {
1180 : size 0.25 0.20 0.20
1181 : }
1182 : appearance IS plastic
1183 : }
1184 : translation 0 0.10 -0.10
1185 : }
1186 : Shape {}
1187 : ]
1188 : }
1189 : DEF PS ProximitySensor {
1190 : center 0 0 0
1191 : size 4 4 4
1192 : enabled TRUE
1193 : }
1194 : DEF SL SpotLight {
1195 : ambientIntensity 1
1196 : beamWidth 1.570796
1197 : color IS light
1198 : cutOffAngle 0.55
1199 : direction 0 -1 0
1200 : intensity 1
1201 : location 0 0.5 -0.1
1202 : on FALSE
1203 : radius 1
1204 : }
1205 : ]
1206 : }
1207 : ROUTE PS.isActive TO SL.on
1208 : ROUTE Keyb.SpaceTouched TO RBox.SpaceTouched
1209 : }