質問

<Window x:Class="Viewport2DVisual3DExample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Button on 3D"  
    WindowStyle="None"
    Background="{x:Null}"
    Foreground="{x:Null}"
    AllowsTransparency="True"
    >

    <Viewport3D>
        <Viewport3D.Camera>
            <PerspectiveCamera Position="0, 0, 4"/>
        </Viewport3D.Camera>

        <!-- Front -->
        <Viewport2DVisual3D>
            <!-- Give the plane a slight rotation -->
            <Viewport2DVisual3D.Transform>
                <RotateTransform3D>
                    <RotateTransform3D.Rotation>
                        <AxisAngleRotation3D x:Name="frontTransform" Angle="0" Axis="0, 1, 0" />
                    </RotateTransform3D.Rotation>
                </RotateTransform3D>
            </Viewport2DVisual3D.Transform>

            <!-- The Geometry, Material, and Visual for the Viewport2DVisual3D -->
            <Viewport2DVisual3D.Geometry>
                <MeshGeometry3D Positions="-1,1,0 -1,-1,0 1,-1,0 1,1,0"
                                TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>
            </Viewport2DVisual3D.Geometry>

            <Viewport2DVisual3D.Material>
                <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/>
            </Viewport2DVisual3D.Material>

            <!-- Here Here Here Here Here  -->
            <Image Source="i:\\tempa\\tm.png" Width="534" Height="458" />

    </Viewport2DVisual3D>

        <!-- Back -->
        <Viewport2DVisual3D>
            <!-- Give the plane a slight rotation -->
            <Viewport2DVisual3D.Transform>
                <RotateTransform3D >
                    <RotateTransform3D.Rotation>
                        <AxisAngleRotation3D x:Name="backTransform" Angle="180" Axis="0, 1, 0" />
                    </RotateTransform3D.Rotation>
                </RotateTransform3D>
            </Viewport2DVisual3D.Transform>

            <!-- The Geometry, Material, and Visual for the Viewport2DVisual3D -->
            <Viewport2DVisual3D.Geometry>
                <MeshGeometry3D Positions="-1,1,0 -1,-1,0 1,-1,0 1,1,0"
                                TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>
            </Viewport2DVisual3D.Geometry>

            <Viewport2DVisual3D.Material>
                <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/>
            </Viewport2DVisual3D.Material>

            <Button Name="btnBack">Back</Button>
        </Viewport2DVisual3D>

        <ModelVisual3D>
            <ModelVisual3D.Content>
                <DirectionalLight Color="#FFFFFFFF" Direction="0,0,-1"/>
            </ModelVisual3D.Content>
        </ModelVisual3D>

    </Viewport3D>

Viewport3dを使用して2サイドウィンドウを構築しようとしています。しかし、その後、私はサイズについていくつかの問題を抱えていました。

                <!-- Here Here Here Here Here  -->
            <Image Source="i:\\tempa\\tm.png" Width="534" Height="458" />

この画像をソース画像とまったく同じサイズにしたいと思います。

指定された値も「自動」も機能しません。

どうすれば欲しいものを手に入れることができますか?

役に立ちましたか?

解決

私の3Dの知識は限られており、誰かがおそらくこれにもっとよく答えることができますが、3D環境では、オブジェクトのサイズは多くのものに依存しています。そのオブジェクト、ビューポートサイズ、そしておそらく私が忘れている他のものに適用されます。 3Dエンジンは、ものをレンダリングするときにすべてのものを考慮に入れます。画像のサイズを設定するのは、1つの部分にすぎません。

カメラの位置をいじったり、画像にscaletransformを追加したりしてみてください。

他のヒント

あなたが探しているのはです カメラの投影マトリックス. 。そのマトリックスは、3Dポイントを2Dポイントに変換します。したがって、Meshgeometry3Dの3D座標を渡すことにより、2D座標とサイズを見つけることができます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top