PDA

View Full Version : Creating a plane thats parallel to the view camera

kellogs
08-28-2008, 08:40 AM
...from an arbitrary point.

Hi, i'm trying to implement something similar to maya's (well, pretty much all 3d editors) vertex/object move edit.
What that allows you to do is click on any edit point on the screen from any viewing orientation,
then move that edit point with the mouse along what appears to be a plane parallel to the view cam.

Reason being, i'm trying to create a simple curve editor for a game i'd like to make, and although I've already
got a few hacky ways of getting results its obviously going to be better to get something like this right from the start

Problem is though, the only way i know how to create a plane is from a triangle, i've tried using parts of the modelview matrix to create
a vector perpendicular to my pick point and cam by using modleview[4],[5],[6] = up vector, but these seem to warp.

It seems like a fairly common problem but my googleing hasn't turned up much useful info and my maths is rubbish

Many thanks

Fastjack
08-28-2008, 10:40 AM
You probably know where the camera's at, as you probably specified it using eye and center coordinates.

So, the difference of those vectors gives a vector from cam to view center.

The plane you're looking for is the plane with that vector as its normal:
so P:Ax + By + Cz + D = 0 with (A, B, C) being the vector (center-eye),
any D will give a plane paralel to the viewing plane.

kellogs
08-28-2008, 12:50 PM
hi, think i'm half way there, heres what i'm doing with the info you gave to get my normal:

Vec3 camPos(modelview[12], modelview[13], modelview[14]);
Vec3 lookAt(modelview[ 8], modelview[ 9], modelview[10]);
planeNormal = lookAt - camPos;

The plane you're looking for is the plane with that vector as its normal:
so P:Ax + By + Cz + D = 0 with (A, B, C) being the vector (center-eye),
any D will give a plane paralel to the viewing plane.

I'm not 100% sure what you mean by "P:Ax + By + Cz + D = 0 with (A, B, C) being the vector (center-eye)"
I take it P = pickPoint.dot( planeNormal ); ?

Many thanks though, think i'm getting there now, i'm dreading to think how the mouse movement is going to work, but i'll bother with that once i've got my ray to pickPoint thingy working, which shouldn't be too hard.

Cheers

Fastjack
08-29-2008, 06:20 AM
P="Plane P"

From the manpages (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/lookat.html):

First/second rows should be the normalized relative X and Y axes in which you want your pick point to be able to move.
I'd multiply mouse movement distances by those vectors, scaled by the distance of the point to the viewer.

To avoid warping, make sure the up vector really is 'up' to the direction you are looking. Your up vector may have been replaced, what's stored in the matrix is X-axis cross normalized viewing direction.

kellogs
08-29-2008, 10:21 AM
Thanks for your help, i've sorted it out now, its actually very easy.
The ray i'm looking for is held in modelview[2][6][10], i'll call this voodooRay.
Once you've got the ray the plane distance is found by voodoo.dot(pick_pos);
Then alls i do after that is get a mouse ray plane pos and use that to move the pick_pos about, works a treat.

This is much better an leaner than the old poly gizmo method i was using.

caukorea
11-08-2011, 10:12 PM
I'm trying this, Would you elaborate & explain it clearly. I want to visualize the plane parallel to camera.