VTK在三维空间内写字

VTK在三维空间内写字

1. 最简单的一种方法:

使用 vtkBillboardTextActor3D 类,直接构建Actor,调整好属性添加到Render中即可;
下面是参数设置供大家参考:
	vtkNew<vtkBillboardTextActor3D> textActor;

	textActor->SetInput("6  6  6  6");

	textActor->SetPosition(400, 400, 400);

	textActor->GetTextProperty()->SetFontSize(20);
	
	textActor->GetTextProperty()->SetColor(1,1,0);
	
	//设置居中显示
	textActor->GetTextProperty()->SetJustificationToCentered();
	
	_render->AddActor(textActor);

2.vtkTextActor 类创建文本Actor;
直接上码;

	vtkNew<vtkTextActor> textActor;
	textActor->SetTextScaleModeToProp();
	textActor->SetDisplayPosition(90, 50);//Position
	textActor->SetInput("lala");
	textActor->GetActualPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
	textActor->GetPosition2Coordinate()->SetValue(0.6, 0.1);


	textActor->GetTextProperty()->SetFontSize(18);
	textActor->GetTextProperty()->SetFontFamilyToArial();
	textActor->GetTextProperty()->SetJustificationToCentered();
	textActor->GetTextProperty()->BoldOn();
	textActor->GetTextProperty()->ItalicOn();
	textActor->GetTextProperty()->ShadowOn();
	textActor->GetTextProperty()->SetColor(0, 0, 1);

你可能感兴趣的:(VTK,c++,图形渲染)