0

Camera rotates unmeant around z axis for 180 degrees.

Anonymous 10 years ago 0
This discussion was imported from CodePlex

31337 wrote at 2012-10-18 14:06:

Hi,

I have the following function 

  private void MoveToDoubleClick(Point3D doubleClickedTarget)
        {
            doubleClickedTarget.Z += 10;
            CameraHelper.AnimateTo(myCamera, doubleClickedTarget, new   Vector3D(0, 0, -1), myCamera.UpDirection, 1000);
}

 

And only in some situationes the camera rotates for 180 degrees around the z axis. How is this possible? Thanks for help in advance.


31337 wrote at 2012-10-22 09:49:

Changed it to 

   private void animateToTargetPosition(Point3D hitPoint)
        {
            #region Code from Helix lib
            Vector3D newUpDirection = _cam.UpDirection;
            Vector3D newRightVector = Vector3D.CrossProduct(_cam.LookDirection, _cam.UpDirection);
            newRightVector.Normalize();
            Vector3D modUpDir = Vector3D.CrossProduct(newRightVector, _cam.LookDirection);
            modUpDir.Normalize();
            #endregion
            double distance = GeoMath.GeoMathUtils.LineDistance3D(_cam.Position, hitPoint);
            hitPoint.Z += 10;
            CameraHelper.AnimateTo(_cam, hitPoint, new Vector3D(0, 0, -1), modUpDir, StaticUtils.GetAnimationTime(distance));
           
        }