Camera, axes, back clip plane and other stuff :)

Started by
1 comment, last by kill 21 years, 10 months ago
I have a couple of questions. I figured out some real dirty hacks for them, but I''m looking for more elegant solutions. If anyone has any suggestions, please reply. 1. How can I figure out an equation for the back clipping plane from the camera transformation matrix? I need this to clip geometry behind it that I render manually. 2. I have a camera system set up that uses local coordinate axes. For every object I keep the up, view and right vectors and when I need to change the transformation I just rotate two vectors around one. Then I just get the transformation matrix from these three vectors. Now, for the FPS style camera the user can''t look up higher then 89 degrees and can''t look down lower then 89 degrees otherwise he''ll flip (and that''s unwanted). How do I prevent this flipping? I only have the three vectors and the degree to rotate by, nothing else. Thanks.
Advertisement
The dot product is our friend, because its fast to compute. The dot product of two normalized vectors will give you the cosine of the angle between them. If the dot product of the forward vector and the vector from the eye to a point is less than cos(FOV), you know the point is outside the field of view.

Similarly you can figure out the deviation of the forward vector from the xz plane and constrain accordingly.
For that last problem of yours, i got the same problem and managed to "correct" it with a really dirty hack. I suposed, and still do, that this flipping was due to some floating point imprecision, so when i was to render a full 90 or -90 (y) degree i'de just decrease it a bit (something like 0.002 wich would result in a 89.998 angle), the result was perfect enought for me to point down rotate the intire view and the crosshair would remain in the same pixel. So it's NOT perfect but it looks perfect and would only be noticed in really high resolutions.

"Follow the white rabbit."

[edited by - White Rabbit on June 7, 2002 1:31:53 AM]
"Follow the white rabbit."

This topic is closed to new replies.

Advertisement