public virtual bool ChangeViewpoint(Viewpoint newViewpoint, float speedFactor)
        {
            bool flag = FezMath.IsOrthographic(newViewpoint) != FezMath.IsOrthographic(this.viewpoint);

            if (flag && this.ProjectionTransition)
            {
                return(false);
            }
            this.ProjectionTransition   = flag && (double)speedFactor > 0.0;
            this.radiusBeforeTransition = FezMath.IsOrthographic(this.viewpoint) ? this.current.Radius : this.predefinedViews[this.lastViewpoint].Radius;
            if ((double)speedFactor > 0.0)
            {
                float num = (float)((double)(Math.Abs(FezMath.GetDistance(newViewpoint, this.Viewpoint)) - 1) / 2.0 + 1.0);
                if (newViewpoint == Viewpoint.Perspective || this.Viewpoint == Viewpoint.Perspective)
                {
                    num = 1f;
                }
                Vector3 from = this.current.Direction;
                Vector3 to   = this.predefinedViews[newViewpoint].Direction;
                this.directionTransition = new Vector3SplineInterpolation(TimeSpan.FromSeconds((double)DefaultCameraManager.TransitionSpeed * (double)num * (double)speedFactor), new Vector3[3]
                {
                    from,
                    DefaultCameraManager.GetIntemediateVector(from, to),
                    to
                });
                this.directionTransition.Start();
            }
            if (FezMath.IsOrthographic(this.viewpoint))
            {
                this.current.Direction = -FezMath.ForwardVector(this.viewpoint);
                this.current.Radius    = this.DefaultViewableWidth;
            }
            this.olderViewpoint = this.lastViewpoint;
            this.lastViewpoint  = this.viewpoint;
            this.viewpoint      = newViewpoint;
            Vector3 center = this.Center;

            this.current        = this.predefinedViews[newViewpoint];
            this.current.Center = center;
            if (this.lastViewpoint != Viewpoint.None)
            {
                this.PreViewpointChanged();
                if (!this.ViewTransitionCancelled)
                {
                    this.ViewpointChanged();
                }
            }
            if ((double)speedFactor == 0.0 && !this.ViewTransitionCancelled)
            {
                this.RebuildView();
            }
            bool transitionCancelled = this.ViewTransitionCancelled;

            this.ViewTransitionCancelled = false;
            return(!transitionCancelled);
        }
        public void AlterTransition(Viewpoint newTo)
        {
            Viewpoint rotatedView = FezMath.GetRotatedView(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[0])), FezMath.GetDistance(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[2])), newTo));
            Vector3   from        = this.predefinedViews[rotatedView].Direction;
            Vector3   to          = this.predefinedViews[newTo].Direction;

            this.directionTransition.Points[0] = from;
            this.directionTransition.Points[1] = DefaultCameraManager.GetIntemediateVector(from, to);
            this.directionTransition.Points[2] = to;
            this.current       = this.predefinedViews[newTo];
            this.lastViewpoint = rotatedView;
            this.viewpoint     = newTo;
        }
 public override void Initialize()
 {
     this.InterpolationSpeed = 10f;
     this.ResetViewpoints();
     this.viewpoint = Viewpoint.Right;
     this.current   = this.predefinedViews[Viewpoint.Right];
     this.SnapInterpolation();
     this.GraphicsService.DeviceReset += (EventHandler <EventArgs>) delegate
     {
         this.PixelsPerTrixel = this.pixelsPerTrixel;
         this.RebuildProjection();
     };
 }
 public virtual void ResetViewpoints()
 {
     this.predefinedViews.Clear();
     this.predefinedViews.Add(Viewpoint.Perspective, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, Vector3.One));
     this.predefinedViews.Add(Viewpoint.Front, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, -FezMath.ForwardVector(Viewpoint.Front)));
     this.predefinedViews.Add(Viewpoint.Right, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, -FezMath.ForwardVector(Viewpoint.Right)));
     this.predefinedViews.Add(Viewpoint.Back, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, -FezMath.ForwardVector(Viewpoint.Back)));
     this.predefinedViews.Add(Viewpoint.Left, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, -FezMath.ForwardVector(Viewpoint.Left)));
     if (this.viewpoint == Viewpoint.None)
     {
         return;
     }
     this.current = this.predefinedViews[this.viewpoint];
 }
