Re: certainly already asked

New Message Reply Date view Thread view Subject view Author view

Nicolas Gauvin (nicolas++at++cae.ca)
Thu, 6 Jun 1996 14:45:49 -0400


On Jun 6, 2:43pm, Martin Reddy wrote:
> Subject: Re: certainly already asked
>
> > Does anybody have, or does this exist in Performer, a function that
> > computes from 3D coordinates to 2D screen coords ?
>
> This is something that I am interested in too. I have seen a few posts
> asking this in the past, but never any answers. For myself I need to be
> able to compute the size (e.g. projected bounding sphere diameter) and
> position of objects in (2D) screen coordinates.
>
> I gather that this is not possible in Performer? (but I'd love to be
> proved wrong). As a result I am considering re-inventing the wheel and

Basically you want to get the same transformation matrices that Performer
sends to GL.

Here are two suggestions for doing this:

1) Using Performer only:

// get the viewing matrix from your channel
chan->getViewMat( viewMat );

// get the channel frustum
chan->getBaseFrust( frust );

// get the projected GL matrix from this frustum
frust->getGLProjMat( projMat );

// the final transformation matrix is the product of both
mat = viewMatrix * projMatrix;

you can now apply this matrix to your 3D vertices and get their 2D screen coords

Unless I'm wrong this should give you the same result as Performer.

2) Using GL directly:

In the DRAW process you can get those two matrices from IRISGL:

mmode( MPROJECTION )
getmatrix( projMat );

mmode( MVIEWING )
getmatrix( viewMat );

With OpenGL you should use:
  
glGetFloatv( GL_PROJECTION_MATRIX, ...
and
glGetFloatv( GL_MODELVIEW_MATRIX, ...

but you need to be carefull here since OpenGL has different axis orientations
then IrisGL.

Nicolas Gauvin CAE Electronics Ltd., 8585 Cote De Liesse
Software Developer Saint-Laurent, Quebec, Canada, H4L-4X4
3-D Graphics Applications tel: +1 514 341 2000 extension 2275
nicolas++at++cae.ca fax: +1 514 340 5496
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer.html
            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:52:59 PDT

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