Re: GL to Performer Transformation

New Message Reply Date view Thread view Subject view Author view

Lew Hitchner (hitchner++at++netcom.com)
Tue, 23 Nov 1993 10:11:37 -0800


Here is my C code that I used to convert from a viewing transformation
matrix that was caclulated in GL coord. axis frame to the Performer
coord. frame. This is just a "trivial" 90 degree rotation matrix as
was pointed out by a couple list members. The "non-trivial" part was
figuring out how to use this matrix in Performer. My discovery (by
trial and error) was that Performer composes its viewing transformation
matrices differently than GL. Thus pre-multiplication by the inverse
of the 90 degree rotation worked instead of post-multiplication by the
forward matrix. My calculations for composing the viewing transf.
matrix used below (calculated in a separate function) were also done by
pre-multiplying of inverse transf. rather than post-mult. forward
transf. Perhaps the explanation of how transformation matrices are
composed could be included in future Performer documentation.

        Lew Hitchner
        Xtensory Inc.
        Scotts Valley, CA

void ViewUpdate(
ObjectPtr viewObjPtr
)
{
        ViewPtr theView;
        int chan, nChannels;
        ChannelPtr *chanInfoPtr;
        pfMatrix channelViewTransf;
        static pfMatrix
                        /* conversion transf. from:
                           RHS Euclidean Coords.:
                                        +X = right, +Y = up, +Z = backwards
                           to SGI Performer Coords.:
                                        +X = right, +Y = forwards, +Z = up
                        */
                        coordTransfFwd =
                                { { ONEF, ZEROF, ZEROF, ZEROF },
                                  { ZEROF, ZEROF, ONEF, ZEROF },
                                  { ZEROF, -ONEF, ZEROF, ZEROF },
                                  { ZEROF, ZEROF, ZEROF, ONEF } },
                        coordTransfInv =
                                { { ONEF, ZEROF, ZEROF, ZEROF },
                                  { ZEROF, ZEROF, -ONEF, ZEROF },
                                  { ZEROF, ONEF, ZEROF, ZEROF },
                                  { ZEROF, ZEROF, ZEROF, ONEF } };

        if (viewObjPtr == (ObjectPtr)NULL)
                return;
        theView = (ViewPtr)viewObjPtr;

        .
        .
        .

        /*
        ** Set the viewing transformation matrix for each channel.
        */
        nChannels = theView->chanList->nChannels;
        for (chan = 0, chanInfoPtr = theView->chanList->chanInfo;
                                chan < nChannels; chan++, chanInfoPtr++) {
                /*
                ** Get the transformation matrix for the View platform
                ** associated with this 3D viewing channel.
                ** (This is calculated elsewhere. It is calculated
                ** by pre-multiplying of inverse transf. rather than
                ** post-mult. forward transf.)
                */
                vpGetGlobalTransf(theView->chanList->platform[chan],
                                        (char *)NULL,
                                        channelViewTransf, False, False);
                .
                .
                .

                /*
                ** Set Performer's channel view transf. matrix.
                ** Change coord. system from GL to SGI Performer coords.:
                ** from RHS with +X right, +Y up, and +Z backwards
                ** to RHS system with +X right, +Y forwards, and +Z up.
                */
                matMultiply(coordTransfInv, channelViewTransf,
                                                channelViewTransf);
                pfChanViewMat((*chanInfoPtr)->pfchannel, channelViewTransf);
                .
                .
                .
        }
        .
        .
        .

        return;
}


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:50:06 PDT

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