Exemplo n.º 1
0
        public override void Update()
        {
            SpecularPointLightMaterial material = ((SpecularPointLightMaterial)Material);

            float _radius = material.Attenuation;
            Color _color  = material.LightColor;
            float _speed  = 1f;

            DebugEngine.AddBoundingSphere(new BoundingSphere(material.Position, _radius), _color);

            if (InputEngine.IsKeyHeld(Keys.Up))
            {
                material.Position += new Vector3(0, 0, -_speed);
            }

            if (InputEngine.IsKeyHeld(Keys.Down))
            {
                material.Position += new Vector3(0, 0, _speed);
            }

            if (InputEngine.IsKeyHeld(Keys.Left))
            {
                material.Position += new Vector3(-_speed, 0, 0);
            }

            if (InputEngine.IsKeyHeld(Keys.Right))
            {
                material.Position += new Vector3(_speed, 0, 0);
            }

            if (InputEngine.IsKeyHeld(Keys.PageUp))
            {
                material.Position += new Vector3(0, _speed, 0);
            }

            if (InputEngine.IsKeyHeld(Keys.PageDown))
            {
                material.Position += new Vector3(0, -_speed, 0);
            }

            if (InputEngine.IsKeyHeld(Keys.Add))
            {
                material.Attenuation += _speed * 2;
            }

            if (InputEngine.IsKeyHeld(Keys.Subtract))
            {
                material.Attenuation -= _speed * 2;
            }

            base.Update();
        }
Exemplo n.º 2
0
        public override void LoadContent()
        {
            // Load effect first
            CustomEffect = GameUtilities.Content.Load <Effect>("Effects/SpecularPointLight");

            Texture2D texture  = GameUtilities.Content.Load <Texture2D>(_albedo);
            Texture2D normal   = GameUtilities.Content.Load <Texture2D>(_normal);
            Texture2D specular = GameUtilities.Content.Load <Texture2D>(_specular);

            if (texture == null || normal == null || specular == null)
            {
                throw new NullReferenceException();
            }

            Material = new SpecularPointLightMaterial()
            {
                Texture  = texture,
                Normal   = normal,
                Specular = specular
            };

            base.LoadContent();
        }