Quote:> I need a couple more pointers.....I assume the middle of the screen is the
> camera position....so if the cursor is at the middle i can project a ray.
> But how do i project a ray when the cursor is not in the middle.
If (x,y) is the device coordinate point under the cursor, then:
GLdouble x, y, nx, ny, nz, fx, fy, fz, vecx, vecy, vecz;
GLdouble m, p;
// First, get m, p, and vp using glGet functions
// Now compute the ray
vecx=fx-nx; vecy=fy-ny; vecz=fz-nz;
(vecx,vecy,vecz) is the ray under the mouse cursor pointing away from the
BTW, that code is off the top of my head. I wouldn't be surprised if it
doesn't compile as-is. But the concept should be right. Just unproject the
point under the cursor at the near and far planes, and compute a ray from
the unprojected values.
Quote:> Also how do i determine which plane is most accurate to place my model
> against...I guess that this plane must be pependicular at the point where
> the camera ray hits it....
This is application dependant. Any plane will work. Which plane do you want
your object to move along in response to user input? Use that plane. It
doesn't have to be perpendicular to the ray.
Hewlett Packard Technical Solutions Lab
OpenGL FAQ: http://www.frii.com/~martz/oglfaq