Esempio n. 1
0
        private Keyframe[][] GenerateRotationTrack(List <Assimp.QuaternionKey> keys, Bone bone)
        {
            Keyframe[] x_track = new Keyframe[keys.Count];
            Keyframe[] y_track = new Keyframe[keys.Count];
            Keyframe[] z_track = new Keyframe[keys.Count];

            for (int i = 0; i < keys.Count; i++)
            {
                Assimp.QuaternionKey current_key = keys[i];
                Quaternion           value       = new Quaternion(current_key.Value.X, current_key.Value.Y, current_key.Value.Z, current_key.Value.W);
                Vector3 quat_as_vec = QuaternionExtensions.ToEulerAngles(value);

                x_track[i].Key  = quat_as_vec.X;
                x_track[i].Time = (float)current_key.Time;

                y_track[i].Key  = quat_as_vec.Y;
                y_track[i].Time = (float)current_key.Time;

                z_track[i].Key  = quat_as_vec.Z;
                z_track[i].Time = (float)current_key.Time;
            }

            return(new Keyframe[][] { x_track, y_track, z_track });
        }
Esempio n. 2
0
        public static Track Identity(Matrix4 Transform, float MaxTime)
        {
            Track      ident_track = new Track();
            Quaternion XRot        = Quaternion.FromAxisAngle(Vector3.UnitX, (float)(0));

            ident_track.IsIdentity = true;
            Vector3 Translation = Transform.ExtractTranslation();

            ident_track.Translation = new Keyframe[][]
            {
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = Translation.X, OutTangent = 0
                                 } },
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = Translation.Y, OutTangent = 0, Time = 0
                                 } },
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = Translation.Z, OutTangent = 0, Time = 0
                                 } },
            };

            Quaternion Rotation = Transform.ExtractRotation();
            Vector3    Rot_Vec  = QuaternionExtensions.ToEulerAngles(Rotation);

            ident_track.Rotation = new Keyframe[][]
            {
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = Rot_Vec.X, OutTangent = 0, Time = 0
                                 } },
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = Rot_Vec.Y, OutTangent = 0, Time = 0
                                 } },
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = Rot_Vec.Z, OutTangent = 0, Time = 0
                                 } },
            };

            Vector3 Scale = Transform.ExtractScale();

            ident_track.Scale = new Keyframe[][]
            {
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = 1, OutTangent = 0, Time = 0
                                 } },
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = 1, OutTangent = 0, Time = 0
                                 } },
                new Keyframe[] { new Keyframe()
                                 {
                                     InTangent = 0, Key = 1, OutTangent = 0, Time = 0
                                 } },
            };

            return(ident_track);
        }