Re: Gettting the modelview matrix from precull callback
Hansong Zhang (zhangh++at++cs.unc.edu)
Fri, 5 Sep 1997 10:30:53 -0400 (EDT)
>
> I need to compute the modelview matrix that performer loads for
> rendering a given geode. Here is what I am trying (and failing to
> get the right matrix):
>
> Inside the precull-callback:
>
> 1. Get the view matrix for the channel: pfChannel::getViewMat(myPfVMat);
>
> 2. Collect the transformations from DCS's/SCS's along the path to the
> geode: pfTraverser::getMat(myCMat);
> 3. myPfVMat->preMult(myCMat);
> 4. Transform to OpenGL system by a 90-degree rotation about x-axis and
> then a transpose:
> myTmpMat.preRot(90, 1,0,0, myPfVMat) ;
> myOglMat.transpose(myTmpMat) ;
>
> Now, I compare this with the OpenGL modelview matrix that I get by doing
> glGetFloatv(GL_MODELVIEW_MATRIX, ...) in the post/pre-draw callbacks for
> the same node, I get a different matrix!!
>
> Does someone see what's going wrong here?
>
> Some additional info that might be relevant:
>
> 1. I have tried minor variations of the above such as postRot(..) in place of
> preRot(...) etc. :-)
>
> 2. I need to get this in the precull-callback because for my application,
> based on the nature of the modelview matrix, at times I cull the geode.
> So obtaining the MODELVIEW matrix from the draw callbacks is not an
> option.
>
> Thanks,
>
> - shankar swamy
The viewing matrix you get from pfChannel::getViewMat() is the
inverse of a "normal" viewmat. That is, it tranforms from eye coord
to world coord. To transform the performer viewing matrix (viewMat)
into an OpenGL one (glViewMat), you could:
glViewMat.invertAff(viewMat);
glViewMat.postRot(glViewMat, -90, 1, 0, 0);
Hansong
-------------------------------------------------------------
Hansong Zhang \ zhangh++at++cs.unc.edu
Walkthrough Group \ http://www.cs.unc.edu/~zhangh
Department of Computer Science \ (919)962-1835 (O)
UNC-Chapel Hill \ (919)914-0761 (H)
-------------------------------------------------------------
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2
on Mon Aug 10 1998 - 17:55:53 PDT