converting world-coordinates to window-coordinates (mouse over)?

converting world-coordinates to window-coordinates (mouse over)?

Post by Jan Panhof » Fri, 13 Jun 2003 21:45:22



Hi,

I want to implement a mouse over for an object.

I get the mouse coordinates with SoLocation2Event -> it returns the x and y
coordinates of the mouse cursor in cases of mouse movement ... as window
coordinates.

I get the coordinates of the bounding box of the object ... but they are
world-coordinates.

It is possible to move the camera to any place in the world.

How can I calculate the coordinates to make a comparison of both
coordinates?

Thanks in advance

 
 
 

converting world-coordinates to window-coordinates (mouse over)?

Post by Peder Blekke » Fri, 13 Jun 2003 22:05:03



> I want to implement a mouse over for an object.

> I get the mouse coordinates with SoLocation2Event -> it returns the x and y
> coordinates of the mouse cursor in cases of mouse movement ... as window
> coordinates.

> I get the coordinates of the bounding box of the object ... but they are
> world-coordinates.

> It is possible to move the camera to any place in the world.

> How can I calculate the coordinates to make a comparison of both
> coordinates?

You can use SbViewVolume::projectToScreen(), which will project a
3D coordinate to normalized screen coordinates.

Peder

 
 
 

converting world-coordinates to window-coordinates (mouse over)?

Post by Madari » Sat, 14 Jun 2003 19:57:43


Hello,

I tried to implement the

SbViewVolume::projectToScreen()

The reference states that:
The returned coordinates (dst) are normalized to be in range [0, 1].

But it returns numbers like 3,5 or -0,7 ....

Is this an error in the method?

CU

mandarin



> > I want to implement a mouse over for an object.

> > I get the mouse coordinates with SoLocation2Event -> it returns the x
and y
> > coordinates of the mouse cursor in cases of mouse movement ... as window
> > coordinates.

> > I get the coordinates of the bounding box of the object ... but they are
> > world-coordinates.

> > It is possible to move the camera to any place in the world.

> > How can I calculate the coordinates to make a comparison of both
> > coordinates?

> You can use SbViewVolume::projectToScreen(), which will project a
> 3D coordinate to normalized screen coordinates.

> Peder

 
 
 

converting world-coordinates to window-coordinates (mouse over)?

Post by Peder Blekke » Sat, 14 Jun 2003 23:54:57



> Hello,

> I tried to implement the

> SbViewVolume::projectToScreen()

> The reference states that:
> The returned coordinates (dst) are normalized to be in range [0, 1].

> But it returns numbers like 3,5 or -0,7 ....

No, it probably just means that your geometry is outside the view
volume, and is then projected outside the viewport. (0,0) is the lower
left corner of the viewport, (1,1) is the upper right corner.

Fetching the correct SbViewVolume is not always that easy BTW. You
can use SoCamera::getViewVolume(), but you need to adjust for the
viewport mapping. See
<URL:http://doc.coin3d.org/Coin/classSoCamera.html#a3> for more
information.

Peder