Exemplo n.º 1
0
        public BFRES_MTA(MaterialAnim vis)
        {
            ImageKey         = "image";
            SelectedImageKey = "image";


            Text = vis.Name;

            FrameCount = (uint)vis.FrameCount;

            foreach (MaterialAnimData matanim in vis.MaterialAnimDataList)
            {
                MatAnimEntry mat = new MatAnimEntry();

                FMAANode matnode = new FMAANode(matanim);

                mat.Text = matanim.Name;

                for (int Frame = 0; Frame < vis.FrameCount; Frame++)
                {
                    int CurTrack = 0;
                    foreach (FMAATrack track in matnode.tracks)
                    {
                        MatAnimData md = new MatAnimData();

                        float value;

                        if (matanim.Curves[CurTrack].CurveType == AnimCurveType.Cubic)
                        {
                            FMAAKey left  = track.GetLeft(Frame);
                            FMAAKey right = track.GetRight(Frame);

                            value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);

                            md.keys.Add(value);
                        }


                        mat.matCurves.Add(md);
                        CurTrack++;
                    }
                }

                matEntries.Add(mat);
            }
        }
Exemplo n.º 2
0
            public PerShapeAnim(BFRES.MTA mta, ShapeAnim vis)
            {
                mta.Text             = vis.Name;
                mta.ImageKey         = "mesh";
                mta.SelectedImageKey = "mesh";

                mta.FrameCount = (uint)vis.FrameCount;


                foreach (VertexShapeAnim vtxanim in vis.VertexShapeAnims)
                {
                    BFRES.MatAnimEntry mat = new BFRES.MatAnimEntry();

                    mat.ImageKey         = "bone";
                    mat.SelectedImageKey = "bone";


                    //First set the data then iterpolate
                    mat.Text = vtxanim.Name;
                    foreach (AnimCurve cr in vtxanim.Curves)
                    {
                        mat.Interpolate(cr);
                    }

                    for (int Frame = 0; Frame < vis.FrameCount; Frame++)
                    {
                        foreach (BFRES.MatAnimData track in mat.matCurves)
                        {
                            BFRES.AnimKey left  = track.GetLeft(Frame);
                            BFRES.AnimKey right = track.GetRight(Frame);



                            track.Value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);
                        }
                    }
                    mta.matEntries.Add(mat);
                }
            }
