Ejemplo n.º 1
0
        public void FrameAdvance()
        {
            if (playing)
            {
                elapsed += Time.fixedDeltaTime;
                if (elapsed >= frameTime)
                {
                    elapsed = 0;
                    frame++;
                }
            }

            if (frame < animation.startFrame)
            {
                frame = animation.startFrame;
            }

            if (frame >= animation.endFrame)
            {
                if (loopPlay == false)
                {
                    playing = false;
                    return;
                }
                else
                {
                    frame = animation.startFrame;
                }
            }

            //SuperController.LogMessage(frame + " / " + bvh.nFrames);

            if (frame >= animation.endFrame - 1)
            {
                // Last frame
                UpdateModel(bvh.ReadFrame(frame));
            }
            else
            {
                // Interpolate
                var frm = bvh.ReadFrame(frame);
                var to  = bvh.ReadFrame(frame + 1);

                float t = elapsed / frameTime;
                UpdateModel(Interpolate(frm, to, t));
            }
        }
Ejemplo n.º 2
0
        public void FrameAdvance()
        {
            if (playing)
            {
                float elapsedTime = Time.time - playStartTime;
                //SuperController.LogMessage("elapsed " + elapsedTime);
                float duration = bvh.nFrames * bvh.frameTime;
                //SuperController.LogMessage("duration " + duration);
                float alpha = elapsedTime / duration;
                //SuperController.LogMessage("alpha" + alpha);
                int currentFrame = Mathf.RoundToInt(alpha * bvh.nFrames);

                frame = currentFrame;

                //elapsed += Time.deltaTime * playbackMultiplier;
                //if (elapsed >= frameTime)
                //{
                //    int framesAdvanced = Mathf.FloorToInt(elapsed / frameTime);
                //    frame += framesAdvanced;
                //    elapsed = elapsed % frameTime;
                //}
            }

            if (frame < animation.startFrame)
            {
                frame = animation.startFrame;
            }

            finished = frame >= animation.endFrame;

            if (finished)
            {
                if (loopPlay == false)
                {
                    playing = false;
                    return;
                }
                else
                {
                    frame         = animation.startFrame;
                    playStartTime = Time.time;
                }
            }

            //SuperController.LogMessage(frame + " / " + bvh.nFrames);

            if (frame >= animation.endFrame - 1)
            {
                // Last frame
                UpdateModel(bvh.ReadFrame(frame));
            }
            else
            {
                // Interpolate
                var frm = bvh.ReadFrame(frame);
                var to  = bvh.ReadFrame(frame + 1);

                float t = elapsed / frameTime;
                UpdateModel(Interpolate(frm, to, t));
            }
        }