Beispiel #1
0
        // partikkeliengine kutsuu tätä, asetettu räjähdykseen (halutaan muuttaa sen väriä)
        void RenderParticleCallback(Particle p)
        {
            // nyt voi tehdä joka partikkelille mitä haluaa, esim asettaa alphan lifeksi.
            float tc = p.life / 2;

            GLExt.Color4(1f, tc, tc, tc);
        }
Beispiel #2
0
        public override void Render()
        {
            ang += 1;
            GL.Clear(ClearFlags);

            back.DrawFullScreen(0, 0);

            GLExt.Color4(0.5f, 0.5f, 0.5f, 0.5f);
            // images at random z (0.0 - 1.0)
            for (int q = 0; q < 100; q++)
            {
                back.Draw(x[q], y[q], z[q], 0, 0.2f, 0.2f, false); // no blending
            }
            GLExt.Color4(1, 1, 1, 1);


            GLExt.Color4(1, 1, 1, (float)Math.Abs(Math.Sin(ang * 0.01f)));
            back.Draw(10, 10, 0, 1, 1, false);                     // no blending
            back.Draw(Settings.Width / 2 + 10, 10, 0, 1, 1, true); // blending
            GLExt.Color4(1, 1, 1, 1);

            // must invert mouse y
            img.Draw(Mouse.X, Settings.Height - Mouse.Y,
                     mouseZ,
                     ang, 1, 1, true);

            font.Write("2D-test.", 0, 0);
            font.Write("\nUse mouse wheel to move mouse pointer at Z-axis.\n\nPress ESC\nto start the next test.", 10, 20);

            //Console.WriteLine("> " + Mouse.X + "  " + Mouse.Y);

            base.Render();
        }
Beispiel #3
0
        public override void Render()
        {
            GL.Clear(ClearFlags);

            GLExt.Color4((float)Mouse.X / Settings.Width,
                         (float)Mouse.Y / Settings.Height,
                         1, 1);
            back.DrawFullScreen(0, 0);
            GLExt.Color4(1, 1, 1, 1);

            base.Render();
        }
Beispiel #4
0
        // debug
        public void RenderSkeleton()
        {
            if (Settings.UseGL3 == false)
            {
                GLSLShader.UnBindShader();

                GL.Disable(EnableCap.Texture2D);
                GL.Disable(EnableCap.DepthTest);
                GLExt.PushMatrix();
                {
                    GL.Translate(Position.X, Position.Y, Position.Z);
                    GL.Rotate(Rotation.X, 1, 0, 0);
                    GL.Rotate(Rotation.Y, 0, 1, 0);
                    GL.Rotate(Rotation.Z, 0, 0, 1);
                    GL.Rotate(-90, 1, 0, 0);
                    GL.Scale(Scale.X, Scale.Y, Scale.Z);
                    GL.PointSize(5);
                    GLExt.Color4(1, 0, 0, 1);
                    GL.Begin(BeginMode.Points);
                    for (int q = 0; q < numJoints; q++)
                    {
                        GL.Vertex3(skeleton[q].pos);
                    }
                    GL.End();
                    GL.PointSize(1);
                    GLExt.Color4(0, 1, 0, 1);
                    GL.Begin(BeginMode.Lines);
                    for (int q = 0; q < numJoints; q++)
                    {
                        if (skeleton[q].parent != -1)
                        {
                            GL.Vertex3(skeleton[skeleton[q].parent].pos);
                            GL.Vertex3(skeleton[q].pos);
                        }
                    }
                    GL.End();
                }
                GLExt.PopMatrix();
                GL.Enable(EnableCap.DepthTest);
                GL.Enable(EnableCap.Texture2D);
                GLExt.Color4(1, 1, 1, 1);
            }
        }
Beispiel #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;
        }