private FBXNode CreateFbxBone(FBBone bone, FBXScene pScene, FBXNode parent) { FBXSkeleton lSkeletonLimbNodeAttribute1 = FBXSkeleton.Create(pScene, bone.Name); lSkeletonLimbNodeAttribute1.SetSkeletonType(FBXWrapper.SkelType.eLimbNode); lSkeletonLimbNodeAttribute1.SetSize(1.0); FBXNode lSkeletonLimbNode1 = FBXNode.Create(pScene, bone.Name); lSkeletonLimbNode1.SetNodeAttribute(lSkeletonLimbNodeAttribute1); for (int i = 0; i < bone.Children.Count; i++) { FBBone childBone = bone.Children[i]; FBXNode fbxChildBone = CreateFbxBone(childBone, pScene, lSkeletonLimbNode1); lSkeletonLimbNode1.AddChild(fbxChildBone); } return(lSkeletonLimbNode1); }
private FBXNode CreateFbxBone(int boneIndex, List <MESkeletalMesh.BoneStruct> Skeleton, FBXScene pScene, FBXNode parent) { MESkeletalMesh.BoneStruct bone = Skeleton[boneIndex]; string boneName = bone.BoneName; FBXSkeleton lSkeletonLimbNodeAttribute1 = FBXSkeleton.Create(pScene, boneName); lSkeletonLimbNodeAttribute1.SetSkeletonType(FBXWrapper.SkelType.eLimbNode); lSkeletonLimbNodeAttribute1.SetSize(1.0); FBXNode lSkeletonLimbNode1 = FBXNode.Create(pScene, boneName); lSkeletonLimbNode1.SetNodeAttribute(lSkeletonLimbNodeAttribute1); lSkeletonLimbNode1.LclTranslation = new List <double> { bone.Position.X, -bone.Position.Y, bone.Position.Z }; ME3Explorer.Unreal.Classes.SkeletalMeshOld.Quad boneQuad; boneQuad.x = -bone.Orientation.X; boneQuad.y = bone.Orientation.Y; boneQuad.z = bone.Orientation.Z; boneQuad.w = -bone.Orientation.W; if (boneIndex == 0) { boneQuad.w = boneQuad.w * -1; } Rotator rot = QuatToRotator(boneQuad); lSkeletonLimbNode1.LclRotation = new List <double> { rot.Roll, rot.Pitch, rot.Yaw }; var children = Skeleton.Where(b => b.Parent == boneIndex).ToList(); foreach (var childBone in children) { int childIndexInSkeleton = Skeleton.FindIndex(b => b.Name == childBone.Name); if (childIndexInSkeleton != boneIndex) { FBXNode fbxChildBone = CreateFbxBone(childIndexInSkeleton, Skeleton, pScene, lSkeletonLimbNode1); lSkeletonLimbNode1.AddChild(fbxChildBone); } } return(lSkeletonLimbNode1); }