我在 C# wpf 中有一个 3D 模型,每次使用时间跨度旋转 360 度旋转 5 度。但我希望能够查看它的坐标,就像在我的窗口窗体上查看 point3DX、point3DY、point3DZ 一样。
有什么想法我该怎么做?
这是我设置模型初始位置和旋转的功能
private void SetViewPosition()
{
Vector3D vAxis = new Vector3D(0, 0, 1);
///<summary>
///R = AxisAngleRotation()
///vAxis = Vector length
///-15 = Angle
///</summary>
AxisAngleRotation3D myRotation = new AxisAngleRotation3D(vAxis, -15);
RotateTransform3D myRotationTransform = new RotateTransform3D(myRotation);
gCamWC = myRotationTransform.Value;
gCamWC.M14 = -50;
gCamWC.M24 = 10;
gCamWC.M34 = 0;
Point3D camPosition = new Point3D(gCamWC.M14, gCamWC.M24, gCamWC.M34);
Vector3D startLookAt = new Vector3D(gCamWC.M11, gCamWC.M21, gCamWC.M31);//VLook = 1st Column//DT=[1,0,0]//Vertical
Vector3D startLookUp = new Vector3D(gCamWC.M13, gCamWC.M23, gCamWC.M33);//VUp = 2nd Column//DT = [0,0,1]//Vertical
DrawingControl.Viewport.SetView(camPosition, startLookAt, startLookUp, 0);//=DR -> How the camera should move
}
//STEP 4
private void RotatingModelAround(object sender, EventArgs e)
{
Vector3D vAxis = new Vector3D(gCamWC.M31, gCamWC.M32, gCamWC.M33); //Rotate about world z-axis.
AxisAngleRotation3D myRotation = new AxisAngleRotation3D(vAxis, 5);
RotateTransform3D myRotationTransform = new RotateTransform3D(myRotation);
Matrix3D doTranslation = new Matrix3D();
doTranslation.M24 = 3; // Offset along camera y-axis. Presumed to be parallel to world plane.
gCamWC.Append(myRotationTransform.Value);
gCamWC.Append(doTranslation);
Point3D camPosition = new Point3D(gCamWC.M14, gCamWC.M24, gCamWC.M34);
Vector3D camLookAt = new Vector3D(gCamWC.M11, gCamWC.M21, gCamWC.M31);
Vector3D camLookUp = new Vector3D(gCamWC.M13, gCamWC.M23, gCamWC.M33);
DrawingControl.Viewport.SetView(camPosition, camLookAt, camLookUp, 0);
}
这就是他们的名字
public XplorerMainWindow()
{
InitializeComponent();
Closed += XplorerMainWindow_Closed;
//STEP 1
Loaded += XplorerMainWindow_Loaded;
Closing += XplorerMainWindow_Closing;
DrawingControl.UserModeledDimensionChangedEvent += DrawingControl_MeasureChangedEvent;
InitFromSettings();
RefreshRecentFiles();
UserFilters = new FilterValues();//COBie Class filters, set to initial defaults
CoBieTemplate = UkTemplate;
if (Settings.Default.PluginStartupLoad)
RefreshPlugins();
//STEP 4
// Add Dispatcer Time so the Rotation will be repeated
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += RotatingModelAround;
//dispatcherTimer.Tick += QRotateModel;
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0,300);//(d,h,m,s,mil.s.)
dispatcherTimer.Start();
}
例如根据我的项目,我想要这部分代码:
Point3D camPosition = new Point3D(gCamWC.M14, gCamWC.M24, gCamWC.M34);
Vector3D camLookAt = new Vector3D(gCamWC.M11, gCamWC.M21, gCamWC.M31);
Vector3D camLookUp = new Vector3D(gCamWC.M13, gCamWC.M23, gCamWC.M33);
...要显示在我的窗口窗体上,例如:
摄像头位置:(-50.00, 10.00, 0.00) 摄像头注视:(1.00, 0.00, 0.00) 摄像头注视:(0.00, 0.00, 1.00)
并且相机每旋转5度,改变的数值就会显示在窗体上