1 : #VRML V2.0 utf8
2 :
3 : PROTO Col [
4 : exposedField SFColor col 0 1 0
5 : ] {
6 : Appearance {
7 : material Material {
8 : emissiveColor IS col
9 : diffuseColor IS col
10 :
11 : shininess 0
12 : }
13 : }
14 : }
15 :
16 : PROTO Col2 [
17 : exposedField SFColor col 0 .373 0
18 : exposedField MFString url ""
19 : ] {
20 : Appearance {
21 : material Material {
22 : emissiveColor IS col
23 : diffuseColor IS col
24 : shininess 0
25 : }
26 : texture ImageTexture {
27 : url IS url
28 : }
29 : }
30 : }
31 :
32 : PROTO Button [
33 : exposedField SFColor col 0 1 0
34 : exposedField SFVec3f pos 0 0 0
35 : eventOut SFTime touchTime
36 : exposedField MFString url ""
37 : ]{
38 : Transform {
39 : translation IS pos
40 : children [
41 : Transform {
42 : rotation 1 0 0 1.54
43 : children [
44 : TouchSensor {touchTime IS touchTime}
45 : Shape {
46 : geometry Cylinder {radius .003 height .001}
47 : appearance Col2 {col IS col url IS url }
48 : }
49 : ]
50 : }
51 : ]
52 : }
53 : }
54 :
55 : PROTO Square [
56 : field SFColor col 0 1 0
57 : exposedField SFVec3f pos 0 0 0
58 : field SFVec3f size .0025 .0025 .0004
59 : exposedField SFFloat trans .6
60 : ]{
61 : Transform {
62 : translation IS pos
63 : children [
64 : Shape {
65 : geometry Box {size IS size}
66 : appearance Col {col IS col}
67 : }
68 : ]
69 : }
70 : }
71 :
72 : PROTO HudSystem [
73 : eventOut SFTime button1touchOn #rotace
74 : eventOut SFTime button1touchOff #rotace
75 : eventOut SFBool button2touch #svetla
76 : eventIn SFTime button2change #svetla
77 : eventOut SFFloat slider
78 : exposedField SFVec3f pos 0 0 0
79 : exposedField SFRotation rot 0 0 1 0
80 : ]{
81 : Transform{
82 : translation IS pos
83 : rotation IS rot
84 : children [
85 : DEF MAIN Script {
86 : field SFBool t1 FALSE
87 : field SFBool t2 FALSE
88 : eventIn SFTime touch1
89 : eventOut SFTime touch1On IS button1touchOn
90 : eventOut SFTime touch1Off IS button1touchOff
91 : eventIn SFTime touch2 IS button2change
92 : eventOut SFBool active1
93 : eventOut SFBool active2 IS button2touch
94 : eventOut SFColor tex1
95 : eventOut SFColor tex2
96 : eventIn SFVec3f vslide
97 : eventOut SFFloat slide IS slider
98 : url "javascript:
99 : function touch1(q) {
100 : t1=!t1;
101 : if (t1) {
102 : touch1On=q;
103 : tex1[0]=.5;tex1[1]=.25;tex1[2]=0;
104 : } else {
105 : touch1Off=q;
106 : tex1[0]=0.25;tex1[1]=0;tex1[2]=0;
107 : }
108 : active1=t1;
109 : }
110 : function touch2(q) {
111 : t2=!t2;
112 : if (t2) {
113 : tex2[0]=0;tex2[1]=.25;tex2[2]=.5;
114 : } else {
115 : tex2[0]=0;tex2[1]=0;tex2[2]=0.25;
116 : }
117 : active2=t2;
118 : }
119 : function vslide(q) {
120 : var l=q.y*q.y*100;
121 : if (l<0) l=0;
122 : slide=Math.abs(l+0.00005)*1000;
123 : }
124 : "
125 : }
126 : #buttons
127 : Group{
128 : children [
129 : DEF ALL ProximitySensor {size 1000 1000 1000}
130 : Collision {
131 : collide FALSE
132 : children DEF H Transform{
133 : children [
134 : DEF B1 Button {pos -.052 -.028 -.1 col .25 0 0 url "rotate.png"}
135 : DEF B2 Button {pos -.052 -.036 -.1 col 0 0 .25 url "bulb.png"}
136 : Square {pos -.046 -.028 -.1005 col .3 .3 .3 size .001 .022 .0001}
137 : Group{
138 : children [
139 : Transform{
140 : translation -.046 -.038 -.1
141 : children
142 : DEF S Transform{
143 : children [
144 : DEF SLIDER PlaneSensor {
145 : maxPosition 0 .02
146 : minPosition 0 0
147 : }
148 : Square {col 1 1 0 trans 0}
149 : ]
150 : }
151 : }
152 : ]
153 : }
154 : ]
155 : }
156 : }
157 : ]
158 : }
159 : ]
160 : }
161 : ROUTE B1.touchTime TO MAIN.touch1
162 : ROUTE B2.touchTime TO MAIN.touch2
163 : ROUTE MAIN.tex1 TO B1.col
164 : ROUTE MAIN.tex2 TO B2.col
165 :
166 : ROUTE S.translation TO MAIN.vslide
167 : ROUTE SLIDER.translation_changed TO S.translation
168 : ROUTE ALL.orientation_changed TO H.rotation
169 : ROUTE ALL.position_changed TO H.translation
170 : ROUTE ALL.position_changed TO ALL.center
171 : }