Helix工具包旋转3D模型
我是WPF的新手,我正在尝试创建一个显示3D模型的程序(保存在我的计算机上)并根据按钮点击进行旋转。 我想有三个按钮来围绕x,y和z轴旋转对象。 我有代码显示模型,但我不确定如何使用按钮点击旋转它。 这是我到目前为止所拥有的;
C#
public MainWindow() { InitializeComponent(); ModelVisual3D device3D = new ModelVisual3D(); device3D.Content = Display3d(MODEL_PATH); // Add to view port viewPort3d.Children.Add(device3D); } private Model3D Display3d(string model) { Model3D device = null; try { //Adding a gesture here viewPort3d.RotateGesture = new MouseGesture(MouseAction.LeftClick); //Import 3D model file ModelImporter import = new ModelImporter(); //Load the 3D model file device = import.Load(model); } catch (Exception e) { // Handle exception in case can not find the 3D model file MessageBox.Show("Exception Error : " + e.StackTrace); } return device; } private void buttonX_Click(object sender, RoutedEventArgs e) { //not sure what to put in here }
XAML
我目前正在使用Helix工具包,但如果有更简单的方法,请告诉我。
根据你的问题的措辞,我假设你想要旋转模型而不是相机,在这种情况下将device3D
保存device3D
某处并执行此操作:
上述就是C#学习教程:Helix工具包旋转3D模型分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
private void buttonX_Click(object sender, RoutedEventArgs e) { var axis = new Vector3D(0, 0, 1); var angle = 10; var matrix = device3D.Transform.Value; matrix.Rotate(new Quaternion(axis, angle)); device3D.Transform = new MatrixTransform3D(matrix); }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1010048.html