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-textbox.vr

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


  

textbox


  

Web3D/VR

#@extern @vr-extern-proto-object-box.wrl PROTO ClickableTextBox [ eventIn MFString lineInput field SFVec2f position 0 0 field SFVec2f size 1 1 field SFFloat fontSize 0.05 exposedField SFFloat transparency 0 ] { DEF TRANSFORM Transform { children [ DEF TOUCHSENSOR TouchSensor { enabled TRUE } DEF TEXTTRANSFORM Transform { children [ Shape { appearance Appearance { material Material { emissiveColor 0 0 0 diffuseColor 0 0 0 } } geometry DEF TEXT Text { fontStyle FontStyle { family "TYPEWRITER" style "BOLD" size IS fontSize } } } ] } DEF BOXTRANSFORM Transform { children [ # DEF TOUCHSENSOR TouchSensor { # enabled TRUE # } Shape { appearance Appearance { material Material { transparency IS transparency emissiveColor 1 1 1 diffuseColor 0 0 0 } } geometry DEF BOX box {} } ] } ] } DEF SCRIPT Script { eventIn SFTime touchTime eventIn SFVec3f hitPoint_changed field SFVec3f hitPoint 0 0 0 field SFNode transformNode USE TRANSFORM field SFNode boxNode USE BOX field SFNode boxTransform USE BOXTRANSFORM field SFNode textNode USE TEXT field SFNode textTransform USE TEXTTRANSFORM field SFVec2f position IS position field SFVec2f size IS size field SFFloat fontSize IS fontSize field SFInt32 maxLength 0 field SFInt32 maxLines 0 eventIn MFString lineInput IS lineInput field MFString temp [] field SFInt32 nrLines 0 eventOut MFString tempOutput url "vrmlscript: function hitPoint_changed(value,time) { hitPoint = value; } function touchTime(value,time) { y = (-hitPoint.y)/fontSize; //Browser.print('Touched at location : '+hitPoint+' is line '+y); if(y>=0 && y<nrLines) { Browser.print('Selected : ' + temp[y]); } } function initialize() { transformNode.translation = new SFVec3f(position.x,position.y,0); boxNode.size = new SFVec3f(size.x,size.y,0.01); boxTransform.translation = new SFVec3f(size.x/2,-size.y/2,0); textTransform.translation = new SFVec3f(0,-fontSize,0.015); // The maxLength is an approximation based upon experimentation in // getting the right size... maxLength = (size.x/fontSize)*1.9; maxLines = (size.y/fontSize); line = ''; } function cycle() { // only called when nrLines > maxLines && maxLines > 0 i = 0; for(i=0;i<maxLines-1;i++) { temp[i] = temp[i+1]; } } function addLine(line) { length = line.length; while(length > 0) { if(maxLines>0 && nrLines==maxLines) { cycle(); } else { nrLines = nrLines + 1; } if(maxLength>0 && length>maxLength) { temp[nrLines-1] = line.substring(0,maxLength); line = line.substring(maxLength,line.length); length = length - maxLength; } else { temp[nrLines-1] = line; line = ''; length = 0; } } } function lineInput(value,time) { // Should have a way to determine the array size ! i = 0; addLine('' + value[i]); tempOutput = temp; } " } ROUTE SCRIPT.tempOutput TO TEXT.string ROUTE TOUCHSENSOR.touchTime TO SCRIPT.touchTime ROUTE TOUCHSENSOR.hitPoint_changed TO SCRIPT.hitPoint_changed }

[] 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.