Ejemplo n.º 1
0
        public void Render(double delta)
        {
            if (game.Graphics.LostContext)
            {
                return;
            }
            IGraphicsApi gfx = game.Graphics;

                        #if !USE_DX && !ANDROID
            gfx.AlphaBlending = true;
            //gfx.DepthWrite = false;

            gfx.DrawLine(new Vector3(pos2.X, pos2.Y, pos2.Z), new Vector3(pos1.X, pos2.Y, pos2.Z));
            gfx.DrawLine(new Vector3(pos1.X, pos2.Y, pos2.Z), new Vector3(pos1.X, pos2.Y, pos1.Z));
            gfx.DrawLine(new Vector3(pos1.X, pos2.Y, pos1.Z), new Vector3(pos2.X, pos2.Y, pos1.Z));
            gfx.DrawLine(new Vector3(pos2.X, pos2.Y, pos1.Z), new Vector3(pos2.X, pos2.Y, pos2.Z));

            gfx.DrawLine(new Vector3(pos2.X, pos2.Y, pos2.Z), new Vector3(pos2.X, pos1.Y, pos2.Z));
            gfx.DrawLine(new Vector3(pos1.X, pos2.Y, pos2.Z), new Vector3(pos1.X, pos1.Y, pos2.Z));
            gfx.DrawLine(new Vector3(pos1.X, pos2.Y, pos1.Z), new Vector3(pos1.X, pos1.Y, pos1.Z));
            gfx.DrawLine(new Vector3(pos2.X, pos2.Y, pos1.Z), new Vector3(pos2.X, pos1.Y, pos1.Z));

            gfx.DrawLine(new Vector3(pos2.X, pos1.Y, pos2.Z), new Vector3(pos1.X, pos1.Y, pos2.Z));
            gfx.DrawLine(new Vector3(pos1.X, pos1.Y, pos2.Z), new Vector3(pos1.X, pos1.Y, pos1.Z));
            gfx.DrawLine(new Vector3(pos1.X, pos1.Y, pos1.Z), new Vector3(pos2.X, pos1.Y, pos1.Z));
            gfx.DrawLine(new Vector3(pos2.X, pos1.Y, pos1.Z), new Vector3(pos2.X, pos1.Y, pos2.Z));

            //gfx.DepthWrite = true;
            gfx.AlphaBlending = false;
                        #else
            gfx.AlphaBlending = true;
            gfx.DepthWrite    = false;
            gfx.SetBatchFormat(VertexFormat.P3fC4b);
            gfx.UpdateDynamicVb_IndexedTris(vb, vertices, index);
            gfx.DepthWrite    = true;
            gfx.AlphaBlending = false;
                        #endif

            if (pickingBlock)
            {
                //gfx.AlphaTest = true;
                gfx.Texturing = true;
                //gfx.AlphaTest = true;
                gfx.AlphaBlending = true;
                gfx.FaceCulling   = true;
                float[] texCols = new float[4];
                texCols[0] = (127f / 256f);
                texCols[1] = (127f / 256f);
                texCols[2] = (127f / 256f);
                texCols[3] = (128f / 256f);

                /*GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Combine);
                 * //GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.CombineRgb, (int)TextureEnvModeCombine.Subtract);
                 * GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.CombineAlpha, (int)TextureEnvModeCombine.Subtract);
                 * GL.TexEnvfv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvColor, texCols);
                 * //GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.Source0Rgb, (int)TextureEnvModeSource.Texture);
                 * GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.Src0Alpha, (int)TextureEnvModeSource.PrimaryColor);
                 * //GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.Src1Rgb, (int)TextureEnvModeSource.Constant);
                 * GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.Src1Alpha, (int)TextureEnvModeSource.Constant);*/
                //GL.Enable(EnableCap.ColorMaterial);
                //graphics.AlphaTestFunc(CompareFunc.Greater, 0.0f);
                //GL.BlendFuncSeparate(BlendingFactor.DstColor, BlendingFactor.SrcColor, BlendingFactor.DstAlpha, BlendingFactor.DstAlpha);
                graphics.RGBAlphaBlendFunc(BlendFunc.DestColor, BlendFunc.SourceColor, BlendFunc.DestAlpha, BlendFunc.SourceAlpha);

                //VertexP3fT2fC4b[] vertices2 = new VertexP3fT2fC4b[8 * 10 * (4 * 4)];
                //game.Graphics.CreateDynamicVb(VertexFormat.P3fT2fC4b, vertices.Length);


                gfx.BindTexture(pickTexId);
                gfx.SetBatchFormat(VertexFormat.P3fT2fC4b);
                gfx.BindVb(vb2);
                gfx.UpdateDynamicVb_IndexedTris(vb2, vertices2, index2);

                //graphics.AlphaBlendFunc(BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha);
                graphics.AlphaBlendFunc(BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha);
                //graphics.AlphaTestFunc(CompareFunc.Greater, 0.5f);
                //GL.Disable(EnableCap.ColorMaterial);
                //GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Modulate);
                gfx.FaceCulling   = false;
                gfx.AlphaBlending = false;
                //gfx.AlphaTest = false;
                gfx.Texturing = false;
                //gfx.AlphaTest = false;
            }
        }