VTK里面三维文本显示

来源:互联网 发布:淘宝什么时候打折活动 编辑:程序博客网 时间:2024/05/05 23:49
资料上看到了一种方法,但是不是很通用。如下:
//建立3D 文本,为多边形数据
vtkVectorText *atext =vtkVectorText::New();
atext->SetText("Origin");
//映射文本,注意映射器的类型
vtkPolyDataMapper *textMapper =vtkPolyDataMapper::New();
textMapper->SetInput((vtkPolyData *)atext->GetOutput());
vtkFollower *textActor =vtkFollower::New();
textActor->SetMapper(textMapper);
textActor->SetPosition(0 ,-0.1 , 0);
textActor->SetScale(0.2 ,0.2 , 0.2);
ren1->AddActor( textActor);


自己看vtk自带说明,成功。具体如下:
 vtkTextProperty*pTexProper=vtkTextProperty::New(); //声明文本属性
 pTexProper->SetColor(1 ,1 ,0);
 pTexProper->SetFontSize(18);
 pTexProper->SetFontFamily(0);
 pTexProper->SetJustification(1);
 pTexProper->SetBold(1);
 pTexProper->SetItalic(1);
 pTexProper->SetShadow(1);
 vtkSmartPointer textActor =vtkSmartPointer::New(); //声明3D文本
 textActor->SetInput("hengshui");
 textActor->SetTextProperty(pTexProper);
 textActor->SetPosition(80 ,80 , 5); //设置位置
 textActor->SetScale(0.7 ,0.7 , 0.7); //设置文字大小
 textActor->RotateX(90.0);//沿X轴旋转90度

0 0
原创粉丝点击