Hi,
I’m facing the following issue:in the case of vtkPolyDataMapper::ScalarVisibilityOn , setting the color value for BackfaceProperty of vtkActor does not work as expected. How can this be resolved?
Hello,
Please, post:
- The code you’re using;
- Post a picture of what you’re getting and describe in details or illustrate what you need to achieve.
This way you increase the likelyhood of getting an answer.
best,
PC
Hi Paulo,
Thank you for your suggestion.
This is an example code:
vtkNew plyReader;
plyReader->SetFileName(“file/to/model.ply”);
plyReader->Update();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputData(plyReader->GetOutput());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkProperty> backFace;
backFace->SetColor(.5,.6,.7);
actor->SetBackfaceProperty(backFace);
vtkNew<vtkRenderer> render;
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(render);
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(renderWindow);
vtkNew<vtkInteractorStyleTrackballCamera> style;
interactor->SetInteractorStyle(style);
render->AddActor(actor);
render->SetBackground(.8,.8,.8);
interactor->Start();
In the example above, the backface property of the actor is set, but it did not take effect. The model’s backside is still rendered according to the color in the PLY file. See the image below for the result:
Is this a problem with VTK or did I miss any crucial points in my code?
G’day,
Try calling TwoSidedLightingOff()
on the renderer before rendering.
regards,
PC
Hi Paulo,
Thank you for providing the solution approach, but the explanation of the method TwoSidedLightingOff() is as follows:“If two-sided lighting is off, then only the side of the surface facing the light(s) will be lit, and the other side dark. If two-sided lighting on, both sides of the surface will be lit.”
When the model rotates to the back, it is actually still facing the light, so the back side remains in the same situation as shown in the illustration above.