[X3D-Public] Any way to do a 'LineSensor' (Like PlaneSensor but in one dimension)

Bederov, Sergey bederov at cortona3d.com
Thu Sep 23 00:53:44 PDT 2010

Hello Dave and Tony,


The problem is that PlaneSensor is inherently planar, even if it has
minY=maxY. If you limit the Y motion, the output values will always be
on one line, but the plane still matters. The sensor works in the
following algorithm:


1. Calculate a ray from the camera through the mouse pointer

2. Intersect the ray with the PlanarSensor plane (Z=0 in its local
coordinate system)

3. Calculate the local X and Y coordinates of the intersection point

4. Clamp X and Y values, if needed

5. Output the (X, Y, 0) event


In most non-trivial cases, a different plane yields different X and Y
coordinates, and while Y is clamped, X is still different. The worst
case is when you look almost along the plane. Any small movement of the
mouse produces a large movement of the intersection point, and while Y
is clamped, X changes rapidly. When the mouse pointer approaches the
"horizon", you can move the target object away from the screen and even
to infinity.


Dave, I would recommend you placing the PlaneSensor into a Billboard
whose axisOfRotation coincides with the clamped area of the PlaneSensor.
The billboard will always rotate the PlaneSensor to the best orientation
respective to the camera, and everything will work in the most "natural"
way. Effectively, this yields an (approximate) orthogonal projection of
the mouse pointer to the needed line, in screen coordinates.


                                             Sergey Bederov




From: x3d-public-bounces at web3d.org [mailto:x3d-public-bounces at web3d.org]
On Behalf Of Tony Parisi
Sent: Thursday, September 23, 2010 6:25 AM
To: Dave A
Cc: x3d-public at web3d.org
Subject: Re: [X3D-Public] Any way to do a 'LineSensor' (Like PlaneSensor
but in one dimension)



This might be an implementation artifact (possible even in two players),
or it might be correct to-spec behavior.

But now we've gone beyond my ability to visualize. Hoping KV can weigh
in. Keith are you listening?!


On Wed, Sep 22, 2010 at 6:27 PM, Dave A <dave at realmofconcepts.com>

Yeah. I try to save myself some time/trouble by asking if anyone's seen
anything, such that I don't have to reinvent a wheel.....

Anyway, I see this behavior in Vivaty and Contact.

Imagine you have a plane. Let's say it's face-on to the screen. The
PlaneSensor works well in this case, and setting min.y = max.y will
restrict motion to just X. That's fine. Intuitive interaction.

Now navigate such that the plane is not face-on to the screen. It's a
rhombus. If you were to draw bisectors on the plane (its local axes),
you would see a line representing the X axis no longer parallel to
screen X, and Y no longer parallel to Y.

Now when you get translation events from the sensor, there are X and Y
components to that. But if you map that to motion, you'll see that MOUSE
motion in any direction will result in object motion (in one direction).
And when the unwanted axis is 'shorter' (more oblique), there is much
more motion resulting from mouse-movement in that direction. It's a
horribly non-intuitive interaction.

It's hard to describe, sorry, but try it. Make something in Vivaty
studio with a PlaneSensor and just set the min/max values. Then run it,
rotate the scene around, and play with it. Won't be long before you run
into this behavior.

I imagine I may have to transform the sensor's values to screen coords,
filter, and transform back?

Dave A

On 9/22/2010 5:34 PM, Tony Parisi wrote: 

Poor Dave, they're still bashing you after all these years. I feel for
ya man.

Ok now on-topic: if I recall, there is a way to constrain the
PlaneSensor to one dimension. From da spec:

"minPosition and maxPosition may be set to clamp translation_changed
events to a range of values as measured from the origin of the Z=0 plane
of the local sensor coordinate system. If the X or Y component of
minPosition is greater than the corresponding component of maxPosition,
translation_changed events are not clamped in that dimension. If the X
or Y component of minPosition is equal to the corresponding component of
maxPosition, that component is constrained to the given value. This
technique provides a way to implement a line sensor that maps dragging
motion into a translation in one dimension."



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20100923/56e7d773/attachment.html>

More information about the X3D-Public mailing list