[vtkusers] PROJECTION & VIEW Matrix from vtkPerspectiveTransform

Karthik Krishnan karthik.krishnan at kitware.com
Tue Feb 22 00:09:39 EST 2011


You can get the projection transform matrix and the view transform matrix
from vtkCamera as a 4x4 matrix. see GetProjectionTransformMatrix(..) and
GetViewTransformMatrix(..). The actual matrix pushed onto the GL_PROJECTION
and GL_MODELVIEW stacks is the transpose of those 4x4 matrices...

You should dig into the code of vtkOpenGLCamera.cxx to look for
correspondance with your OpenGL code, Specifically....

  glMatrixMode( GL_PROJECTION);
  if(usize && vsize)
    {
    matrix->DeepCopy(this->GetProjectionTransformMatrix(
                       aspectModification*usize/vsize, -1,1));
    matrix->Transpose();
    }
  ...
  glLoadMatrixd(matrix->Element[0]);

  ...
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  matrix->DeepCopy(this->GetViewTransformMatrix());
  matrix->Transpose();
  glMultMatrixd(matrix->Element[0]);


--
karthik

On Tue, Feb 22, 2011 at 7:35 AM, Sergio Aguirre <sergio.aguirre at gmail.com>wrote:

> Hi everyone,
>
> I am attempting to implement some specific PROJECTION and VIEW matrices.
>
> Reviewing the vtkCamera class documentation you can call
> getProjectionTransformMatrix, however, this returns a
> vtkPerspectiveTransform class object (vtkTransform for the VIEW matrix).
>
> When debugging single step on a simple example (
> http://vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/Tutorial/Step4/Cxx/Cone4.cxx;h=d6ae8f5a4cd3e0b19328effea5d97883d369efe4;hb=HEAD)
> I was only able to notice the vtkPerspectiveTransform objects but not their
> matrices...
>
> Can anyone suggest how I could interrogate the final PROJECTION and VIEW
> matrix just before the render is actually done?
>
> I'd like to make sure I am setting up everything correctly to some OpenGL
> code I have.
>
> Hope you can help,
>
> Sergio
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110222/736faae9/attachment.htm>


More information about the vtkusers mailing list