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.PositionUsesAnchorPoint = 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();
87 /// Get the number of ModelPrimitive of this ModelNode.
89 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
90 [EditorBrowsable(EditorBrowsableState.Never)]
91 public uint ModelPrimitiveCount
95 return GetModelPrimitiveCount();
100 /// Adds a ModelPrimitive object to the ModelNode object.
102 /// <param name="modelPrimitive">The ModelPrimitive object to add.</param>
103 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
104 [EditorBrowsable(EditorBrowsableState.Never)]
105 public void AddModelPrimitive(ModelPrimitive modelPrimitive)
107 Interop.ModelNode.AddModelPrimitive(SwigCPtr, ModelPrimitive.getCPtr(modelPrimitive));
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112 /// Removes a ModelPrimitive object from the ModelNode object.
114 /// <param name="modelPrimitive">The ModelPrimitive object to remove.</param>
115 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
116 [EditorBrowsable(EditorBrowsableState.Never)]
117 public void RemoveModelPrimitive(ModelPrimitive modelPrimitive)
119 Interop.ModelNode.RemoveModelPrimitive(SwigCPtr, ModelPrimitive.getCPtr(modelPrimitive));
120 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124 /// Removes a ModelPrimitive object from the ModelNode object at the specified index.
126 /// <param name="index">The index of the ModelPrimitive object to remove.</param>
127 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
128 [EditorBrowsable(EditorBrowsableState.Never)]
129 public void RemoveModelPrimitive(uint index)
131 Interop.ModelNode.RemoveModelPrimitive(SwigCPtr, index);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 /// Gets the ModelPrimitive object at the specified index.
138 /// <param name="index">The index of the ModelPrimitive object to get.</param>
139 /// <returns>The ModelPrimitive object at the specified index.</returns>
140 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
141 [EditorBrowsable(EditorBrowsableState.Never)]
142 public ModelPrimitive GetModelPrimitive(uint index)
144 global::System.IntPtr cPtr = Interop.ModelNode.GetModelPrimitive(SwigCPtr, index);
145 ModelPrimitive ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelPrimitive;
148 // Register new animatable into Registry.
149 ret = new ModelPrimitive(cPtr, true);
153 // We found matched NUI animatable. Reduce cPtr reference count.
154 HandleRef handle = new HandleRef(this, cPtr);
155 Tizen.NUI.Interop.BaseHandle.DeleteBaseHandle(handle);
156 handle = new HandleRef(null, IntPtr.Zero);
158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 /// Removes Returns a child ModelNode object with a name that matches nodeName.
165 /// <param name="nodeName">The name of the child ModelNode object you want to find.</param>
166 /// <returns>Child ModelNode that has nodeName as name.</returns>
167 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
168 [EditorBrowsable(EditorBrowsableState.Never)]
169 public ModelNode FindChildModelNodeByName(string nodeName)
171 global::System.IntPtr cPtr = Interop.Model.FindChildModelNodeByName(SwigCPtr, nodeName);
172 ModelNode ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelNode;
175 // Register new animatable into Registry.
176 ret = new ModelNode(cPtr, true);
180 // We found matched NUI animatable. Reduce cPtr reference count.
181 HandleRef handle = new HandleRef(this, cPtr);
182 Tizen.NUI.Interop.BaseHandle.DeleteBaseHandle(handle);
183 handle = new HandleRef(null, IntPtr.Zero);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// Gets the number of ModelPrimitive objects in the ModelNode object.
192 /// <returns>The number of ModelPrimitive objects in the ModelNode object.</returns>
193 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
194 [EditorBrowsable(EditorBrowsableState.Never)]
195 private uint GetModelPrimitiveCount()
197 uint ret = Interop.ModelNode.GetModelPrimitiveCount(SwigCPtr);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 /// Release swigCPtr.
205 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
206 [EditorBrowsable(EditorBrowsableState.Never)]
207 protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr)
209 Interop.ModelNode.DeleteModelNode(swigCPtr);