[vtkusers] Questions about vtkWarpLens, Cameras, and Interactors

David Hope ARA/SED dhope at ara.com
Wed Dec 5 17:11:23 EST 2012


Can anyone help me with vtkWarpLens?

What I am trying to do is implement a distortion pattern on the camera to modify how the data is seen.

Here is the meat of the code (it's in C#, I'm using Activis)

            vtkPolyData pd = vtkPolyData.New();

            CreateFromFile(pd); // this creates a triangle representation of a height field

            double [] sr = pd.GetScalarRange();

            vtkLookupTable lut = vtkLookupTable.New();
            lut.SetNumberOfColors(16);
            lut.SetHueRange(0.667, 0.0);
            lut.Build();

            wl = vtkWarpLens.New();
            wl.SetInputConnection(pd.GetProducerPort());
            wl.SetPrincipalPoint(0.5, 0.5);
            wl.SetFormatWidth(1);
            wl.SetFormatHeight(1);
            wl.SetImageWidth(1000);
            wl.SetImageHeight(1000);
            wl.SetK1(0.01307);
            wl.SetK2(0.0003102);
            wl.SetP1(1.953e-005);
            wl.SetP2(-9.655e-005);


            vtkDataSetMapper dsmDistorted = vtkDataSetMapper.New();
            dsmDistorted.SetInputConnection(wl.GetOutputPort());
            dsmDistorted.SetLookupTable(lut);
            dsmDistorted.SetScalarRange(sr[0]+20, sr[1]);

            vtkActor dsDistortedActor = vtkActor.New();
            dsDistortedActor.SetMapper(dsmDistorted);

            m_renDistorted.AddActor(dsDistortedActor);
            m_renWin.SetDesiredUpdateRate(0);
            m_renWin.Render();
            m_renDistorted.ResetCamera();

So, basically, I am creating a terrain representation using polygons, passing it through the warplens, passing that through a dataset mapper to give it pretty colors, then displaying it.

The issue is that the "warp" appears to be static to the terrain, not to the camera. I'm pretty new to VTK, so it's possible that I don't understand how the Interactor and the Camera are related.

Can someone help?

Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121205/004befe6/attachment.htm>


More information about the vtkusers mailing list