Exemplo n.º 1
0
        public void Draw(GraphicsDeviceManager graphics, BasicEffect effect, AlphaTestEffect alpha)
        {
            Samplers.SetToDevice(graphics, EngineSampler.Default);

            foreach (var ql in normalq)
            {
                ql.Value.Draw(graphics, effect, null);
            }

            Samplers.SetToDevice(graphics, EngineSampler.Animated);

            foreach (var ql in animatedq)
            {
                ql.Value.Draw(graphics, effect, null);
            }

            Samplers.SetToDevice(graphics, EngineSampler.Default);

            graphics.GraphicsDevice.BlendState = BlendState.Additive;

            if (flagq.ContainsKey(((QuadFlags)(1 << Game1.currentflag)).ToString()))
            {
                flagq[((QuadFlags)(1 << Game1.currentflag)).ToString()].Draw(graphics, effect, alpha);
            }

            graphics.GraphicsDevice.BlendState = BlendState.NonPremultiplied;

            foreach (var ql in alphaq)
            {
                ql.Value.Draw(graphics, effect, alpha);
            }

            effect.Alpha = 0.5f;

            if (!Game1.HideWater)
            {
                foreach (var ql in waterq)
                {
                    ql.Value.Draw(graphics, effect, null);
                }
            }

            if (!Game1.HideInvisible)
            {
                if (flagq.ContainsKey("invis"))
                {
                    flagq["invis"].Draw(graphics, effect, null);
                }
            }


            effect.Alpha = 1f;
        }
Exemplo n.º 2
0
        public void Draw(GraphicsDeviceManager graphics, BasicEffect effect, AlphaTestEffect alpha)
        {
            if (indices != null && verts != null)
            {
                if (verts.Count > 0)
                {
                    effect.TextureEnabled = textureEnabled;

                    if (textureEnabled)
                    {
                        if (Game1.textures.ContainsKey(textureName))
                        {
                            effect.Texture = Game1.textures[textureName];
                        }
                        else
                        {
                            //Console.WriteLine("missing texture: " + textureName);
                            effect.Texture = Game1.textures["test"];
                        }
                    }

                    Samplers.SetToDevice(graphics, EngineRasterizer.DoubleSided);

                    foreach (var pass in effect.CurrentTechnique.Passes)
                    {
                        pass.Apply();

                        graphics.GraphicsDevice.DrawUserIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            verts.ToArray(), 0, verts.Count,
                            indices, 0, indices.Length / 3,
                            VertexPositionColorTexture.VertexDeclaration
                            );
                    }

                    if (Samplers.EnableWireframe)
                    {
                        effect.TextureEnabled = false;

                        Samplers.SetToDevice(graphics, EngineRasterizer.Wireframe);

                        foreach (var pass in effect.CurrentTechnique.Passes)
                        {
                            pass.Apply();

                            graphics.GraphicsDevice.DrawUserIndexedPrimitives(
                                PrimitiveType.TriangleList,
                                verts_sealed, 0, verts_sealed.Length,
                                indices, 0, indices.Length / 3,
                                VertexPositionColorTexture.VertexDeclaration
                                );
                        }

                        Samplers.SetToDevice(graphics, EngineRasterizer.Default);
                    }
                }
                else
                {
                    Console.WriteLine("Empty Trilist!");
                }
            }
        }