Beispiel #5
0
 public virtual void ResetViewpoints()
 {
   this.predefinedViews.Clear();
   this.predefinedViews.Add(Viewpoint.Perspective, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, Vector3.One));
   this.predefinedViews.Add(Viewpoint.Front, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, -FezMath.ForwardVector(Viewpoint.Front)));
   this.predefinedViews.Add(Viewpoint.Right, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, -FezMath.ForwardVector(Viewpoint.Right)));
   this.predefinedViews.Add(Viewpoint.Back, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, -FezMath.ForwardVector(Viewpoint.Back)));
   this.predefinedViews.Add(Viewpoint.Left, new DefaultCameraManager.PredefinedView(Vector3.Zero, this.defaultViewableWidth, -FezMath.ForwardVector(Viewpoint.Left)));
   if (this.viewpoint == Viewpoint.None)
     return;
   this.current = this.predefinedViews[this.viewpoint];
 }
Beispiel #6
0
 public void AlterTransition(Viewpoint newTo)
 {
   Viewpoint rotatedView = FezMath.GetRotatedView(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[0])), FezMath.GetDistance(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[2])), newTo));
   Vector3 from = this.predefinedViews[rotatedView].Direction;
   Vector3 to = this.predefinedViews[newTo].Direction;
   this.directionTransition.Points[0] = from;
   this.directionTransition.Points[1] = DefaultCameraManager.GetIntemediateVector(from, to);
   this.directionTransition.Points[2] = to;
   this.current = this.predefinedViews[newTo];
   this.lastViewpoint = rotatedView;
   this.viewpoint = newTo;
 }
Beispiel #7
0
 public virtual bool ChangeViewpoint(Viewpoint newViewpoint, float speedFactor)
 {
   bool flag = FezMath.IsOrthographic(newViewpoint) != FezMath.IsOrthographic(this.viewpoint);
   if (flag && this.ProjectionTransition)
     return false;
   this.ProjectionTransition = flag && (double) speedFactor > 0.0;
   this.radiusBeforeTransition = FezMath.IsOrthographic(this.viewpoint) ? this.current.Radius : this.predefinedViews[this.lastViewpoint].Radius;
   if ((double) speedFactor > 0.0)
   {
     float num = (float) ((double) (Math.Abs(FezMath.GetDistance(newViewpoint, this.Viewpoint)) - 1) / 2.0 + 1.0);
     if (newViewpoint == Viewpoint.Perspective || this.Viewpoint == Viewpoint.Perspective)
       num = 1f;
     Vector3 from = this.current.Direction;
     Vector3 to = this.predefinedViews[newViewpoint].Direction;
     this.directionTransition = new Vector3SplineInterpolation(TimeSpan.FromSeconds((double) DefaultCameraManager.TransitionSpeed * (double) num * (double) speedFactor), new Vector3[3]
     {
       from,
       DefaultCameraManager.GetIntemediateVector(from, to),
       to
     });
     this.directionTransition.Start();
   }
   if (FezMath.IsOrthographic(this.viewpoint))
   {
     this.current.Direction = -FezMath.ForwardVector(this.viewpoint);
     this.current.Radius = this.DefaultViewableWidth;
   }
   this.olderViewpoint = this.lastViewpoint;
   this.lastViewpoint = this.viewpoint;
   this.viewpoint = newViewpoint;
   Vector3 center = this.Center;
   this.current = this.predefinedViews[newViewpoint];
   this.current.Center = center;
   if (this.lastViewpoint != Viewpoint.None)
   {
     this.PreViewpointChanged();
     if (!this.ViewTransitionCancelled)
       this.ViewpointChanged();
   }
   if ((double) speedFactor == 0.0 && !this.ViewTransitionCancelled)
     this.RebuildView();
   bool transitionCancelled = this.ViewTransitionCancelled;
   this.ViewTransitionCancelled = false;
   return !transitionCancelled;
 }
Beispiel #8
0
 public override void Initialize()
 {
   this.InterpolationSpeed = 10f;
   this.ResetViewpoints();
   this.viewpoint = Viewpoint.Right;
   this.current = this.predefinedViews[Viewpoint.Right];
   this.SnapInterpolation();
   this.GraphicsService.DeviceReset += (EventHandler<EventArgs>) delegate
   {
     this.PixelsPerTrixel = this.pixelsPerTrixel;
     this.RebuildProjection();
   };
 }