// Methods
        public override void Load(Stream fileStream)
        {
            // Header
            var reader = new GensReader(fileStream, true);

            Header = new GensHeader(reader);

            // Root Node
            uint lightType = reader.ReadUInt32();

            if (lightType < 0 || lightType > 1)
            {
                throw new InvalidDataException(
                          $"Cannot read light - unknown light type! ({lightType})");
            }

            // Data
            LightType = (LightTypes)lightType;

            Position = reader.ReadVector3();
            Color    = reader.ReadVector3();

            if (LightType == LightTypes.Omni)
            {
                UnknownTotal1 = reader.ReadUInt32();
                UnknownTotal2 = reader.ReadUInt32();
                UnknownTotal3 = reader.ReadUInt32();

                OmniInnerRange = reader.ReadSingle();
                OmniOuterRange = reader.ReadSingle();
            }
        }
Exemple #2
0
 public LightStructBuffer(LightTypes type, Vector3 pos, Vector3 dir, Vector4 color, float intensity)
 {
     Type      = (uint)type;
     Intensity = intensity;
     Position  = pos;
     Direction = dir;
     Color     = color;
 }
Exemple #3
0
        //public readonly Vector3 Position;

        public LightStructBuffer(LightTypes type, Vector3 pos, Vector4 dir, Vector4 color, float intensity) : this()
        {
            Type      = (uint)type;
            Intensity = intensity;
            // Position = pos;
            Direction = dir;
            Color     = color;
            offset    = Vector2.Zero;
        }
Exemple #4
0
 LightComponent(float intensity, int index, Vector3 position, Vector3 direction, LightTypes type) : this()
 {
     Tag       = ElementTag.New();
     IsValid   = true;
     Intensity = intensity;
     Index     = index;
     Position  = position;
     Direction = direction;
     Type      = type;
 }
Exemple #5
0
    void UpdateSettings()
    {
        _cameraHasBeenUpdated = CameraHasBeenUpdated();
        if (_cameraHasBeenUpdated)
        {
            if (_prevLightType != lightType)
            {
                CreateMaterials();
            }

            pointLightRadius = Mathf.Max(0.001f, pointLightRadius);
            orthoSize        = Mathf.Max(0.001f, orthoSize);

            cam.ResetProjectionMatrix();
            cam.projectionMatrix = CalculateProjectionMatrix();
            switch (lightType)
            {
            case LightTypes.Area:
            case LightTypes.Point:
            case LightTypes.Orthographic:
                cam.orthographic = true;
                break;

            case LightTypes.Spot:
                cam.orthographic = false;
                break;
            }

            if (shadowMode == ShadowMode.None || shadowMode == ShadowMode.Baked)
            {
                if (_depthTexture != null)
                {
                    SafeDestroy(_depthTexture);
                }
            }
        }

        _prevSlices            = slices;
        _prevFov               = spotAngle;
        _prevNear              = Mathf.Max(0.01f, spotNear);
        _prevFar               = spotRange;
        _prevIsOrtho           = cam.orthographic;
        _prevOrthoSize         = orthoSize;
        _prevShadowMode        = shadowMode;
        _prevLightType         = lightType;
        _prevPointLightRadius  = pointLightRadius;
        _prevRenderFullShadows = renderFullShadows;
        _prevOrtho             = orthoSize;
        _prevOrthoAspect       = aspect;

        if (!Application.isPlaying)
        {
            _prevBoundsCentreOffset = _boundsCentreOffset;
        }
    }
Exemple #6
0
    Texture CreateBakedShadowTexture(LightTypes type)
    {
        switch (type)
        {
        case LightTypes.Point:
            return(new Cubemap(shadowMapRes, TextureFormat.ARGB32, false));

        case LightTypes.Spot:
        case LightTypes.Orthographic:
            return(new Texture2D(shadowMapRes, shadowMapRes, TextureFormat.ARGB32, false, true));
        }
        return(null);
    }
