[vtkusers] problems with setting camera distance

Liam Kurmos quantum.leaf at googlemail.com
Mon Jan 25 11:23:26 EST 2010


Hi,

I'm still getting to grips with vtk. Building up a picture of how to
use it from the books and examples.

I have a vtkImageData which I initialise with gaussian data, and
render a contour taken with marching cubes. I've been using
vtkCamera.Azimuth() and vtkCamera.Elevevation() to control the viewing
angle.

Now i want to control the distance from the focal point. From the
doxygen i thought this would be simple using setDistance/Dolly but i
can't get it to work as expected.

I've been experimenting with code like:

ren1->AddActor(contourActor);
    vtkCamera* cam1=vtkCamera::New();
    cam1->SetFocalPoint(0,0,0);
    cam1->SetDistance(10);
    cam1->Dolly(-30);
    ren1->SetActiveCamera(cam1);
    //ren1->ResetCamera();
    cam1->SetDistance(10);
    //ren1->GetActiveCamera()->Dolly(200);
    cout<<"dist is "<<ren1->GetActiveCamera()->GetDistance()<<endl;


I find that SetDistance changes the value report by GetDistance, but
not what is rendered on the screen. Doing a negative Dolly has no
effect, Doing a positive dolly affect the reported distance but not
what is rendered on the screen. Doing a ResetCamera() affects the
reported distance and changes what is rendered on the screen.

I've started using SetPosition() and this seems to work as i would expect.

Is VtkCamera::setDistance() broken, or am I using it incorrectly?

regards,

Liam



More information about the vtkusers mailing list