Ejemplo n.º 1
0
        public void DrawGoo()
        {
            float CurrTime = DXUtil.Timer(DirectXTimer.GetApplicationTime);
            float fTime    = (float)(((CurrTime % 180.0f) / 180.0f) * (2 * Math.PI));

            WorldMatrix = DirectX.Matrix.RotationYawPitchRoll((float)((CurrTime % 240) / 240 * Math.PI), 0, 0) * DirectX.Matrix.Translation(0, -45, -400);

            DirectX.Matrix WorldViewMatrix     = WorldMatrix * ViewMatrix;
            DirectX.Matrix WorldViewProjMatrix = WorldMatrix * ViewMatrix * ProjectionMatrix;

            GooEffect.SetValue("fMixTime", fTime);
            GooEffect.SetValue("WorldView", WorldViewMatrix);
            GooEffect.SetValue("WorldViewProjection", WorldViewProjMatrix);

            GameDevice.RenderState.AlphaBlendEnable = false;
            int numPasses = GooEffect.Begin(0);

            for (int i = 0; i < numPasses; i++)
            {
                GooEffect.BeginPass(i);
                GooMesh.DrawSubset(0);
                GooEffect.EndPass();
            }
            GooEffect.End();

            // Restore alpha blend setting
            GameDevice.RenderState.AlphaBlendEnable = true;
        }
Ejemplo n.º 2
0
        public void DrawWall()
        {
            // Disable alpha blend setting
            GameDevice.RenderState.AlphaBlendEnable = false;

            // Apply shaders to wall
            int numPasses = WallEffect.Begin(0);

            for (int iPass = 0; iPass < numPasses; iPass++)
            {
                WallEffect.BeginPass(iPass);
                for (int i = 0; i < WallMaterials.Length; i++)
                {
                    // Set texture tiling properties for parts of the wall.
                    if (i == 6)                    // Drain Texture
                    {
                        WallEffect.SetValue("xMultiply", 20.0f);
                        WallEffect.SetValue("yMultiply", 1.0f);
                    }
                    else if (i == 4)                    // Wall Texture
                    {
                        WallEffect.SetValue("xMultiply", 5.0f);
                        WallEffect.SetValue("yMultiply", 5.0f);
                    }
                    else if (i == 7)                    // Catwalk Texture
                    {
                        WallEffect.SetValue("xMultiply", 3.0f);
                        WallEffect.SetValue("yMultiply", 3.0f);
                    }
                    else
                    {
                        WallEffect.SetValue("xMultiply", 3.0f);
                        WallEffect.SetValue("yMultiply", 3.0f);
                    }
                    WallEffect.CommitChanges();
                    GameDevice.SetTexture(0, WallTextures[i]);
                    WallMesh.DrawSubset(i);
                }
                WallEffect.EndPass();
            }
            WallEffect.End();

            numPasses = PipeEffect.Begin(0);
            for (int iPass = 0; iPass < numPasses; iPass++)
            {
                PipeEffect.BeginPass(iPass);
                // Set texture tiling properties for parts of the pipe.
                for (int i = 0; i < PipeMaterials.Length; i++)
                {
                    if (i == 6)                    // Bars Texture
                    {
                        PipeEffect.SetValue("xMultiply", 1.0f);
                        PipeEffect.SetValue("yMultiply", 1.0f);
                    }
                    else if (i == 5)                    // Outside pipe
                    {
                        PipeEffect.SetValue("xMultiply", 1.0f);
                        PipeEffect.SetValue("yMultiply", 2.0f);
                    }
                    else if (i == 3)                    // Inside pipe
                    {
                        PipeEffect.SetValue("xMultiply", 3.0f);
                        PipeEffect.SetValue("yMultiply", 3.0f);
                    }
                    else
                    {
                        PipeEffect.SetValue("xMultiply", 1.0f);
                        PipeEffect.SetValue("yMultiply", 1.0f);
                    }
                    PipeEffect.CommitChanges();
                    GameDevice.SetTexture(0, PipeTextures[i]);
                    PipeMesh.DrawSubset(i);
                }
                PipeEffect.EndPass();
            }
            PipeEffect.End();

            // Restore alpha blend setting
            GameDevice.RenderState.AlphaBlendEnable = true;
        }