Exemple #7
0
    void CreateDepthTexture(LightTypes type)
    {
        shadowMapRes = Mathf.NextPowerOfTwo(shadowMapRes);
        if (_depthTexture == null || _depthTexture.width != shadowMapRes)
        {
#if DEBUG_MODE
            Debug.Log("Creating new depth texture");
#endif
            if (_depthTexture != null)
            {
                SafeDestroy(_depthTexture);
            }
            _depthTexture              = GenerateShadowMap(shadowMapRes);
            _depthTexture.hideFlags    = HideFlags.HideAndDontSave;
            _depthTexture.isPowerOfTwo = true;
            switch (type)
            {
            case LightTypes.Point:
                _depthTexture.dimension = TextureDimension.Cube;
                break;
            }
        }
        else if (type == LightTypes.Point && (_depthTexture.dimension != TextureDimension.Cube) && _depthTexture.IsCreated())
        {
#if DEBUG_MODE
            Debug.Log("Swapping to cubemap depth texture");
#endif
            SafeDestroy(_depthTexture);
            _depthTexture = GenerateShadowMap(shadowMapRes);

            _depthTexture.hideFlags    = HideFlags.HideAndDontSave;
            _depthTexture.isPowerOfTwo = true;
            _depthTexture.dimension    = TextureDimension.Cube;
        }
        else if ((type == LightTypes.Spot || type == LightTypes.Orthographic) && (_depthTexture.dimension == TextureDimension.Cube) && _depthTexture.IsCreated())
        {
#if DEBUG_MODE
            Debug.Log("Swapping to non cubemap depth texture");
#endif
            SafeDestroy(_depthTexture);
            _depthTexture              = GenerateShadowMap(shadowMapRes);
            _depthTexture.hideFlags    = HideFlags.HideAndDontSave;
            _depthTexture.isPowerOfTwo = true;
            _depthTexture.dimension    = TextureDimension.Tex2D;
        }
    }
Exemple #8
0
        public override void Deserialize(StreamReader SR)
        {
            //SR.ReadLine();

            base.Deserialize(SR);
            CastShadows_Global = bool.Parse(SR.ReadLine().Split('\t')[1]);
            CastShadow         = bool.Parse(SR.ReadLine().Split('\t')[1]);
            Type = (LightTypes)Enum.Parse(Type.GetType(), SR.ReadLine().Split('\t')[1]);
            string[] COLOR = SR.ReadLine().Split('\t');
            color                = new Color(byte.Parse(COLOR[1]), byte.Parse(COLOR[2]), byte.Parse(COLOR[3]), byte.Parse(COLOR[4]));
            AngularRadius        = float.Parse(SR.ReadLine().Split('\t')[1]);
            OuterRadius          = float.Parse(SR.ReadLine().Split('\t')[1]);
            InnerRadius          = float.Parse(SR.ReadLine().Split('\t')[1]);
            InnerInensity        = float.Parse(SR.ReadLine().Split('\t')[1]);
            Attenuation          = float.Parse(SR.ReadLine().Split('\t')[1]);
            DirectionalIntensity = float.Parse(SR.ReadLine().Split('\t')[1]);
            ShadowIntensity      = float.Parse(SR.ReadLine().Split('\t')[1]);

            SR.ReadLine();
        }
    public void ChangeLightType(LightTypes e)
    {
        switch (e)
        {
        case LightTypes.DirectionalLight:
            mainLight.type = LightType.Directional;
            Debug.Log("LightType changed to Directional");
            break;

        case LightTypes.SpotLight:
            mainLight.type = LightType.Spot;
            Debug.Log("LightType changed to Spotlight");
            break;

        case LightTypes.PointLight:
            mainLight.type = LightType.Point;
            Debug.Log("LightType changed to Point light");
            break;
        }
    }
