LoadMatrix() public static method

public static LoadMatrix ( Matrix4 &mat ) : void
mat Matrix4
return void
Ejemplo n.º 1
0
        protected override void OnResize(EventArgs e)
        {
            GL.Viewport(0, 0, Width, Height);

            aspect_ratio = Width / (float)Height;
            perspective  = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
            GL.MatrixMode(TK.MatrixMode.Projection);
            GL.LoadMatrix(ref perspective);
        }
Ejemplo n.º 2
0
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4f, Width / (float)Height, 1.0f, 60000.0f);

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref projection);
            ResizeObjects(ClientRectangle.Width, ClientRectangle.Height);
        }
Ejemplo n.º 3
0
        internal void Prepare(Size framebuffersize)
        {
            if (GraphicsContext.CurrentContext != this.glControl.Context)
            {
                this.glControl.MakeCurrent();
            }

            if (framebuffersize != this.size || this.loaded == false)
            {
                this.size = framebuffersize;
                this.CreateFramebuffer();

                GL.Viewport(0, 0, framebuffersize.Width, framebuffersize.Height);
                this.scene.Camera.ResizeViewport(framebuffersize.Width, framebuffersize.Height);
                Matrix4 projMatrix = scene.Camera.ProjMatrix;
                GL.MatrixMode(MatrixMode.Projection);
                GL.LoadMatrix(ref projMatrix);
            }

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, this.framebufferId);
        }
Ejemplo n.º 4
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);
#if TEST
#else
            GL.Clear(TK.ClearBufferMask.DepthBufferBit | TK.ClearBufferMask.ColorBufferBit);

            if (ortho)
            {
                modelView = Matrix4.CreateOrthographic(width, height, -height, height);
                GL.MatrixMode(TK.MatrixMode.Projection);
                GL.PushMatrix();
                GL.LoadMatrix(ref modelView);
                GL.Scale(scale_factor, scale_factor, scale_factor);
            }
            else
            {
                modelView = Matrix4.LookAt(eye, target, up);
                GL.MatrixMode(TK.MatrixMode.Modelview);
                GL.PushMatrix();
                GL.LoadMatrix(ref modelView);
            }
            GL.PushMatrix();
            GL.Rotate(offsetX, 0.0f, 1.0f, 0.0f);
            GL.Rotate(offsetY, 1.0f, 0.0f, 0.0f);

            DrawGrid();

            #region Draw 3D Polyhedrons

            GL.Color3(0.0, 0.5, 1.0);

            GL.Enable(TK.EnableCap.Light0);
            GL.Enable(TK.EnableCap.Lighting);

            int i = 0;
            foreach (Body body in bodies)
            {
                float[] color = colors[i % colors.Count()];
                color[3] = 0.9f;
                GL.Color4(color);
                body.Draw();
                color[3] = 0.25f;
                GL.Color4(color);
                body.getBSphere().Draw();
                i++;
            }

            if (picked != -1)
            {
                GL.Color3(colors[picked % colors.Count()]);
                GL.PolygonMode(TK.MaterialFace.FrontAndBack, TK.PolygonMode.Line);
                foreach (Body body in bodies.ElementAt(picked).getBSphere().cells)
                {
                    body.Draw();
                }
                GL.PolygonMode(TK.MaterialFace.FrontAndBack, TK.PolygonMode.Fill);
            }

            GL.Disable(TK.EnableCap.Lighting);
            GL.Disable(TK.EnableCap.Light0);
            #endregion

            #region Draw Gizmos
            drawCollisionIntervals();
            #endregion

            GL.PopMatrix();
            GL.PopMatrix();

            SwapBuffers();

            showFPS();
            //showInfo();
#endif
        }