Пример #1
0
        public LightingDemo(IntPtr hInstance) : base(hInstance) {
            _landVB = null;
            _landIB = null;
            _waveVB = null;
            _waveIB = null;
            _fx = null;
            _tech = null;
            _fxWorld = null;
            _fxWIT = null;
            _fxEyePosW = null;
            _fxDirLight = null;
            _fxPointLight = null;
            _fxSpotLight = null;
            _fxMaterial = null;
            _fxWVP = null;
            _inputLayout = null;
            _eyePosW = new Vector3();
            _theta = 1.5f*MathF.PI;
            _phi = 0.1f*MathF.PI;
            _radius = 80.0f;

            MainWindowCaption = "Lighting Demo";

            _lastMousePos = new Point();

            _landWorld = Matrix.Identity;
            _wavesWorld = Matrix.Translation(0, -3.0f, 0);
            _view = Matrix.Identity;
            _proj = Matrix.Identity;

            _dirLight = new DirectionalLight {
                Ambient = new Color4(0.2f, 0.2f, 0.2f),
                Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                Specular = new Color4(0.5f, 0.5f, 0.5f),
                Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
            };

            _pointLight = new PointLight {
                Ambient = new Color4(0.3f, 0.3f, 0.3f),
                Diffuse = new Color4(0.7f, 0.7f, 0.7f),
                Specular = new Color4(0.7f, 0.7f, 0.7f),
                Attenuation = new Vector3(0.0f, 0.1f, 0.0f),
                Range = 25.0f
            };
            _spotLight = new SpotLight {
                Ambient = new Color4(0,0,0),
                Diffuse = new Color4(1.0f, 1.0f, 0.0f),
                Specular = Color.White,
                Attenuation = new Vector3(1.0f, 0.0f, 0.0f),
                Spot = 96.0f,
                Range = 10000.0f
            };

            // NOTE: must put alpha (spec power) first, rather than last as in book code
            _landMaterial = new Material {
                Ambient = new Color4(1.0f, 0.48f, 0.77f, 0.46f),
                Diffuse = new Color4(1.0f, 0.48f, 0.77f, 0.46f),
                Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f)
            };
            _wavesMaterial = new Material {
                Ambient =  new Color4(0.137f, 0.42f, 0.556f),
                Diffuse = new Color4(0.137f, 0.42f, 0.556f),
                Specular = new Color4(96.0f, 0.8f, 0.8f, 0.8f)
            };

        }
Пример #2
0
        public void RenderMinimap(DirectionalLight[] lights)
        {
            _dc.OutputMerger.SetTargets((DepthStencilView)null, _minimapRTV);
            _dc.Rasterizer.SetViewports(_minimapViewport);

            _dc.ClearRenderTargetView(_minimapRTV, Color.White);
            _terrain.Draw(_dc, _orthoCamera, lights);

            DrawCameraFrustum();
        }