/* * 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 { /// /// Class for Model Primitives for 3D Geometry and Material. /// /// /// /// This ModelPrimitive class is required to draw the mesh geometry defined by the user. /// Users can set Geometry and Material to ModelPrimitive. /// When ModelPrimitive added to ModelNode using ModelNode.AddModelPrimitive() method, /// the Geometry is rendered on the screen according to the Material settings. /// /// If you load resources from 3D format files such as glTF using Model class, /// ModelPrimitive is also created internally. In this case, blendShape morphing /// or skeletal animation defined in the format can be used. /// However, for the custom ModelPrimitive that is created by user, blendShape morphing or skeletal animation is not supported. /// [EditorBrowsable(EditorBrowsableState.Never)] public class ModelPrimitive : BaseHandle { internal ModelPrimitive(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { } /// /// Create an initialized ModelPrimitive. /// [EditorBrowsable(EditorBrowsableState.Never)] public ModelPrimitive() : this(Interop.ModelPrimitive.ModelPrimitiveNew(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Copy constructor. /// /// Source object to copy. [EditorBrowsable(EditorBrowsableState.Never)] public ModelPrimitive(ModelPrimitive modelPrimitive) : this(Interop.ModelPrimitive.NewModelPrimitive(ModelPrimitive.getCPtr(modelPrimitive)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Assignment operator. /// /// Source object to be assigned. /// Reference to this. internal ModelPrimitive Assign(ModelPrimitive modelPrimitive) { ModelPrimitive ret = new ModelPrimitive(Interop.ModelPrimitive.ModelPrimitiveAssign(SwigCPtr, ModelPrimitive.getCPtr(modelPrimitive)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// The Geometry object of the ModelNode object. /// /// /// 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. /// // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] public Geometry Geometry { set { SetGeometry(value); } get { return GetGeometry(); } } /// /// The Material object of the ModelNode object. /// /// /// 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. /// // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] public Material Material { set { SetMaterial(value); } get { return GetMaterial(); } } /// /// Sets the geometry of the ModelPrimitive object. /// /// The Geometry object to set. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] private void SetGeometry(Geometry geometry) { Interop.ModelPrimitive.SetGeometry(SwigCPtr, Geometry.getCPtr(geometry)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets the geometry of the ModelPrimitive object. /// /// The Geometry object of the ModelPrimitive object. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] private Geometry GetGeometry() { IntPtr cPtr = Interop.ModelPrimitive.GetGeometry(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); Geometry ret = (cPtr == IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Geometry; return ret; } /// /// Sets the material of the ModelPrimitive object. /// /// The Material object to set. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] private void SetMaterial(Material material) { Interop.ModelPrimitive.SetMaterial(SwigCPtr, Material.getCPtr(material)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets the material of the ModelPrimitive object. /// /// The Material object of the ModelPrimitive object. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] private Material GetMaterial() { IntPtr cPtr = Interop.ModelPrimitive.GetMaterial(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); Material ret = (cPtr == IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Material; return ret; } /// /// Release swigCPtr. /// // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr) { Interop.ModelPrimitive.DeleteModelPrimitive(swigCPtr); } } }