Beispiel #1
0
        public static byte ToGXTrackType(SBTrackType type)
        {
            switch (type)
            {
            case SBTrackType.TranslateX:
                return((byte)JointTrackType.HSD_A_J_TRAX);

            case SBTrackType.TranslateY:
                return((byte)JointTrackType.HSD_A_J_TRAY);

            case SBTrackType.TranslateZ:
                return((byte)JointTrackType.HSD_A_J_TRAZ);

            case SBTrackType.RotateX:
                return((byte)JointTrackType.HSD_A_J_ROTX);

            case SBTrackType.RotateY:
                return((byte)JointTrackType.HSD_A_J_ROTY);

            case SBTrackType.RotateZ:
                return((byte)JointTrackType.HSD_A_J_ROTZ);

            case SBTrackType.ScaleX:
                return((byte)JointTrackType.HSD_A_J_SCAX);

            case SBTrackType.ScaleY:
                return((byte)JointTrackType.HSD_A_J_SCAY);

            case SBTrackType.ScaleZ:
                return((byte)JointTrackType.HSD_A_J_SCAZ);

            default:
                return(0);
            }
        }
Beispiel #2
0
        /// <summary>
        /// gets the interpolated values for track type at frame
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public float GetTrackValueAt(float frame, SBTrackType type)
        {
            var track = Tracks.Find(e => e.Type == type);

            if (track == null)
            {
                return(0);
            }

            return(track.Keys.GetValue(frame));
        }
Beispiel #3
0
        /// <summary>
        /// adds a new key frame to the animation
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="value"></param>
        /// <param name="type"></param>
        /// <param name="interpolationType"></param>
        public void AddKey(float frame, float value, SBTrackType type, InterpolationType interpolationType = InterpolationType.Linear)
        {
            var track = Tracks.Find(e => e.Type == type);

            if (track == null)
            {
                track = new SBTransformTrack(type);
                Tracks.Add(track);
            }
            track.AddKey(frame, value, interpolationType);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fobj"></param>
        /// <returns></returns>
        private static SBTransformTrack DecodeFOBJ(HSD_FOBJ fobj)
        {
            SBTrackType trackType = SBTrackType.TranslateX;

            switch (fobj.JointTrackType)
            {
            case JointTrackType.HSD_A_J_ROTX: trackType = SBTrackType.RotateX; break;

            case JointTrackType.HSD_A_J_ROTY: trackType = SBTrackType.RotateY; break;

            case JointTrackType.HSD_A_J_ROTZ: trackType = SBTrackType.RotateZ; break;

            case JointTrackType.HSD_A_J_TRAX: trackType = SBTrackType.TranslateX; break;

            case JointTrackType.HSD_A_J_TRAY: trackType = SBTrackType.TranslateY; break;

            case JointTrackType.HSD_A_J_TRAZ: trackType = SBTrackType.TranslateZ; break;

            case JointTrackType.HSD_A_J_SCAX: trackType = SBTrackType.ScaleX; break;

            case JointTrackType.HSD_A_J_SCAY: trackType = SBTrackType.ScaleY; break;

            case JointTrackType.HSD_A_J_SCAZ: trackType = SBTrackType.ScaleZ; break;
            }

            SBTransformTrack track = new SBTransformTrack(trackType);

            var Keys = fobj.GetDecodedKeys();

            // get current frame state
            AnimState prevState = null;

            for (int i = 0; i < Keys.Count; i++)
            {
                var state = GetState(Keys[i].Frame, Keys);

                bool nextSlope = i + 1 < Keys.Count && Keys[i + 1].InterpolationType == GXInterpolationType.HSD_A_OP_SLP;

                if (Keys[i].Frame == state.t1)
                {
                    state.t0 = state.t1;
                    state.p0 = state.p1;
                    state.d0 = state.d1;
                }

                if (Keys[i].InterpolationType == GXInterpolationType.HSD_A_OP_SLP)
                {
                    continue;
                }

                if (state.op_intrp == GXInterpolationType.HSD_A_OP_CON || state.op_intrp == GXInterpolationType.HSD_A_OP_KEY)
                {
                    track.AddKey(state.t0, state.p0, InterpolationType.Step);
                }

                if (state.op_intrp == GXInterpolationType.HSD_A_OP_LIN)
                {
                    track.AddKey(state.t0, state.p0, InterpolationType.Linear);
                }

                if (state.op_intrp == GXInterpolationType.HSD_A_OP_SPL ||
                    state.op_intrp == GXInterpolationType.HSD_A_OP_SPL0 ||
                    state.op_intrp == GXInterpolationType.HSD_A_OP_SLP)
                {
                    track.AddKey(state.t0, state.p0, InterpolationType.Hermite,
                                 (nextSlope && prevState != null) ? prevState.d1 : state.d0, state.d0);
                }

                prevState = state;
            }

            return(track);
        }
 public SBTransformTrack(SBTrackType type)
 {
     Type = type;
 }