■ Viewport3D 클래스를 사용하는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<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 클래스 사용하기" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <Viewport3D> <Viewport3D.Camera> <PerspectiveCamera Position="0 0 5" /> </Viewport3D.Camera> <Viewport2DVisual3D> <Viewport2DVisual3D.Transform> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Angle="30" Axis="0 1 0" /> </RotateTransform3D.Rotation> </RotateTransform3D> </Viewport2DVisual3D.Transform> <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>테스트 3D</Button> </Viewport2DVisual3D> <ModelVisual3D> <ModelVisual3D.Content> <DirectionalLight Color="#ffffffff" Direction="0 0 -1" /> </ModelVisual3D.Content> </ModelVisual3D> </Viewport3D> </Grid> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
using System.Windows; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); } #endregion } } |