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 /// ModelNode is a class for representing the Node of Model in Scene3D.
32 /// ModelNode contains multiple ModelPrimitives and allows easy access and
33 /// modification of Material information that ModelPrimitive has. If a 3D
34 /// format file is loaded by Model, ModelNode is created internally to
35 /// construct the model. In addition, you can create a Custom ModelNode
36 /// using ModelPrimitive and Material directly and add it to Model.
39 /// ModelNode modelNode = new ModelNode();
40 /// ModelPrimitive modelPrimitive = new ModelPrimitive();
41 /// modelNode.AddModelPrimitive(modelPrimitive);
43 /// Material material = new Material;
44 /// modelPrimitive.Material = material;
47 [EditorBrowsable(EditorBrowsableState.Never)]
48 public class ModelNode : View
50 internal ModelNode(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
55 /// Create an initialized ModelNode.
57 [EditorBrowsable(EditorBrowsableState.Never)]
58 public ModelNode() : this(Interop.ModelNode.ModelNodeNew(), true)
60 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61 this.PositionUsesPivotPoint = true;
67 /// <param name="modelNode">Source object to copy.</param>
68 [EditorBrowsable(EditorBrowsableState.Never)]
69 public ModelNode(ModelNode modelNode) : this(Interop.ModelNode.NewModelNode(ModelNode.getCPtr(modelNode)), true)
71 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
75 /// Assignment operator.
77 /// <param name="modelNode">Source object to be assigned.</param>
78 /// <returns>Reference to this.</returns>
79 internal ModelNode Assign(ModelNode modelNode)
81 ModelNode ret = new ModelNode(Interop.ModelNode.ModelNodeAssign(SwigCPtr, ModelNode.getCPtr(modelNode)), false);
82 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83 ret.PositionUsesPivotPoint = modelNode.PositionUsesPivotPoint;
88 /// Get the number of ModelPrimitive of this ModelNode.
90 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
91 [EditorBrowsable(EditorBrowsableState.Never)]
92 public uint ModelPrimitiveCount
96 return GetModelPrimitiveCount();
101 /// Adds a ModelPrimitive object to the ModelNode object.
103 /// <param name="modelPrimitive">The ModelPrimitive object to add.</param>
104 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
105 [EditorBrowsable(EditorBrowsableState.Never)]
106 public void AddModelPrimitive(ModelPrimitive modelPrimitive)
108 Interop.ModelNode.AddModelPrimitive(SwigCPtr, ModelPrimitive.getCPtr(modelPrimitive));
109 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113 /// Removes a ModelPrimitive object from the ModelNode object.
115 /// <param name="modelPrimitive">The ModelPrimitive object to remove.</param>
116 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
117 [EditorBrowsable(EditorBrowsableState.Never)]
118 public void RemoveModelPrimitive(ModelPrimitive modelPrimitive)
120 Interop.ModelNode.RemoveModelPrimitive(SwigCPtr, ModelPrimitive.getCPtr(modelPrimitive));
121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 /// Removes a ModelPrimitive object from the ModelNode object at the specified index.
127 /// <param name="index">The index of the ModelPrimitive object to remove.</param>
128 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
129 [EditorBrowsable(EditorBrowsableState.Never)]
130 public void RemoveModelPrimitive(uint index)
132 Interop.ModelNode.RemoveModelPrimitive(SwigCPtr, index);
133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137 /// Gets the ModelPrimitive object at the specified index.
139 /// <param name="index">The index of the ModelPrimitive object to get.</param>
140 /// <returns>The ModelPrimitive object at the specified index.</returns>
141 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 public ModelPrimitive GetModelPrimitive(uint index)
145 global::System.IntPtr cPtr = Interop.ModelNode.GetModelPrimitive(SwigCPtr, index);
146 ModelPrimitive ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelPrimitive;
149 // Register new animatable into Registry.
150 ret = new ModelPrimitive(cPtr, true);
154 // We found matched NUI animatable. Reduce cPtr reference count.
155 HandleRef handle = new HandleRef(this, cPtr);
156 Tizen.NUI.Interop.BaseHandle.DeleteBaseHandle(handle);
157 handle = new HandleRef(null, IntPtr.Zero);
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164 /// Removes Returns a child ModelNode object with a name that matches nodeName.
166 /// <param name="nodeName">The name of the child ModelNode object you want to find.</param>
167 /// <returns>Child ModelNode that has nodeName as name.</returns>
168 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
169 [EditorBrowsable(EditorBrowsableState.Never)]
170 public ModelNode FindChildModelNodeByName(string nodeName)
172 global::System.IntPtr cPtr = Interop.Model.FindChildModelNodeByName(SwigCPtr, nodeName);
173 ModelNode ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelNode;
176 // Store the value of PositionUsesAnchorPoint from dali object (Since View object automatically change PositionUsesPivotPoint value as false, we need to keep value.)
177 HandleRef handle = new HandleRef(this, cPtr);
178 bool originalPositionUsesAnchorPoint = Object.InternalGetPropertyBool(handle, View.Property.PositionUsesAnchorPoint);
179 handle = new HandleRef(null, IntPtr.Zero);
181 // Register new animatable into Registry.
182 ret = new ModelNode(cPtr, true);
183 ret.PositionUsesPivotPoint = originalPositionUsesAnchorPoint;
187 // We found matched NUI animatable. Reduce cPtr reference count.
188 HandleRef handle = new HandleRef(this, cPtr);
189 Tizen.NUI.Interop.BaseHandle.DeleteBaseHandle(handle);
190 handle = new HandleRef(null, IntPtr.Zero);
192 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197 /// Gets the number of ModelPrimitive objects in the ModelNode object.
199 /// <returns>The number of ModelPrimitive objects in the ModelNode object.</returns>
200 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
201 [EditorBrowsable(EditorBrowsableState.Never)]
202 private uint GetModelPrimitiveCount()
204 uint ret = Interop.ModelNode.GetModelPrimitiveCount(SwigCPtr);
205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210 /// Release swigCPtr.
212 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
213 [EditorBrowsable(EditorBrowsableState.Never)]
214 protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr)
216 Interop.ModelNode.DeleteModelNode(swigCPtr);