Beispiel #1
0
            public FSKANode(ResU.BoneAnim b)
            {
                Text = b.Name;

                sca = new Vector3(b.BaseData.Scale.X, b.BaseData.Scale.Y, b.BaseData.Scale.Z);
                rot = new Vector4(b.BaseData.Rotate.X, b.BaseData.Rotate.Y, b.BaseData.Rotate.Z, b.BaseData.Rotate.W);
                pos = new Vector3(b.BaseData.Translate.X, b.BaseData.Translate.Y, b.BaseData.Translate.Z);

                foreach (ResU.AnimCurve tr in b.Curves)
                {
                    FSKATrack t = new FSKATrack();
                    t.flag = (int)tr.AnimDataOffset;
                    tracks.Add(t);

                    float tanscale = tr.Delta;
                    if (tanscale == 0)
                    {
                        tanscale = 1;
                    }

                    for (int i = 0; i < (ushort)tr.Frames.Length; i++)
                    {
                        if (tr.CurveType == ResU.AnimCurveType.Cubic)
                        {
                            int   framedata = (int)tr.Frames[i];
                            float keydata   = tr.Offset + ((tr.Keys[i, 0] * tr.Scale));
                            float keydata2  = tr.Offset + ((tr.Keys[i, 1] * tr.Scale));
                            float keydata3  = tr.Offset + ((tr.Keys[i, 2] * tr.Scale));
                            float keydata4  = tr.Offset + ((tr.Keys[i, 3] * tr.Scale));
                        }
                        if (tr.KeyType == ResU.AnimCurveKeyType.Int16)
                        {
                        }
                        else if (tr.KeyType == ResU.AnimCurveKeyType.Single)
                        {
                        }
                        else if (tr.KeyType == ResU.AnimCurveKeyType.SByte)
                        {
                        }
                        t.keys.Add(new FSKAKey()
                        {
                            frame = (int)tr.Frames[i],
                            unk1  = tr.Offset + ((tr.Keys[i, 0] * tr.Scale)),
                            unk2  = tr.Offset + ((tr.Keys[i, 1] * tr.Scale)),
                            unk3  = tr.Offset + ((tr.Keys[i, 2] * tr.Scale)),
                            unk4  = tr.Offset + ((tr.Keys[i, 3] * tr.Scale)),
                        });
                    }
                }
            }
        public static ResU.SkeletalAnim FSKAConvertSwitchToWiiU(ResNX.SkeletalAnim skeletalAnimNX)
        {
            ResU.SkeletalAnim ska = new ResU.SkeletalAnim();
            ska.Name       = skeletalAnimNX.Name;
            ska.Path       = skeletalAnimNX.Path;
            ska.FrameCount = skeletalAnimNX.FrameCount;
            ska.FlagsScale = ResU.SkeletalAnimFlagsScale.None;

            if (skeletalAnimNX.FlagsScale.HasFlag(ResNX.SkeletalAnimFlagsScale.Maya))
            {
                ska.FlagsScale = ResU.SkeletalAnimFlagsScale.Maya;
            }
            if (skeletalAnimNX.FlagsScale.HasFlag(ResNX.SkeletalAnimFlagsScale.Softimage))
            {
                ska.FlagsScale = ResU.SkeletalAnimFlagsScale.Softimage;
            }
            if (skeletalAnimNX.FlagsScale.HasFlag(ResNX.SkeletalAnimFlagsScale.Standard))
            {
                ska.FlagsScale = ResU.SkeletalAnimFlagsScale.Standard;
            }

            ska.FrameCount  = skeletalAnimNX.FrameCount;
            ska.BindIndices = skeletalAnimNX.BindIndices;
            ska.BakedSize   = skeletalAnimNX.BakedSize;
            ska.Loop        = skeletalAnimNX.Loop;
            ska.Baked       = skeletalAnimNX.Baked;
            foreach (var boneAnimNX in skeletalAnimNX.BoneAnims)
            {
                var boneAnimU = new ResU.BoneAnim();
                ska.BoneAnims.Add(boneAnimU);
                boneAnimU.Name               = boneAnimNX.Name;
                boneAnimU.BeginRotate        = boneAnimNX.BeginRotate;
                boneAnimU.BeginTranslate     = boneAnimNX.BeginTranslate;
                boneAnimU.BeginBaseTranslate = boneAnimNX.BeginBaseTranslate;
                var baseData = new ResU.BoneAnimData();
                baseData.Translate       = boneAnimNX.BaseData.Translate;
                baseData.Scale           = boneAnimNX.BaseData.Scale;
                baseData.Rotate          = boneAnimNX.BaseData.Rotate;
                baseData.Flags           = boneAnimNX.BaseData.Flags;
                boneAnimU.BaseData       = baseData;
                boneAnimU.FlagsBase      = (ResU.BoneAnimFlagsBase)boneAnimNX.FlagsBase;
                boneAnimU.FlagsCurve     = (ResU.BoneAnimFlagsCurve)boneAnimNX.FlagsCurve;
                boneAnimU.FlagsTransform = (ResU.BoneAnimFlagsTransform)boneAnimNX.FlagsTransform;
                boneAnimU.Curves         = ConvertAnimCurveSwitchToWiiU(boneAnimNX.Curves);
            }

            return(ska);
        }
