询问者
关于wpf3D 透明显示的问题

问题
-
<age x:Class="wpf_vislink.TestPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="Six Squares in Search of a Cube"
Title="Six Squares in Search of a Cube">
<Viewport3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
<!-- Rectangle One. -->
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="-0.5 -0.5 0, -0.5 0.5 0, 0.5 -0.5 0, 0.5 0.5 0"
TriangleIndices="0 2 1, 1 2 3" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Blue" Opacity="0.5"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<!-- Rectangle Two. -->
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="0 0 -1, 0 1 -1, 1 0 -1, 1 1 -1"
TriangleIndices="0 2 1, 1 2 3" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Green" Opacity="0.5" />
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<!-- Light source. -->
<AmbientLight Color="White" />
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<!-- Camera. -->
<Viewport3D.Camera>
<OrthographicCamera Position="0 0 3"
LookDirection="0 0 -1"
UpDirection="0 1 0"
/>
</Viewport3D.Camera>
</Viewport3D>
</Page>
效果如下:
http://lh5.ggpht.com/Phang.Aaron/SPB3jiiexiI/AAAAAAAAAJo/Hwg9C_x15h8/3.jpg
可是我期望的是能够透过蓝矩形看到绿矩形,但结果是看不到。如果将蓝矩形放的比绿矩形远(z值设为-2),则可以通过绿矩形看到蓝矩形,
效果如下:
http://lh6.ggpht.com/Phang.Aaron/SPBzbnfzzKI/AAAAAAAAAJI/QPbXqFc2XDI/4.jpg
这是为什么?除了Opacity之外有没有其它属性可以设置的?
I appreciate your answer. Thanks very much!
全部回复
-
Has your problem been solved? In the all children of viewport3d, the former element could be seen through the latter element, however, the latter one cannot been seen through the former one. So if you reorder the children of viewport3d after every adjustment, you could make it.
If you have better solution, please reply to me.
-
解决方法是有的,我以前下过一个3D的例子,当时没有碰到这样的问题.
后来碰到了,问Bob Bao,他发了个地址给我.
发现就是我以前下的例子
这里是地址http://www.codeproject.com/Articles/25030/Animating-Interactive-2D-Elements-in-a-3D-Panel
感谢Bob Bao
Hero