media @ VU
vrml-math-Tree3t.vr
vrml-math-Tree3t.vr
(wrl
)
[ flux /
bitmanagement /
cortona /
octaga
]
NavigationInfo{ type "EXAMINE" }
Viewpoint{ description "start" position 0 0 10}
Background{ skyColor .5 .5 1}
DEF ROOT Transform{ scale 2 2 2 translation 0 -2 0
children[]}
DEF Polyhedron Script {
eventIn SFBool Plus
eventIn SFBool Minus
eventOut MFNode new_f
field SFNode ROOT USE ROOT
directOutput TRUE
url ["javascript:
function initialize(){
MaxIt = 10;
strArr = new MFString(); strArr.length = MaxIt;
str =
'DEF L0 Shape{ appearance Appearance{ material Material{ diffuseColor 0 1 0}} '+
'geometry IndexedFaceSet{ solid FALSE '+
'coord Coordinate{ point[0 1 0,.4 1.6 .2,.8 2.2 0,.2 1.6 -.2]} '+
'coordIndex[0 1 2 3]}} '+
'Transform{ rotation 0 1 0 3.14 translation 0 1 0 children USE L0} '+
'DEF B0 Shape{ appearance Appearance{ material Material{ emissiveColor .5 .5 0}} '+
'geometry IndexedLineSet{ coord Coordinate{ point[0 0 0,0 2 0]} '+
'coordIndex[0 1]}}';
for ( i= 1; i<MaxIt; i++){
str = 'Transform{ translation 0 1 0 children '+
'DEF s'+i+' Transform{ scale .5 .5 .5 children[ '+
str +
']} } Transform{ scale .5 .5 .5 children trunk{}} '+
'DEF g'+i+' Transform{ rotation 1 0 0 1 translation 0 1 0 children USE s'+i+'} '+
'Transform{ rotation 0 1 0 2.09 children USE g'+i+'} '+
'Transform{ rotation 0 1 0 -2.09 children USE g'+i+'}';
strArr[i] = 'PROTO trunk[]{Transform{ scale .2 .2 .2 children[ '+
'Shape{ appearance Appearance{ material Material{ diffuseColor .8 .8 0}} '+
'geometry IndexedFaceSet{ coord Coordinate{ '+
'point[1 0 0,.5 0 -.87,-.5 0 -.87,-1 0 0,-.5 0 .87,.5 0 .87, '+
'.5 10 0,.25 10 -.44,-.25 10 -.44,-.5 10 0,-.25 10 .44,.25 10 .44]} '+
'coordIndex[0 1 7 6 -1 1 2 8 7 -1 2 3 9 8 -1 3 4 10 9 -1 4 5 11 10 -1 5 0 6 11] '+
' creaseAngle 2}}]}} ' + str;
}
iter = 4;
// print( strArr[1] );
new_f = Browser.createVrmlFromString( strArr[iter] );
ROOT.addChildren = new_f;
}
function Plus(value){
if (value && (iter < MaxIt-1)){
iter++;
ROOT.removeChildren = new_f;
new_f = Browser.createVrmlFromString( strArr[iter] );
ROOT.addChildren = new_f;
}
}
function Minus(value){
if (value && (iter>1)){
ROOT.removeChildren = new_f;
iter--;
new_f = Browser.createVrmlFromString( strArr[iter] );
ROOT.addChildren = new_f;
}
}
"]}
# Controls
DEF Clock TimeSensor{ cycleInterval 15}
DEF Animation OrientationInterpolator{ key [ 0, .5, 1 ]
keyValue [ 0 1 0 0, 0 1 0 1.57, 0 1 0 3.14 ]}
Transform{ translation -4 -1 0 rotation 1 0 0 1.57 children[
Shape{ appearance Appearance{ material Material{ diffuseColor 1 0 0}}
geometry Cylinder{ height .2 radius .25}}
DEF tsRot TouchSensor{} ]}
Transform{ translation -4 1 0 children[
Shape{ appearance Appearance{ material Material{ diffuseColor 1 0 0}}
geometry Box{ size .4 .4 .2 }}
DEF tsPlus TouchSensor{} ]}
Transform{ translation -4 0 0 children[
Shape{ appearance Appearance{ material Material{ diffuseColor 0 1 0}}
geometry Box{ size .4 .4 .2 }}
DEF tsMinus TouchSensor{} ]}
ROUTE tsPlus.isActive TO Polyhedron.Plus
ROUTE tsMinus.isActive TO Polyhedron.Minus
ROUTE tsRot.touchTime TO Clock.startTime
ROUTE Clock.fraction_changed TO Animation.set_fraction
ROUTE Animation.value_changed TO ROOT.rotation
(C) A. Eliëns
2/9/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.