コード例 #1
0
        /// <summary>Generates a brush and returns a <see cref="Chisel.Core.CSGTreeBrush"/> struct that contains a reference to it.</summary>
        /// <param name="userID">A unique id to help identify this particular brush. For instance, this could be an InstanceID to a [UnityEngine.Object](https://docs.unity3d.com/ScriptReference/Object.html)</param>
        /// <param name="localTransformation">The transformation of the brush relative to the tree root</param>
        /// <param name="brushMesh">A <see cref="Chisel.Core.BrushMeshInstance"/>, which is a reference to a <see cref="Chisel.Core.BrushMesh"/>.</param>
        /// <param name="operation">The <see cref="Chisel.Core.CSGOperationType"/> that needs to be performed with this <see cref="Chisel.Core.CSGTreeBrush"/>.</param>
        /// <param name="flags"><see cref="Chisel.Core.CSGTreeBrush"/> specific flags</param>
        /// <returns>A new <see cref="Chisel.Core.CSGTreeBrush"/>. May be an invalid node if it failed to create it.</returns>
        public static CSGTreeBrush Create(Int32 userID, Matrix4x4 localTransformation, BrushMeshInstance brushMesh = default(BrushMeshInstance), CSGOperationType operation = CSGOperationType.Additive, CSGTreeBrushFlags flags = CSGTreeBrushFlags.Default)
        {
            int brushNodeID;

            if (GenerateBrush(userID, out brushNodeID))
            {
                if (localTransformation != default(Matrix4x4))
                {
                    CSGTreeNode.SetNodeLocalTransformation(brushNodeID, ref localTransformation);
                }
                if (operation != CSGOperationType.Additive)
                {
                    CSGTreeNode.SetNodeOperationType(brushNodeID, operation);
                }
                if (flags != CSGTreeBrushFlags.Default)
                {
                    SetBrushFlags(brushNodeID, flags);
                }
                if (brushMesh.Valid)
                {
                    SetBrushMesh(brushNodeID, brushMesh);
                }
            }
            else
            {
                brushNodeID = 0;
            }
            return(new CSGTreeBrush()
            {
                brushNodeID = brushNodeID
            });
        }
コード例 #2
0
        /// <summary>Generates a branch and returns a <see cref="Chisel.Core.CSGTreeBranch"/> struct that contains a reference to it.</summary>
        /// <param name="userID">A unique id to help identify this particular branch. For instance, this could be an InstanceID to a [UnityEngine.Object](https://docs.unity3d.com/ScriptReference/Object.html)</param>
        /// <param name="children">The child nodes that are children of this branch. A branch may not have duplicate children, contain itself or contain a <see cref="Chisel.Core.CSGTree"/>.</param>
        /// <returns>A new <see cref="Chisel.Core.CSGTreeBranch"/>. May be an invalid node if it failed to create it.</returns>
        public static CSGTreeBranch Create(Int32 userID = 0, CSGOperationType operation = CSGOperationType.Additive, params CSGTreeNode[] children)
        {
            int branchNodeID;

            if (!GenerateBranch(userID, out branchNodeID))
            {
                return new CSGTreeBranch()
                       {
                           branchNodeID = 0
                       }
            }
            ;
            if (children != null && children.Length > 0)
            {
                if (operation != CSGOperationType.Additive)
                {
                    CSGTreeNode.SetNodeOperationType(userID, operation);
                }
                if (!CSGTreeNode.SetChildNodes(branchNodeID, children))
                {
                    CSGTreeNode.DestroyNode(branchNodeID);
                    return(new CSGTreeBranch()
                    {
                        branchNodeID = 0
                    });
                }
            }
            return(new CSGTreeBranch()
            {
                branchNodeID = branchNodeID
            });
        }