첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="800"
    Height="600"
    Title="Viewport3D 엘리먼트 : 컨트롤 3D 회전시키기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"    />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Viewport3D Margin="10">
            <Viewport3D.Camera>
                <PerspectiveCamera Position="0 0 10" />
            </Viewport3D.Camera>
            <Viewport2DVisual3D>
                <Viewport2DVisual3D.Transform>
                    <RotateTransform3D>
                        <RotateTransform3D.Rotation>
                            <AxisAngleRotation3D
                                Angle="{Binding ElementName=Slider, Path=Value}" 
                                Axis="0 1 0" />
                        </RotateTransform3D.Rotation>
                    </RotateTransform3D>
                </Viewport2DVisual3D.Transform>
                <Viewport2DVisual3D.Geometry>
                    <MeshGeometry3D
                        Positions="-2 1 0, -2 -1 0, 2 -1 0, 2 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 
                    Width="100"
                    Height="25"
                    FontSize="12"
                    Content="Rotate 3D" />
            </Viewport2DVisual3D>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <DirectionalLight Direction="0 0 -1" Color="#ffffffff" />
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>
        <StackPanel
            Grid.Row="1"
            Margin="5"
            Orientation="Horizontal">
            <TextBlock>회전</TextBlock>
            <Slider x:Name="Slider"
                Width="300"
                Minimum="-90"
                Maximum="90" />
        </StackPanel>
    </Grid>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요