[NUI] Add ModelPivotPoint property
authorseungho baek <sbsh.baek@samsung.com>
Wed, 15 Nov 2023 14:36:34 +0000 (23:36 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 15 Nov 2023 14:42:35 +0000 (23:42 +0900)
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs

index 784f46b..ae24095 100755 (executable)
@@ -76,6 +76,7 @@ namespace Tizen.NUI.Scene3D
     /// <since_tizen> 10 </since_tizen>
     public partial class Model : View
     {
+        private Position modelPivotPoint = new Position();
         internal Model(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
         }
@@ -96,6 +97,7 @@ namespace Tizen.NUI.Scene3D
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             this.PositionUsesPivotPoint = true;
+            ResourcesLoaded += OnResourcesLoaded;
         }
 
         /// <summary>
@@ -134,6 +136,22 @@ namespace Tizen.NUI.Scene3D
         }
 
         /// <summary>
+        /// Get The original pivot point of the model
+        /// </summary>
+        /// <remarks>
+        /// This returns (0, 0, 0) before resources are loaded.
+        /// </remarks>
+        // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Position ModelPivotPoint
+        {
+            get
+            {
+                return modelPivotPoint;
+            }
+        }
+
+        /// <summary>
         /// Set/Get the ImageBasedLight ScaleFactor.
         /// Scale factor controls light source intensity in [0.0f, 1.0f]
         /// </summary>
@@ -617,6 +635,26 @@ namespace Tizen.NUI.Scene3D
             return scaleFactor;
         }
 
+        private void OnResourcesLoaded(object sender, EventArgs e)
+        {
+            this.modelPivotPoint.X = this.PivotPoint.X;
+            this.modelPivotPoint.Y = this.PivotPoint.Y;
+            this.modelPivotPoint.Z = this.PivotPoint.Z;
+        }
+
+        /// <summary>
+        /// To make transitionSet instance be disposed.
+        /// </summary>
+        protected override void Dispose(DisposeTypes type)
+        {
+            if (disposed)
+            {
+                return;
+            }
+            ResourcesLoaded -= OnResourcesLoaded;
+            base.Dispose(type);
+        }
+
         /// <summary>
         /// Release swigCPtr.
         /// </summary>