Re: performer channel view

New Message Reply Date view Thread view Subject view Author view

Sharon Clay (src++at++rose.engr.sgi.com)
Tue, 12 Aug 1997 23:25:19 -0700


+>---- On Aug 11, 11:23am, Rémi Arnaud wrote:
> Subject: Re: performer channel view
->From guest++at++holodeck.csd.sgi.com Mon Aug 11 16:43:50 1997
->
->Anita Kishore wrote:
->>
->> Hi :
->>
->> I am trying to compare and get to work two different ways of
->> setting eye point's position and orientation. For both the methods, the
->> scene graph is same, having just one simple geometry with pre and post
->> DRAW callbacks.
->>
->> method 1 :
->> ----------
->> - set performer channel's view matrix with the foll. values:
->> view.xyz = (2.5, -5, 1.6), view.hpr = (9, 5, 3)
->> - get openGL modelview matrix in the pre callback and print it.
->> - matrix printed is:
->>
->> matarray :
->> 0.985621 0.065307 0.155839 0.000000
->> 0.160725 -0.077778 -0.983930 0.000000
->> -0.052137 0.994829 -0.087156 0.000000
->> -1.577008 -2.143883 -5.169798 1.000000
->
-> Note that the offsets (pfChannel::setViewOffsets) are also applied if
-> non null to that transformation matrix
->
->>
->>
->> method 2 :
->> ----------
->> - reset performer channel's view matrix to all 0, ie:
->> view.xyz = (0,0,0), view.hpr = (0,0,0)
->> - in the pre callback, use pfMakeCoordMat to make coordMat
->> with the foll. values:
->> xyz = (2.5, 1.6, 5.0) - in openGL coordinate system
->> hpr = (9, 5, 3)
->> - pfMakeRotMat(viewMat, 90.0, 1, 0, 0) - to convert rotation part
->> from pf to openGL coordinate system.

It takes a bit more than that....

Here is what we have on the GL viewing stack (matrix 1):

    PFSET_VEC3(coord.xyz, 2.5, -5, 1.6);
    PFSET_VEC3(coord.hpr, 9, 5, 3);
    pfMakeCoordMat(coordMat, &coord);
    pfInvertOrthoMat(invMat, coordMat);
    pfMakeRotMat(rotMat, -90.0, 1, 0, 0);
    pfPostMultMat(invMat, rotMat);

    -> ([R(r,y)R(p,x)R(h,z)T]^-1) * R(-90,x)

The view mat is equivalent to (even inthe man page!)
    R(r,y)*R(p,x)*R(h,z)*T

So we rotate the axes into pfSpace and then apply the inverse eye parameters
to get the origin at 0.
Since we _always_ will have the R(-90,X) on the mat stack, you'll need
to rotate from pfSpace to GL space and then back to use your GL position.
You seem to have HPR in pfSpace by your example.
You can't just use pfMakeCoordMat because you need to
insert a rotation in between the translate and the HPR rotations to apply
things in the proper frame.
So your view mat (use some faster construction math than this :-)) is:

    pfMatrix coordMat, rotMat, invMat, transMat;
    pfCoord coord;

    PFSET_VEC3(coord.xyz, 2.5, 1.6, 5);
    PFSET_VEC3(coord.hpr, 0, 0, 0);
    pfMakeIdentMat(coordMat);

    /* apply hpr by hand */
    pfMakeRotMat(rotMat, 3, 0, 1, 0);
    pfPostMultMat(coordMat, rotMat);
    pfMakeRotMat(rotMat, 5, 1, 0, 0);
    pfPostMultMat(coordMat, rotMat);
    pfMakeRotMat(rotMat, 9, 0, 0, 1);
    pfPostMultMat(coordMat, rotMat);

    pfMakeTransMat(transMat, coord.xyz[0],coord.xyz[1],coord.xyz[2]);
    /* rotate pfSpace into GL for GL postion, then back for pfHPR */
    pfMakeRotMat(rotMat, 90.0, 1, 0, 0);
    pfPostMultMat(transMat, rotMat);
    pfMakeRotMat(rotMat, -90.0, 1, 0, 0);
    pfPreMultMat(transMat, rotMat);
    pfPostMultMat(coordMat, transMat);

    pfInvertOrthoMat(invMat, coordMat);
    /* finally, we apply our rotation matrix for the final GL matrix */
    pfMakeRotMat(rotMat, -90.0, 1, 0, 0);
    pfPostMultMat(invMat, rotMat);

If your HPR is actually in GL space with heading rotated around +Y instead
of +Z, then you'd do:

    pfMatrix coordMat, rotMat, invMat, transMat;
    pfCoord coord;

    PFSET_VEC3(coord.xyz, 2.5, 1.6, 5);
    PFSET_VEC3(coord.hpr, 0, 0, 0);
    pfMakeIdentMat(coordMat);

    /* apply GL space hpr by hand */
    pfMakeRotMat(rotMat, -3, 0, 0, 1);
    pfPostMultMat(coordMat, rotMat);
    pfMakeRotMat(rotMat, 5, 1, 0, 0);
    pfPostMultMat(coordMat, rotMat);
    pfMakeRotMat(rotMat, 9, 0, 1, 0);
    pfPostMultMat(coordMat, rotMat);

    pfMakeTransMat(transMat, coord.xyz[0],coord.xyz[1],coord.xyz[2]);
    pfPostMultMat(coordMat, transMat);

    /* rotate pfSpace into GL for GL postion specification */
    pfMakeRotMat(rotMat, 90.0, 1, 0, 0);
    pfPostMultMat(coordMat, rotMat);

    /* now rotate back to restore pfSpace */
    pfMakeRotMat(rotMat, -90.0, 1, 0, 0);
    pfPreMultMat(coordMat, rotMat);

    pfInvertOrthoMat(invMat, coordMat);
    /* our rotation matrix */
    pfMakeRotMat(rotMat, -90.0, 1, 0, 0);
    pfPostMultMat(invMat, rotMat);

And as Remi points out, if you have channel view offsets, you need
to add that to the xyz and hpr as well.

Hope this helps!
src.

-- 
-----{-----{---++at++   -----{----{---++at++   -----{----{---++at++   -----{----{---++at++
Sharon Rose Clay (Fischler) - Silicon Graphics, Advanced Systems Dev.
src++at++sgi.com  (415) 933 - 1002  FAX: (415) 965 - 2658  MS 8U-590
-----{-----{---++at++   -----{----{---++at++   -----{----{---++at++   -----{----{---++at++

===================================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:55:43 PDT

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