hud.wrl

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