Exemplo n.º 1
0
        SkeletonBone AddNodeToSkeletonRecursive(
            FbxNode node,
            SkeletonBone parentBone,
            Dictionary <ulong, bool> skeletonNodeTree,
            FbxSkin[] skins)
        {
            if (BoneIndexDictionary.ContainsKey(node.GetUniqueID()))
            {
                return(null);
            }

            SkeletonBone pBone = new SkeletonBone(node, parentBone, skins, Scene);

            //pBone.CalculateAnimations(animationTracks);
            BoneIndexDictionary[node.GetUniqueID()] = Bones.Count;
            Bones.Add(pBone);

            for (int i = 0; i < node.GetChildCount(); i++)
            {
                FbxNode pChild = node.GetChild(i);
                if (skeletonNodeTree[pChild.GetUniqueID()])
                {
                    var childBone = AddNodeToSkeletonRecursive(pChild, pBone, skeletonNodeTree, skins);
                    if (childBone != null)
                    {
                        pBone.Children.Add(childBone);
                    }
                }
            }
            return(pBone);
        }
Exemplo n.º 2
0
        //Find the cluster that links to the skeleton bone node
        public static FbxCluster FindCluster(FbxNode boneNode, FbxSkin[] skins, out FbxSkin skin)
        {
            for (int i = 0; i < skins.Length; i++)
            {
                skin = skins[i];

                int nClusterCount = skin.GetClusterCount();
                for (int j = 0; j < nClusterCount; j++)
                {
                    FbxCluster fbxCluster = skin.GetCluster(j);
                    if (fbxCluster == null)
                    {
                        continue;
                    }

                    if (fbxCluster.GetLinkMode() == FbxCluster.ELinkMode.eAdditive && fbxCluster.GetAssociateModel() != null)
                    {
                        FbxImportLog.LogMessage(boneNode, "Warning! Associated model.");
                    }

                    if (fbxCluster.GetLink()?.GetUniqueID() == boneNode.GetUniqueID())
                    {
                        return(fbxCluster);
                    }
                }
            }

            skin = null;
            return(null);
        }
Exemplo n.º 3
0
        static bool CheckIsNodeContainsSkeletonRecursive(FbxNode node, Dictionary <ulong, bool> skeletonNodeTree)
        {
            bool isSkeletonNode = IsNodeSkeleton(node);

            for (int i = 0; i < node.GetChildCount(); i++)
            {
                FbxNode pChild = node.GetChild(i);
                if (CheckIsNodeContainsSkeletonRecursive(pChild, skeletonNodeTree))
                {
                    isSkeletonNode = true;
                }
            }

            skeletonNodeTree[node.GetUniqueID()] = isSkeletonNode;

            return(isSkeletonNode);
        }
Exemplo n.º 4
0
 public int GetBoneIndexByNode(FbxNode node)
 {
     return(BoneIndexDictionary[node.GetUniqueID()]);
 }