8

我有这段代码在 WPF Viewport3D 中绘制一个立方体:

        <Viewport3D Name="viewport3D1">
            <Viewport3D.Camera>
                <PerspectiveCamera x:Name="camMain" Position="6 5 4" LookDirection="-6 -5 -4">
                </PerspectiveCamera>
            </Viewport3D.Camera>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <DirectionalLight x:Name="dirLightMain" Direction="-1,-1,-1">
                    </DirectionalLight>
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <GeometryModel3D>
                        <GeometryModel3D.Geometry>
                            <MeshGeometry3D x:Name="meshMain"
                                Positions="0 0 0  1 0 0  0 1 0  1 1 0  0 0 1  1 0 1  0 1 1  1 1 1"
                                TriangleIndices="2 3 1  2 1 0  7 1 3  7 5 1  6 5 7  6 4 5  6 2 0  2 0 4  2 7 3  2 6 7  0 1 5  0 5 4">
                            </MeshGeometry3D>
                        </GeometryModel3D.Geometry>
                        <GeometryModel3D.Material>
                            <DiffuseMaterial x:Name="matDiffuseMain">
                                <DiffuseMaterial.Brush>
                                    <SolidColorBrush Color="Red"/>
                                </DiffuseMaterial.Brush>
                            </DiffuseMaterial>
                        </GeometryModel3D.Material>
                    </GeometryModel3D>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>

这给出了以下结果:

如何使渲染为线框?

4

2 回答 2

9

查看LinesVisual3D(免费)Helix 3D 工具包(https://github.com/helix-toolkit)中的课程。这是“屏幕空间线”的一个版本,可让您像示例一样绘制线框。

如果您正在做任何 WPF 3D 工作,我强烈推荐Helix 3D Toolkit 。

于 2012-06-08T09:42:47.137 回答
0

也许这可以帮助:

                <GeometryModel3D.Material>
                    <DiffuseMaterial x:Name="matDiffuseMain">
                        <DiffuseMaterial.Brush>
                            <SolidColorBrush Color="Red" Opacity="0.5" />
                        </DiffuseMaterial.Brush>
                    </DiffuseMaterial>
                </GeometryModel3D.Material>
                <GeometryModel3D.BackMaterial>
                    <DiffuseMaterial x:Name="matDiffuseMain2">
                        <DiffuseMaterial.Brush>
                            <SolidColorBrush Color="Red" Opacity="0.5" />
                        </DiffuseMaterial.Brush>
                    </DiffuseMaterial>
                </GeometryModel3D.BackMaterial>
于 2012-06-08T08:51:16.867 回答