[info-performer] reverse projection

Date view Thread view Subject view Author view

From: Denis Mohnhaupt (demohn++at++gmx.de)
Date: 10/21/2004 05:28:49


Greetings,

i am writing a performerapplication where i sometimes need to know the ray
which is directed away from the camera and goes through the point of the
mouse cursor.
To compute that ray i intended to do a reverse projection from screen
coordinates to world space, but i have some problems with details.
roughly i want to do the following:

1.) get cursor's window coordinates and normalize them (screenspace) to
s_x(-1,1) s_y(-1,1). here i am not sure if i have to pay attention to the
aspect ratio, so s_y may not between -1 and 1 but -0.75 and 0.75 if my
window has a 4:3 ratio?

2.) create a 4d-vector c which represents that point in clipspace
c_x = s_x, c_y=s_y, c_z = 1.0f c_w=1.0f

3.) (transformation to viewspace) take the projection matrix via
pfProjMat(pfMatrix mat), invert it and get a point v in view space by
multiplying the inverted projection matrix by c, the normalize c by dividing
by c_w
here i have the greatest problems, 1st pfProjMat() gives me an identy matrix
where it makes little sense to invert it. i tried to build my own projection
matrix with a formula i googled (apparently used in glFrustrum), but i am a
bit confused how to do it, because in performer the camera looks down the
positive y-axis whereas in open gl it looks down the negative z-axis. do i
have to pay attention to that or is that handled due to the pfChannel's
ModelView-Matrix? and does that affect the 2nd step, meaning that i have to
set c_z = s_y?

4.) (transformation to world space) get modelview matrix via
pfChannel::getOffsetViewMat, invert it an get the world coordinates w by
multiplying that matrix by c. the ray then is defined as
camera-position + t * w

until now i had a workaround which pretended the projection plane to be in
the local space of the camera at y=1 ranging from x = -1 to 1 and z as well.
i determined the mouse cursors "local space" coordinates similar to step 1
and transformed it then into world space by multiplying the modelview matrix
with that point. it works but causes inaccuracies the more the mouse curser
comes to the window borders. thats the reason why i want to try the method
described above

if someone could give me hints on that matter, i would really appreciate it.
thnx in advance
Denis

-- 
+++ GMX DSL Premiumtarife 3 Monate gratis* + WLAN-Router 0,- EUR* +++
Clevere DSL-Nutzer wechseln jetzt zu GMX: http://www.gmx.net/de/go/dsl


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Oct 21 2004 - 05:28:58 PDT