示例#1
0
 public FSKL(ResU.Skeleton skl)
 {
     node           = new fsklNode();
     node.fskl      = this;
     node.SkeletonU = skl;
     BfresWiiU.ReadSkeleton(node, skl, this);
 }
示例#2
0
            public override void Replace(string FileName)
            {
                string extension = System.IO.Path.GetExtension(FileName);

                if (extension == ".bfskl")
                {
                    //Todo regenerate indices.
                    //This will just fix swapping the same bonesets with slightly adjusted indices
                    if (SkeletonU != null)
                    {
                        var indices = this.SkeletonU.MatrixToBoneList;

                        SkeletonU = new ResU.Skeleton();
                        SkeletonU.Import(FileName, GetResFileU());
                        SkeletonU.MatrixToBoneList = indices;

                        Nodes.Clear();
                        fskl.bones.Clear();
                        BfresWiiU.ReadSkeleton(this, SkeletonU, fskl);
                    }
                    else
                    {
                        var indices = this.SkeletonU.MatrixToBoneList;

                        Skeleton = new Skeleton();
                        Skeleton.Import(FileName);
                        SkeletonU.MatrixToBoneList = indices;

                        Nodes.Clear();
                        fskl.bones.Clear();
                        BfresSwitch.ReadSkeleton(this, Skeleton, fskl);
                    }
                }
            }
示例#3
0
            public void ReplaceMatchingFolder()
            {
                FolderSelectDialog ofd = new FolderSelectDialog();

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    foreach (var file in System.IO.Directory.GetFiles(ofd.SelectedPath))
                    {
                        string extension = System.IO.Path.GetExtension(file);

                        if (extension == ".bfbon")
                        {
                            if (SkeletonU != null)
                            {
                                ResU.Bone BoneTemp = new ResU.Bone();
                                BoneTemp.Import(file, GetResFileU());

                                foreach (BfresBone bone in fskl.bones)
                                {
                                    if (BoneTemp.Name == bone.Text)
                                    {
                                        bone.CopyData(BoneTemp);
                                    }
                                }

                                BfresWiiU.ReadSkeleton(this, SkeletonU, fskl);
                            }
                            else
                            {
                                Bone BoneTemp = new Bone();
                                BoneTemp.Import(file);

                                foreach (BfresBone bone in fskl.bones)
                                {
                                    if (BoneTemp.Name == bone.Text)
                                    {
                                        bone.CopyData(BoneTemp);
                                    }
                                }

                                BfresSwitch.ReadSkeleton(this, Skeleton, fskl);
                            }
                        }
                    }
                }
            }
示例#4
0
            public void ReplaceMatchingFile( )
            {
                OpenFileDialog ofd = new OpenFileDialog();

                ofd.DefaultExt = ReplaceFilter;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string extension = System.IO.Path.GetExtension(ofd.FileName);

                    if (extension == ".bfskl")
                    {
                        if (SkeletonU != null)
                        {
                            ResU.Skeleton SkeltonTemp = new ResU.Skeleton();
                            SkeltonTemp.Import(ofd.FileName, GetResFileU());

                            foreach (BfresBone bone in fskl.bones)
                            {
                                if (SkeltonTemp.Bones.ContainsKey(bone.Text))
                                {
                                    bone.CopyData(SkeltonTemp.Bones[bone.Text]);
                                }
                            }

                            BfresWiiU.ReadSkeleton(this, SkeletonU, fskl);
                        }
                        else
                        {
                            Skeleton SkeltonTemp = new Skeleton();
                            SkeltonTemp.Import(ofd.FileName);

                            foreach (BfresBone bone in fskl.bones)
                            {
                                if (SkeltonTemp.BoneDict.ContainsKey(bone.Text))
                                {
                                    int index = SkeltonTemp.BoneDict.GetIndex(bone.Text);
                                    bone.CopyData(SkeltonTemp.Bones[index]);
                                }
                            }

                            BfresSwitch.ReadSkeleton(this, Skeleton, fskl);
                        }
                    }
                }
            }
示例#5
0
            public override void Replace(string FileName)
            {
                string extension = System.IO.Path.GetExtension(FileName);

                if (extension == ".bfskl")
                {
                    if (SkeletonU != null)
                    {
                        SkeletonU = new ResU.Skeleton();
                        SkeletonU.Import(FileName, GetResFileU());
                        Nodes.Clear();
                        fskl.bones.Clear();
                        BfresWiiU.ReadSkeleton(this, SkeletonU, fskl);
                    }
                    else
                    {
                        Skeleton = new Skeleton();
                        Skeleton.Import(FileName);
                        Nodes.Clear();
                        fskl.bones.Clear();
                        BfresSwitch.ReadSkeleton(this, Skeleton, fskl);
                    }
                }
            }
