[vtkusers] Placement of actors in world coordinate system wierdness

Mads M. Hansen madsmh at gmail.com
Thu Aug 10 14:59:01 EDT 2017


Hello, I am attempting to placed number of actors (spheres) at various
positions throughout the scene with the following routine

for (int i = 0; i < radii.size(); ++i) {
        vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
        sphereSource->SetRadius(radii[i]);
        sphereSource->SetPhiResolution(100);
        sphereSource->SetThetaResolution(100);
        sphereSource->Update();

        vtkSmartPointer<vtkPolyDataMapper> sphereMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
        sphereMapper->SetInputConnection(sphereSource->GetOutputPort());

        vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
        actor->SetPosition(start_pos[i].x(), start_pos[i].y(),
start_pos[i].z());
        actor->SetMapper(sphereMapper);
        actor->GetProperty()->SetInterpolationToFlat();
        actor->GetProperty()->SetFrontfaceCulling(true);

        actors.push_back(actor);

    }

//Set up renderer
    vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();


    // Create new camera
    vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
    renderer->SetActiveCamera(camera);

    for (int j = 0; j < radii.size(); ++j) {
        renderer->AddActor(actors[j]);
    }
//Set up renderer
    vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();


    // Create new camera
    vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
    renderer->SetActiveCamera(camera);

    for (int j = 0; j < radii.size(); ++j) {
        renderer->AddActor(actors[j]);
    }

...

this->ui->widget->GetRenderWindow()->AddRenderer(renderer);
}

But when rendered I get all spheres superimposed on top of each other and
when the camera movies they appear to turn about their individual origins -
which is not the desired outcome, rather that they should be placed at
their respective coordinates in 3D space.

Any help with this would be greatly appreciated

.. Mads
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170810/b87f4899/attachment.html>


More information about the vtkusers mailing list