[vtkusers] How's the Projection Transform Matrix computed in VTK?

Pato Sandana patricio.sandana at synopsys.com
Mon Oct 22 14:33:15 EDT 2018


Hi maskjp,

What I found so far, is that for some reason the depth buffer is filled with 1.0s and not 0.0s as one could expect. I asked about that before and I got no answer.

To get the correct projection matrix, you can use this in C++, assuming a vtkRenderer* renderer

vtkCamera* camera = renderer->GetActiveCamera();
vtkSmartPointer<vtkMatrix4x4> projection  = vtkSmartPointer<vtkMatrix4x4>::New();
projection->DeepCopy( camera->GetCompositeProjectionTransformMatrix( renderer->GetTiledAspectRation(), 0.0, 1.0) ); // This maps the z-buffer from 0.0 to 1.0.

I found this usage in classes like vtkRenderer and vtkVolume source code. Hope that helps.

Cheers,
Pato



More information about the vtkusers mailing list