예제 #1
0
        public INF1(Scene scene, JNT1 skeleton)
        {
            FlatNodes = new List <SceneNode>();
            Root      = new SceneNode(NodeType.Joint, 0, null);
            FlatNodes.Add(Root);

            int downNodeCount = 0;

            // First add objects that should be the direct children of the root bone.
            // This includes any objects that are weighted to multiple bones, as well as objects weighted to only the root bone itself.
            for (int mat_index = 0; mat_index < scene.MaterialCount; mat_index++)
            {
                for (int i = 0; i < scene.MeshCount; i++)
                {
                    if (scene.Meshes[i].MaterialIndex != mat_index)
                    {
                        continue;
                    }
                    if (scene.Meshes[i].BoneCount == 1 && scene.Meshes[i].Bones[0].Name != skeleton.FlatSkeleton[0].Name)
                    {
                        continue;
                    }

                    SceneNode downNode1 = new SceneNode(NodeType.OpenChild, 0, Root);
                    SceneNode matNode   = new SceneNode(NodeType.Material, scene.Meshes[i].MaterialIndex, Root);
                    SceneNode downNode2 = new SceneNode(NodeType.OpenChild, 0, Root);
                    SceneNode shapeNode = new SceneNode(NodeType.Shape, i, Root);

                    FlatNodes.Add(downNode1);
                    FlatNodes.Add(matNode);
                    FlatNodes.Add(downNode2);
                    FlatNodes.Add(shapeNode);

                    downNodeCount += 2;
                }
            }

            // Next add objects as children of specific bones, if those objects are weighted to only a single bone.
            if (skeleton.FlatSkeleton.Count > 1)
            {
                SceneNode rootChildDown = new SceneNode(NodeType.OpenChild, 0, Root);
                FlatNodes.Add(rootChildDown);

                foreach (Rigging.Bone bone in skeleton.SkeletonRoot.Children)
                {
                    GetNodesRecursive(bone, skeleton.FlatSkeleton, Root, scene.Meshes, scene.Materials);
                }

                SceneNode rootChildUp = new SceneNode(NodeType.CloseChild, 0, Root);
                FlatNodes.Add(rootChildUp);
            }

            for (int i = 0; i < downNodeCount; i++)
            {
                FlatNodes.Add(new SceneNode(NodeType.CloseChild, 0, Root));
            }

            FlatNodes.Add(new SceneNode(NodeType.Terminator, 0, Root));
        }
예제 #2
0
        public INF1(Scene scene, JNT1 skeleton)
        {
            FlatNodes = new List <SceneNode>();
            Root      = new SceneNode(NodeType.Joint, 0, null);
            FlatNodes.Add(Root);

            for (int i = 0; i < scene.MeshCount; i++)
            {
                SceneNode downNode1 = new SceneNode(NodeType.OpenChild, 0, Root);
                SceneNode matNode   = new SceneNode(NodeType.Material, i, Root);
                SceneNode downNode2 = new SceneNode(NodeType.OpenChild, 0, Root);
                SceneNode shapeNode = new SceneNode(NodeType.Shape, i, Root);

                FlatNodes.Add(downNode1);
                FlatNodes.Add(matNode);
                FlatNodes.Add(downNode2);
                FlatNodes.Add(shapeNode);
            }

            if (skeleton.FlatSkeleton.Count > 1)
            {
                foreach (Rigging.Bone bone in skeleton.SkeletonRoot.Children)
                {
                    SceneNode rootChildDown = new SceneNode(NodeType.OpenChild, 0, Root);
                    FlatNodes.Add(rootChildDown);

                    GetNodesRecursive(bone, skeleton.FlatSkeleton, Root);

                    SceneNode rootChildUp = new SceneNode(NodeType.CloseChild, 0, Root);
                    FlatNodes.Add(rootChildUp);
                }
            }

            for (int i = 0; i < scene.MeshCount * 2; i++)
            {
                FlatNodes.Add(new SceneNode(NodeType.CloseChild, 0, Root));
            }

            FlatNodes.Add(new SceneNode(NodeType.Terminator, 0, Root));
        }