Exemplo n.º 3
0
        public static AnimationGroupNode Read(string filename, ResFile TargetWiiUBFRES)
        {
            FileData f = new FileData(filename);

            f.seek(0);

            f.Endian = Endianness.Little;

            Console.WriteLine("Reading Animations ...");

            f.seek(4);                     // magic check
            int SwitchCheck = f.readInt(); //Switch version only has padded magic

            f.skip(4);
            if (SwitchCheck == 0x20202020)
            {
                //    SwitchAnim2WiiU(path); //Hacky auto convert switch anims to wii u


                ResNSW.ResFile b = new ResNSW.ResFile(filename);

                AnimationGroupNode ThisAnimation = new AnimationGroupNode()
                {
                    Text = "Skeleton Animations"
                };

                TreeNode dummy = new TreeNode()
                {
                    Text = "Animation Set"
                };

                int i = 0;
                foreach (ResNSW.SkeletalAnim ska in b.SkeletalAnims)
                {
                    Animation a = new Animation(ska.Name);
                    ThisAnimation.Nodes.Add(a);

                    a.FrameCount = ska.FrameCount;
                    i++;
                    try
                    {
                        foreach (Syroot.NintenTools.NSW.Bfres.BoneAnim bn in ska.BoneAnims)
                        {
                            FSKANode bonean = new FSKANode(bn);

                            Animation.KeyNode bone = new Animation.KeyNode("");
                            a.Bones.Add(bone);
                            if (ska.FlagsRotate == ResNSW.SkeletalAnimFlagsRotate.EulerXYZ)
                            {
                                bone.RotType = Animation.RotationType.EULER;
                            }
                            else
                            {
                                bone.RotType = Animation.RotationType.QUATERNION;
                            }

                            bone.Text = bonean.Text;

                            for (int Frame = 0; Frame < ska.FrameCount; Frame++)
                            {
                                //Set base/start values for bones.
                                //Note. BOTW doesn't use base values as it uses havok engine. Need to add option to disable these
                                if (Frame == 0 && Runtime.HasNoAnimationBaseValues == false)
                                {
                                    bone.XSCA.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = 1
                                    });
                                    bone.YSCA.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = 1
                                    });
                                    bone.ZSCA.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = 1
                                    });
                                    bone.XROT.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.rot.X
                                    });
                                    bone.YROT.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.rot.Y
                                    });
                                    bone.ZROT.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.rot.Z
                                    });
                                    bone.XPOS.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.pos.X
                                    });
                                    bone.YPOS.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.pos.Y
                                    });
                                    bone.ZPOS.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.pos.Z
                                    });
                                }
                                foreach (FSKATrack track in bonean.tracks)
                                {
                                    Animation.KeyFrame frame = new Animation.KeyFrame();
                                    frame.InterType = Animation.InterpolationType.HERMITE;
                                    frame.Frame     = Frame;

                                    FSKAKey left  = track.GetLeft(Frame);
                                    FSKAKey right = track.GetRight(Frame);
                                    float   value;



                                    value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);

                                    // interpolate the value and apply
                                    switch (track.flag)
                                    {
                                    case (int)TrackType.XPOS: frame.Value = value; bone.XPOS.Keys.Add(frame); break;

                                    case (int)TrackType.YPOS: frame.Value = value; bone.YPOS.Keys.Add(frame); break;

                                    case (int)TrackType.ZPOS: frame.Value = value; bone.ZPOS.Keys.Add(frame); break;

                                    case (int)TrackType.XROT: frame.Value = value; bone.XROT.Keys.Add(frame); break;

                                    case (int)TrackType.YROT: frame.Value = value; bone.YROT.Keys.Add(frame); break;

                                    case (int)TrackType.ZROT: frame.Value = value; bone.ZROT.Keys.Add(frame); break;

                                    case (int)TrackType.XSCA: frame.Value = value; bone.XSCA.Keys.Add(frame); break;

                                    case (int)TrackType.YSCA: frame.Value = value; bone.YSCA.Keys.Add(frame); break;

                                    case (int)TrackType.ZSCA: frame.Value = value; bone.ZSCA.Keys.Add(frame); break;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                return(ThisAnimation);
            }
            else
            {
                f.eof();

                TargetWiiUBFRES = new ResFile(filename);

                ThisAnimation = new AnimationGroupNode()
                {
                    Text = "Skeleton Animations"
                };

                TreeNode dummy = new TreeNode()
                {
                    Text = "Animation Set"
                };

                int i = 0;
                foreach (SkeletalAnim ska in TargetWiiUBFRES.SkeletalAnims.Values)
                {
                    Animation a = new Animation(ska.Name);
                    ThisAnimation.Nodes.Add(a);

                    a.FrameCount = ska.FrameCount;
                    i++;
                    try
                    {
                        foreach (BoneAnim bn in ska.BoneAnims)
                        {
                            FSKANodeWiiU bonean = new FSKANodeWiiU(bn);

                            Animation.KeyNode bone = new Animation.KeyNode("");
                            a.Bones.Add(bone);
                            if (ska.FlagsRotate == SkeletalAnimFlagsRotate.EulerXYZ)
                            {
                                bone.RotType = Animation.RotationType.EULER;
                            }
                            else
                            {
                                bone.RotType = Animation.RotationType.QUATERNION;
                            }

                            bone.Text = bonean.Text;


                            for (int Frame = 0; Frame < ska.FrameCount; Frame++)
                            {
                                //Set base/start values for bones.
                                //Note. BOTW doesn't use base values as it uses havok engine. Need to add option to disable these
                                if (Frame == 0 && Runtime.HasNoAnimationBaseValues == false)
                                {
                                    bone.XSCA.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.sca.X
                                    });
                                    bone.YSCA.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.sca.Y
                                    });
                                    bone.ZSCA.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.sca.Z
                                    });
                                    bone.XROT.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.rot.X
                                    });
                                    bone.YROT.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.rot.Y
                                    });
                                    bone.ZROT.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.rot.Z
                                    });
                                    bone.XPOS.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.pos.X
                                    });
                                    bone.YPOS.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.pos.Y
                                    });
                                    bone.ZPOS.Keys.Add(new Animation.KeyFrame()
                                    {
                                        Frame = 0, Value = bonean.pos.Z
                                    });
                                }
                                foreach (FSKATrack track in bonean.tracks)
                                {
                                    Animation.KeyFrame frame = new Animation.KeyFrame();
                                    frame.InterType = Animation.InterpolationType.HERMITE;
                                    frame.Frame     = Frame;

                                    FSKAKey left  = track.GetLeft(Frame);
                                    FSKAKey right = track.GetRight(Frame);
                                    float   value;



                                    value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);

                                    // interpolate the value and apply
                                    switch (track.flag)
                                    {
                                    case (int)TrackType.XPOS: frame.Value = value; bone.XPOS.Keys.Add(frame); break;

                                    case (int)TrackType.YPOS: frame.Value = value; bone.YPOS.Keys.Add(frame); break;

                                    case (int)TrackType.ZPOS: frame.Value = value; bone.ZPOS.Keys.Add(frame); break;

                                    case (int)TrackType.XROT: frame.Value = value; bone.XROT.Keys.Add(frame); break;

                                    case (int)TrackType.YROT: frame.Value = value; bone.YROT.Keys.Add(frame); break;

                                    case (int)TrackType.ZROT: frame.Value = value; bone.ZROT.Keys.Add(frame); break;

                                    case (int)TrackType.XSCA: frame.Value = value; bone.XSCA.Keys.Add(frame); break;

                                    case (int)TrackType.YSCA: frame.Value = value; bone.YSCA.Keys.Add(frame); break;

                                    case (int)TrackType.ZSCA: frame.Value = value; bone.ZSCA.Keys.Add(frame); break;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                return(ThisAnimation);
            }
        }
