Example #1
0
            public void LoadVisibilyGroup(Gfbanim.Group visAnim)
            {
                VisibiltyGroup groupAnim = new VisibiltyGroup();

                groupAnim.Name = visAnim.Name;
                AnimGroups.Add(groupAnim);

                if (visAnim.ValueType == Gfbanim.BooleanTrack.FixedBooleanTrack)
                {
                    var track = visAnim.Value <Gfbanim.FixedBooleanTrack>();
                    if (track.HasValue)
                    {
                        var animTrack = new STAnimationTrack();
                        animTrack.KeyFrames.Add(new STKeyFrame(0, track.Value.Value));
                        groupAnim.BooleanTrack = animTrack;
                    }
                }
                else if (visAnim.ValueType == Gfbanim.BooleanTrack.DynamicBooleanTrack)
                {
                    var track = visAnim.Value <Gfbanim.DynamicBooleanTrack>();
                    if (track.HasValue)
                    {
                        groupAnim.BooleanTrack = GfbanimKeyFrameLoader.LoadBooleanTrack(track.Value);
                    }
                }
                else if (visAnim.ValueType == Gfbanim.BooleanTrack.FramedBooleanTrack)
                {
                    var track = visAnim.Value <Gfbanim.FramedBooleanTrack>();
                    if (track.HasValue)
                    {
                        groupAnim.BooleanTrack = GfbanimKeyFrameLoader.LoadBooleanTrack(track.Value);
                    }
                }
            }
Example #2
0
            public void LoadBoneGroup(Gfbanim.Bone boneAnim)
            {
                BoneGroup groupAnim = new BoneGroup();

                groupAnim.Name = boneAnim.Name;
                AnimGroups.Add(groupAnim);

                //Tracks use 3 types
                // Fixed/constant
                // Dynamic (baked and multiple keys, no frames)
                // Framed (multiple keys and frames)

                List <float> Frames = new List <float>();

                switch (boneAnim.RotateType)
                {
                case Gfbanim.QuatTrack.DynamicQuatTrack:
                {
                    var rotate = boneAnim.Rotate <Gfbanim.DynamicQuatTrack>();
                    if (rotate.HasValue)
                    {
                        var values = GfbanimKeyFrameLoader.LoadRotationTrack(rotate.Value);
                        groupAnim.RotationX = values[0];
                        groupAnim.RotationY = values[1];
                        groupAnim.RotationZ = values[2];
                    }
                }
                break;

                case Gfbanim.QuatTrack.FixedQuatTrack:
                {
                    var rotate = boneAnim.Rotate <Gfbanim.FixedQuatTrack>();
                    if (rotate.HasValue)
                    {
                        var vec = rotate.Value.Value.Value;
                        groupAnim.RotationX.KeyFrames.Add(new STKeyFrame(0, GfbanimKeyFrameLoader.ConvertRotation(vec.X)));
                        groupAnim.RotationY.KeyFrames.Add(new STKeyFrame(0, GfbanimKeyFrameLoader.ConvertRotation(vec.Y)));
                        groupAnim.RotationZ.KeyFrames.Add(new STKeyFrame(0, GfbanimKeyFrameLoader.ConvertRotation(vec.Z)));
                    }
                }
                break;

                case Gfbanim.QuatTrack.FramedQuatTrack:
                {
                    var rotate = boneAnim.Rotate <Gfbanim.FramedQuatTrack>();
                    if (rotate.HasValue)
                    {
                        var values = GfbanimKeyFrameLoader.LoadRotationTrack(rotate.Value);
                        groupAnim.RotationX = values[0];
                        groupAnim.RotationY = values[1];
                        groupAnim.RotationZ = values[2];
                    }
                }
                break;
                }
                switch (boneAnim.ScaleType)
                {
                case Gfbanim.VectorTrack.FixedVectorTrack:
                {
                    var scale = boneAnim.Scale <Gfbanim.FixedVectorTrack>();
                    if (scale.HasValue)
                    {
                        var vec = scale.Value.Value.Value;
                        groupAnim.ScaleX.KeyFrames.Add(new STKeyFrame(0, vec.X));
                        groupAnim.ScaleY.KeyFrames.Add(new STKeyFrame(0, vec.Y));
                        groupAnim.ScaleZ.KeyFrames.Add(new STKeyFrame(0, vec.Z));
                    }
                }
                break;
                }
                switch (boneAnim.ScaleType)
                {
                case Gfbanim.VectorTrack.DynamicVectorTrack:
                {
                    var scale = boneAnim.Scale <Gfbanim.DynamicVectorTrack>();
                    if (scale.HasValue)
                    {
                        var values = GfbanimKeyFrameLoader.LoadVectorTrack(scale.Value);
                        groupAnim.ScaleX = values[0];
                        groupAnim.ScaleY = values[1];
                        groupAnim.ScaleZ = values[2];
                    }
                }
                break;

                case Gfbanim.VectorTrack.FramedVectorTrack:
                {
                    var scale = boneAnim.Scale <Gfbanim.FramedVectorTrack>();
                    if (scale.HasValue)
                    {
                        var values = GfbanimKeyFrameLoader.LoadVectorTrack(scale.Value);
                        groupAnim.ScaleX = values[0];
                        groupAnim.ScaleY = values[1];
                        groupAnim.ScaleZ = values[2];
                    }
                }
                break;

                case Gfbanim.VectorTrack.FixedVectorTrack:
                {
                    var scale = boneAnim.Scale <Gfbanim.FixedVectorTrack>();
                    if (scale.HasValue)
                    {
                        var vec = scale.Value.Value.Value;
                        groupAnim.ScaleX.KeyFrames.Add(new STKeyFrame(0, vec.X));
                        groupAnim.ScaleY.KeyFrames.Add(new STKeyFrame(0, vec.Y));
                        groupAnim.ScaleZ.KeyFrames.Add(new STKeyFrame(0, vec.Z));
                    }
                }
                break;
                }
                switch (boneAnim.TranslateType)
                {
                case Gfbanim.VectorTrack.DynamicVectorTrack:
                {
                    var trans = boneAnim.Translate <Gfbanim.DynamicVectorTrack>();
                    if (trans.HasValue)
                    {
                        var values = GfbanimKeyFrameLoader.LoadVectorTrack(trans.Value);
                        groupAnim.TranslateX = values[0];
                        groupAnim.TranslateY = values[1];
                        groupAnim.TranslateZ = values[2];
                    }
                }
                break;

                case Gfbanim.VectorTrack.FramedVectorTrack:
                {
                    var trans = boneAnim.Translate <Gfbanim.FramedVectorTrack>();
                    if (trans.HasValue)
                    {
                        var values = GfbanimKeyFrameLoader.LoadVectorTrack(trans.Value);
                        groupAnim.TranslateX = values[0];
                        groupAnim.TranslateY = values[1];
                        groupAnim.TranslateZ = values[2];
                    }
                }
                break;

                case Gfbanim.VectorTrack.FixedVectorTrack:
                {
                    var trans = boneAnim.Translate <Gfbanim.FixedVectorTrack>();
                    if (trans.HasValue)
                    {
                        var vec = trans.Value.Value.Value;
                        groupAnim.TranslateX.KeyFrames.Add(new STKeyFrame(0, vec.X));
                        groupAnim.TranslateY.KeyFrames.Add(new STKeyFrame(0, vec.Y));
                        groupAnim.TranslateZ.KeyFrames.Add(new STKeyFrame(0, vec.Z));
                    }
                }
                break;
                }
            }