2010-05-31 43 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