Exemple #10
0
        private void LightTypeSelection_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem item      = LightTypeSelection.SelectedItem as ComboBoxItem;
            LightTypes   lightType = (LightTypes)item.Tag;

            PointProperties.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
            SpotProperties.Visibility      = Windows.UI.Xaml.Visibility.Collapsed;
            DirectionProperties.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            DefaultProperties.Visibility   = Windows.UI.Xaml.Visibility.Collapsed;

            switch (lightType)
            {
            case LightTypes.Point:
                DefaultProperties.Visibility = Windows.UI.Xaml.Visibility.Visible;
                PointProperties.Visibility   = Windows.UI.Xaml.Visibility.Visible;
                break;

            case LightTypes.Spot:
                DefaultProperties.Visibility   = Windows.UI.Xaml.Visibility.Visible;
                SpotProperties.Visibility      = Windows.UI.Xaml.Visibility.Visible;
                DirectionProperties.Visibility = Windows.UI.Xaml.Visibility.Visible;
                break;

            case LightTypes.Distant:
                PointProperties.Visibility     = Windows.UI.Xaml.Visibility.Visible;
                DirectionProperties.Visibility = Windows.UI.Xaml.Visibility.Visible;
                break;

            case LightTypes.Ambient:
                PointProperties.Visibility = Windows.UI.Xaml.Visibility.Visible;
                break;

            default:
                break;
            }

            if (lightType != _light.Light.Type)
            {
                UpdateLight();
            }
        }
Exemple #11
0
    private void CreateDepthTexture(LightTypes type)
    {
        if (_depthTexture == null)
        {
#if DEBUG_MODE
            Debug.Log("Creating new depth texture");
#endif
            _depthTexture              = GenerateShadowMap(256, 256);
            _depthTexture.hideFlags    = HideFlags.HideAndDontSave;
            _depthTexture.isPowerOfTwo = true;
            switch (type)
            {
            case LightTypes.Point:
                _depthTexture.isCubemap = true;
                break;
            }
        }
        else if (type == LightTypes.Point && !_depthTexture.isCubemap && _depthTexture.IsCreated())
        {
#if DEBUG_MODE
            Debug.Log("Swapping to cubemap depth texture");
#endif
            SafeDestroy(_depthTexture);
            _depthTexture = GenerateShadowMap(256, 256);

            _depthTexture.hideFlags    = HideFlags.HideAndDontSave;
            _depthTexture.isPowerOfTwo = true;
            _depthTexture.isCubemap    = true;
        }
        else if (type == LightTypes.Spot && _depthTexture.isCubemap && _depthTexture.IsCreated())
        {
#if DEBUG_MODE
            Debug.Log("Swapping to non cubemap depth texture");
#endif
            SafeDestroy(_depthTexture);
            _depthTexture              = GenerateShadowMap(512, 512);
            _depthTexture.hideFlags    = HideFlags.HideAndDontSave;
            _depthTexture.isPowerOfTwo = true;
            _depthTexture.isCubemap    = false;
        }
    }
Exemple #12
0
        private void UpdateLight()
        {
            if (LightTypeSelection.SelectedValue != null)
            {
                ComboBoxItem item      = LightTypeSelection.SelectedItem as ComboBoxItem;
                LightTypes   lightType = (LightTypes)item.Tag;

                _light.Light.Type = lightType;

                switch (lightType)
                {
                case LightTypes.Point:
                {
                    _light.Light.Offset = new Vector3((float)XOffset.Value, (float)YOffset.Value, (float)ZOffset.Value);
                    _light.Light.SetProperty("ConstantAttenuation", (float)ConstantAttenuation.Value * c_ConstantAttenMultiplier);
                    _light.Light.SetProperty("LinearAttenuation", (float)LinearAttenuation.Value * c_LinearAttenMultiplier);
                    _light.Light.SetProperty("QuadraticAttenuation", (float)QuadraticAttenuation.Value * c_QuadraticAttenMultiplier);
                    _light.Light.SetProperty("Color", LightColor.Color);
                    _light.Light.SetProperty("Intensity", (float)IntensitySlider.Value / 100f);
                }
                break;

                case LightTypes.Spot:
                {
                    _light.Light.Offset = new Vector3((float)XOffset.Value, (float)YOffset.Value, (float)ZOffset.Value);
                    _light.Light.SetProperty("ConstantAttenuation", (float)ConstantAttenuation.Value * c_ConstantAttenMultiplier);
                    _light.Light.SetProperty("LinearAttenuation", (float)LinearAttenuation.Value * c_LinearAttenMultiplier);
                    _light.Light.SetProperty("QuadraticAttenuation", (float)QuadraticAttenuation.Value * c_QuadraticAttenMultiplier);
                    _light.Light.SetProperty("InnerConeAngleInDegrees", (float)InnerCone.Value);
                    _light.Light.SetProperty("InnerConeColor", InnerConeColor.Color);
                    _light.Light.SetProperty("InnerConeIntensity", (float)InnerIntensitySlider.Value / 100f);
                    _light.Light.SetProperty("OuterConeAngleInDegrees", (float)OuterCone.Value);
                    _light.Light.SetProperty("OuterConeColor", OuterConeColor.Color);
                    _light.Light.SetProperty("OuterConeIntensity", (float)OuterIntensitySlider.Value / 100f);

                    Vector3 lookAt = new Vector3((float)DirectionX.Value, (float)DirectionY.Value, 0);
                    Vector3 offset = new Vector3(300, 300, 100);
                    _light.Light.SetProperty("Direction", Vector3.Normalize(lookAt - offset));
                }
                break;

                case LightTypes.Distant:
                {
                    _light.Light.SetProperty("Color", LightColor.Color);
                    _light.Light.SetProperty("Intensity", (float)IntensitySlider.Value / 100f);

                    Vector3 lookAt = new Vector3((float)DirectionX.Value, (float)DirectionY.Value, 0);
                    Vector3 offset = new Vector3(300, 300, 100);
                    _light.Light.SetProperty("Direction", Vector3.Normalize(lookAt - offset));
                }
                break;

                case LightTypes.Ambient:
                {
                    _light.Light.SetProperty("Color", LightColor.Color);
                    _light.Light.SetProperty("Intensity", (float)IntensitySlider.Value / 100f);
                }
                break;

                default:
                    Debug.Assert(false, "Unexpected type");
                    break;
                }
            }
        }
