AR第二个视频发布
This commit is contained in:
1 parent
573aa2ff4c
commit
431d128ad8
19 files changed
+3813
-2975
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
@@ -14,7 +15,7 @@ namespace Assets.AR
|
||||
|
||||
public float RouteDistance { get; set; }//线路上的距离
|
||||
|
||||
public float Lane { get; set; }//车道上的位置
|
||||
public float Lane { get; set; } //车道上的位置
|
||||
|
||||
public float BaseOffset { get; set; }//基准偏移量
|
||||
|
||||
@@ -38,6 +39,8 @@ namespace Assets.AR
|
||||
|
||||
public int TestPower { get; set; }
|
||||
|
||||
public float ZOffset { get; set; }
|
||||
|
||||
//重置碰撞检测参数
|
||||
public void ResetCollisionDetectionParameters()
|
||||
{
|
||||
@@ -56,13 +59,14 @@ namespace Assets.AR
|
||||
{
|
||||
PositionOffset = Vector3.up * route.CameraHeight * (-1);
|
||||
var cameraRotation = this.GetCameraRotation(this.frame - this.FrameIndexDistanceCorrection);
|
||||
var normalizeCameraRotation = Quaternion.Euler(new Vector3(cameraRotation.eulerAngles.x, cameraRotation.eulerAngles.y, cameraRotation.eulerAngles.z+ZOffset));
|
||||
|
||||
var filteredCameraPosition = this.GetFilteredCameraPosition(this.frame - this.FrameIndexDistanceCorrection);
|
||||
|
||||
var vector3 = Vector3.left * (this.route.LeftHanded ? -1f : 1f) * (this.LaneWidth * (this.Lane + this.LaneCamera) - this.BaseOffset);
|
||||
var targetPos = filteredCameraPosition + cameraRotation * (vector3 + this.PositionOffset);
|
||||
|
||||
var targetPos = filteredCameraPosition + normalizeCameraRotation * (vector3 + this.PositionOffset);
|
||||
|
||||
this.transform.position = targetPos;
|
||||
this.transform.rotation = cameraRotation * Quaternion.Euler(this.RotationOffset) * Quaternion.Euler(this.Lean);
|
||||
this.transform.rotation = normalizeCameraRotation * Quaternion.Euler(this.RotationOffset) * Quaternion.Euler(this.Lean);
|
||||
this.transform.localScale = this.Scale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Assets.AR
|
||||
{
|
||||
var frame = 100f;
|
||||
this.StartRegionRouteWidth = this.GetRouteLeftOffset(frame) + this.GetRouteRightOffset(frame);
|
||||
this.RiderCountInStartRow = Mathf.Max(1, Mathf.CeilToInt(this.StartRegionRouteWidth / 0.7f));
|
||||
this.RiderCountInStartRow = Mathf.Max(2, Mathf.CeilToInt(this.StartRegionRouteWidth / 0.7f));
|
||||
}
|
||||
|
||||
protected override void UpdateGameObjects(
|
||||
@@ -233,10 +233,13 @@ namespace Assets.AR
|
||||
{
|
||||
if (!this.AllowStartOrder || (double)routeDistance >= 200.0)
|
||||
return routeDistance;
|
||||
var num = Mathf.Lerp((float)((double)(RiderCountInStartRow == 0 ? 0 :(startPosition - 1) / this.RiderCountInStartRow) * 2.2000000476837158 + 6.0) + this.GetStartOffset(startPosition).y, 0.0f, routeDistance / 200f);
|
||||
var start = (float)((RiderCountInStartRow == 0 ? 0 : (startPosition - 1) / this.RiderCountInStartRow) * 2.2000000476837158 + 6.0) + this.GetStartOffset(startPosition).y;
|
||||
var num = Mathf.Lerp(start , 0.0f, routeDistance / 200f);
|
||||
return routeDistance + num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//计算碰撞距离
|
||||
protected static float GetCollisionParameter(
|
||||
float distSource,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
@@ -58,6 +59,8 @@ namespace Assets.AR
|
||||
public int VideoFrameOffset { get; set; }
|
||||
|
||||
public float CameraHeight { get; set; }
|
||||
|
||||
public float ZOffset { get; set; }
|
||||
|
||||
public float RiderScale { get; set; } = 1f;
|
||||
|
||||
@@ -428,9 +431,17 @@ namespace Assets.AR
|
||||
|
||||
public void LoadData(ARRouteData data)
|
||||
{
|
||||
// //todo:修改rotation z
|
||||
// foreach (var rotation in data.CameraRotations)
|
||||
// {
|
||||
// rotation.z += 4f;
|
||||
// }
|
||||
//
|
||||
// var str = JsonConvert.SerializeObject(data);
|
||||
this.Visibility = data.Visibility;
|
||||
this.VideoFrameOffset = data.VideoFrameOffset;
|
||||
this.LeftHanded = data.LeftHanded;
|
||||
this.ZOffset = data.Zoffset;
|
||||
this.SlamSegments = data.SlamSegments;
|
||||
this.CameraHeight = data.CameraHeight;
|
||||
this.RiderScale = (double)data.RiderScale != 0.0 ? data.RiderScale : 1f;
|
||||
|
||||
@@ -248,6 +248,7 @@ namespace Assets.AR
|
||||
public int VideoFrameOffsetMac = -1;
|
||||
public float CameraHeight;
|
||||
public float RiderScale = 1f;
|
||||
public float Zoffset = 0f;
|
||||
public int[] LeftSideOffsetFrames;
|
||||
public float[] LeftSideOffsets;
|
||||
public int[] RightSideOffsetFrames;
|
||||
|
||||
@@ -101,16 +101,27 @@ namespace Assets.AR
|
||||
return;
|
||||
}
|
||||
|
||||
this.PlayFrameDistance();
|
||||
PlayFrameDistance();
|
||||
VideoPlayerControl.UpdateVideoPlayRate(mainRiderObject.PreSpeed, mainRiderObject.Distance);
|
||||
this.FrameIndexDistanceCorrection = this.VideoPlayerControl.FrameIndexDistanceCorrection;
|
||||
this.UpdateCameraFollowDistance();
|
||||
FrameIndexDistanceCorrection = this.VideoPlayerControl.FrameIndexDistanceCorrection;
|
||||
UpdateCameraFollowDistance();
|
||||
|
||||
base.Update();
|
||||
this.UpdateRidersVisibility();
|
||||
this.UpdateRidersLean();
|
||||
this.UpdateBackLight();
|
||||
this.SetUpVideoControlMode();
|
||||
UpdateRidersVisibility();
|
||||
UpdateRidersLean();
|
||||
UpdateBackLight();
|
||||
SetUpVideoControlMode();
|
||||
UpdateRemainingTime();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理人物快倒计时
|
||||
/// </summary>
|
||||
private void UpdateRemainingTime()
|
||||
{
|
||||
if (mainRiderObject == null) return;
|
||||
var remainingDistance = Math.Round(manager.GetMapRoute().Distance * 1000f - mainRiderObject.Distance);
|
||||
manager.ShowUpRemainTime(remainingDistance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -247,7 +258,7 @@ namespace Assets.AR
|
||||
case AR.CameraDistance.Near:
|
||||
return 1.5f;
|
||||
case AR.CameraDistance.Middle:
|
||||
return 5f;
|
||||
return 8f;
|
||||
case AR.CameraDistance.Far:
|
||||
return 10f;
|
||||
default:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
using System;
|
||||
using Assets.Scripts.Scenes.VideoRide;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.AR
|
||||
@@ -98,12 +99,14 @@ namespace Assets.AR
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
SetZOffset();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (this.route == null)
|
||||
return;
|
||||
SetMainRiderLane();
|
||||
base.Update();
|
||||
var num = this.Speed;
|
||||
this.Paused = this.Speed == 0;
|
||||
@@ -169,7 +172,24 @@ namespace Assets.AR
|
||||
|
||||
this.lastVisibilitylevel = this.VisibilityLevel;
|
||||
}
|
||||
|
||||
|
||||
private void SetZOffset()
|
||||
{
|
||||
var manager = FindObjectOfType<VideoGameManager>();
|
||||
var map = manager.GetMapRoute();
|
||||
this.ZOffset = map.Id == 6296 ? -4f : 0f;
|
||||
}
|
||||
|
||||
private void SetMainRiderLane()
|
||||
{
|
||||
if (IsMain)
|
||||
{
|
||||
var manager = FindObjectOfType<VideoGameManager>();
|
||||
var map = manager.GetMapRoute();
|
||||
if(map.Id == 6296)
|
||||
Lane = -2f;
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user