Example #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();
        }
Example #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();
        }
Example #3
0
        /// <summary>Updates the openGL viewport</summary>
        /// <param name="Mode">The viewport change mode</param>
        internal static void UpdateViewport(ViewPortChangeMode Mode)
        {
            if (Mode == ViewPortChangeMode.ChangeToCab)
            {
                LibRender.Renderer.CurrentViewPortMode = ViewPortMode.Cab;
            }
            else
            {
                LibRender.Renderer.CurrentViewPortMode = ViewPortMode.Scenery;
            }

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

                Matrix4d perspective = Matrix4d.Perspective(Camera.VerticalViewingAngle, -LibRender.Screen.AspectRatio, 0.5, cd);
                GL.MultMatrix(ref perspective);
            }
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
        }
Example #4
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();
 }
Example #5
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();
		}
Example #6
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();
		}