This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > December 2003 > A problem with 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 A problem with CylinderSensor
Marc

2003-12-08, 11:57 am


I am having a problem getting the most basic CylinderSensor example to work
correctly. The goal is to constrain the rotation of a stack two blocks as
if they are on top of a turntable or "Lazy Susan". The blocks are stacked
vertically along the Z axis, the same as the axis of rotation.

Could anyone tell me what I'm doing wrong?
I have the feeling I don't have the transformation/rotation implemented
correctly. When I click on the turntable the blocks fall over then rotate.

Suggestions welcomed. Thanks in advance.
Marc

-----------------snip snip snip ----------------------
#VRML V2.0 utf8
# The goal is to stack two blocks in the Z axis on top of a
# circular disk that will act as a turntable or "Lazy Susan".

Transform {

#The turntable
rotation 1 0 0 1.57
children [
DEF TURNTABLE CylinderSensor {
enabled TRUE
diskAngle 0.01
}
Shape { geometry Cylinder { radius 3 height .5 } }

#The blocks on top of the turntable
DEF BLOCKS Transform {
#rotate the coordinate frame back
rotation 1 0 0 -1.57
children [
Transform {
translation 0 0 1
children[ Shape{ geometry Box{ size 2 2 2 } }]
}
Transform {
translation 0 0 2.5
children[ Shape{ geometry Box{ size 1 1 1} }]
}
]
}
]
}

ROUTE TURNTABLE.rotation_changed TO BLOCKS.rotation



Joerg Scheurich aka MUFTI

2003-12-08, 11:57 am

> correctly. When I click on the turntable the blocks fall over then rotate.
quote:

> DEF BLOCKS Transform {
> #rotate the coordinate frame back
> rotation 1 0 0 -1.57


quote:

> ROUTE TURNTABLE.rotation_changed TO BLOCKS.rotation



When the sensor is used, the initial rotation value is overwritten
by the value from the sensor (which is near angle 0 at first moment).

You should use a Transform with no rotation set as a target of your
ROUTE.

so long
MUFTI
--
Wenn Sie das Bearbeiten des Bildes beenden, koennen Sie die
Ballabwehrfuehrung benutzen.
(aus einem Softwarehandbuch, Sinn "Ballabwehrfuehrung" unklar (Trackball ?))
Marc

2003-12-09, 10:03 am



Mufti's suggestion is a good one but I don't think it is the problem.
Implementing the change he suggests changes the orentation of the objects.
The intent is to stack the blocks in the Z direction.

When the mouse is clicked on any of the objects the orientation of both
blocks with respect the turntable changes. I've updated the file to include
some color to make the objects easier to see what is going on.

I've have had trouble finding a basic example of the correct use of a
CylinderSensor. Suggestions welcomed.

Marc

------------------------snip snip snip -------------------------------------
#VRML V2.0 utf8
# The goal is to stack two blocks in the Z axis on top of a
# circular disk that will act as a turntable or "Lazy Susan".

Transform {

#The turntable
rotation 1 0 0 1.57
children [
DEF TURNTABLE CylinderSensor {
enabled TRUE
diskAngle 0.01
}
Shape{
appearance Appearance{ material Material { diffuseColor 1 0 0 }}
geometry Cylinder { radius 3 height .5 }
}

#The blocks on top of the turntable
DEF BLOCKS Transform {
#rotate the coordinate frame back so that the blocks stack in
the Z
rotation 1 0 0 -1.57
children [
Transform {
translation 0 0 1
children[ Shape{
appearance Appearance{ material Material {
diffuseColor 0 1 0 }}
geometry Box{ size 2 2 2 } }]
}
Transform {
translation 0 0 2.5
children[ Shape{
appearance Appearance{material Material {
diffuseColor 0 0 1}}
geometry Box{ size 1 1 1} }]
}
]
}
]
}

ROUTE TURNTABLE.rotation_changed TO BLOCKS.rotation



"Joerg Scheurich aka MUFTI" <rusmufti@helpdesk.rus.uni-stuttgart.de> wrote
in message news:br1kdv$2mn$2@news.uni-stuttgart.de...
quote:

rotate.[QUOTE][color=darkred]
>
>
> When the sensor is used, the initial rotation value is overwritten
> by the value from the sensor (which is near angle 0 at first moment).
>
> You should use a Transform with no rotation set as a target of your
> ROUTE.
>
> so long
> MUFTI
> --
> Wenn Sie das Bearbeiten des Bildes beenden, koennen Sie die
> Ballabwehrfuehrung benutzen.
> (aus einem Softwarehandbuch, Sinn "Ballabwehrfuehrung" unklar


(Trackball ?))


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews