Exemple #1
0
    public static void CacheSkeletonInfo(Transform root, List <FMeshBoneInfo> SkeletonInfo)
    {
        FMeshBoneInfo aMeshBoneInfo = new FMeshBoneInfo();

        aMeshBoneInfo.BoneTransform.position = root.localPosition;
        aMeshBoneInfo.BoneTransform.rotation = root.localRotation.eulerAngles;
        aMeshBoneInfo.BoneTransform.scale    = root.localScale;
        aMeshBoneInfo.ParentIndex            = 0;
        aMeshBoneInfo.Name = root.gameObject.name;
        SkeletonInfo.Add(aMeshBoneInfo);
        AddToSkeletonInfo(root, 0, SkeletonInfo);
    }
Exemple #2
0
    //public List<FMeshBoneInfo> SkeletonInfo = new List<FMeshBoneInfo>();
    //public List<List<FMeshBoneInfo>> animationFames;

    static void AddToSkeletonInfo(Transform tm, int InParentIndex, List <FMeshBoneInfo> SkeletonInfo)
    {
        for (int i = 0; i < tm.childCount; i++)
        {
            Transform     ctm           = tm.GetChild(i);
            FMeshBoneInfo aMeshBoneInfo = new FMeshBoneInfo();
            aMeshBoneInfo.BoneTransform.position = ctm.localPosition;
            aMeshBoneInfo.BoneTransform.rotation = ctm.localRotation.eulerAngles;
            aMeshBoneInfo.BoneTransform.scale    = ctm.localScale;
            aMeshBoneInfo.ParentIndex            = InParentIndex;
            aMeshBoneInfo.Name = ctm.gameObject.name;
            SkeletonInfo.Add(aMeshBoneInfo);
            AddToSkeletonInfo(ctm, SkeletonInfo.Count - 1, SkeletonInfo);
        }
    }
Exemple #3
0
    public FbxNode CreateSkeleton(List <FMeshBoneInfo> boneInfos, ref List <FbxNode> BoneNodes)
    {
        if (boneInfos == null || boneInfos.Count == 0)
        {
            return(null);
        }

        for (int BoneIndex = 0; BoneIndex < boneInfos.Count; BoneIndex++)
        {
            FMeshBoneInfo CurrentBone       = boneInfos[BoneIndex];
            FbxSkeleton   SkeletonAttribute = FbxSkeleton.Create(Scene, CurrentBone.Name);
            if (BoneIndex != 0)
            {
                SkeletonAttribute.SetSkeletonType(FbxSkeleton.EType.eLimbNode);
                //SkeletonAttribute.Size.Set(1.0);
            }
            else
            {
                SkeletonAttribute.SetSkeletonType(FbxSkeleton.EType.eRoot);
                //SkeletonAttribute.Size.Set(1.0);
            }

            // Create the node
            FbxNode BoneNode = FbxNode.Create(Scene, CurrentBone.Name);
            BoneNode.SetNodeAttribute(SkeletonAttribute);

            FbxDouble3 LocalPos   = FbxDataConverter.ConvertToFbxPos(CurrentBone.BoneTransform.position);
            FbxDouble3 LocalRot   = FbxDataConverter.ConvertToFbxRot(CurrentBone.BoneTransform.rotation);
            FbxDouble3 LocalScale = FbxDataConverter.ConvertToFbxScale(CurrentBone.BoneTransform.scale);

            BoneNode.LclTranslation.Set(LocalPos);
            BoneNode.LclRotation.Set(LocalRot);
            BoneNode.LclScaling.Set(LocalScale);

            if (BoneIndex != 0)
            {
                BoneNodes[CurrentBone.ParentIndex].AddChild(BoneNode);
            }

            BoneNodes.Add(BoneNode);
        }

        return(BoneNodes[0]);
    }