Exemple #13
0
 public static LightComponent Create(float intensity, int index, Vector3 direction, Vector3 position, LightTypes type)
 {
     return(new LightComponent(intensity, index, position, direction, type));
 }
Exemple #14
0
 public static LightComponent Create(float intensity, int index, Vector3 direction, Vector3 position, LightTypes type)
 {
     return(new LightComponent {
         Tag = new ElementTag(Guid.NewGuid().ToString()),
         Intensity = intensity,
         Index = index,
         Direction = direction,
         Position = position,
         Type = type
     });
 }
        private void UpdateLight()
        {
            if (LightTypeSelection.SelectedValue != null)
            {
                ComboBoxItem item      = LightTypeSelection.SelectedValue as ComboBoxItem;
                LightTypes   lightType = (LightTypes)item.Tag;

                if (_light != null)
                {
                    _light.Targets.RemoveAll();
                }

                switch (lightType)
                {
                case LightTypes.PointLight:
                {
                    PointLight light = _compositor.CreatePointLight();
                    light.CoordinateSpace      = CoordinateSpace;
                    light.Offset               = new Vector3((float)XOffset.Value, (float)YOffset.Value, (float)ZOffset.Value);
                    light.ConstantAttenuation  = (float)ConstantAttenuation.Value / c_ConstantAttenRange;
                    light.LinearAttenuation    = (float)LinearAttenuation.Value / c_LinearAttenRange * .1f;
                    light.QuadraticAttenuation = (float)QuadraticAttenuation.Value / c_QuadraticAttenRange * .01f;
                    light.Color = LightColor.Color;

                    _light = light;
                }
                break;

                case LightTypes.SpotLight:
                {
                    SpotLight light = _compositor.CreateSpotLight();
                    light.CoordinateSpace         = CoordinateSpace;
                    light.Offset                  = new Vector3((float)XOffset.Value, (float)YOffset.Value, (float)ZOffset.Value);
                    light.ConstantAttenuation     = (float)ConstantAttenuation.Value / c_ConstantAttenRange;
                    light.LinearAttenuation       = (float)LinearAttenuation.Value / c_LinearAttenRange * .1f;
                    light.QuadraticAttenuation    = (float)QuadraticAttenuation.Value / c_QuadraticAttenRange * .01f;
                    light.InnerConeAngleInDegrees = (float)InnerCone.Value;
                    light.InnerConeColor          = InnerConeColor.Color;
                    light.OuterConeAngleInDegrees = (float)OuterCone.Value;
                    light.OuterConeColor          = OuterConeColor.Color;

                    Vector3 lookAt    = new Vector3((float)DirectionX.Value, (float)DirectionY.Value, 0);
                    Vector3 direction = Vector3.Normalize(lookAt - new Vector3(300, 300, 300));
                    light.Direction = direction;

                    _light = light;
                }
                break;

                case LightTypes.DistantLight:
                {
                    DistantLight light = _compositor.CreateDistantLight();
                    light.CoordinateSpace = CoordinateSpace;
                    light.Color           = LightColor.Color;

                    Vector3 lookAt = new Vector3((float)DirectionX.Value, (float)DirectionY.Value, 0);
                    Vector3 offset = new Vector3(300, 300, 100);
                    light.Direction = Vector3.Normalize(lookAt - offset);

                    _light = light;
                }
                break;

                default:
                    Debug.Assert(false, "Unexpected type");
                    break;
                }

                // Add the visual to the light target collection
                foreach (Visual target in _targetVisualList)
                {
                    _light.Targets.Add(target);
                }
            }
        }
