예제 #1
0
        void panel_Click(object sender, EventArgs e)
        {
            var pointRelativeToTreeview = PointToClient(Cursor.Position);
            var panelClickedNode        = TreeView.GetNodeAt(pointRelativeToTreeview) as TreeNodeEx;

            //we want to delete this node from out list
            Controller.DeleteTreeNode(panelClickedNode);

            DebugMethods.Log(panelClickedNode.Text);
        }
예제 #2
0
        public static BaseNode CreateNode(IINode iNode, bool isPolyObject, bool isParentNode)
        {
            //We need to create our 'RealBaseNode'
            BaseNode tempBaseNode;

            if (isParentNode)
            {
                tempBaseNode = new ParentNode(iNode, isPolyObject);
            }
            else
            {
                tempBaseNode = new ChildNode(iNode, isPolyObject);
            }

            IObject baseObjectRef = iNode.ObjectRef.FindBaseObject();

            if (!isPolyObject)
            {
                //Cast base object to triObject because we know it's a triObject
                ITriObject triObj = baseObjectRef as ITriObject;
                if (triObj == null)
                {
                    return(null);                //if for some reason the cast failed, return
                }
                IMesh triMesh = triObj.Mesh;

                var numFaces = triMesh.NumFaces;

                DebugMethods.Log(isParentNode? String.Format("ParentNode num face {0}", numFaces) : String.Format("ChildNode num face {0}", numFaces));

                //Build FaceID Dictionary.
                for (int index = 0; index < numFaces; index++)
                {
                    IFace  face  = triMesh.Faces[index];
                    ushort matID = face.MatID;

                    if (tempBaseNode.DoesKeyExist(matID))
                    {
                        tempBaseNode.SetMaterialIDBit(matID, index);
                    }
                    else
                    {
                        tempBaseNode.CreateNewMaterialBitArray(matID, index, numFaces);
                    }
                }
            }
            else
            {
                IPolyObject polyObj = baseObjectRef as IPolyObject;
                if (polyObj == null)
                {
                    return(null);                 //if for some reason the cast failed, return
                }
                IMNMesh polyMesh = polyObj.Mesh;

                var numFaces = polyMesh.FNum;

                DebugMethods.Log(isParentNode ? String.Format("ParentNode num face {0}", numFaces) : String.Format("ChildNode num face {0}", numFaces));

                //Build FaceID Dictionary.
                for (int index = 0; index < numFaces; index++)
                {
                    IMNFace face  = polyMesh.F(index);
                    ushort  matID = face.Material;

                    if (tempBaseNode.DoesKeyExist(matID))
                    {
                        //Same material ID, just set the bit
                        //tempBaseNode.GetMaterialBitArray(matID).Set(index, true);
                        tempBaseNode.SetMaterialIDBit(matID, index);
                    }
                    else
                    {
                        tempBaseNode.CreateNewMaterialBitArray(matID, index, numFaces);
                    }
                }
            }
            //We should have a 'RealBaseNode' with a filled up dictionary full of IDs & faces!
            //Maybe there is some weird object with 0 faces?
            if (tempBaseNode.GetMaterialIDCount() == 0)
            {
                return(null);
            }

            return(tempBaseNode);
        }