If I have a sphere that is being rotate by the users mouse, how could I (at any time, say via a button) apply some rotation transformation on the Camera so that a specific spot on the Sphere is facing the User?
Currently I'm implementing a trackball approach that moves the camera around when the user clicks and drags, and I would like to be able to "Pan" to a specific spot on the Sphere, but I dont know how to calculate the required 3D rotation transformation based on the cameras current position.
Any help here would be greatly appreciated.
Thanks, 开发者_StackOverflowMark
I think you need something like this(it's rather simple you just have to know where do want your camera and where to look, the rest will be taken care of by WPF :-) ):
Vector3DAnimation lookAnimation = new Vector3DAnimation(
currentLookDirection, nextLookDirection,
TimeSpan.FromMilliseconds(1000));
Point3DAnimation positionAnimation =
new Point3DAnimation(currentPosition, nextPosition,
TimeSpan.FromMilliseconds(1000));
mainViewport.Camera.BeginAnimation(
PerspectiveCamera.LookDirectionProperty, lookAnimation);
mainViewport.Camera.BeginAnimation(
PerspectiveCamera.PositionProperty, positionAnimation);
精彩评论