2 * Copyright(c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.InteropServices;
20 using System.ComponentModel;
22 using Tizen.NUI.Binding;
23 using Tizen.NUI.BaseComponents;
25 namespace Tizen.NUI.Scene3D
28 /// This class is to define 3D Light source.
29 /// Currently this Light class supports Directional Light that lights every position from the same direction. (e.g, Sun light)
30 /// If a Light object is added on SceneView, the 3D objects in the SceneView are shined the Light.
31 /// NUI Scene3D limits the maximum enabled light count per each SceneView.
32 /// Currently the maximum number is set to 5, and it can be retrieved by using <see cref="MaximumActivatedLightCount"/>.
33 /// If more than 5 enabled Light objects are added on SceneView, SceneView turns on only 5 lights in the order the lights were added.
34 /// This Light can be added to SceneView directly but also it can be added on other View.
35 /// When a parent actor is added to a SceneView, its Light behaves in the SceneView the same as if it were added directly to the SceneView.
38 /// Light inherits View, so Light color and direction can be controlled by setting View's <see cref="View.Color"/> and <see cref="View.Orientation"/> Property.
39 /// <see cref="View.LookAt(Vector3, Vector3, Vector3, Vector3)"/> method can be used to set light direction easily.
42 /// Default light direction is to Z-axis
46 /// SceneView sceneView = new SceneView();
47 /// Light light = new Light();
48 /// light.Color = Color.Brown;
49 /// light.LookAt(new Vector3(1.0f, 1.0f, 1.0f));
50 /// sceneView.Add(light);
53 [EditorBrowsable(EditorBrowsableState.Never)]
54 public class Light : View
56 internal Light(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
61 /// Create an initialized Light.
63 [EditorBrowsable(EditorBrowsableState.Never)]
64 public Light() : this(Interop.Light.New(), true)
66 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72 /// <param name="light">Source object to copy.</param>
73 [EditorBrowsable(EditorBrowsableState.Never)]
74 public Light(Light light) : this(Interop.Light.NewLight(Light.getCPtr(light)), true)
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
80 /// Maximum Activated Light Count.
81 /// It is possible to add more Lights to the SceneView than the Maximum Activated Light Count,
82 /// but only up to the Maximum Activated Light Count Lights will work.
85 /// This property is read only.
87 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
88 [EditorBrowsable(EditorBrowsableState.Never)]
89 public uint MaximumActivatedLightCount
93 return Interop.Light.GetMaximumEnabledLightCount();
98 /// The Light is turned on when the Light object is added on SceneView and enabled.
99 /// And checks whether this light is enabled or not.
102 /// SceneView can turn on only up to maximum enabled light count that can be retrieved by GetMaximumEnabledLightCount().
104 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
105 [EditorBrowsable(EditorBrowsableState.Never)]
106 public bool IsLightEnabled
111 bool isEnabled = Interop.Light.IsEnabled(SwigCPtr);
112 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117 Interop.Light.Enable(SwigCPtr, value);
118 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 /// Make the light enable shadow for this light or not.
124 /// NUI.Scene3D generates shadow by using shadow map.
125 /// For the Directional Light, the shadow map is created to cover view frustum of current selected camera.
126 /// This means that if the distance between the near and far planes is too large,
127 /// the shadow map has to cover an unnecessarily large area. This results in lower shadow quality.
130 /// This light should be already turned on in the SceneView.
131 /// (When true) If there is previous light already enabled shadow in the SceneView, this function call is ignored.
132 /// (When false, and this light is currently used for shader)
133 /// If there are other lights those are turned on and shadow enabled, one of the light will be used for shadow automatically.
135 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
136 [EditorBrowsable(EditorBrowsableState.Never)]
137 public bool IsShadowEnabled
142 bool isEnabled = Interop.Light.IsShadowEnabled(SwigCPtr);
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148 Interop.Light.EnableShadow(SwigCPtr, value);
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154 /// Make the shadow edge soften or not.
155 /// Basically the shadow is hard shadow that has sharp edge.
156 /// This method enables soft filtering to make the sharp edge to smoothing.
159 /// This soft filtering requires expensive computation power.
161 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
162 [EditorBrowsable(EditorBrowsableState.Never)]
163 public bool IsShadowSoftFilteringEnabled
168 bool isEnabled = Interop.Light.IsShadowSoftFilteringEnabled(SwigCPtr);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 Interop.Light.EnableShadowSoftFiltering(SwigCPtr, value);
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180 /// Sets and gets shadow intensity.
181 /// If the intensity is larger, the shadow area will be darker.
182 /// The intensity value is between [0, 1].
183 /// Default value is 0.5
185 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
186 [EditorBrowsable(EditorBrowsableState.Never)]
187 public float ShadowIntensity
192 float shadowIntensity = Interop.Light.GetShadowIntensity(SwigCPtr);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194 return shadowIntensity;
198 Interop.Light.SetShadowIntensity(SwigCPtr, value);
199 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204 /// Sets and gets shadow bias.
205 /// Shadow bias is an offset value to remove shadow acne that is a visual artifact can be shown on the Shadow
206 /// Default value is 0.001
208 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
209 [EditorBrowsable(EditorBrowsableState.Never)]
210 public float ShadowBias
215 float shadowBias = Interop.Light.GetShadowBias(SwigCPtr);
216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221 Interop.Light.SetShadowBias(SwigCPtr, value);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();