Example #1
0
        protected override void RenderModel()
        {
            if (VBO.FastRenderPass)
            {
                return;
            }
            GameClass.NumOfObjects++;

            GL.Disable(EnableCap.DepthTest);
            GL.DepthMask(false); // ei kirjoiteta z-bufferiin
            GLExt.SetLighting(false);

            GLExt.PushMatrix();
            GLExt.ModelViewMatrix.Row3.X = GLExt.ModelViewMatrix.Row3.Y = GLExt.ModelViewMatrix.Row3.Z = 0;
            GLExt.Scale(10, 10, 10);
            for (int q = 0; q < 6; q++)
            {
                OgreMesh m = skyboxSides[q];
                m.Material.SetMaterial();
                m.Vbo.Render();
            }
            GLExt.PopMatrix();

            GLExt.SetLighting(true);
            GL.DepthMask(true);
            GL.Enable(EnableCap.DepthTest);
        }
Example #2
0
        /// <summary>
        /// renderoi yhden billboardin.
        /// </summary>
        public void RenderBillboard(float x, float y, float z, float zrot, float size, bool blend)
        {
            billBoard.Bind(0);
            GL.Disable(EnableCap.CullFace);

            if (blend)
            {
                GL.Enable(EnableCap.Blend);
                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            }

            GLExt.PushMatrix();
            {
                GLExt.Translate(x, y, z);
                size *= 0.1f;
                GLExt.Scale(size, size, size);
                GLExt.RotateZ(zrot);
                Matrix4 matrix = Matrix4.Identity;
                matrix.Row3           = GLExt.ModelViewMatrix.Row3;
                GLExt.ModelViewMatrix = matrix;

                GLExt.SetLighting(false);
                billBoard.Vbo.Render();
                GLExt.SetLighting(true);
            }
            GLExt.PopMatrix();

            if (blend)
            {
                GL.Disable(EnableCap.Blend);
            }
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
0
        /// <summary>
        /// renderoi partikkelit, sorttaa läpinäkyvät.
        /// </summary>
        public static new void Render()
        {
            GLExt.Color4(1f, 1, 1, 1f);
            GLExt.PushMatrix();
            GLExt.SetLighting(false);

            List <SortedList_Particles> slist = new List <SortedList_Particles>();

            GL.Disable(EnableCap.CullFace);

            int c = 0;

            // järjestetään taulukko kauimmaisesta lähimpään. pitää rendata siinä järjestyksessä.
            // vain läpikuultavat pitää järjestää. täysin näkyvät renderoidaan samantien.
            for (int q = 0; q < ParticleGroups.Count; q++)
            {
                Particles curpar = ParticleGroups[q];
                if (curpar.particles.Count <= 0)
                {
                    continue;
                }
                if (VBO.FastRenderPass == true)
                {
                    if (curpar.CastShadow == false)
                    {
                        continue;
                    }
                }

                curpar.particles[0].partTex.Bind(0);

                GLExt.PushMatrix();
                GLExt.MultMatrix(ref curpar.WorldMatrix);

                for (int w = 0; w < curpar.NumOfParticles; w++)
                {
                    Particle p = curpar.particles[w];
                    GLExt.PushMatrix();
                    GLExt.Translate(p.pos.X, p.pos.Y, p.pos.Z);
                    Matrix4 matrix = Matrix4.Identity;
                    matrix.Row3           = GLExt.ModelViewMatrix.Row3;
                    GLExt.ModelViewMatrix = matrix;

                    Vector3 v = curpar.WorldMatrix.Row3.Xyz + curpar.Position + p.pos;
                    if (Frustum.SphereInFrustum(v.X, v.Y, v.Z, 10) != 0)
                    {
                        if (VBO.FastRenderPass == true) // renderoi partikkeli depthbufferiin (varjostusta varten)
                        {
                            GLExt.Scale(p.size, p.size, p.size);
                            GLExt.RotateZ(p.zrot);
                            p.partTex.RenderBillboard();
                        }
                        else
                        {
                            c++;
                            if (p.isTransparent == true) // listaan renderoitavaks myöhemmin
                            {
                                float len = (Camera.cam.Position - matrix.Row3.Xyz).LengthSquared;
                                slist.Add(new SortedList_Particles(len, p, matrix));
                            }
                            else // rendataan se nyt, ei lisätä sortattavaks
                            {
                                GLExt.Scale(p.size, p.size, p.size);
                                GLExt.RotateZ(p.zrot);
                                GLExt.Color4(p.color.X, p.color.Y, p.color.Z, p.color.W);;
                                if (p.callBack != null)
                                {
                                    p.callBack(p);
                                }
                                p.partTex.RenderBillboard();
                            }
                        }
                    }
                    GLExt.PopMatrix();
                }
                GLExt.PopMatrix();
            }

            if (VBO.FastRenderPass == false)
            {
                slist.Sort(delegate(SortedList_Particles z1, SortedList_Particles z2) { return(z2.Len.CompareTo(z1.Len)); });
                GL.Enable(EnableCap.Blend);
                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);

                // rendataan läpikuultavat
                GL.DepthMask(false); // ei kirjoiteta zbufferiin
                for (int q = 0; q < slist.Count; q++)
                {
                    Particle p = slist[q].Part;
                    if (VBO.FastRenderPass == false)
                    {
                        p.partTex.Bind(0);
                        GLExt.Color4(p.color.X, p.color.Y, p.color.Z, p.color.W);
                        if (p.callBack != null)
                        {
                            p.callBack(p);
                        }
                    }
                    GLExt.LoadMatrix(ref slist[q].Matrix);
                    GLExt.Scale(p.size, p.size, p.size);
                    GLExt.RotateZ(p.zrot);
                    p.partTex.RenderBillboard();
                }
                GL.DepthMask(true);
                GL.Disable(EnableCap.Blend);
            }
            GLExt.PopMatrix();

            GL.Enable(EnableCap.CullFace);
            GLExt.Color4(1, 1, 1, 1);
            GLExt.SetLighting(true);
            GameClass.NumOfObjects += c;
        }