Exemplo n.º 4
0
            public void Read(ResFile TargetWiiUBFRES, AnimationGroupNode ThisAnimation, ResNSW.ResFile b)
            {
                Console.WriteLine("Reading Skeleton Animations ...");

                if (b != null)
                {
                    TreeNode SkeletonAnimation = new TreeNode()
                    {
                        Text = "Skeleton Animations"
                    };

                    ThisAnimation.Nodes.Add(SkeletonAnimation);

                    TreeNode dummy = new TreeNode()
                    {
                        Text = "Animation Set"
                    };

                    int i = 0;
                    foreach (ResNSW.SkeletalAnim ska in b.SkeletalAnims)
                    {
                        if (i == 0)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "0 - 100"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 100)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "100 - 200"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 200)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "200 - 300"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 300)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "300 - 400"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 400)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "400 - 500"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 500)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "500 - 600"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 600)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "600 - 700"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 700)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "700 - 800"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 800)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "800 - 900"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 900)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "900 - 1000"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 1000)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "1000+"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }

                        Animation a = new Animation(ska.Name);
                        SkeletonAnimations.Add(a);

                        a.FrameCount = ska.FrameCount;

                        if (i >= 0 && i < 100)
                        {
                            SkeletonAnimation.Nodes[0].Nodes.Add(a);
                        }
                        if (i >= 100 && i < 200)
                        {
                            SkeletonAnimation.Nodes[1].Nodes.Add(a);
                        }
                        if (i >= 200 && i < 300)
                        {
                            SkeletonAnimation.Nodes[2].Nodes.Add(a);
                        }
                        if (i >= 300 && i < 400)
                        {
                            SkeletonAnimation.Nodes[3].Nodes.Add(a);
                        }
                        if (i >= 400 && i < 500)
                        {
                            SkeletonAnimation.Nodes[4].Nodes.Add(a);
                        }
                        if (i >= 500 && i < 600)
                        {
                            SkeletonAnimation.Nodes[5].Nodes.Add(a);
                        }
                        if (i >= 600 && i < 700)
                        {
                            SkeletonAnimation.Nodes[6].Nodes.Add(a);
                        }
                        if (i >= 700 && i < 800)
                        {
                            SkeletonAnimation.Nodes[7].Nodes.Add(a);
                        }
                        if (i >= 800 && i < 900)
                        {
                            SkeletonAnimation.Nodes[8].Nodes.Add(a);
                        }
                        if (i >= 900 && i < 1000)
                        {
                            SkeletonAnimation.Nodes[9].Nodes.Add(a);
                        }

                        i++;
                        try
                        {
                            foreach (ResNSW.BoneAnim bn in ska.BoneAnims)
                            {
                                FSKANode bonean = new FSKANode(bn);

                                Animation.KeyNode bone = new Animation.KeyNode("");
                                a.Bones.Add(bone);
                                if (ska.FlagsRotate == ResNSW.SkeletalAnimFlagsRotate.EulerXYZ)
                                {
                                    bone.RotType = Animation.RotationType.EULER;
                                }
                                else
                                {
                                    bone.RotType = Animation.RotationType.QUATERNION;
                                }

                                bone.Text = bonean.Text;

                                for (int Frame = 0; Frame < ska.FrameCount; Frame++)
                                {
                                    //Set base/start values for bones.
                                    //Note. BOTW doesn't use base values as it uses havok engine. Need to add option to disable these
                                    if (Frame == 0)
                                    {
                                        if (bn.FlagsBase.HasFlag(ResNSW.BoneAnimFlagsBase.Scale))
                                        {
                                            bone.XSCA.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.sca.X
                                            });
                                            bone.YSCA.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.sca.Y
                                            });
                                            bone.ZSCA.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.sca.Z
                                            });
                                        }
                                        if (bn.FlagsBase.HasFlag(ResNSW.BoneAnimFlagsBase.Rotate))
                                        {
                                            bone.XROT.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.rot.X
                                            });
                                            bone.YROT.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.rot.Y
                                            });
                                            bone.ZROT.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.rot.Z
                                            });
                                            bone.WROT.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.rot.W
                                            });
                                        }
                                        if (bn.FlagsBase.HasFlag(ResNSW.BoneAnimFlagsBase.Translate))
                                        {
                                            bone.XPOS.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.pos.X
                                            });
                                            bone.YPOS.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.pos.Y
                                            });
                                            bone.ZPOS.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.pos.Z
                                            });
                                        }
                                    }
                                    foreach (FSKATrack track in bonean.tracks)
                                    {
                                        Animation.KeyFrame frame = new Animation.KeyFrame();
                                        frame.InterType = Animation.InterpolationType.HERMITE;
                                        frame.Frame     = Frame;

                                        FSKAKey left  = track.GetLeft(Frame);
                                        FSKAKey right = track.GetRight(Frame);
                                        float   value;



                                        value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);

                                        // interpolate the value and apply
                                        switch (track.flag)
                                        {
                                        case (int)TrackType.XPOS: frame.Value = value; bone.XPOS.Keys.Add(frame); break;

                                        case (int)TrackType.YPOS: frame.Value = value; bone.YPOS.Keys.Add(frame); break;

                                        case (int)TrackType.ZPOS: frame.Value = value; bone.ZPOS.Keys.Add(frame); break;

                                        case (int)TrackType.XROT: frame.Value = value; bone.XROT.Keys.Add(frame); break;

                                        case (int)TrackType.YROT: frame.Value = value; bone.YROT.Keys.Add(frame); break;

                                        case (int)TrackType.ZROT: frame.Value = value; bone.ZROT.Keys.Add(frame); break;

                                        case (int)TrackType.XSCA: frame.Value = value; bone.XSCA.Keys.Add(frame); break;

                                        case (int)TrackType.YSCA: frame.Value = value; bone.YSCA.Keys.Add(frame); break;

                                        case (int)TrackType.ZSCA: frame.Value = value; bone.ZSCA.Keys.Add(frame); break;
                                        }
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                else
                {
                    TreeNode SkeletonAnimation = new TreeNode()
                    {
                        Text = "Skeleton Animations"
                    };

                    ThisAnimation.Nodes.Add(SkeletonAnimation);

                    TreeNode dummy = new TreeNode()
                    {
                        Text = "Animation Set"
                    };

                    int i = 0;
                    foreach (SkeletalAnim ska in TargetWiiUBFRES.SkeletalAnims.Values)
                    {
                        if (i == 0)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "0 - 100"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 100)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "100 - 200"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 200)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "200 - 300"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 300)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "300 - 400"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 400)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "400 - 500"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 500)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "500 - 600"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 600)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "600 - 700"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 700)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "700 - 800"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 800)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "800 - 900"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 900)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "900 - 1000"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }
                        if (i == 1000)
                        {
                            dummy = new TreeNode()
                            {
                                Text = "Animation Set " + "1000+"
                            };
                            SkeletonAnimation.Nodes.Add(dummy);
                        }

                        Animation a = new Animation(ska.Name);
                        SkeletonAnimations.Add(a);

                        if (i >= 0 && i < 100)
                        {
                            SkeletonAnimation.Nodes[0].Nodes.Add(a);
                        }
                        if (i >= 100 && i < 200)
                        {
                            SkeletonAnimation.Nodes[1].Nodes.Add(a);
                        }
                        if (i >= 200 && i < 300)
                        {
                            SkeletonAnimation.Nodes[2].Nodes.Add(a);
                        }
                        if (i >= 300 && i < 400)
                        {
                            SkeletonAnimation.Nodes[3].Nodes.Add(a);
                        }
                        if (i >= 400 && i < 500)
                        {
                            SkeletonAnimation.Nodes[4].Nodes.Add(a);
                        }
                        if (i >= 500 && i < 600)
                        {
                            SkeletonAnimation.Nodes[5].Nodes.Add(a);
                        }
                        if (i >= 600 && i < 700)
                        {
                            SkeletonAnimation.Nodes[6].Nodes.Add(a);
                        }
                        if (i >= 700 && i < 800)
                        {
                            SkeletonAnimation.Nodes[7].Nodes.Add(a);
                        }
                        if (i >= 800 && i < 900)
                        {
                            SkeletonAnimation.Nodes[8].Nodes.Add(a);
                        }
                        if (i >= 900 && i < 1000)
                        {
                            SkeletonAnimation.Nodes[9].Nodes.Add(a);
                        }


                        a.FrameCount = ska.FrameCount;
                        i++;
                        try
                        {
                            foreach (BoneAnim bn in ska.BoneAnims)
                            {
                                FSKANodeWiiU bonean = new FSKANodeWiiU(bn);

                                Animation.KeyNode bone = new Animation.KeyNode("");
                                a.Bones.Add(bone);
                                if (ska.FlagsRotate == SkeletalAnimFlagsRotate.EulerXYZ)
                                {
                                    bone.RotType = Animation.RotationType.EULER;
                                }
                                else
                                {
                                    bone.RotType = Animation.RotationType.QUATERNION;
                                }

                                bone.Text = bonean.Text;


                                for (int Frame = 0; Frame < ska.FrameCount; Frame++)
                                {
                                    //Set base/start values for bones.
                                    //Note. BOTW doesn't use base values as it uses havok engine. Need to add option to disable these
                                    if (Frame == 0)
                                    {
                                        if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Scale))
                                        {
                                            bone.XSCA.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.sca.X
                                            });
                                            bone.YSCA.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.sca.Y
                                            });
                                            bone.ZSCA.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.sca.Z
                                            });
                                        }
                                        if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Rotate))
                                        {
                                            bone.XROT.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.rot.X
                                            });
                                            bone.YROT.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.rot.Y
                                            });
                                            bone.ZROT.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.rot.Z
                                            });
                                            bone.WROT.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.rot.W
                                            });
                                        }
                                        if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Translate))
                                        {
                                            bone.XPOS.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.pos.X
                                            });
                                            bone.YPOS.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.pos.Y
                                            });
                                            bone.ZPOS.Keys.Add(new Animation.KeyFrame()
                                            {
                                                Frame = 0, Value = bonean.pos.Z
                                            });
                                        }
                                    }
                                    foreach (FSKATrack track in bonean.tracks)
                                    {
                                        Animation.KeyFrame frame = new Animation.KeyFrame();
                                        frame.InterType = Animation.InterpolationType.HERMITE;
                                        frame.Frame     = Frame;

                                        FSKAKey left  = track.GetLeft(Frame);
                                        FSKAKey right = track.GetRight(Frame);
                                        float   value;



                                        value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);

                                        // interpolate the value and apply
                                        switch (track.flag)
                                        {
                                        case (int)TrackType.XPOS: frame.Value = value; bone.XPOS.Keys.Add(frame); break;

                                        case (int)TrackType.YPOS: frame.Value = value; bone.YPOS.Keys.Add(frame); break;

                                        case (int)TrackType.ZPOS: frame.Value = value; bone.ZPOS.Keys.Add(frame); break;

                                        case (int)TrackType.XROT: frame.Value = value; bone.XROT.Keys.Add(frame); break;

                                        case (int)TrackType.YROT: frame.Value = value; bone.YROT.Keys.Add(frame); break;

                                        case (int)TrackType.ZROT: frame.Value = value; bone.ZROT.Keys.Add(frame); break;

                                        case (int)TrackType.XSCA: frame.Value = value; bone.XSCA.Keys.Add(frame); break;

                                        case (int)TrackType.YSCA: frame.Value = value; bone.YSCA.Keys.Add(frame); break;

                                        case (int)TrackType.ZSCA: frame.Value = value; bone.ZSCA.Keys.Add(frame); break;
                                        }
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }


                Console.WriteLine("Saving " + SkeletonAnimations.Count + " anims");

                foreach (var anim in SkeletonAnimations)
                {
                    anim.SaveAsExpeditedAnim();
                }
            }
