I need to reset my 3D camera position in a WPF 3D viewport. I'm using the trackball decorator from 3Dtools. Hacking around I've found I can clear the camera's transformations using :
Transform3DGroup group = camera.Transform as Transform3DGroup;
group.Children.Clear();
However this breaks the trackball as I'm guessing the camera no longer has a transform matrix. Is there a way I can get the camera back to where I created it, ie: can I manually reposition the camera and have the trackball still work ?
Edit :
I create a perspective camera and add it to a 3D Viewport using the following code :
perspectiveCamera.Position = new Point3D(sceneSize.X * 4 ,
sceneSize.Y ,
sceneSize.Z * (-4));
CameraLookAt = new Point3D(0, (sceneSize.Y / 2), 0);
perspectiveCamera.LookDirection = new Vector3D (
CameraLookAt.X - perspectiveCamera.Position.X,
CameraLookAt.Y - perspectiveCamera.Position.Y,
CameraLookAt.Z - perspectiveCamera.Position.Z);
perspectiveCamera.FieldOfView = 24;
Viewport_3D.Camera = perspectiveCamera;
The viewport has a Trackball decorator, which allows the user to rotate the camera around the scene. However I want a function to reset the camera back to it's original position, but I can't find a way to directly set it's position once created.
首先,您应该删除相机上使用的动画,可以通过方法camera.ApplyAnimationClock(ProjectCamera.PositionProperty,null)进行操作,然后将原始值分配给相机
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.