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 /// Class for Model Primitives for 3D Geometry and Material.
32 /// This ModelPrimitive class is required to draw the mesh geometry defined by the user.
33 /// Users can set Geometry and Material to ModelPrimitive.
34 /// When ModelPrimitive added to ModelNode using ModelNode.AddModelPrimitive() method,
35 /// the Geometry is rendered on the screen according to the Material settings.
37 /// If you load resources from 3D format files such as glTF using Model class,
38 /// ModelPrimitive is also created internally. In this case, blendShape morphing
39 /// or skeletal animation defined in the format can be used.
40 /// However, for the custom ModelPrimitive that is created by user, blendShape morphing or skeletal animation is not supported.
42 [EditorBrowsable(EditorBrowsableState.Never)]
43 public class ModelPrimitive : BaseHandle
45 internal ModelPrimitive(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
50 /// Create an initialized ModelPrimitive.
52 [EditorBrowsable(EditorBrowsableState.Never)]
53 public ModelPrimitive() : this(Interop.ModelPrimitive.ModelPrimitiveNew(), true)
55 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61 /// <param name="modelPrimitive">Source object to copy.</param>
62 [EditorBrowsable(EditorBrowsableState.Never)]
63 public ModelPrimitive(ModelPrimitive modelPrimitive) : this(Interop.ModelPrimitive.NewModelPrimitive(ModelPrimitive.getCPtr(modelPrimitive)), true)
65 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
69 /// Assignment operator.
71 /// <param name="modelPrimitive">Source object to be assigned.</param>
72 /// <returns>Reference to this.</returns>
73 internal ModelPrimitive Assign(ModelPrimitive modelPrimitive)
75 ModelPrimitive ret = new ModelPrimitive(Interop.ModelPrimitive.ModelPrimitiveAssign(SwigCPtr, ModelPrimitive.getCPtr(modelPrimitive)), false);
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 /// The Geometry object of the ModelNode object.
84 /// This Geometry object is for setting Geometry properties of 3D models. Also, Geometry can be shared with multiple ModelPrimitives and if the value is modified, the rendering results of all ModelPrimitives using this Geometry will be changed.
86 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
87 [EditorBrowsable(EditorBrowsableState.Never)]
88 public Geometry Geometry
101 /// The Material object of the ModelNode object.
104 /// This Material object is for setting Material properties of 3D models. Also, Material can be shared with multiple ModelPrimitives and if the value is modified, the rendering results of all ModelPrimitives using this Material will be changed.
106 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
107 [EditorBrowsable(EditorBrowsableState.Never)]
108 public Material Material
116 return GetMaterial();
121 /// Sets the geometry of the ModelPrimitive object.
123 /// <param name="geometry">The Geometry object to set.</param>
124 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
125 [EditorBrowsable(EditorBrowsableState.Never)]
126 private void SetGeometry(Geometry geometry)
128 Interop.ModelPrimitive.SetGeometry(SwigCPtr, Geometry.getCPtr(geometry));
129 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133 /// Gets the geometry of the ModelPrimitive object.
135 /// <returns>The Geometry object of the ModelPrimitive object.</returns>
136 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
137 [EditorBrowsable(EditorBrowsableState.Never)]
138 private Geometry GetGeometry()
140 IntPtr cPtr = Interop.ModelPrimitive.GetGeometry(SwigCPtr);
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 Geometry ret = (cPtr == IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Geometry;
147 /// Sets the material of the ModelPrimitive object.
149 /// <param name="material">The Material object to set.</param>
150 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
151 [EditorBrowsable(EditorBrowsableState.Never)]
152 private void SetMaterial(Material material)
154 Interop.ModelPrimitive.SetMaterial(SwigCPtr, Material.getCPtr(material));
155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159 /// Gets the material of the ModelPrimitive object.
161 /// <returns>The Material object of the ModelPrimitive object.</returns>
162 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
163 [EditorBrowsable(EditorBrowsableState.Never)]
164 private Material GetMaterial()
166 IntPtr cPtr = Interop.ModelPrimitive.GetMaterial(SwigCPtr);
167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168 Material ret = (cPtr == IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Material;
173 /// Release swigCPtr.
175 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
176 [EditorBrowsable(EditorBrowsableState.Never)]
177 protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr)
179 Interop.ModelPrimitive.DeleteModelPrimitive(swigCPtr);