/// <summary>
        /// Updates per directional light variables
        /// </summary>
        /// <param name="light">Light</param>
        /// <param name="shadowMaps">Shadow map flags</param>
        /// <param name="shadowMap">Shadow map</param>
        public void UpdatePerLight(
            SceneLightDirectional light,
            IShadowMap shadowMap)
        {
            this.DirectionalLight = new BufferLightDirectional(light);

            this.ShadowMapDirectional = shadowMap?.Texture;
        }
        /// <summary>
        /// Updates per spot light variables
        /// </summary>
        /// <param name="light">Light</param>
        /// <param name="transform">Translation and rotation matrix</param>
        /// <param name="viewProjection">View * projection matrix</param>
        /// <param name="shadowMap">Shadow map</param>
        public void UpdatePerLight(
            SceneLightSpot light,
            Matrix transform,
            Matrix viewProjection,
            IShadowMap shadowMap)
        {
            this.SpotLight = new BufferLightSpot(light);

            this.World = transform;
            this.WorldViewProjection = transform * viewProjection;

            this.ShadowMapSpot = shadowMap?.Texture;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update per frame data
        /// </summary>
        /// <param name="world">World</param>
        /// <param name="viewProjection">View * projection</param>
        /// <param name="eyePositionWorld">Eye position in world coordinates</param>
        /// <param name="lights">Scene ligths</param>
        /// <param name="shadowMapDirectional">Low definition shadow map</param>
        /// <param name="shadowMapPoint">Point light shadow map</param>
        /// <param name="shadowMapSpot">Spot light shadow map</param>
        private void UpdatePerFrame(
            Matrix world,
            Matrix viewProjection,
            Vector3 eyePositionWorld,
            SceneLights lights,
            IShadowMap shadowMapDirectional,
            IShadowMap shadowMapPoint,
            IShadowMap shadowMapSpot)
        {
            this.World = world;
            this.WorldViewProjection = world * viewProjection;

            if (lights != null)
            {
                this.EyePositionWorld = eyePositionWorld;

                this.HemiLight   = BufferLightHemispheric.Build(lights.GetVisibleHemisphericLight());
                this.DirLights   = BufferLightDirectional.Build(lights.GetVisibleDirectionalLights(), out int dirLength);
                this.PointLights = BufferLightPoint.Build(lights.GetVisiblePointLights(), out int pointLength);
                this.SpotLights  = BufferLightSpot.Build(lights.GetVisibleSpotLights(), out int spotLength);
                this.LightCount  = new[] { dirLength, pointLength, spotLength };

                this.FogStart = lights.FogStart;
                this.FogRange = lights.FogRange;
                this.FogColor = lights.FogColor;

                this.ShadowMapDirectional = shadowMapDirectional?.Texture;
                this.ShadowMapPoint       = shadowMapPoint?.Texture;
                this.ShadowMapSpot        = shadowMapSpot?.Texture;
            }
            else
            {
                this.EyePositionWorld = Vector3.Zero;

                this.HemiLight   = BufferLightHemispheric.Default;
                this.DirLights   = BufferLightDirectional.Default;
                this.PointLights = BufferLightPoint.Default;
                this.SpotLights  = BufferLightSpot.Default;
                this.LightCount  = new[] { 0, 0, 0 };

                this.FogStart = 0;
                this.FogRange = 0;
                this.FogColor = Color.Transparent;

                this.ShadowMapDirectional = null;
                this.ShadowMapPoint       = null;
                this.ShadowMapSpot        = null;
            }
        }
Exemplo n.º 4
0
        public SimpleShadowShader(IShadowMap shadowMap)
        {
            this.ShadowMap = shadowMap;
            if (State.Device == null)
            {
                throw new GoblinException(
                          "GoblinXNA device is not initialized, can't create Shader.");
            }

            effect = State.Content.Load <Effect>(
                System.IO.Path.Combine(State.GetSettingVariable("ShaderDirectory"),
                                       "SimpleShadowShader"));

            lights = new List <LightNode>();

            GetParameters();
        }
Exemplo n.º 5
0
        public Graphics3D(MarkerNode MarkerNode, IShadowMap ShadowMap)
        {
            //Asignation Ground Node
            this.groundMarkerNode = MarkerNode;
            //Asignation Shadow Map
            this.GShadowMap = ShadowMap;

            //Add Big Parent for All Scenary Elements
            parentTNodeGrd      = new TransformNode();
            parentTNodeGrd.Name = "Level";
            groundMarkerNode.AddChild(parentTNodeGrd);

            // Create a material for the model
            BulletrMat               = new Material();
            BulletrMat.Diffuse       = Color.Blue.ToVector4();
            BulletrMat.Specular      = Color.White.ToVector4();
            BulletrMat.SpecularPower = 10;

            //create Bullet Model
            BulletModel = new TexturedBox(2.0f);

            LoadLevel = false;
            LoadCars  = false;
        }
Exemplo n.º 6
0
        TransformNode parentTNodeGrd; //Parent for all Scene Objects

        #endregion Fields

        #region Constructors

        public Graphics3D(MarkerNode MarkerNode, IShadowMap ShadowMap)
        {
            //Asignation Ground Node
            this.groundMarkerNode = MarkerNode;
            //Asignation Shadow Map
            this.GShadowMap = ShadowMap;

            //Add Big Parent for All Scenary Elements
            parentTNodeGrd = new TransformNode();
            parentTNodeGrd.Name = "Level";
            groundMarkerNode.AddChild(parentTNodeGrd);

            // Create a material for the model
            BulletrMat = new Material();
            BulletrMat.Diffuse = Color.Blue.ToVector4();
            BulletrMat.Specular = Color.White.ToVector4();
            BulletrMat.SpecularPower = 10;

            //create Bullet Model
            BulletModel = new TexturedBox(2.0f);

            LoadLevel = false;
            LoadCars = false;
        }
Exemplo n.º 7
0
        public SimpleShadowShader(IShadowMap shadowMap)
        {
            this.ShadowMap = shadowMap;
            if (State.Device == null)
                throw new GoblinException(
                    "GoblinXNA device is not initialized, can't create Shader.");

            effect = State.Content.Load<Effect>(
                System.IO.Path.Combine(State.GetSettingVariable("ShaderDirectory"),
                "SimpleShadowShader"));

            lights = new List<LightNode>();

            GetParameters();
        }