This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > April 2004 > Cylinder Sensors





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 Cylinder Sensors
Lee

2004-04-21, 11:05 pm

Hi,

I have a problem. What I am trying to produce is kind of like a marble maze
if you have ever seen one? Where you have a wooden maze with two knobs on 2
different sides, allowing you to rotate the maze in two different axis.

I have placed two cylinder sensors and used two scripts to alter the
original Y axis rotation of each cylinder to rotate in the X and Z axis
where necessary. How do you combine the two rotations because they do
affect each other? I have attempted to make the two cylinder sensor
rotations available in the same script without any success.....

Any ideas?

Thanx in Advance

Lee


Lee

2004-04-21, 11:05 pm

Not sure that me previous post was too clear on what I wanted to know so
hope this makes it a little more clear.

I am using a script which responds to events cause by rotating two different
CylinderSensors, altering each of the rotations to act in the required axis.
These two rotations rely on each other though so I need to be able to have
access to both sets of rotations in each event function. I do not know how
to do this, can anyone help?

Below is the script: -

DEF convertAxis Script
{
eventIn SFRotation zRot
eventOut SFRotation zNewRot

eventIn SFRotation xRot
eventOut SFRotation xNewRot

url "javascript:

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 = rot.z;
xNewRot.angle = rot.angle;
}
"
}

ROUTE tiltZ.rotation_changed TO convertAxis.zRot
ROUTE convertAxis.zNewRot TO maze.rotation

ROUTE tiltX.rotation_changed TO convertAxis.xRot
ROUTE convertAxis.xNewRot TO maze.rotation

I also have another question. I have a script which generates a maze, which
is stored in a 2-d array, upon execution. I need access to this same array
all the way through the running of the vrml program in order to perform
collision calculations. Is it possible to do this? If not, is there any
work around which I could utilise?

Thx in advance

Lee


mdk

2004-04-25, 10:30 pm

> I am using a script which responds to events cause by rotating two different
> CylinderSensors, altering each of the rotations to act in the required axis.
> These two rotations rely on each other though so I need to be able to have
> access to both sets of rotations in each event function. I do not know how
> to do this, can anyone help?


I'm not sure if i understand what you mean but you can put your maze
object into two Transforms - one'll be responsible for rotation in X
axis second for the rotation in Z axis:

DEF T1 Transform {
children DEF T2 Transform {
children maze...
}
}

And the script should be:

> DEF convertAxis Script
> {
> eventIn SFRotation zRot
> eventOut SFRotation zNewRot
>
> eventIn SFRotation xRot
> eventOut SFRotation xNewRot
>
> url "java script:
>
> 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 tiltZ.rotation_changed TO convertAxis.zRot


ROUTE convertAxis.zNewRot TO T1.rotation

>
> ROUTE tiltX.rotation_changed TO convertAxis.xRot


ROUTE convertAxis.xNewRot TO T2.rotation


Hope it helps


> I also have another question. I have a script which generates a maze, which
> is stored in a 2-d array, upon execution. I need access to this same array
> all the way through the running of the vrml program in order to perform
> collision calculations. Is it possible to do this? If not, is there any
> work around which I could utilise?


You can send this maze-data to every other Script node, with a ROUTE
command. I don't know where the problem is ;)

md
Lee

2004-04-28, 4:30 am

Was very helpful, thanks very much.

Lee


Sponsored Links


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