Ejemplo n.º 1
0
        internal static void UpdateViewport(ViewPortChangeMode Mode)
        {
            if (Mode == ViewPortChangeMode.ChangeToCab)
            {
                CurrentViewPortMode = ViewPortMode.Cab;
            }
            else
            {
                CurrentViewPortMode = ViewPortMode.Scenery;
            }

            GL.Viewport(0, 0, Screen.Width, Screen.Height);
            World.AspectRatio            = (double)Screen.Width / (double)Screen.Height;
            World.HorizontalViewingAngle = 2.0 * Math.Atan(Math.Tan(0.5 * World.VerticalViewingAngle) * World.AspectRatio);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            if (CurrentViewPortMode == ViewPortMode.Cab)
            {
                Matrix4d perspective = Matrix4d.Perspective(World.VerticalViewingAngle, -World.AspectRatio, 0.025, 50.0);
                GL.MultMatrix(ref perspective);
            }
            else
            {
                var b  = BackgroundManager.CurrentBackground as BackgroundManager.BackgroundObject;
                var cd = b != null?Math.Max(World.BackgroundImageDistance, b.ClipDistance) : World.BackgroundImageDistance;

                Matrix4d perspective = Matrix4d.Perspective(World.VerticalViewingAngle, -World.AspectRatio, 0.5, cd);
                GL.MultMatrix(ref perspective);
            }
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
        }
Ejemplo n.º 2
0
        internal static void UpdateViewport(ViewPortChangeMode Mode)
        {
            if (Mode == ViewPortChangeMode.ChangeToCab)
            {
                CurrentViewPortMode = ViewPortMode.Cab;
            }
            else
            {
                CurrentViewPortMode = ViewPortMode.Scenery;
            }

            GL.Viewport(0, 0, Screen.Width, Screen.Height);
            World.AspectRatio            = (double)Screen.Width / (double)Screen.Height;
            World.HorizontalViewingAngle = 2.0 * Math.Atan(Math.Tan(0.5 * World.VerticalViewingAngle) * World.AspectRatio);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            //This value was used to convert radians to degrees
            //OpenTK works in radians, so removed.....
            //const double invdeg = 57.295779513082320877;
            if (CurrentViewPortMode == ViewPortMode.Cab)
            {
                //Glu.Perspective(World.VerticalViewingAngle * invdeg, -World.AspectRatio, 0.025, 50.0);
                Matrix4d perspective = Matrix4d.Perspective(World.VerticalViewingAngle, -World.AspectRatio, 0.025, 50.0);
                GL.MultMatrix(ref perspective);
            }
            else
            {
                Matrix4d perspective = Matrix4d.Perspective(World.VerticalViewingAngle, -World.AspectRatio, 0.5, World.BackgroundImageDistance);
                GL.MultMatrix(ref perspective);
            }
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
        }
Ejemplo n.º 3
0
 internal static void UpdateViewport(ViewPortChangeMode Mode)
 {
     if (Mode == ViewPortChangeMode.ChangeToCab) {
         CurrentViewPortMode = ViewPortMode.Cab;
     } else {
         CurrentViewPortMode = ViewPortMode.Scenery;
     }
     Gl.glViewport(0, 0, Screen.Width, Screen.Height);
     World.AspectRatio = (double)Screen.Width / (double)Screen.Height;
     World.HorizontalViewingAngle = 2.0 * Math.Atan(Math.Tan(0.5 * World.VerticalViewingAngle) * World.AspectRatio);
     Gl.glMatrixMode(Gl.GL_PROJECTION);
     Gl.glLoadIdentity();
     const double invdeg = 57.295779513082320877;
     if (CurrentViewPortMode == ViewPortMode.Cab) {
         Glu.gluPerspective(World.VerticalViewingAngle * invdeg, -World.AspectRatio, 0.025, 50.0);
     } else {
         Glu.gluPerspective(World.VerticalViewingAngle * invdeg, -World.AspectRatio, 0.5, World.BackgroundImageDistance);
     }
     Gl.glMatrixMode(Gl.GL_MODELVIEW);
     Gl.glLoadIdentity();
 }
Ejemplo n.º 4
0
		internal static void UpdateViewport(ViewPortChangeMode Mode) {
			CurrentViewPortMode = Mode == ViewPortChangeMode.ChangeToCab ? ViewPortMode.Cab : ViewPortMode.Scenery;
			GL.Viewport(0, 0, Screen.Width, Screen.Height);
			World.AspectRatio = (double)Screen.Width / (double)Screen.Height;
			World.HorizontalViewingAngle = 2.0 * Math.Atan(Math.Tan(0.5 * World.VerticalViewingAngle) * World.AspectRatio);
			GL.MatrixMode(MatrixMode.Projection);
			GL.LoadIdentity();
			const double invdeg = 57.295779513082320877;
			if (CurrentViewPortMode == ViewPortMode.Cab) {
				Matrix4d persp = Matrix4d.CreatePerspectiveFieldOfView(World.VerticalViewingAngle/* * invdeg  * Math.PI / 180*/, World.AspectRatio, 0.025, 50.0);
				GL.MatrixMode(MatrixMode.Projection);
				GL.LoadMatrix(ref persp);
				GL.Scale(-1,1,1);
			} else {
				Matrix4d persp = Matrix4d.CreatePerspectiveFieldOfView(World.VerticalViewingAngle/* * invdeg  * Math.PI / 180*/, World.AspectRatio, 0.5, World.BackgroundImageDistance);
				GL.MatrixMode(MatrixMode.Projection);
				GL.LoadMatrix(ref persp);
				GL.Scale(-1,1,1);
			}
			GL.MatrixMode(MatrixMode.Modelview);
			GL.LoadIdentity();
		}
Ejemplo n.º 5
0
		internal static void UpdateViewport(ViewPortChangeMode Mode) {
			if (Mode == ViewPortChangeMode.ChangeToCab) {
				CurrentViewPortMode = ViewPortMode.Cab;
			} else {
				CurrentViewPortMode = ViewPortMode.Scenery;
			}

			GL.Viewport(0,0,Screen.Width, Screen.Height);
			World.AspectRatio = (double)Screen.Width / (double)Screen.Height;
			World.HorizontalViewingAngle = 2.0 * Math.Atan(Math.Tan(0.5 * World.VerticalViewingAngle) * World.AspectRatio);
			GL.MatrixMode(MatrixMode.Projection);
			GL.LoadIdentity();
			//This value was used to convert radians to degrees
			//OpenTK works in radians, so removed.....
			//const double invdeg = 57.295779513082320877;
			if (CurrentViewPortMode == ViewPortMode.Cab) {

				//Glu.Perspective(World.VerticalViewingAngle * invdeg, -World.AspectRatio, 0.025, 50.0);
				Matrix4d perspective = Matrix4d.Perspective(World.VerticalViewingAngle,-World.AspectRatio, 0.025, 50.0);
				GL.MultMatrix(ref perspective);
			} else {
				Matrix4d perspective = Matrix4d.Perspective(World.VerticalViewingAngle, -World.AspectRatio, 0.5, World.BackgroundImageDistance);
				GL.MultMatrix(ref perspective);
			}
			GL.MatrixMode(MatrixMode.Modelview);
			GL.LoadIdentity();
		}