2. 確認已安裝NuGet Package
3.參考處加入 Helix Toolkit
4. xaml 檔 加入ns
<Window x:Class="AInstallEx1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helix="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid>
<helix:HelixViewport3D x:Name="view1" Background="DarkGreen" IsHeadLightEnabled="True">
<!--<helix:DefaultLightsVisual3D/>-->
</helix:HelixViewport3D>
</Grid>
</Grid>
</Window>
5. C# 加入
using HelixToolkit.Wpf;
using System.Windows.Media.Media3D;
namespace AInstallEx1
{
/// <summary>
/// MainWindow.xaml 的互動邏輯
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
MeshBuilder mb = new MeshBuilder();
mb.AddBox(new Point3D(0, 0, 0), 2, 2, 2);
view1.Children.Add(
new ModelVisual3D { Content = new GeometryModel3D { Geometry = mb.ToMesh(), Material = Materials.White } }
);
}
}
}
6. Done!
沒有留言:
張貼留言