示例#6
0
            public void ReplaceMatchingFile( )
            {
                OpenFileDialog ofd = new OpenFileDialog();

                ofd.DefaultExt = ReplaceFilter;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string extension = System.IO.Path.GetExtension(ofd.FileName);

                    if (extension == ".bfskl")
                    {
                        if (SkeletonU != null)
                        {
                            ResU.Skeleton SkeltonTemp = new ResU.Skeleton();
                            SkeltonTemp.Import(ofd.FileName, GetResFileU());

                            foreach (BfresBone bone in fskl.bones)
                            {
                                if (SkeltonTemp.Bones.ContainsKey(bone.Text))
                                {
                                    bone.CopyData(SkeltonTemp.Bones[bone.Text]);
                                }
                            }

                            BfresWiiU.ReadSkeleton(this, SkeletonU, fskl);
                        }
                        else
                        {
                            Skeleton SkeltonTemp = new Skeleton();
                            SkeltonTemp.Import(ofd.FileName);

                            foreach (BfresBone bone in fskl.bones)
                            {
                                if (SkeltonTemp.BoneDict.ContainsKey(bone.Text))
                                {
                                    int index = SkeltonTemp.BoneDict.GetIndex(bone.Text);
                                    bone.CopyData(SkeltonTemp.Bones[index]);
                                }
                            }

                            BfresSwitch.ReadSkeleton(this, Skeleton, fskl);
                        }
                    }
                    if (extension == ".csv")
                    {
                        using (var reader = new System.IO.StringReader(System.IO.File.ReadAllText(ofd.FileName)))
                        {
                            string value = reader.ReadLine();
                            if (value != "Bones Geometry")
                            {
                                return;
                            }

                            float X = 0;
                            float Y = 0;
                            float Z = 0;
                            float W = 0;
                            while (true)
                            {
                                string line = reader.ReadLine();
                                if (line != null)
                                {
                                    foreach (BfresBone bone in fskl.bones)
                                    {
                                        if (bone.Text == line)
                                        {
                                            string name           = line;
                                            string scaleStr       = reader.ReadLine();
                                            string rotationStr    = reader.ReadLine();
                                            string translationStr = reader.ReadLine();

                                            string[] valuesS = scaleStr.Replace("\n", "").Replace("\r", "").Split(',');
                                            string[] valuesR = rotationStr.Replace("\n", "").Replace("\r", "").Split(',');
                                            string[] valuesT = translationStr.Replace("\n", "").Replace("\r", "").Split(',');

                                            Syroot.Maths.Vector3F translate;
                                            Syroot.Maths.Vector3F scale;
                                            Syroot.Maths.Vector4F rotate;

                                            float.TryParse(valuesT[0], out X);
                                            float.TryParse(valuesT[1], out Y);
                                            float.TryParse(valuesT[2], out Z);
                                            translate = new Syroot.Maths.Vector3F(X, Y, Z);

                                            float.TryParse(valuesR[0], out X);
                                            float.TryParse(valuesR[1], out Y);
                                            float.TryParse(valuesR[2], out Z);
                                            float.TryParse(valuesR[3], out W);
                                            rotate = new Syroot.Maths.Vector4F(X, Y, Z, W);

                                            float.TryParse(valuesS[0], out X);
                                            float.TryParse(valuesS[1], out Y);
                                            float.TryParse(valuesS[2], out Z);
                                            scale = new Syroot.Maths.Vector3F(X, Y, Z);

                                            if (bone.BoneU != null)
                                            {
                                                bone.BoneU.Position = translate;
                                                bone.BoneU.Scale    = scale;
                                                bone.BoneU.Rotation = rotate;
                                            }
                                            else
                                            {
                                                bone.Bone.Position = translate;
                                                bone.Bone.Scale    = scale;
                                                bone.Bone.Rotation = rotate;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (SkeletonU != null)
                            {
                                BfresWiiU.ReadSkeleton(this, SkeletonU, fskl);
                            }
                            else
                            {
                                BfresSwitch.ReadSkeleton(this, Skeleton, fskl);
                            }

                            LibraryGUI.UpdateViewport();
                        }
                    }
                }
            }