public bool ShouldDraw(float curTime)
        {
            PlaybackMoveEvent activeEvent = null;

            for (int k = 0; k < moveArrayIndex; k++)
            {
                if (moveArrayIndex > moveEvents.Length)
                {
                    break;
                }

                if (moveEvents[k].timeStamp <= curTime)
                {
                    activeEvent = moveEvents[k];
                }
                else if (moveEvents[k].timeStamp > curTime)
                {
                    break;
                }
            }

            if (activeEvent == null)
            {
                return(false);
            }

            return(activeEvent.isActive);
        }
Ejemplo n.º 2
0
        private void UpdateShips(GameTime gameTime)
        {
            if (!HasFocus)
            {
                return;
            }

            for (int i = 0; i < FrameworkCore.playbackSystem.ItemIndex; i++)
            {
                PlaybackItem ship = FrameworkCore.playbackSystem.PlaybackItems[i];

                if (ship.isStatic)
                {
                    if (ship.moveEvents[0] != null)
                    {
                        ship.position = ship.moveEvents[0].position;
                        ship.rotation = ship.moveEvents[0].rotation;
                    }

                    continue;
                }


                for (int k = 0; k < ship.moveArrayIndex; k++)
                {
                    PlaybackMoveEvent moveEvent = ship.moveEvents[k];

                    if (moveEvent.timeStamp == playbackTime)
                    {
                        ship.position = moveEvent.position;
                        ship.rotation = moveEvent.rotation;
                        continue;
                    }

                    if (k < ship.moveArrayIndex - 1)  //NOT the last node.
                    {
                        if (moveEvent.timeStamp < playbackTime && ship.moveEvents[k + 1].timeStamp > playbackTime)
                        {
                            //this is the interval we are interested in.

                            float adjustedPlaybackTime = playbackTime - moveEvent.timeStamp;

                            float intervalTransition = adjustedPlaybackTime /
                                                       (ship.moveEvents[k + 1].timeStamp - moveEvent.timeStamp);

                            ship.position = Vector3.Lerp(
                                moveEvent.position,
                                ship.moveEvents[k + 1].position,
                                intervalTransition);

                            ship.rotation = Quaternion.Lerp(
                                moveEvent.rotation,
                                ship.moveEvents[k + 1].rotation,
                                intervalTransition);

                            continue;
                        }
                    }
                }
            }
        }