Example #1
0
        LightStructs.SpotLight GetSpotLightFromLight(Light light)
        {
            if (light == null)
                return new LightStructs.SpotLight();

            if (light.Type != LIGHT_TYPE.Spot)
                throw new Exception("Type of light to convert must be Spot");

            LightStructs.SpotLight spot = new LightStructs.SpotLight();

            spot.Ambient = new Vector4(light.AmbientColor, 1);
            spot.Diffuse = new Vector4(light.DiffuseColor, 1);
            spot.Specular = new Vector4(light.SpecularColor, 1);

            spot.Direction = light.Direction;
            spot.SpotExp = light.SpotExp;

            spot.Position = light.Owner.Transform.Position;
            spot.Range = light.Range;

            spot.Attenuation = light.Attenuation;

            return spot;

        }
Example #2
0
        LightStructs.DirectionalLight GetDirectionalLightFromLight(Light light)
        {
            if (light == null)
                return new LightStructs.DirectionalLight();

            if (light.Type != LIGHT_TYPE.Directional)
                throw new Exception("Type of light to convert must be Directional");

            LightStructs.DirectionalLight directional = new LightStructs.DirectionalLight();

            directional.Ambient = new Vector4(light.AmbientColor,1);
            directional.Diffuse = new Vector4(light.DiffuseColor, 1);
            directional.Specular = new Vector4(light.SpecularColor,1);

            directional.Direction = light.Direction;

            return directional;
        }
Example #3
0
        LightStructs.PointLight GetPointLightFromLight(Light light)
        {
            if (light == null)
                return new LightStructs.PointLight();

            if (light.Type != LIGHT_TYPE.Point)
                throw new Exception("Type of light to convert must be Point");

            LightStructs.PointLight point = new LightStructs.PointLight();

            point.Ambient = new Vector4(light.AmbientColor, 1);
            point.Diffuse = new Vector4(light.DiffuseColor, 1);
            point.Specular = new Vector4(light.SpecularColor, 1);

            point.Position = light.Owner.Transform.Position;
            point.Range = light.Range;

            point.Attenuation = light.Attenuation;


            return point;

        }
Example #4
0
 public void SetLights(Light directional, Light point, Light spot)
 {
     _directionalLight.Set(GetDirectionalLightFromLight(directional));
     _pointLight.Set(GetPointLightFromLight(point));
     _spotLight.Set(GetSpotLightFromLight(spot));
 }