Exemplo n.º 5
0
            public BFRES_FSHU(MTA mta, ShaderParamAnim fshu, ResFile b)
            {
                mta.Text = fshu.Name;

                mta.FrameCount = (uint)fshu.FrameCount;

                foreach (ShaderParamMatAnim matanim in fshu.ShaderParamMatAnims)
                {
                    MatAnimEntry mat = new MatAnimEntry();

                    mat.Text = matanim.Name;
                    Console.WriteLine($"MatAnim = {mat.Text}");
                    Console.WriteLine($"Curve Count = {matanim.Curves.Count}");

                    if (matanim.Curves.Count == 0)
                    {
                    }

                    //First set the data then iterpolate
                    foreach (AnimCurve cr in matanim.Curves)
                    {
                        mat.InterpolateWU(cr);
                    }
                    mta.matEntries.Add(mat);



                    for (int Frame = 0; Frame < fshu.FrameCount; Frame++)
                    {
                        foreach (MatAnimData track in mat.matCurves)
                        {
                            AnimKey left  = track.GetLeft(Frame);
                            AnimKey right = track.GetRight(Frame);

                            track.Value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);
                        }
                    }

                    int CurCurve = 0;
                    for (int Frame = 0; Frame < fshu.FrameCount; Frame++)
                    {
                        foreach (MatAnimData track in mat.matCurves)
                        {
                            //This works like this
                            //Each param has their own info. While this loop through each curve determine which data is which
                            //Set the param name. Then detemine the data in between begin curve and total count
                            //Example. Begin curve starts at 0. Count may be 3 for RGB values
                            //Then for next curve would start at 3 and so on
                            //For color I simply use the values starting from RGBA
                            //Then for the next param i subtract the start value to reset the index back to 0
                            foreach (ParamAnimInfo inf in matanim.ParamAnimInfos)
                            {
                                track.shaderParamName = inf.Name;

                                if (inf.BeginCurve >= CurCurve)
                                {
                                    if (inf.FloatCurveCount >= CurCurve)
                                    {
                                        int ColorIndex = CurCurve - inf.BeginCurve;

                                        track.AnimColorType = (MatAnimData.ColorType)ColorIndex;
                                    }
                                }
                            }
                        }
                        CurCurve++;
                    }

                    mta.matEntries.Add(mat);
                }
            }