2010-05-31 165 views
1

我想在Viewport3D中呈现多达300个字符串(只是几个字) - 快!我想在不同的Z位置渲染它们,并流畅地放大和缩小。WPF - 在Viewport3D中渲染文本

到目前为止,我还发现了呈现在文本的Viewport3D的方式:

  • 放在一个TextBlock在Viewport2DVisual3D。
  • This guy's PlanarText类。
  • 同一个人的SolidText类。
  • 创建我自己的2D面板并对齐它上面的TextBlocks。每次更新相机位置时调用InvalidateArrange()。

所有这些都非常缓慢,远远超出了流畅的变焦,即使只有10根弦。 有没有人有这个方便的解决方案?有可能在不等待秒的情况下渲染Viewport3D中的文本!

回答

1

您是否尝试过使用VisualBrush作为每个GeometryModel3D的材质?

事情是这样的:

<GeometryModel3D> 
    <GeometryModel3D.Geometry> 
    <MeshGeometry3D Positions="0,0,0 1,0,0 1,1,0 0,1,0" TriangleIndices="0,1,2 2,3,0" /> 
    </GeometryModel3D.Geometry> 
    <GeometryModel3D.Material> 
    <VisualBrush ...> 
     <VisualBrush.Visual> 
     <TextBlock Text="Some text here" /> 
     </VisualBrush.Visual> 
    </VisualBrush> 
    </GeometryModel3D.Material> 
</GeometryModel3D> 
+1

这个昨天刚试过 - 我猜我发现了性能问题的原因现在:如果文本具有背景色,所以对象的形状为矩形,一切正常快速。但只要我想通过文本看到其他对象(不透明,但通过hOles),它就会变慢。 – eWolf 2010-06-10 12:52:12