Exemple #1
0
        public static Node Find(this INodeContainer node, string nodePath, NodeFindMethod method)
        {
            // early exit check against null for passed reference
            if (node == null)
            {
                return(null);
            }

            nodePath = nodePath.Trim('/');
            int    sepIndex = nodePath.IndexOf('/');
            string curLevel = nodePath;

            if (sepIndex != -1)
            {
                curLevel = nodePath.Substring(0, sepIndex);
                nodePath = nodePath.Substring(sepIndex);
            }
            else
            {
                nodePath = nodePath.Substring(curLevel.Length);
            }


            if (node != null && node.nodes != null)
            {
                if (method == NodeFindMethod.ByName)
                {
                    // check if the path exceeds the current node level
                    foreach (Node child in node.nodes)
                    {
                        if (child.name != null && child.name.Equals(curLevel))
                        {
                            if (nodePath.Length > 1)
                            {
                                Node result = child.Find(nodePath, method);
                                if (result != null)
                                {
                                    return(result);
                                }
                            }
                            return(child);
                        }
                    }
                }
                else
                {
                    // check if the path exceeds the current node level
                    foreach (Node child in node.nodes)
                    {
                        if (child.id != null && child.id.Equals(curLevel))
                        {
                            if (nodePath.Length > 1)
                            {
                                Node result = child.Find(nodePath, method);
                                if (result != null)
                                {
                                    return(result);
                                }
                            }
                            return(child);
                        }
                    }
                }
            }
            return(null);

            /*
             * if (node != null && node.nodes != null)
             *  // check if the path exceeds the current node level
             *  foreach (Node child in node.nodes)
             *  {
             *      //if (child.name.Equals(curLevel))
             *      if (child.id.Equals(curLevel)) // changed check against .name to .id
             *      {
             *          if (nodePath.Length > 1)
             *          {
             *              Node result = child.Find(nodePath);
             *              if (result != null)
             *                  return result;
             *          }
             *          return child;
             *      }
             *  }
             * return null;
             */
        }
Exemple #2
0
        // ! ! ! ! !
        // add the AddInstanceController method to include skin/rig controller to the scene instead of the InstanceGeometry
        // ! ! ! ! !



        public Node FindPath(string nodePath, NodeFindMethod method)
        {
            return(this.Find(nodePath, method));
        }