media @ VU
music-dossier-History.vr
music-dossier-History.vr
(wrl
)
[ flux /
bitmanagement /
cortona /
octaga
]
EXTERNPROTO pointer[
eventIn SFFloat transparency
]"models/buttonBar/back/back_forward_button.wrl#ModelBackForwardNode"
PROTO History[
eventIn SFString nodeIn
eventIn SFFloat endTransparencyButton
eventOut SFString nodeOut
eventOut SFBool show
eventOut SFBool ready
]
{
DEF SW Switch {
whichChoice 0
choice [
Transform {
scale 0.9 0.9 0.9
translation -0.1 0 0
rotation 0 0 1 3.14
children [
DEF pointer pointer {
}
DEF touch TouchSensor{}
]
}
]
}
DEF script Script {
directOutput TRUE
eventOut SFBool show IS show
eventOut SFString nodeOut IS nodeOut
eventIn SFString nodeIn IS nodeIn
eventOut SFBool ready IS ready
eventIn SFBool clicked
field MFNode history []
field SFInt32 current -1
field SFBool goingBack FALSE
url "javascript:
function initialize()
{
ready=true;
}
function clicked(value)
{
if(value)
{
if(current>0) // only react if there have been 2 clicks (start value of current = 2)
// the first click is for opening the main node the second is the first real step
{
goingBack = true;
nodeOut = history[current-1].nodes;
current-=2;
show =true;
}
}
}
function nodeIn(value)
{
if (current < 0 || history[current].nodes != value) { // always add the first clicked node, do not add the same node twice
goingBack = false;
current++;
history[current] =Browser.createVrmlFromString('PROTO Nodes[field SFString nodes \"\"]{} Nodes{}')[0];
history[current].nodes = value;
}
}
"
}
DEF historyButtonScript Script {
eventIn SFBool rollOver
eventIn SFTime time
eventIn SFFloat setTransparency IS endTransparencyButton
field SFFloat beginTransparency 0
eventOut SFFloat transparency
field SFTime beginTimeTransparency 0
field SFBool transparencyEffectEnabled FALSE
field SFFloat totalTimeTransparency 2
eventOut SFInt32 whichchoice
eventOut MFString rollOverText
url "javascript:
function initialize() {
transparency = beginTransparency;
}
// transparency effect: see buttonbar.wrl for description
function time(value) {
if (transparencyEffectEnabled) {
var factor = (value - beginTimeTransparency) / totalTimeTransparency;
if (factor < 1) {
transparency = factor * (setTransparency - beginTransparency) + beginTransparency;
} else {
transparency = setTransparency;
transparencyEffectEnabled = false;
if (setTransparency == 1) whichchoice = -1;
}
}
}
function setTransparency (value,time) {
//print('transparantie is: ');
whichchoice = 0;
beginTimeTransparency = time;
beginTransparency = transparency;
transparencyEffectEnabled = true;
}
function rollOver(value){
if (value){
//print('rollOver is true');
rollOverText = 'back';
}
else{
rollOverText = '';
//print('rollOver is false');
}
}
"
}
DEF rollOverHistoryText Transform { # rollover text for the back button
translation 0 0 0
children [
Shape {
geometry DEF rolloverHistoryText Text {
string ""
}
}
]
}
DEF Timer TimeSensor {
loop TRUE
enabled TRUE
}
ROUTE touch.isOver TO historyButtonScript.rollOver
ROUTE historyButtonScript.rollOverText TO rolloverHistoryText.string
ROUTE touch.isActive TO script.clicked
ROUTE historyButtonScript.whichchoice TO SW.whichChoice
ROUTE Timer.time TO historyButtonScript.time
ROUTE historyButtonScript.transparency TO pointer.transparency
}
History {}
(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.