Exemple #16
0
 public LightEventArgs(EightNightsMgr.GroupID g, EightNightsMgr.LightID l, LightTypes lt, LightData d)
 {
     Group = g; Light = l; LightType = lt; Data = d;
 }
Exemple #17
0
    //finds the GroupID and LightID of a light with the given channel #
    //returns false if it doesnt find a compatible light in any of the groups
    bool FindLight(int channel, LightTypes lightType, ref GroupID gID, ref LightID lID)
    {
        for (int i = 0; i < LightGroups.Length; i++)
          {
         LightGroupConfig g = LightGroups[i];

         for (int j = 0; j < g.Lights.Length; j++)
         {
            LightConfig l = g.Lights[j];

            if ((l.Channel == channel) && (l.LightType == lightType))
            {
               gID = g.Group;
               lID = (LightID)j;
               return true;
            }
         }
          }

          return false;
    }
        private void LightTypeSelection_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem item      = LightTypeSelection.SelectedValue as ComboBoxItem;
            LightTypes   lightType = (LightTypes)item.Tag;

            switch (lightType)
            {
            case LightTypes.PointLight:
                XOffsetRow.Height              = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                YOffsetRow.Height              = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                ZOffsetRow.Height              = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                ConstantAttenuationRow.Height  = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                LinearAttenuationRow.Height    = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                QuadraticAttenuationRow.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                InnerConeRow.Height            = new Windows.UI.Xaml.GridLength(0);
                OuterConeRow.Height            = new Windows.UI.Xaml.GridLength(0);
                InnerConeColorRow.Height       = new Windows.UI.Xaml.GridLength(0);
                OuterConeColorRow.Height       = new Windows.UI.Xaml.GridLength(0);
                LightColorRow.Height           = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                DirectionXRow.Height           = new Windows.UI.Xaml.GridLength(0);
                DirectionYRow.Height           = new Windows.UI.Xaml.GridLength(0);
                break;

            case LightTypes.SpotLight:
                XOffsetRow.Height              = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                YOffsetRow.Height              = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                ZOffsetRow.Height              = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                ConstantAttenuationRow.Height  = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                LinearAttenuationRow.Height    = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                QuadraticAttenuationRow.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                InnerConeRow.Height            = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                OuterConeRow.Height            = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                InnerConeColorRow.Height       = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                OuterConeColorRow.Height       = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                LightColorRow.Height           = new Windows.UI.Xaml.GridLength(0);
                DirectionXRow.Height           = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                DirectionYRow.Height           = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                break;

            case LightTypes.DistantLight:
                XOffsetRow.Height              = new Windows.UI.Xaml.GridLength(0);
                YOffsetRow.Height              = new Windows.UI.Xaml.GridLength(0);
                ZOffsetRow.Height              = new Windows.UI.Xaml.GridLength(0);
                ConstantAttenuationRow.Height  = new Windows.UI.Xaml.GridLength(0);
                LinearAttenuationRow.Height    = new Windows.UI.Xaml.GridLength(0);
                QuadraticAttenuationRow.Height = new Windows.UI.Xaml.GridLength(0);
                InnerConeRow.Height            = new Windows.UI.Xaml.GridLength(0);
                OuterConeRow.Height            = new Windows.UI.Xaml.GridLength(0);
                InnerConeColorRow.Height       = new Windows.UI.Xaml.GridLength(0);
                OuterConeColorRow.Height       = new Windows.UI.Xaml.GridLength(0);
                LightColorRow.Height           = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                DirectionXRow.Height           = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                DirectionYRow.Height           = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                break;

            default:
                break;
            }

            // Update UI for selected light type
            if (lightType == LightTypes.SpotLight)
            {
                InnerConeRow.Height      = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                OuterConeRow.Height      = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                InnerConeColorRow.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                OuterConeColorRow.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);

                LightColorRow.Height = new Windows.UI.Xaml.GridLength(0);
            }
            else
            {
                InnerConeRow.Height      = new Windows.UI.Xaml.GridLength(0);
                OuterConeRow.Height      = new Windows.UI.Xaml.GridLength(0);
                InnerConeColorRow.Height = new Windows.UI.Xaml.GridLength(0);
                OuterConeColorRow.Height = new Windows.UI.Xaml.GridLength(0);

                LightColorRow.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
            }

            UpdateLight();
        }
