media @ VU
proto-rif-interface-plainbox.vr
proto-rif-interface-plainbox.vr
(wrl
)
[ flux /
bitmanagement /
cortona /
octaga
]
plainbox
Web3D/VR
#@extern @vr-extern-proto-object-box.wrl
PROTO TextBox [
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 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 [
Shape {
appearance Appearance {
material Material {
transparency IS transparency
emissiveColor 1 1 1
diffuseColor 0 0 0
}
}
geometry DEF BOX box {}
}
]
}
]
}
DEF SCRIPT Script {
field SFNode transformNode USE TRANSFORM
eventOut SFVec3f boxNodeSize
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 initialize() {
transformNode.translation
= new SFVec3f(position.x,position.y,0);
boxNodeSize = 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 SCRIPT.boxNodeSize TO BOX.size
}
(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.