Re: Getting Projection and ModelView matrices

New Message Reply Date view Thread view Subject view Author view

MLM Veraart (Veraart++at++fel.tno.nl)
Tue, 20 Apr 1999 15:15:30 +0200


Tom Flynn wrote:
>
> Greetings,
>
> Background
> ---------
> We're implementing a little utility for ourselves to measure distance
> between two points at the click(s) of a mouse (note: we're using an
> orthographic viewing projection when "measuring"). Given the
> coordinates of where the mouse is on the screen (found via
> XQueryPointer()), we find the associated world coordinates via
> gluUnProject(). Works great....in the draw process.
>
> Problem
> -------
> gluUnProject() requires the Projection and ModelView matrices as input
> (as well as a couple other things that we already know). In the draw
> process, I can do a:
>
> glGetDoublev(GL_PROJECTION_MATRIX, projMatD);
> glGetDoublev(GL_MODELVIEW_MATRIX, modelViewMatD);
>
> to get the matrices and then do the gluUnProject(). Life is
> fine...except that I really would prefer not to do this in the draw
> process. I'd rather avoid setting up a draw callback (just for this)
> and IPC mechanisms to command that draw callback to get the matrices and
> return world coordinates. Yes, I've already done this, but I'd prefer
> to eliminate all that code by getting the matices in the app process and
> doing everything there. I've tried getting the matrices with:
>
> pfGetProjMat(); or pfGetFrustGLProjMat(); for the Projection matrix
> and
> pfGetChanOffsetViewMat() for the ModelView matrix
>
> and get unreliable results.
>
> The Question
> ----------
> Am I using the wrong calls? Or can this just not be done from the app
> process?
>
> Thanks in advance,
> tom

The way I did a similar thing. Because you have an orthographic frustum
you know the bounding coordinates. With the pfuGetMouse() call I sample
if there is a mouse click and use pfuMapMouseToChan() to calc it to the
range -1..1 and then map that to my frustum boundary.

A few code lines

    pfuGetMouse (&mouse);
    if ((mouse.inWin) && pfuMapMouseToChan (&mouse, chan))
    {
        int buttonClicked = (~gPrevMouseState.flags) & mouse.flags;
        ........
    }

This is all done in the APP

Mario


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Tue Apr 20 1999 - 06:15:17 PDT

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