RE: [Plib-users] Window (x,y) to world coordinates
Brought to you by:
sjbaker
|
From: Norman V. <nh...@ca...> - 2001-12-20 04:56:44
|
Steve Baker writes:
>
>Ask For Joy wrote:
>
>> What I am looking for is a way to translate window coordinates obtained
from the
>> mouse to world coordinates, taking into account the window dimensions and
>> current camera position.
>
>Well, you can't do that for an arbitary setup - because there are an
infinite
>number of world coordinates that lie in a line from your eye through the
mouse
>position and out into the world.
>
>However, if you just want to know where it hit your XY plane
>(or any other specific plane for that matter) then you need to do this:
>There are SG routines for all of those separate operations - but no single
>function to do the entire thing (that I'm aware of).
>
>If some kind soul were to write such a thing, it would be cool
>to put it into the SSG camera class.
I believe PPE contains a 'generic' function that can be adapted for this
ppe / src / viewer / ppeViewerDraw.cxx
void ppeViewer::update_3D_cursor ( sgVec2 mouseXY )
and just use the
case FOLLOW_PLANE :
code block
I believe the only necessary data external to the function will be
the window width and height
the camera orientation (hpr)
and the sgVec4 plane we want to report our position on
in this case I believe
the camera is [0, 90, 0 ]
and the plane is [ 0, 0, 1, 0 ]
so all Joy needs is the window width and height
Cheers
Norman
|