Ejemplo n.º 1
0
        protected override void OnDraw(ModelEffectInstance effect, RenderPass pass)
        {
            var alpha = CalculateCurrentGhostAlpha();

            if (alpha > 0.0f)
            {
                m_ghostModel.Alpha = alpha;
                m_ghostModel.Draw(effect);
            }

            effect.ModelMatrix     = m_ghostModel.Transform;
            effect.UVOffset        = Vector2.Zero;
            effect.UVScale         = Vector2.One;
            effect.DiffuseColour   = Vector4.One;
            effect.DiffuseTexture  = Texture.White;
            effect.SpecularColour  = Vector3.Zero;
            effect.SpecularTexture = Texture.Black;
            effect.NormalTexture   = Texture.Black;
            effect.EmissiveColour  = Vector3.One;
            effect.EmissiveTexture = Texture.White;
            effect.Bind();
            //m_shell.Draw();
        }
Ejemplo n.º 2
0
        public void Draw(ModelEffectInstance modelEffect, RenderPass pass)
        {
            // Draw the geometry for the current pass
            var geometry = m_geometry[(int)pass];

            if (geometry.IndexCount > 0)
            {
                modelEffect.ModelMatrix     = Matrix4.Identity;
                modelEffect.UVOffset        = Vector2.Zero;
                modelEffect.UVScale         = Vector2.One;
                modelEffect.DiffuseColour   = Vector4.One;
                modelEffect.DiffuseTexture  = m_atlas;
                modelEffect.SpecularColour  = Vector3.One;
                modelEffect.SpecularTexture = m_atlas;
                modelEffect.NormalTexture   = m_atlas;
                modelEffect.EmissiveColour  = Vector3.One;
                modelEffect.EmissiveTexture = m_atlas;
                modelEffect.Bind();
                geometry.Draw();

                /*
                 * // Wireframe test code
                 * modelEffect.ModelMatrix = Matrix4.Identity;
                 * modelEffect.DiffuseColour = Vector4.One;
                 * modelEffect.DiffuseTexture = Texture.White;
                 * modelEffect.SpecularColour = Vector3.One;
                 * modelEffect.SpecularTexture = Texture.White;
                 * modelEffect.NormalTexture = Texture.Flat;
                 * modelEffect.Bind();
                 * using( var wireframe = geometry.ToWireframe( lines:false, normals:true, tangents:true, binormals:true ) )
                 * {
                 *  wireframe.Draw();
                 * }
                 */
            }

            foreach (var pair in m_liquidGeometry)
            {
                var behaviour      = pair.Key;
                var liquidGeometry = pair.Value;
                if (liquidGeometry.IndexCount > 0 && behaviour.Tile.RenderPass == pass)
                {
                    bool    visible;
                    Matrix4 modelMatrix;
                    Vector2 uvOffset, uvScale;
                    Vector4 colour;
                    if (behaviour.Animation != null)
                    {
                        float cameraFOV;
                        var   anim = LuaAnimation.Get(behaviour.Animation);
                        anim.Animate("Liquid", m_level.TimeMachine.RealTime, out visible, out modelMatrix, out uvOffset, out uvScale, out colour, out cameraFOV);
                    }
                    else
                    {
                        visible     = true;
                        modelMatrix = Matrix4.Identity;
                        uvOffset    = Vector2.Zero;
                        uvScale     = Vector2.One;
                        colour      = Vector4.One;
                    }
                    if (visible)
                    {
                        var surface = Texture.Get(behaviour.Texture, false);
                        surface.Wrap = true;

                        modelEffect.ModelMatrix     = modelMatrix;
                        modelEffect.UVOffset        = uvOffset;
                        modelEffect.UVScale         = uvScale;
                        modelEffect.DiffuseColour   = colour;
                        modelEffect.DiffuseTexture  = surface;
                        modelEffect.SpecularColour  = Vector3.One;
                        modelEffect.SpecularTexture = Texture.Black;
                        modelEffect.NormalTexture   = Texture.Flat;
                        modelEffect.EmissiveColour  = Vector3.One;
                        modelEffect.EmissiveTexture = Texture.Black;
                        modelEffect.Bind();
                        liquidGeometry.Draw();
                    }
                }
            }
        }