Exemple #19
0
 int NumLightsOfType(LightTypes t)
 {
     int count = 0;
       for (int i = 0; i < LightGroups.Length; i++)
       {
      LightGroupConfig lg = LightGroups[i];
      for (int j = 0; j < lg.Lights.Length; j++)
      {
         LightConfig lc = lg.Lights[j];
         if (lc.LightType == t)
            count++;
      }
       }
       return count;
 }
Exemple #20
0
 public LightEventArgs(GroupID g, LightID l, LightTypes lt, LightData d)
 {
     Group = g; Light = l; LightType = lt;  Data = d;
 }
Exemple #21
0
    public void UpdateSettings()
    {
        _cameraHasBeenUpdated = CameraHasBeenUpdated();
        if (_cameraHasBeenUpdated)
        {
            switch (lightType)
            {
            case LightTypes.Point:
                renderer.sharedMaterial = _instancedPointMaterial;
                camera.isOrthoGraphic   = true;

#if UNITY_4_2 || UNITY_4_3 || UNITY_4_4
                camera.nearClipPlane = -pointLightRadius;
                camera.farClipPlane  = pointLightRadius;
#else
                camera.near = -pointLightRadius;
                camera.far  = pointLightRadius;
#endif
                camera.orthographicSize = pointLightRadius * 2.0f;
                break;

            case LightTypes.Spot:
                renderer.sharedMaterial = _instancedSpotMaterial;
#if UNITY_4_2 || UNITY_4_3 || UNITY_4_4
                camera.farClipPlane  = spotRange;
                camera.nearClipPlane = spotNear;
                camera.fieldOfView   = spotAngle;
#else
                camera.far  = spotRange;
                camera.near = spotNear;
                camera.fov  = spotAngle;
#endif
                camera.isOrthoGraphic = false;
                break;
            }

            if (shadowMode == ShadowMode.None || shadowMode == ShadowMode.Baked)
            {
                if (_depthTexture != null)
                {
                    SafeDestroy(_depthTexture);
                }
            }
        }

        _prevSlices = slices;
#if UNITY_4_2 || UNITY_4_3 || UNITY_4_4
        _prevFov  = camera.fieldOfView;
        _prevNear = camera.nearClipPlane;
        _prevFar  = camera.farClipPlane;
#else
        _prevFov  = camera.fov;
        _prevNear = camera.near;
        _prevFar  = camera.far;
#endif
        _prevIsOrtho          = camera.isOrthoGraphic;
        _prevOrthoSize        = camera.orthographicSize;
        _prevMaterialSpot     = spotMaterial;
        _prevMaterialPoint    = pointMaterial;
        _prevShadowMode       = shadowMode;
        _prevLightType        = lightType;
        _prevPointLightRadius = pointLightRadius;
    }
Exemple #22
0
 private static extern void Light_setType(IntPtr light, LightTypes type);
Exemple #23
0
 /// <summary>
 /// Sets the type of light - see LightTypes for more info.
 /// </summary>
 /// <param name="type">The type of light.</param>
 public void setType(LightTypes type)
 {
     Light_setType(ogreObject, type);
 }