How do you rotate a 3D model using HelixToolkit?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 00:29:28

问题


I need some help rotating a 3D model in a WPF project on visual studios. I have imported the model in through the use of the helix toolkit. But I can not find any example of how to rotate the 3D model online. I've found some C# and xaml examples but they mainly seem to rotate the camera not the model.


回答1:


WPF 3D Rotation

Create a RotateTransform3D for your GeometryModel3D.Transform




回答2:


I have found it particularly useful to use matrices in order to make tranformations.

In my case, what I noticed was that usually if you apply a transformation such as a RotateTransform3D, and then apply another transformation using your model's '.transform' property, it overrides the last transform. In most cases, you want the new transformation to be applied over the last one.

This is how I make my rotations:

Vector3D axis = new Vector3D (1,0,0) //In case you want to rotate it about the x-axis
Matrix3D transformationMatrix = model.Content.Transform.Value; //Gets the matrix indicating the current transformation value
transformationMatrix.Rotate(new Quaternion(axis, angle)) //Makes a rotation transformation over this matrix
model.Content.Transform = new MatrixTransform3D(transformationMatrix); //Applies the transformation to your model

Don't forget, if you want the model to rotate on it's own center, instead of '.Rotate', use '.RotateAt' like such:

transformationMatrix.RotateAt(new Quaternion(axis, angle), modelCenter); //modelCenter is the Point3D variable indicating the center


来源:https://stackoverflow.com/questions/54889775/how-do-you-rotate-a-3d-model-using-helixtoolkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!