media @ VU
[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

talk show tell print

proto-rif-interface-toggle.vr

proto-rif-interface-toggle.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]


  

toggle


  

Web3D/VR

#@extern @vr-extern-proto-object-box.wrl PROTO Toggle [ exposedField SFVec3f scale 1 1 1 field SFVec2f position 0 0 field SFVec2f size 1 1 field MFString texture_on [ "toggle_on.gif" ] field MFString texture_off [ "toggle_off.gif" ] exposedField SFBool enabled FALSE eventOut SFInt32 switch ] { DEF TRANS Transform { scale IS scale children [ DEF TOUCHSENSOR TouchSensor { enabled TRUE } Shape { appearance Appearance { texture DEF TEXTURE ImageTexture { } } geometry DEF WINDOWBOX box { } } ] } DEF SCRIPT Script { directOutput TRUE eventIn SFTime touchTime field SFNode transformNode USE TRANS field SFVec2f position IS position field SFVec2f size IS size eventOut SFVec3f set_size eventIn SFBool set_enabled IS enabled field SFBool enabled IS enabled eventOut SFBool enabled_changed IS enabled eventOut SFInt32 switch_changed IS switch field SFNode texture USE TEXTURE field MFString texture_on IS texture_on field MFString texture_off IS texture_off url "vrmlscript: function initialize() { transformNode.translation = new SFVec3f(position.x,position.y,0); set_size = new SFVec3f(size.x,size.y,0.02); if(enabled) { texture.url = texture_on; } else { texture.url = texture_off; } } function touchTime(value,time) { if(enabled) { enabled = FALSE; enabled_changed = FALSE; switch_changed = -1; texture.url = texture_off; } else { enabled = TRUE; enabled_changed = TRUE; switch_changed = 0; texture.url = texture_on; } } " } ROUTE SCRIPT.set_size TO WINDOWBOX.size ROUTE TOUCHSENSOR.touchTime TO SCRIPT.touchTime }

[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

(C) A. Eliëns 21/5/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.