From: seungho baek Date: Mon, 12 Jun 2023 04:43:51 +0000 (+0900) Subject: [NUI] Add Directional Light X-Git-Tag: accepted/tizen/unified/20231205.024657~267 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b30b4340dbe56b38cc3405f7c31226a6b867a1a;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add Directional Light Signed-off-by: seungho baek --- diff --git a/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Light.cs b/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Light.cs new file mode 100755 index 0000000..db80aea --- /dev/null +++ b/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Light.cs @@ -0,0 +1,50 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace Tizen.NUI.Scene3D +{ + internal static partial class Interop + { + internal static partial class Light + { + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Light_New_SWIG_0")] + public static extern global::System.IntPtr New(); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_new_Light_SWIG_0")] + public static extern global::System.IntPtr NewLight(); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_new_Light_SWIG_1")] + public static extern global::System.IntPtr NewLight(global::System.Runtime.InteropServices.HandleRef light); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_delete_Light")] + public static extern void DeleteLight(global::System.Runtime.InteropServices.HandleRef light); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Light_DownCast")] + public static extern global::System.IntPtr LightDownCast(global::System.Runtime.InteropServices.HandleRef light); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Light_Enable")] + public static extern void Enable(global::System.Runtime.InteropServices.HandleRef light, bool enable); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Light_IsEnabled")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool IsEnabled(global::System.Runtime.InteropServices.HandleRef light); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_GetMaximumEnabledLightCount")] + public static extern uint GetMaximumEnabledLightCount(); + } + } +} diff --git a/src/Tizen.NUI.Scene3D/src/public/Light/Light.cs b/src/Tizen.NUI.Scene3D/src/public/Light/Light.cs new file mode 100755 index 0000000..52ffc74 --- /dev/null +++ b/src/Tizen.NUI.Scene3D/src/public/Light/Light.cs @@ -0,0 +1,122 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.Runtime.InteropServices; +using System.ComponentModel; +using Tizen.NUI; +using Tizen.NUI.Binding; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Scene3D +{ + /// + /// This class is to define 3D Light source. + /// Currently this Light class supports Directional Light that lights every position from the same direction. (e.g, Sun light) + /// If a Light object is added on SceneView, the 3D objects in the SceneView are shined the Light. + /// NUI Scene3D limits the maximum enabled light count per each SceneView. + /// Currently the maximum number is set to 5, and it can be retrieved by using . + /// If more than 5 enabled Light objects are added on SceneView, SceneView turns on only 5 lights in the order the lights were added. + /// This Light can be added to SceneView directly but also it can be added on other View. + /// 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. + /// + /// + /// Light inherits View, so Light color and direction can be controlled by setting View's and Property. + /// method can be used to set light direction easily. + /// + /// + /// Default light direction is to Z-axis + /// + /// + /// + /// SceneView sceneView = new SceneView(); + /// Light light = new Light(); + /// light.Color = Color.Brown; + /// light.LookAt(new Vector3(1.0f, 1.0f, 1.0f)); + /// sceneView.Add(light); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Light : View + { + internal Light(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// + /// Create an initialized Light. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Light() : this(Interop.Light.New(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Copy constructor. + /// + /// Source object to copy. + [EditorBrowsable(EditorBrowsableState.Never)] + public Light(Light light) : this(Interop.Light.NewLight(Light.getCPtr(light)), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Maximum Activated Light Count. + /// It is possible to add more Lights to the SceneView than the Maximum Activated Light Count, + /// but only up to the Maximum Activated Light Count Lights will work. + /// + /// + /// This property is read only. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public uint MaximumActivatedLightCount + { + get + { + return Interop.Light.GetMaximumEnabledLightCount(); + } + } + + /// + /// The Light is turned on when the Light object is added on SceneView and enabled. + /// And checks whether this light is enabled or not. + /// + /// + /// SceneView can turn on only up to maximum enabled light count that can be retrieved by GetMaximumEnabledLightCount(). + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool IsLightEnabled + { + get + { + + bool isEnabled = Interop.Light.IsEnabled(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return isEnabled; + } + set + { + Interop.Light.Enable(SwigCPtr, value); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + } +}