暂存
This commit is contained in:
parent
d1c84d0a8a
commit
e3059fc1c2
File diff suppressed because it is too large
Load Diff
@ -62,6 +62,7 @@ namespace Assets.Scripts.Apis.Models
|
||||
set
|
||||
{
|
||||
_List = value;
|
||||
_List = _List.ToList();
|
||||
if (_List == null) return;
|
||||
this.CalcDistance();
|
||||
this.CalcGrade();
|
||||
|
||||
@ -13,7 +13,7 @@ public delegate void ChangeLanguageDelegate();
|
||||
|
||||
public static class App
|
||||
{
|
||||
public static string Host = "http://192.168.0.101:5087/";
|
||||
public static string Host = "http://192.168.0.102:6662/";
|
||||
|
||||
public static string AppVersion = Application.version;
|
||||
|
||||
@ -213,7 +213,7 @@ public static class App
|
||||
{
|
||||
InitLanguage();
|
||||
#if !UNITY_EDITOR
|
||||
Host = "http://pf.juze.pro/";
|
||||
//Host = "http://pf.juze.pro/";
|
||||
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
|
||||
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
|
||||
//线上
|
||||
@ -226,7 +226,7 @@ public static class App
|
||||
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
|
||||
Debug.unityLogger.logEnabled = false;
|
||||
#else
|
||||
Host = "http://pf.juze.pro/";//"http://192.168.0.102:5086/"; //
|
||||
Host = "http://pf.juze.pro/"; //"http://192.168.0.102:5082/";//
|
||||
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
|
||||
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
|
||||
#endif
|
||||
|
||||
@ -30,7 +30,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public double wkg;
|
||||
public int? heartRate { get; set; }
|
||||
public int ticks;
|
||||
public double totalDistance;
|
||||
public double totalDistance { get; set; }
|
||||
public double currentSlope;
|
||||
protected double nextSlope;
|
||||
protected double nextSlopeDistance;
|
||||
@ -74,9 +74,9 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
camera = Camera.main;
|
||||
//bone_bottle_2
|
||||
bone_bottle_2 = transform.Find("bone_cable_20");
|
||||
var config = manager.mockDirection;
|
||||
pre = config[0];
|
||||
next = config[0];
|
||||
//var config = manager.mockDirection;
|
||||
//pre = config[0];
|
||||
//next = config[0];
|
||||
}
|
||||
|
||||
//人物状态
|
||||
@ -123,7 +123,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
Debug.LogError(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
@ -298,7 +297,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
if (manager.CurrentPlayer != null && manager.CurrentPlayer.UserId != UserId)
|
||||
return;
|
||||
//ratio = (float)Math.Round(ratio, 1);
|
||||
manager.Play(totalDistance);
|
||||
manager.Play(currentIndex,currentSlopeDistance);
|
||||
|
||||
if (ratio > 1)
|
||||
{
|
||||
|
||||
@ -116,7 +116,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
base.Awake();
|
||||
#if UNITY_EDITOR
|
||||
if (App.RouteIdParam == 0)
|
||||
App.RouteIdParam = 6251;
|
||||
App.RouteIdParam = 6250;
|
||||
#endif
|
||||
#if UNITY_EDITOR
|
||||
if (App.CurrentUser == null) //App.CurrentUser == null
|
||||
@ -772,25 +772,25 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
var currentFrame = GetCurrentFrame();
|
||||
CameraNode pre = null;
|
||||
CameraNode next = null;
|
||||
for (int i = 0; i < cameraList.Count; i++)
|
||||
{
|
||||
if (cameraList[i].Frame >= currentFrame)
|
||||
{
|
||||
pre = i > 0 ? cameraList[i - 1] : cameraList[i];
|
||||
next = cameraList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pre == null || next == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var x = (next.Frame - pre.Frame) * (next.X - pre.X) == 0 ? pre.X : (float)(pre.X + ((currentFrame - pre.Frame) / (next.Frame - pre.Frame)) * (next.X - pre.X));
|
||||
var y = (next.Frame - pre.Frame) * (next.Y - pre.Y) == 0 ? pre.Y : (float)(pre.Y + ((currentFrame - pre.Frame) / (next.Frame - pre.Frame)) * (next.Y - pre.Y));
|
||||
Camera.main.transform.localEulerAngles = new Vector3((float)Math.Round(x, 3), (float)Math.Round(y, 3), 0);//currentCameraRotation;//Vector3.SmoothDamp(Camera.main.transform.localEulerAngles, currentCameraRotation, ref mVelocity, 0.5f);
|
||||
//var currentFrame = GetCurrentFrame();
|
||||
//CameraNode pre = null;
|
||||
//CameraNode next = null;
|
||||
//for (int i = 0; i < cameraList.Count; i++)
|
||||
//{
|
||||
// if (cameraList[i].Frame >= currentFrame)
|
||||
// {
|
||||
// pre = i > 0 ? cameraList[i - 1] : cameraList[i];
|
||||
// next = cameraList[i];
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
//if (pre == null || next == null)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//var x = (next.Frame - pre.Frame) * (next.X - pre.X) == 0 ? pre.X : (float)(pre.X + ((currentFrame - pre.Frame) / (next.Frame - pre.Frame)) * (next.X - pre.X));
|
||||
//var y = (next.Frame - pre.Frame) * (next.Y - pre.Y) == 0 ? pre.Y : (float)(pre.Y + ((currentFrame - pre.Frame) / (next.Frame - pre.Frame)) * (next.Y - pre.Y));
|
||||
//Camera.main.transform.localEulerAngles = new Vector3((float)Math.Round(x, 3), (float)Math.Round(y, 3), 0);//currentCameraRotation;//Vector3.SmoothDamp(Camera.main.transform.localEulerAngles, currentCameraRotation, ref mVelocity, 0.5f);
|
||||
}
|
||||
float velocity;
|
||||
float test = 0;
|
||||
@ -805,7 +805,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
//创建当前线路其他选手
|
||||
private void CreateOnlineUser(List<BaseRider> list)
|
||||
{
|
||||
if (list == null)
|
||||
if (list == null || list.Count == 0)
|
||||
return;
|
||||
CreateCurrentPlayer(list);
|
||||
|
||||
@ -939,17 +939,34 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
CurrentPlayer = videoPlayer.GetComponent<VideoPlayer>();
|
||||
splineController.Position = startOffset;
|
||||
#if UNITY_EDITOR
|
||||
//生成轨迹
|
||||
foreach (var item in spline.ControlPointsList)
|
||||
{
|
||||
GameObject o = new GameObject("oo");
|
||||
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
cube.transform.SetParent(o.transform);
|
||||
cube.transform.position = new Vector3(0, 2f, 0f);
|
||||
var cp = o.AddComponent<SplineController>();
|
||||
cp.Spline = spline;
|
||||
cp.Position = item.Distance;
|
||||
}
|
||||
|
||||
//var txt = Resources.Load<TextAsset>("UI/camera");
|
||||
//var ss = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Vector3>>(txt.text);
|
||||
|
||||
//var curvy = CurvySpline.Create();
|
||||
//curvy.Interpolation = CurvyInterpolation.Bezier;
|
||||
//ss.Take(10);
|
||||
//foreach (var item in ss)
|
||||
//{
|
||||
// //GameObject o = new GameObject("oo");
|
||||
// //var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
// //cube.transform.SetParent(o.transform);
|
||||
// //cube.transform.position = item;
|
||||
// curvy.Add(item);
|
||||
//}
|
||||
|
||||
|
||||
////生成轨迹
|
||||
//foreach (var item in spline.ControlPointsList)
|
||||
//{
|
||||
// GameObject o = new GameObject("oo");
|
||||
// var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
// cube.transform.SetParent(o.transform);
|
||||
// cube.transform.position = new Vector3(0, 0f, 0f);
|
||||
// var cp = o.AddComponent<SplineController>();
|
||||
// cp.Spline = spline;
|
||||
// cp.Position = item.Distance;
|
||||
//}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1089,8 +1106,14 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
double preframe = 0;
|
||||
double preDistance = 0;
|
||||
|
||||
public void Play(float ratio)
|
||||
{
|
||||
mediaPlayer.PlaybackRate = ratio;
|
||||
mediaPlayer.Play();
|
||||
}
|
||||
//设置当前视频播放速度
|
||||
public void Play(double totalDistance)
|
||||
public void Play(int index, double distance)
|
||||
{
|
||||
if (!isStart && _aRMode == ARMode.RIDE)
|
||||
return;
|
||||
@ -1101,15 +1124,33 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
// mediaPlayer.Play();
|
||||
//var frames = DistanceToFrames(totalDistance);
|
||||
//var frame = DistanceToTimers(totalDistance);
|
||||
var result = (float)(totalDistance * ratio);
|
||||
var s1 = frameList.OrderBy(c => c.Distance).Where(c => c.Distance > result).FirstOrDefault();
|
||||
var s2 = frameList.OrderByDescending(c => c.Distance).Where(c => c.Distance <= result).FirstOrDefault();
|
||||
var frame = s2.Second + (result - s2.Distance) / (s1.Distance - s2.Distance) * (s1.Second - s2.Second);
|
||||
//StartCoroutine(DOCameraAnimation(cameraSplineCp.Position, totalDistance - preDistance));
|
||||
//StartCoroutine(DOTrackAnimation(preDistance, totalDistance - preDistance));
|
||||
StartCoroutine(DOSeekToFrame(preframe, frame - preframe));
|
||||
preframe = frame;
|
||||
preDistance = totalDistance;
|
||||
|
||||
//var result = (float)(totalDistance * ratio);
|
||||
//var s1 = frameList.OrderBy(c => c.Distance).Where(c => c.Distance > result).FirstOrDefault();
|
||||
//var s2 = frameList.OrderByDescending(c => c.Distance).Where(c => c.Distance <= result).FirstOrDefault();
|
||||
//var frame = s2.Second + (result - s2.Distance) / (s1.Distance - s2.Distance) * (s1.Second - s2.Second);
|
||||
//StartCoroutine(DOSeekToFrame(preframe, frame - preframe));
|
||||
//preframe = frame;
|
||||
//preDistance = totalDistance;
|
||||
//index = > Spline.AbsolutePosition mediaPlayer.seek()
|
||||
var ttt = mediaPlayer.Info.GetDurationFrames();
|
||||
double offset = 0;
|
||||
if (index + 1 < splineController.Spline.ControlPointsList.Count)
|
||||
{
|
||||
var total = splineController.Spline.ControlPointsList[index + 1].Distance - splineController.Spline.ControlPointsList[index].Distance;
|
||||
offset = distance / mapData.List[index].Distance * total;
|
||||
}
|
||||
|
||||
var currentProcess = index +distance / mapData.List[index].Distance;
|
||||
var currentDistance = splineController.Spline.ControlPointsList[index].Distance + offset;
|
||||
|
||||
StartCoroutine(PlayMoive(preframe, currentProcess - preframe));
|
||||
StartCoroutine(PlayPosition(preDistance, currentDistance - preDistance));
|
||||
|
||||
preframe = currentProcess;
|
||||
preDistance = currentDistance;
|
||||
}
|
||||
if (startTime == null)
|
||||
{
|
||||
@ -1211,6 +1252,33 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
private IEnumerator PlayPosition(double prePos, double offset)
|
||||
{
|
||||
float t = 0;
|
||||
while (t <= 1)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
double result = prePos + offset * t;
|
||||
splineController.AbsolutePosition = (float)result; //(float)(result / (double)s1.Key * s1.Value);
|
||||
TestSpline.AbsolutePosition = (float)result + 2f;
|
||||
|
||||
double result1 = prePos + offset * t/2;
|
||||
cameraSplineCp.AbsolutePosition = (float)result;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator PlayMoive(double preFrame, double offset)
|
||||
{
|
||||
float t = 0;
|
||||
while (t <= 1)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
double result = preFrame + offset * t;
|
||||
mediaPlayer?.Control.Seek(result);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public float startOffset = 0f;
|
||||
private IEnumerator DOSeekToFrame(double preFrame, double offset)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user