private PmxVertex.BoneWeight[] ConvertBoneWeight(BoneWeight unityWeight, Transform[] bones, SkinQuality quality)
        {
            int boneCount = (int)quality;

            if (boneCount < 1)
            {
                boneCount = 1;
            }

            var weights = new PmxVertex.BoneWeight[boneCount];

            weights[0].Bone  = this.bonesMap[bones[unityWeight.boneIndex0].name];
            weights[0].Value = unityWeight.weight0;

            if (boneCount >= 2)
            {
                weights[1].Bone  = this.bonesMap[bones[unityWeight.boneIndex1].name];
                weights[1].Value = unityWeight.weight1;
            }

            if (boneCount >= 4)
            {
                weights[2].Bone  = this.bonesMap[bones[unityWeight.boneIndex2].name];
                weights[2].Value = unityWeight.weight2;
                weights[3].Bone  = this.bonesMap[bones[unityWeight.boneIndex3].name];
                weights[3].Value = unityWeight.weight3;
            }

            return(weights);
        }
Example #2
0
 private void ConvertBoneWeightSingle(PmxVertex.BoneWeight pmxBone, float unityWeight, Transform bone)
 {
     pmxBone.Value = unityWeight;
     if (unityWeight > 0)
     {
         pmxBone.Bone = bonesMap[bone.name];
     }
     else
     {
         pmxBone.Bone = 0;
     }
 }