繁体   English   中英

如何在 wpf helix 工具包中更改默认相机方向

[英]how can i change default camera direction in wpf helix toolkit

<Grid>
    <hx:HelixViewport3D ZoomExtentsWhenLoaded="True" >
        <hx:SunLight/>
        <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>
        <ModelVisual3D>
            <ModelVisual3D.Content>
                <GeometryModel3D>
                    <GeometryModel3D.Geometry>
                        <MeshGeometry3D x:Name="aaa"
                    Positions="1 1 1  2 1 1  1 2 1  2 2 1  1 1 2  2 1 2  1 2 2  2 2 2"
                    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="sa">
                            <DiffuseMaterial.Brush>
                                <SolidColorBrush Color="Red"/>
                            </DiffuseMaterial.Brush>
                        </DiffuseMaterial>
                    </GeometryModel3D.Material>
                </GeometryModel3D>
            </ModelVisual3D.Content>
        </ModelVisual3D>
        <hx:GridLinesVisual3D Width="8" Length="8" MinorDistance="1" MajorDistance="1" Thickness="0.01"/>
    </hx:HelixViewport3D>
</Grid>

当你打开程序时,我怎样才能正常地做到这一点,你让相机从顶部看?

在 helix 工具包中指向你。

所以用户可以从顶部看到 3d 场景,如果需要可以移动

我将逐步向您展示。

将此ShowCameraInfo="True"添加到您的HelixViewport3D

    <hx:HelixViewport3D ShowCameraInfo="True">
        ...
    </hx:HelixViewport3D>

然后运行程序并单击右上角的 position 框的上方。 在此处输入图像描述

然后视图将从顶部开始,您将在左角看到相机信息。 将它们保存在某个地方。

在此处输入图像描述

最后我们将把这些值放入你的HelixViewport3D

<hx:HelixViewport3D ...>
    <hx:HelixViewport3D.Camera>
        <PerspectiveCamera Position="0 0 24.285"
                           LookDirection="0 0 -23.285"
                           UpDirection="0 1 0"/>
    </hx:HelixViewport3D.Camera>
    ...
</hx:HelixViewport3D>

它已经完成了!

对于您的示例:

<Grid>
        <hx:HelixViewport3D ZoomExtentsWhenLoaded="True">
            <hx:HelixViewport3D.Camera>
                <PerspectiveCamera Position="0 0 24.285"
                                   LookDirection="0 0 -23.285"
                                   UpDirection="0 1 0"/>
            </hx:HelixViewport3D.Camera>
            <hx:SunLight/>
            <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>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <GeometryModel3D>
                        <GeometryModel3D.Geometry>
                            <MeshGeometry3D x:Name="aaa"
                    Positions="1 1 1  2 1 1  1 2 1  2 2 1  1 1 2  2 1 2  1 2 2  2 2 2"
                    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="sa">
                                <DiffuseMaterial.Brush>
                                    <SolidColorBrush Color="Red"/>
                                </DiffuseMaterial.Brush>
                            </DiffuseMaterial>
                        </GeometryModel3D.Material>
                    </GeometryModel3D>
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <hx:GridLinesVisual3D Width="8" Length="8" MinorDistance="1" MajorDistance="1" Thickness="0.01"/>
        </hx:HelixViewport3D>
    </Grid>

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM