Re: converting to screen coords

New Message Reply Date view Thread view Subject view Author view

Angus Dorbie (dorbie++at++sgi.com)
Tue, 09 Jun 1998 13:11:16 -0700


leif.stubbfalt++at++enator.se wrote:
>
> Hello!
>
> I want to transform a point from world coordinates to screen
> coordinates. I know that the first step is to convert the point to
> viewing coordinates. I did this by multiply the point by the inverse of
> the viewing matrix (I was told that it had to be the inverse). I got the
> viewing matrix by pfGetChanViewMat. Is this OK?
>
> After this I multiplied the converted point by the projection matrix. I
> got the matrix by pfGetFrustGLProjMat. Is this OK? I guess not, because
> the resulting coordinates where not normalized. When transforming I used
> pfFullXformPt3. The last step, converting from normalized to screen
> coordinates, won't be a problem.

You have the right idea, note if a point is outside the frustum it will
not
lie between -1 and 1 and should be clipped.
Also before projection you should eliminate points in eye space which
are
beyond a y threshold (they are behind eye or near clip).

There may be a 90 degree rotation about x to bring performer y into
alignment with gl projection -z, this is probably what you are missing
but that depends on exactly what's in the GLFrustumMatrix projection
returned by the pfFrustum.

You are definitely on the right track.

The other thing you could do ofcourse is to just divide eye x & y by
screen z and then scale yourself. You have to do the scale anyway for
your viewport so you may as well build in the FOV scale and use a
normalized projection for speed with the added bonus that you know
you are in Performer channel eye space. It's your choice.

Cheers,Angus.

-- 
"Only the mediocre are always at their best." -- Jean Giraudoux 

For advanced 3D graphics Performer + OpenGL based examples and tutors: http://www.dorbie.com/ ======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:57:31 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.