Let's have a file "proto.wrl"
#VRML V2.0 utf8
PROTO myproto
[
eventIn SFFloat f_in
eventOut SFFloat f_out
]
{
Script
{
eventIn SFFloat f_in IS f_in
eventOut SFFloat f_out IS f_out
url "vrmlscript:
function f_in(value, time)
{
f_out=Math.sin(value*2.0*3.14);
}
"
}
}
Let's have a WRL-File using it:
#VRML V2.0 utf8
Shape
{
appearance Appearance
{
material DEF MY_MATERIAL Material
{
transparency 0
}
}
geometry Sphere
{
}
}
DEF MY_TIME TimeSensor
{
cycleInterval 1
loop TRUE
}
EXTERNPROTO myproto
[
eventIn SFFloat f_in
eventOut SFFloat f_out
]
"proto.wrl"
DEF MY_SCRIPT myproto {}
ROUTE MY_TIME.fraction_changed TO MY_SCRIPT.f_in
ROUTE MY_SCRIPT.f_out TO MY_MATERIAL.set_transparency
Load this file into dune and use File -> preview
The browser will show you a error, cause
the following is loaded:
#VRML V2.0 utf8
Shape {
appearance Appearance {
material DEF MY_MATERIAL Material {
}
}
geometry Sphere {
}
}
DEF MY_TIME TimeSensor {
loop TRUE
}
DEF MY_SCRIPT myproto {
ROUTE MY_TIME.fraction_changed TO MY_SCRIPT.f_in
ROUTE MY_SCRIPT.f_out TO MY_MATERIAL.set_transparency
}
saving the file would destroy it...
so long
MUFTI
Logged In: NO
Problem solved in white_dune
Logged In: NO
Fixed in early versions of white_dune, see
http://www.csv.ica.uni-stuttgart.de/vrml/dune/