/* * 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 { /// /// ModelNode is a class for representing the Node of Model in Scene3D. /// /// /// /// ModelNode contains multiple ModelPrimitives and allows easy access and /// modification of Material information that ModelPrimitive has. If a 3D /// format file is loaded by Model, ModelNode is created internally to /// construct the model. In addition, you can create a Custom ModelNode /// using ModelPrimitive and Material directly and add it to Model. /// /// /// ModelNode modelNode = new ModelNode(); /// ModelPrimitive modelPrimitive = new ModelPrimitive(); /// modelNode.AddModelPrimitive(modelPrimitive); /// /// Material material = new Material; /// modelPrimitive.Material = material; /// /// [EditorBrowsable(EditorBrowsableState.Never)] public class ModelNode : View { internal ModelNode(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { } /// /// Create an initialized ModelNode. /// [EditorBrowsable(EditorBrowsableState.Never)] public ModelNode() : this(Interop.ModelNode.ModelNodeNew(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); this.PositionUsesAnchorPoint = true; } /// /// Copy constructor. /// /// Source object to copy. [EditorBrowsable(EditorBrowsableState.Never)] public ModelNode(ModelNode modelNode) : this(Interop.ModelNode.NewModelNode(ModelNode.getCPtr(modelNode)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Assignment operator. /// /// Source object to be assigned. /// Reference to this. internal ModelNode Assign(ModelNode modelNode) { ModelNode ret = new ModelNode(Interop.ModelNode.ModelNodeAssign(SwigCPtr, ModelNode.getCPtr(modelNode)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Get the number of ModelPrimitive of this ModelNode. /// // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] public uint ModelPrimitiveCount { get { return GetModelPrimitiveCount(); } } /// /// Adds a ModelPrimitive object to the ModelNode object. /// /// The ModelPrimitive object to add. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] public void AddModelPrimitive(ModelPrimitive modelPrimitive) { Interop.ModelNode.AddModelPrimitive(SwigCPtr, ModelPrimitive.getCPtr(modelPrimitive)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Removes a ModelPrimitive object from the ModelNode object. /// /// The ModelPrimitive object to remove. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] public void RemoveModelPrimitive(ModelPrimitive modelPrimitive) { Interop.ModelNode.RemoveModelPrimitive(SwigCPtr, ModelPrimitive.getCPtr(modelPrimitive)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Removes a ModelPrimitive object from the ModelNode object at the specified index. /// /// The index of the ModelPrimitive object to remove. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] public void RemoveModelPrimitive(uint index) { Interop.ModelNode.RemoveModelPrimitive(SwigCPtr, index); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets the ModelPrimitive object at the specified index. /// /// The index of the ModelPrimitive object to get. /// The ModelPrimitive object at the specified index. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] public ModelPrimitive GetModelPrimitive(uint index) { global::System.IntPtr cPtr = Interop.ModelNode.GetModelPrimitive(SwigCPtr, index); ModelPrimitive ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelPrimitive; if (ret == null) { // Register new animatable into Registry. ret = new ModelPrimitive(cPtr, true); } else { // We found matched NUI animatable. Reduce cPtr reference count. HandleRef handle = new HandleRef(this, cPtr); Tizen.NUI.Interop.BaseHandle.DeleteBaseHandle(handle); handle = new HandleRef(null, IntPtr.Zero); } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Removes Returns a child ModelNode object with a name that matches nodeName. /// /// The name of the child ModelNode object you want to find. /// Child ModelNode that has nodeName as name. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] public ModelNode FindChildModelNodeByName(string nodeName) { global::System.IntPtr cPtr = Interop.Model.FindChildModelNodeByName(SwigCPtr, nodeName); ModelNode ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelNode; if (ret == null) { // Register new animatable into Registry. ret = new ModelNode(cPtr, true); } else { // We found matched NUI animatable. Reduce cPtr reference count. HandleRef handle = new HandleRef(this, cPtr); Tizen.NUI.Interop.BaseHandle.DeleteBaseHandle(handle); handle = new HandleRef(null, IntPtr.Zero); } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets the number of ModelPrimitive objects in the ModelNode object. /// /// The number of ModelPrimitive objects in the ModelNode object. // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] private uint GetModelPrimitiveCount() { uint ret = Interop.ModelNode.GetModelPrimitiveCount(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); 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.ModelNode.DeleteModelNode(swigCPtr); } } }