Exemple #1
0
        //--------------------------------
        private void WalkNodeHierarchy(TreeNodeAdv parentTreeNode, ModelNode node)
        {
            // add the current node to the tree.
            TreeNodeAdv curTreeNode = new TreeNodeAdv(node.Name);

            parentTreeNode.Nodes.Add(curTreeNode);

            // now add mesh instances to the tree.
            int meshInstCount = node.MeshInstCount;

            for (int i = 0; i < meshInstCount; ++i)
            {
                // add the instance.
                MeshInst    inst        = node.GetMeshInst(i);
                TreeNodeAdv curMeshNode = new TreeNodeAdv("< mesh >");
                curTreeNode.Nodes.Add(curMeshNode);

                // add the instance's ranges.
                Mesh mesh = inst.Mesh;
                for (int j = 0; j < inst.RangeCount; ++j)
                {
                    // get the range info.
                    RangeInfo range;
                    if (!mesh.GetRange(out range, j))
                    {
                        continue;
                    }

                    // get the material assignend to that range.
                    Material material = inst.GetMaterial(j);
                    if (material == null)
                    {
                        continue;
                    }

                    // add the name of the range.
                    TreeNodeAdv curRangeNode = new TreeNodeAdv(range.Name);
                    curMeshNode.Nodes.Add(curRangeNode);

                    // add the range's material.
                    TreeNodeAdv curMatNode = new TreeNodeAdv(material.Name);
                    curRangeNode.Nodes.Add(curMatNode);

                    // add statistics.
                    TreeNodeAdv curTriCountNode = new TreeNodeAdv(range.Count.ToString() + " tris");
                    curRangeNode.Nodes.Add(curTriCountNode);
                }
            }

            // recurse children.
            int childCount = node.ChildCount;

            for (int i = 0; i < childCount; ++i)
            {
                WalkNodeHierarchy(curTreeNode, node.GetChild(i));
            }
        }