コード例 #1
0
 /// <summary>
 /// käytä fps kamerassa
 /// </summary>
 public void SetFPSCamera()
 {
     GLExt.LoadIdentity();
     GLExt.RotateX(-Rotation.X);
     GLExt.RotateY(-Rotation.Y);
     GLExt.RotateZ(-Rotation.Z);
     GLExt.Translate(-Position.X, -Position.Y, -Position.Z);
 }
コード例 #2
0
        public static void Set2D(int width, int height)
        {
            is3D            = false;
            Settings.Width  = width;
            Settings.Height = height;

            GLExt.SetProjectionMatrix(Matrix4.CreateOrthographicOffCenter(0, width, 0, height, -1, 1));
            GLExt.LoadIdentity();
            GL.Viewport(0, 0, width, height);
            GL.Disable(EnableCap.CullFace);
            GLExt.SetLighting(false);
        }
コード例 #3
0
ファイル: ShadowMapping.cs プロジェクト: Keilerr/csat
        /// <summary>
        /// aseta texturematriisit shadowmapping shaderia varten
        /// </summary>
        static void SetTextureMatrix()
        {
            Matrix4 projMatrix = GLExt.ProjectionMatrix, modelMatrix = GLExt.ModelViewMatrix;

            GLExt.MatrixMode(MatrixMode.Texture);
            GLExt.LoadIdentity();
            GLExt.Translate(0.5f, 0.5f, 0.5f); // remap from [-1,1]^2 to [0,1]^2
            GLExt.Scale(0.5f, 0.5f, 0.5f);
            GLExt.MultMatrix(ref projMatrix);
            GLExt.MultMatrix(ref modelMatrix);
            GLExt.MatrixMode(MatrixMode.Modelview);
        }
コード例 #4
0
        protected void CalculatePositions()
        {
            CalcPositions(false);

            GLExt.PushMatrix();
            GLExt.LoadIdentity();
            CalcPositions(true);
            GLExt.PopMatrix();

            MakeLists();

            // järjestä läpinäkyvät listassa olevat objektit etäisyyden mukaan, kauimmaiset ekaks
            transparentObjects.Sort(delegate(SortedList_Model z1, SortedList_Model z2) { return(z2.Len.CompareTo(z1.Len)); });
        }
コード例 #5
0
ファイル: ShadowMapping.cs プロジェクト: Keilerr/csat
        /// <summary>
        /// renderoi worldin valosta päin (pelkän depthin)
        /// </summary>
        public static void SetupShadows(Renderable world, int lightNo, bool withParticles)
        {
            if (UseShadowMapping == false)
            {
                return;
            }

            if (Light.Lights.Count == 0)
            {
                Log.WriteLine("SetupShadows requires at least one light source!", false);
                return;
            }
            GL.Disable(EnableCap.Blend);
            GL.ColorMask(false, false, false, false);
            GL.Disable(EnableCap.CullFace);
            GL.PolygonOffset(1, 1);
            GL.Enable(EnableCap.PolygonOffsetFill);

            fbo.BindDepth();
            fbo.BindFBO();
            fbo.Clear();

            // kuvakulma valosta päin
            GLExt.LoadMatrix(ref Light.Lights[lightNo].OrigOrientationMatrix);
            GLExt.Translate(-Light.Lights[lightNo].Position.X, -Light.Lights[lightNo].Position.Y, -Light.Lights[lightNo].Position.Z);

            SetTextureMatrix();
            Frustum.CalculateFrustum();

            VBO.FastRenderPass = true;
            depthShader.UseProgram();
            world.Render();
            if (withParticles)
            {
                depthShaderAlphaTest.UseProgram();
                Particles.Render();
                GLSLShader.UnBindShader();
            }
            VBO.FastRenderPass = false;
            fbo.UnBindFBO();

            GL.Disable(EnableCap.PolygonOffsetFill);
            GL.Enable(EnableCap.CullFace);
            GL.ColorMask(true, true, true, true);

            GLExt.LoadIdentity();
            GameClass.NumOfObjects = 0;

            ShadowMapping.UnBindLightMask();
        }
コード例 #6
0
        public static void Set3D(int width, int height, float near, float far)
        {
            is3D            = true;
            Settings.Width  = width;
            Settings.Height = height;
            Near            = near;
            Far             = far;

            GLExt.SetProjectionMatrix(Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(Fov),
                                                                           (float)width / (float)height, near, far));
            GLExt.LoadIdentity();
            GL.Viewport(0, 0, width, height);
            GL.Enable(EnableCap.CullFace);
            GLExt.SetLighting(true);
        }