public void GetPlayerMotion(PlayerInput playerInput, float normalizedTime) { var motionFrame = GetBakedMotionFrame(playerInput, normalizedTime); PlayerMotionFrame.Velocity = PlayerInput.Velocity; //PlayerMotionFrame.Joints = motionFrame.Joints; PlayerMotionFrame.Joints = motionFrame.Joints; PlayerMotionFrame.TrajectoryDatas = new MotionTrajectoryData[MotionTrajectoryData.Length()]; for (var i = 0; i < MotionTrajectoryData.Length(); i++) { //var timeStamp = 1f / (float) (i+1); // it is wired var timeStamp = 1f / (float)(MotionTrajectoryData.Length() - i);//non-linear var trajectoryData = new MotionTrajectoryData(); //?? local = float velocity * (Vector 3) direction?? //player trajectory Data trajectoryData.LocalPosition = PlayerInput.Velocity * PlayerInput.Direction * timeStamp; //mark the localPosition always a straight line trajectoryData.Velocity = PlayerInput.Velocity * PlayerInput.Direction; // velocity for each trajectory is always the same //direction based on AngularyVelocity if (PlayerInput.AngularVelocity != 0f) { trajectoryData.Direction = Quaternion.Euler(0, PlayerInput.AngularVelocity * timeStamp, 0) * Vector3.forward.normalized; } PlayerMotionFrame.TrajectoryDatas[i] = trajectoryData; } }
public void GetClipTrajectoryData(MotionFrame frame) { frame.TrajectoryDatas = new MotionTrajectoryData[MotionTrajectoryData.Length()]; for (var i = 0; i < MotionTrajectoryData.Length(); i++) { var timeStamp = 1f / (float)(MotionTrajectoryData.Length() - i); var trajectoryData = new MotionTrajectoryData(); //trajectoryData.LocalPosition = 1000000f * frame.Velocity * frame.Direction * timeStamp; //trajectoryData.Velocity = 1000000f * frame.Velocity * frame.Direction; trajectoryData.LocalPosition = 1000f * frame.Velocity * frame.Direction * timeStamp; trajectoryData.Velocity = 1000f * frame.Velocity * frame.Direction; if (frame.AngularVelocity != 0f) { trajectoryData.Direction = (Quaternion.Euler(0, frame.AngularVelocity * timeStamp, 0) * Vector3.forward).normalized; } frame.TrajectoryDatas[i] = trajectoryData; } }