关键代码:
//改变polydata的颜色
vtkSmartPointer<vtkElevationFilter> colorIt =
vtkSmartPointer<vtkElevationFilter>::New();
colorIt->SetInputConnection(sphere->GetOutputPort());
colorIt->SetLowPoint(0,0,-1);
colorIt->SetHighPoint(0,0,1);
//延顶点法向量生成圆锥
vtkNew<vtkGlyph3D> glyph;
glyph->SetInputConnection(colorIt->GetOutputPort());
glyph->SetSourceConnection(cone->GetOutputPort());
glyph->SetVectorModeToUseNormal();
glyph->SetScaleModeToScaleByVector();
glyph->SetColorModeToColorByScale ();
glyph->SetScaleFactor(0.25);
//显示线及平滑处理
sphereActor->GetProperty()->SetEdgeVisibility(true);
sphereActor->GetProperty()->SetInterpolationToPhong();
demo:
https://lorensen.github.io/VTKExamples/site/Cxx/Rendering/Mace/
https://lorensen.github.io/VTKExamples/site/Cxx/Rendering/FlatVersusGouraud/
https://lorensen.github.io/VTKExamples/site/Cxx/Rendering/ColoredSphere/
https://lorensen.github.io/VTKExamples/site/Cxx/Rendering/CameraBlur/