コード例 #1
0
ファイル: Water.cs プロジェクト: patrykos91/Laikos
 public void DrawReflectionMap(Terrain terrain, List<GameObject> objects, Texture2D normals, Texture2D speculars)
 {
     Vector4 reflectionPlane = CreatePlane(waterHeight - 0.5f, new Vector3(0, -1, 0), true);
     device.SetRenderTarget(reflectionRenderTarget);
     device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);
     GBuffer.Parameters["xClip"].SetValue(true);
     GBuffer.Parameters["xClipPlane"].SetValue(reflectionPlane);
     terrain.DrawTerrain(GBuffer);
     /*foreach (GameObject obj in objects)
     {
         if (obj is Unit)
         {
             Unit unit = (Unit)obj;
             unit.currentModel.Draw(device, unit.GetWorldMatrix(), GBuffer, normals, speculars, false);
         }
         if (obj is Decoration)
         {
             Decoration decoration = (Decoration)obj;
             decoration.currentModel.Draw(device, decoration.GetWorldMatrix(), GBuffer, normals, speculars, false);
         }
     }*/
     DrawSkyDome(Camera.reflectionViewMatrix);
     device.SetRenderTarget(null);
     GBuffer.Parameters["xClip"].SetValue(false);
     reflectionMap = reflectionRenderTarget;
 }
コード例 #2
0
ファイル: DefferedRenderer.cs プロジェクト: patrykos91/Laikos
        void RenderSceneTo3Targets(List<GameObject> objects, Terrain terrain, float time)
        {
            device.BlendState = BlendState.Opaque;
            device.DepthStencilState = DepthStencilState.Default;
            device.RasterizerState = RasterizerState.CullCounterClockwise;

            foreach (GameObject obj in objects)
            {
                if (obj is Unit)
                {
                    Unit unit = (Unit)obj;
                    unit.currentModel.Draw(device, unit.GetWorldMatrix());
                }
                else if (obj is Building)
                {
                    Building building = (Building)obj;
                    building.currentModel.Draw(device, building.GetWorldMatrix());
                    //building.currentModel.Model.Draw(building.GetWorldMatrix(), Camera.viewMatrix, Camera.projectionMatrix);
                }
                else if (obj is Decoration)
                {
                    Decoration decoration = (Decoration)obj;
                    decoration.currentModel.Draw(device, decoration.GetWorldMatrix());
                    //decoration.currentModel.Model.Draw(decoration.GetWorldMatrix(), Camera.viewMatrix, Camera.projectionMatrix);
                }
            }
            water.DrawSkyDome(Camera.viewMatrix);
            terrain.DrawTerrain(GBuffer);
            water.DrawWater(time);
            device.SetRenderTarget(null);

            //Minimap.SetRenderTarget(device);
            //terrain.DrawTerrain(GBuffer);
            //water.DrawWater(time);
            //Minimap.ResolveRenderTarger(device);
            //Minimap.SaveMiniMap();
            //minimap = false;
        }