public FlverBoneInfo(FLVER.Bone bone, List <FLVER.Bone> boneList)
            {
                Matrix GetBoneMatrix(SoulsFormats.FLVER.Bone b)
                {
                    SoulsFormats.FLVER.Bone parentBone = b;

                    var result = Matrix.Identity;

                    do
                    {
                        result *= Matrix.CreateScale(parentBone.Scale.X, parentBone.Scale.Y, parentBone.Scale.Z);
                        result *= Matrix.CreateRotationX(parentBone.Rotation.X);
                        result *= Matrix.CreateRotationZ(parentBone.Rotation.Z);
                        result *= Matrix.CreateRotationY(parentBone.Rotation.Y);
                        result *= Matrix.CreateTranslation(parentBone.Translation.X, parentBone.Translation.Y, parentBone.Translation.Z);

                        if (parentBone.ParentIndex >= 0)
                        {
                            parentBone = boneList[parentBone.ParentIndex];
                        }
                        else
                        {
                            parentBone = null;
                        }
                    }while (parentBone != null);

                    return(result);
                }

                ReferenceMatrix = GetBoneMatrix(bone);
                Name            = bone.Name;

                if (bone.Unk3C == 0)
                {
                    BonePrim = new DbgPrimWireBone(bone.Name, new Transform(ReferenceMatrix), DBG.COLOR_FLVER_BONE)
                    {
                        Category = DbgPrimCategory.FlverBone,
                    };

                    BoundingBoxPrim = new DbgPrimWireBox(Transform.Default,
                                                         new Vector3(bone.BoundingBoxMin.X, bone.BoundingBoxMin.Y, bone.BoundingBoxMin.Z),
                                                         new Vector3(bone.BoundingBoxMax.X, bone.BoundingBoxMax.Y, bone.BoundingBoxMax.Z),
                                                         DBG.COLOR_FLVER_BONE_BBOX)
                    {
                        Category = DbgPrimCategory.FlverBoneBoundingBox,
                    };
                }
            }
Example #2
0
            public FlverBoneInfo(FLVER.Bone bone, List <FLVER.Bone> boneList)
            {
                ParentIndex = bone.ParentIndex;

                if (GlobalBonePrim == null)
                {
                    GlobalBonePrim = new DbgPrimWireBone("(BONE)", new Transform(Matrix.Identity), DBG.COLOR_FLVER_BONE)
                    {
                        Category = DbgPrimCategory.FlverBone,
                    };
                }

                Matrix GetBoneMatrix(SoulsFormats.FLVER.Bone b, bool saveParentBone)
                {
                    SoulsFormats.FLVER.Bone parentBone = b;

                    var result = Matrix.Identity;

                    bool isTopBone = true;

                    do
                    {
                        result *= Matrix.CreateScale(parentBone.Scale.X, parentBone.Scale.Y, parentBone.Scale.Z);
                        result *= Matrix.CreateRotationX(parentBone.Rotation.X);
                        result *= Matrix.CreateRotationZ(parentBone.Rotation.Z);
                        result *= Matrix.CreateRotationY(parentBone.Rotation.Y);
                        result *= Matrix.CreateTranslation(parentBone.Translation.X, parentBone.Translation.Y, parentBone.Translation.Z);

                        if (parentBone.ParentIndex >= 0)
                        {
                            parentBone = boneList[parentBone.ParentIndex];
                        }
                        else
                        {
                            parentBone = null;
                        }

                        isTopBone = false;

                        if (saveParentBone && isTopBone)
                        {
                            ParentReferenceMatrix = GetBoneMatrix(parentBone, saveParentBone: false);
                        }
                    }while (parentBone != null);

                    return(result);
                }

                ReferenceMatrix = GetBoneMatrix(bone, saveParentBone: true);
                Name            = bone.Name;

                //SpawnPrinter.AppendLine(Name, DBG.COLOR_FLVER_BONE);

                if (bone.Unk3C == 0)
                {
                    var nubBone = boneList.Where(bn => bn.Name == bone.Name + "Nub").FirstOrDefault();

                    if (nubBone != null)
                    {
                        var nubMat = Matrix.Identity;
                        nubMat *= Matrix.CreateScale(nubBone.Scale.X, nubBone.Scale.Y, nubBone.Scale.Z);
                        nubMat *= Matrix.CreateRotationX(nubBone.Rotation.X);
                        nubMat *= Matrix.CreateRotationZ(nubBone.Rotation.Z);
                        nubMat *= Matrix.CreateRotationY(nubBone.Rotation.Y);
                        nubMat *= Matrix.CreateTranslation(nubBone.Translation.X, nubBone.Translation.Y, nubBone.Translation.Z);

                        NubReferenceMatrix = nubMat;
                    }
                }

                IsNub = bone.Unk3C != 0;

                BoundingBoxPrim = new DbgPrimWireBox(Transform.Default,
                                                     new Vector3(bone.BoundingBoxMin.X, bone.BoundingBoxMin.Y, bone.BoundingBoxMin.Z),
                                                     new Vector3(bone.BoundingBoxMax.X, bone.BoundingBoxMax.Y, bone.BoundingBoxMax.Z),
                                                     DBG.COLOR_FLVER_BONE_BBOX)
                {
                    Category = DbgPrimCategory.FlverBoneBoundingBox,
                };
            }