That depends on how you implement the camera under OpenGL.
Basically, there are 2 "different" ways how to implement a camera:
1. using the
glRotate and glTranslate commands - this is the most popular method
2. using the
gluLookAt method - the more elegant method
I'm currently working on Eve, my new 3d model editor project. I have decided to use the second option, because, in my opinion, it works better for 3d editors.
If you are using option 2, then getting the vectors to move around is quite simple:
For the
gluLookAt, you need to specify 3 vectors:
- The Center-Vector - this is the point you focus
- The Eye-Vector - this is from where you look
- The Up-Vector - this is the vector that stands orthogonal on the line of sight and specifies, how the camera is rotated.
For moving around you need two other (temporary) vectors, which can be calculated of the three ones above.
1) The
Ray-Vector represents the line of sight, i.e. the vectors from the
Eye-Vector to the
Center-Vector, therefore it is:
Ray = Eye - Center
2) The
Left-Vector which simply points to the left from the camera. The
Left-Vector is orthogonal to the plane which is given by the
Up-Vector and the
Ray-Vector, therefore it can the calculated using the
Cross-Product:
Left = Up × Ray
If you would want to move a vertice to the up or down, you would simply add or subtract the
Up-Vector.
If you want to move a vertice left or right, then you would add or subtract the
Left-VectorI hope this helps a bit.
- Alhexx