Hi all!
I'm trying to pick a point in 3d space using the mouse, and then move
the camera on a plane by dragging the mouse, keeping the 3d point always
under the mouse cursor. Here's what I do:
1) Find the 3d point (A) which will be used as the reference point for
dragging.
2) By using mouse coordinates, compute a point (B) in 3d space using
glunproject, with an arbitrary z buffer(0.75).
3) Find the ray originating from the camera position and passing from
point B.
4) Find the intersection point (C) of the ray and a plane passing from
point A, whose normal is the same with the up vector of the camera. (The
camera will move to a plane parallel to this plane). Point C is the
point where point A would go, if we were moving it by dragging.
5) Compute the shifting from point A to point C.
6) Shift camera position using the above computed shifting, but inverted.
It seems to work, but when I start dragging using the mouse, my
reference point A starts moving away from the mouse cursor. So dragging
works, but not accurately.
Any suggestions and methodologies for this? Thanks in advance.
N
|
|
0
|
|
|
|
Reply
|
Athanasios
|
6/27/2006 11:35:32 AM |
|