q13918

06-03-2017, 11:42 AM

How to calculate what object or to what vertex or cordiante in the world geometry viewport is pointing towards?

In other words how to get the point of touch to word geometry form middle of cameras view angle/direction effectively without very long calulation/comparsions

Dark Photon

06-04-2017, 06:34 AM

If you're using an ordinary projection (orthographic or symmetric perspective projection), the ray down your eye-space -Z axis should be a pretty good indication. That's the vector (0,0,-1) originating at the point (0,0,0) in eye-space. Back-transform that to world-space if you need it there.

If you're using an asymmetric perspective projection, this won't work well. In fact, the eye-space -Z axis may not even be in the view frustum. A better vector to use is general is one which shoots directly through the center of the frustum. For a perspective projection, that's vector ( (L+R)/2, (B+T)/2, -N ) from point (0,0,0) in eye-space. You'll notice this gives you the same answer as above for a symmetric perspective projection (once you normalize the direction vector).

If you need to know more than that, you can easily compute the eye-space plane equations for the edges of your view frustum. Then back-transform those to world-space if you need them there. Or compute a specific ray through a specific point on your window.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.