This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > VRML > April 2004 > Resetting CylinderSensor
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Resetting CylinderSensor
|
|
|
| Hey,
Is it possible to reset the value of a CylinderSensor rotation to 0 again?
Regards,
Lee
| |
|
| > Is it possible to reset the value of a CylinderSensor rotation to 0 again?
I know no other way than a brute force one - resetting by deleting old
sensor and adding a new one. You can do all this in a script using:
Browser.addRoute/deleteRoute
addChildren, deleteChildren
like that :
#VRML V2.0 utf8
DEF tiltXparent Transform {
children [
Shape {
geometry Box{}
}
# DEF tiltX CylinderSensor {minAngle 0 maxAngle 1}
]
translation -4 0 0
}
Transform {
children [
Shape {
geometry Box{}
}
DEF tiltZ CylinderSensor {minAngle 0 maxAngle 1}
]
translation 4 0 0
}
Transform {
children [
Shape {
geometry Box{}
}
DEF touch TouchSensor {}
]
translation 0 4 0
}
DEF T1 Transform {
children DEF T2 Transform {
children Shape {
geometry Box{}
appearance Appearance {
material Material {
diffuseColor 0 0.6 0.9
}
}
}
}
}
DEF convertAxis Script
{
mustEvaluate TRUE
directOutput TRUE
eventIn SFRotation zRot
eventOut SFRotation zNewRot
eventIn SFRotation xRot
eventOut SFRotation xNewRot
eventIn SFTime touchTime
field MFNode tiltX []
field SFNode tiltXparent USE tiltXparent
field SFNode T2 USE T2
url "java script:
function initialize() {
tiltX = Browser.createVrmlFromString('CylinderSensor {minAngle 0
maxAngle 1}');
tiltXparent.addChildren = tiltX;
Browser.addRoute(tiltX, 'rotation_changed', T2, 'set_rotation');
}
function touchTime(time) {
Browser.deleteRoute(tiltX, 'rotation_changed', T2, 'set_rotation');
tiltXparent.removeChildren = tiltX;
tiltX = Browser.createVrmlFromString('CylinderSensor {minAngle 0
maxAngle 1}');
tiltXparent.addChildren = tiltX;
Browser.addRoute(tiltX, 'rotation_changed', T2, 'set_rotation');
}
function zRot(rot, time)
{
zNewRot.x = 0;
zNewRot.y = 0;
zNewRot.z = 1;
zNewRot.angle = -rot.angle;
}
function xRot(rot, time)
{
xNewRot.x = 1;
xNewRot.y = 0;
xNewRot.z = 0;
xNewRot.angle = rot.angle;
}
"
}
ROUTE convertAxis.xNewRot TO T2.rotation
ROUTE tiltZ.rotation_changed TO convertAxis.zRot
ROUTE convertAxis.zNewRot TO T1.rotation
ROUTE touch.touchTime TO convertAxis.touchTime
As you can see you also have to set Box's rotation manually because
deletion doesn't do it. (but it's reseted)
Also I'm not sure if I correctly use removeChildren (it's first time in
my life;)
tiltXparent.removeChildren = tiltX;
???
mkd
| |
|
| Yes, that is what I feared you would have to do. My faith in this language
gets less everyday, time after time I have wanted to accomplish the simplest
of things and it has not been possible without using some ugly long-winded
method.
Thank you for your help.
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|