本文主要是介绍VTK Learning Fifteen - 3D Text,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
VTK Learning Fifteen - 3D Text
Description
线性挤压vtkLinearExtrusionFilter
。
Code
#include <vtkSmartPointer.h>
#include <vtkVectorText.h>
#include <vtkLinearExtrusionFilter.h>
#include <vtkTriangleFilter.h>#include <vtkDataSetMapper.h>
#include <vtkActor.h>
#include <vtkProperty.h>
#include <vtkCamera.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>int main(int, char *[])
{// Create vector text polydatavtkSmartPointer<vtkVectorText> vecText =vtkSmartPointer<vtkVectorText>::New();vecText->SetText("Welcome to my blog!");// Apply linear extrusion vtkSmartPointer<vtkLinearExtrusionFilter> extrude =vtkSmartPointer<vtkLinearExtrusionFilter>::New();extrude->SetInputConnection(vecText->GetOutputPort());extrude->SetExtrusionTypeToNormalExtrusion();extrude->SetVector(0, 0, 1);// 沿文字方向挤压extrude->SetScaleFactor(0.5);// 设置挤压比例//三角化vtkSmartPointer<vtkTriangleFilter> triangleFilter =vtkSmartPointer<vtkTriangleFilter>::New();triangleFilter->SetInputConnection(extrude->GetOutputPort());vtkSmartPointer<vtkDataSetMapper> mapper =vtkSmartPointer<vtkDataSetMapper>::New();mapper->SetInputConnection(triangleFilter->GetOutputPort());vtkSmartPointer<vtkActor> actor =vtkSmartPointer<vtkActor>::New();actor->SetMapper(mapper);actor->GetProperty()->SetColor(0.8900, 0.8100, 0.3400);vtkSmartPointer<vtkRenderWindow> renderWindow =vtkSmartPointer<vtkRenderWindow>::New();vtkSmartPointer<vtkRenderer> renderer =vtkSmartPointer<vtkRenderer>::New();renderer->SetBackground(.4, .5, .7);renderWindow->AddRenderer(renderer);renderer->AddActor(actor);renderer->ResetCamera();// Generate an interesting viewrenderer->ResetCamera();renderer->GetActiveCamera()->Azimuth(30);renderer->GetActiveCamera()->Elevation(30);renderer->GetActiveCamera()->Dolly(1.0);renderer->ResetCameraClippingRange();vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =vtkSmartPointer<vtkRenderWindowInteractor>::New();renderWindowInteractor->SetRenderWindow(renderWindow);renderWindow->Render();renderWindowInteractor->Start();return EXIT_SUCCESS;
}
Result
这篇关于VTK Learning Fifteen - 3D Text的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!