COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Drag point in 3d using mouse

• Email
• Follow

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

See related articles to this posting

0 Replies
673 Views

Similar Articles

12/7/2013 12:51:17 PM
page loaded in 328065 ms. (1)