[vtkusers] Placement of actors in world coordinate system wierdness

Bill Lorensen bill.lorensen at gmail.com
Thu Aug 10 15:11:04 EDT 2017


Looks OK to me. Have your printed the startpos elements?


On Thu, Aug 10, 2017 at 2:59 PM, Mads M. Hansen <madsmh at gmail.com> wrote:
> 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
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
Unpaid intern in BillsBasement at noware dot com


More information about the vtkusers mailing list