public void PlayAnimation(GameTime gameTime)
{
if(cameraAnimTrackStates == null) return;
freezeFreeCamRotation = true;
var state = cameraAnimTrackStates[curStateInd];
curTime += 0.016f; //gameTime.ElapsedSec;
if (curTime < state.WaitTime || curStateInd >= cameraAnimTrackStates.Count - 1) {
SetState(state);
if (curStateInd >= cameraAnimTrackStates.Count - 1)
StopAnimation();
return;
}
float time = curTime - state.WaitTime;
float amount = time/state.TransitionTime;
float factor = MathUtil.SmoothStep(amount);
factor = MathUtil.Clamp(factor, 0.0f, 1.0f);
var nextState = cameraAnimTrackStates[curStateInd+1];
var curPos = DVector3.Lerp(state.FreeSurfacePosition, nextState.FreeSurfacePosition, factor);
var curFreeRot = DQuaternion.Slerp(state.FreeRotation, nextState.FreeRotation, factor);
freeSurfaceRotation = curFreeRot;
CameraPosition = FreeSurfacePosition = curPos;
var newLonLat = GetCameraLonLat();
Yaw = newLonLat.X;
Pitch = -newLonLat.Y;
if (curTime > state.WaitTime + state.TransitionTime) {
curStateInd++;
curTime = 0;
}
}