Beispiel #3
0
        public void FromSeanim(string FileName)
        {
            SEAnim anim = SEAnim.Read(FileName);

            if (GetResFileU() != null)
            {
                SkeletalAnimU             = new ResU.SkeletalAnim();
                SkeletalAnimU.FrameCount  = anim.FrameCount;
                SkeletalAnimU.FlagsScale  = ResU.SkeletalAnimFlagsScale.Maya;
                SkeletalAnimU.FlagsRotate = ResU.SkeletalAnimFlagsRotate.EulerXYZ;
                SkeletalAnimU.Loop        = anim.Looping;
                SkeletalAnimU.Name        = System.IO.Path.GetFileNameWithoutExtension(FileName);
                SkeletalAnimU.Path        = "";
            }
            else
            {
                SkeletalAnim             = new SkeletalAnim();
                SkeletalAnim.FrameCount  = anim.FrameCount;
                SkeletalAnim.FlagsScale  = SkeletalAnimFlagsScale.Maya;
                SkeletalAnim.FlagsRotate = SkeletalAnimFlagsRotate.EulerXYZ;
                SkeletalAnim.Loop        = anim.Looping;
                SkeletalAnim.Name        = System.IO.Path.GetFileNameWithoutExtension(FileName);
                SkeletalAnim.Path        = "";
            }

            for (int i = 0; i < anim.Bones.Count; i++)
            {
                if (GetResFileU() != null)
                {
                    var BoneAnimU = new ResU.BoneAnim();
                    BoneAnimU.Name = anim.Bones[i];
                    SkeletalAnimU.BoneAnims.Add(BoneAnimU);
                    SkeletalAnimU.BindIndices[i] = ushort.MaxValue;
                    bool IsRoot = false;

                    if (!IsRoot)
                    {
                        BoneAnimU.ApplyIdentity               = false;
                        BoneAnimU.ApplyRotateTranslateZero    = false;
                        BoneAnimU.ApplyRotateZero             = false;
                        BoneAnimU.ApplyScaleOne               = true;
                        BoneAnimU.ApplyScaleVolumeOne         = true;
                        BoneAnimU.ApplyScaleUniform           = true;
                        BoneAnimU.ApplySegmentScaleCompensate = true;
                        BoneAnimU.ApplyTranslateZero          = false;
                    }
                    else
                    {
                        BoneAnimU.ApplyIdentity               = true;
                        BoneAnimU.ApplyRotateTranslateZero    = true;
                        BoneAnimU.ApplyRotateZero             = true;
                        BoneAnimU.ApplyScaleOne               = true;
                        BoneAnimU.ApplyScaleVolumeOne         = true;
                        BoneAnimU.ApplyScaleUniform           = true;
                        BoneAnimU.ApplySegmentScaleCompensate = false;
                        BoneAnimU.ApplyTranslateZero          = true;
                    }
                }
                else
                {
                    var BoneAnim = new BoneAnim();
                    BoneAnim.Name = anim.Bones[i];
                    SkeletalAnim.BoneAnims.Add(BoneAnim);
                    SkeletalAnim.BindIndices[i] = ushort.MaxValue;

                    //Set base data and curves
                    var baseData = new BoneAnimData();
                    if (anim.AnimationPositionKeys.ContainsKey(anim.Bones[i]) &&
                        anim.AnimationPositionKeys[anim.Bones[i]].Count > 0)
                    {
                        BoneAnim.FlagsBase |= BoneAnimFlagsBase.Translate;
                        var keys = anim.AnimationPositionKeys[anim.Bones[i]];
                        var data = (SELib.Utilities.Vector3)keys[0].Data;

                        baseData.Translate = new Syroot.Maths.Vector3F((float)data.X, (float)data.Y, (float)data.Z);

                        if (keys.Count > 1)
                        {
                            AnimCurve curve = new AnimCurve();
                            BoneAnim.Curves.Add(curve);
                            CreateCurveData(curve, keys);
                        }
                    }
                    if (anim.AnimationRotationKeys.ContainsKey(anim.Bones[i]) &&
                        anim.AnimationRotationKeys[anim.Bones[i]].Count > 0)
                    {
                        BoneAnim.FlagsBase |= BoneAnimFlagsBase.Rotate;
                        var keys = anim.AnimationPositionKeys[anim.Bones[i]];
                        var data = (SELib.Utilities.Quaternion)keys[0].Data;

                        baseData.Rotate = new Syroot.Maths.Vector4F((float)data.X, (float)data.Y, (float)data.Z, (float)data.W);

                        if (keys.Count > 1)
                        {
                            AnimCurve curve = new AnimCurve();
                            BoneAnim.Curves.Add(curve);
                            CreateCurveData(curve, keys);
                        }
                    }
                    if (anim.AnimationScaleKeys.ContainsKey(anim.Bones[i]) &&
                        anim.AnimationScaleKeys[anim.Bones[i]].Count > 0)
                    {
                        BoneAnim.FlagsBase |= BoneAnimFlagsBase.Scale;
                        var keys = anim.AnimationPositionKeys[anim.Bones[i]];
                        var data = (SELib.Utilities.Vector3)keys[0].Data;

                        baseData.Scale = new Syroot.Maths.Vector3F((float)data.X, (float)data.Y, (float)data.Z);

                        if (keys.Count > 1)
                        {
                            AnimCurve curve = new AnimCurve();
                            BoneAnim.Curves.Add(curve);
                            CreateCurveData(curve, keys);
                        }
                    }


                    //Set transforms
                    bool IsRoot = false;
                    if (!IsRoot)
                    {
                        BoneAnim.ApplyIdentity               = false;
                        BoneAnim.ApplyRotateTranslateZero    = false;
                        BoneAnim.ApplyRotateZero             = false;
                        BoneAnim.ApplyScaleOne               = true;
                        BoneAnim.ApplyScaleVolumeOne         = true;
                        BoneAnim.ApplyScaleUniform           = true;
                        BoneAnim.ApplySegmentScaleCompensate = true;
                        BoneAnim.ApplyTranslateZero          = false;
                    }
                    else
                    {
                        BoneAnim.ApplyIdentity               = true;
                        BoneAnim.ApplyRotateTranslateZero    = true;
                        BoneAnim.ApplyRotateZero             = true;
                        BoneAnim.ApplyScaleOne               = true;
                        BoneAnim.ApplyScaleVolumeOne         = true;
                        BoneAnim.ApplyScaleUniform           = true;
                        BoneAnim.ApplySegmentScaleCompensate = false;
                        BoneAnim.ApplyTranslateZero          = true;
                    }
                }
            }

            for (int frame = 0; frame < anim.FrameCount; frame++)
            {
            }
        }