ar观察者模式
This commit is contained in:
1 parent
df936c4e04
commit
7822584cdd
62 files changed
+8331
-7049
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public class ARObject : MonoBehaviour
|
||||
public class ARGameObject : MonoBehaviour
|
||||
{
|
||||
public string Hash;
|
||||
public const int Layer = 1;
|
||||
@@ -23,12 +23,14 @@ namespace Assets.AR
|
||||
|
||||
private float FrameRate = 29.97f;
|
||||
|
||||
public ARObjectTimeTransform[] TimeTransforms { get; set; }
|
||||
public ARVideoTransform[] TimeTransforms { get; set; }
|
||||
|
||||
public string CustomUrl { get; set; }
|
||||
|
||||
public string ArName { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public Vector3 CameraPositionOffset { get; set; }
|
||||
|
||||
public float Frame => !this.useMultilapTransform ? this.frame : this.frame + this.videoSync.LastVideoFrame;
|
||||
File renamed without changes.
@@ -3,7 +3,7 @@ using UnityEngine.Rendering;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public static class ARMeshFactory
|
||||
public static class ARGameObjectFactory
|
||||
{
|
||||
private static bool IsValidVertex(Vector3 v) => !float.IsNaN(v.x) && !float.IsInfinity(v.x) && !float.IsNaN(v.y) && !float.IsInfinity(v.y) && !float.IsNaN(v.z) && !float.IsInfinity(v.z);
|
||||
//创建轨迹
|
||||
@@ -22,15 +22,15 @@ namespace Assets.AR
|
||||
Vector3[] vector3Array1 = new Vector3[num1 * 2];
|
||||
Vector3 left;
|
||||
Vector3 right;
|
||||
ARMeshFactory.CreateVertices(start, route, lOffset, rOffset, out left, out right, margin);
|
||||
ARGameObjectFactory.CreateVertices(start, route, lOffset, rOffset, out left, out right, margin);
|
||||
vector3Array1[0] = left;
|
||||
vector3Array1[1] = right;
|
||||
int num2 = 2;
|
||||
int num3 = 0;
|
||||
for (int frame = start + 1; frame <= end; ++frame)
|
||||
{
|
||||
ARMeshFactory.CreateVertices(frame, route, lOffset, rOffset, out left, out right, margin);
|
||||
if (ARMeshFactory.IsValidVertex(left) && ARMeshFactory.IsValidVertex(right))
|
||||
ARGameObjectFactory.CreateVertices(frame, route, lOffset, rOffset, out left, out right, margin);
|
||||
if (ARGameObjectFactory.IsValidVertex(left) && ARGameObjectFactory.IsValidVertex(right))
|
||||
{
|
||||
Vector3[] vector3Array2 = vector3Array1;
|
||||
int index1 = num2;
|
||||
File renamed without changes.
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public enum ARObjectType
|
||||
public enum ARGameObjectType
|
||||
{
|
||||
Sign,
|
||||
Box,
|
||||
@@ -17,7 +17,7 @@ namespace Assets.AR
|
||||
Custom,
|
||||
}
|
||||
|
||||
public enum RiderCameraDistance
|
||||
public enum CameraDistance
|
||||
{
|
||||
FirstPerson,
|
||||
Near,
|
||||
@@ -25,7 +25,7 @@ namespace Assets.AR
|
||||
Far,
|
||||
}
|
||||
|
||||
public enum VideoControlMode
|
||||
public enum VideoPlayMode
|
||||
{
|
||||
Front,
|
||||
AutoPanorama,
|
||||
File renamed without changes.
@@ -4,12 +4,12 @@ using UnityEngine.Rendering;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public abstract class ARObjectsController : MonoBehaviour
|
||||
public abstract class ARGameObjectsController : MonoBehaviour
|
||||
{
|
||||
public float MaximumVisibilityDistance = 200f;
|
||||
private readonly Vector3 CameraOriginOffset = Vector3.up * -100f;
|
||||
protected static readonly Vector3 DefaultObjectPosition = new Vector3(0.0f, 1000f, 0.0f);
|
||||
protected List<ARObject> arObjects = new List<ARObject>();
|
||||
protected List<ARGameObject> arObjects = new List<ARGameObject>();
|
||||
protected Material matShadow { get; set; }
|
||||
protected Material matModelMask;
|
||||
protected AVProVideoPlayer videoPlayer { get; set; }
|
||||
@@ -21,7 +21,7 @@ namespace Assets.AR
|
||||
protected GameObject trajectoryObject;
|
||||
private float ambientIntensity;
|
||||
private GameObject camGo;
|
||||
protected Dictionary<int, ARObjectsController.Segment> trajectorySegments = new Dictionary<int, ARObjectsController.Segment>();
|
||||
protected Dictionary<int, ARGameObjectsController.Segment> trajectorySegments = new Dictionary<int, ARGameObjectsController.Segment>();
|
||||
protected int lapCount = 1;
|
||||
protected double lapLength;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Assets.AR
|
||||
this.matShadow = Resources.Load<Material>("UI/Material/TransparentPlane");
|
||||
//this.matModelMask = Resources.Load<Material>("Materials/ModelDepth");
|
||||
this.arObjects.Clear();
|
||||
this.arObjects.AddRange(FindObjectsOfType<ARObject>());
|
||||
this.arObjects.AddRange(FindObjectsOfType<ARGameObject>());
|
||||
SetupCamera();
|
||||
}
|
||||
|
||||
@@ -66,18 +66,18 @@ namespace Assets.AR
|
||||
if (this.Route.CameraRotationsRear != null && this.Route.CameraRotationsRear.Length == this.Route.CameraRotations.Length)
|
||||
{
|
||||
this.AR360Version = true;
|
||||
ARObject.MaxDistanceVisibilityModels = 200f;
|
||||
ARGameObject.MaxDistanceVisibilityModels = 200f;
|
||||
this.MaximumVisibilityDistance = 500f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AR360Version = false;
|
||||
ARObject.MaxDistanceVisibilityModels = 80f;
|
||||
ARGameObject.MaxDistanceVisibilityModels = 80f;
|
||||
this.MaximumVisibilityDistance = 200f;
|
||||
}
|
||||
if (route == null)
|
||||
return;
|
||||
foreach (ARObject arObject in this.arObjects)
|
||||
foreach (ARGameObject arObject in this.arObjects)
|
||||
{
|
||||
arObject.VideoSync = videoSync;
|
||||
arObject.Route = route;
|
||||
@@ -92,10 +92,10 @@ namespace Assets.AR
|
||||
float visibilityRear,
|
||||
float visibilityFront)
|
||||
{
|
||||
foreach (ARObject arObject in this.arObjects)
|
||||
foreach (ARGameObject arObject in this.arObjects)
|
||||
{
|
||||
arObject.CameraPositionOffset = this.cameraPositionOffset;
|
||||
if (arObject is ARLaneObject arLaneObject)
|
||||
if (arObject is ARLaneGameObject arLaneObject)
|
||||
arLaneObject.FrameIndexDistanceCorrection = this.FrameIndexDistanceCorrection;
|
||||
//if (this.SelectedPanorama != null && (arObject.ObjectType == ARObjectType.Box || arObject.ObjectType == ARObjectType.Sphere))
|
||||
//{
|
||||
@@ -112,7 +112,7 @@ namespace Assets.AR
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool IsArObjectActive(ARObject arObject) => (double)arObject.VisibilityLevel > 0.0 ;
|
||||
protected virtual bool IsArObjectActive(ARGameObject arObject) => (double)arObject.VisibilityLevel > 0.0 ;
|
||||
|
||||
|
||||
protected virtual Material GetTrajectoryMaterial() => this.matShadow;
|
||||
@@ -165,13 +165,13 @@ namespace Assets.AR
|
||||
if (!this.trajectorySegments.ContainsKey(index))
|
||||
{
|
||||
GameObject trajectory = this.CreateTrajectory(index, 0.0f, 0.0f);
|
||||
ARObjectsController.Segment segment = new ARObjectsController.Segment(trajectory, trajectory.transform.position);
|
||||
ARGameObjectsController.Segment segment = new ARGameObjectsController.Segment(trajectory, trajectory.transform.position);
|
||||
this.trajectorySegments.Add(index, segment);
|
||||
}
|
||||
}
|
||||
foreach (int key in this.trajectorySegments.Keys)
|
||||
{
|
||||
ARObjectsController.Segment trajectorySegment = this.trajectorySegments[key];
|
||||
ARGameObjectsController.Segment trajectorySegment = this.trajectorySegments[key];
|
||||
trajectorySegment.GameObject.transform.position = trajectorySegment.Position - this.cameraPositionOffset;
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ namespace Assets.AR
|
||||
float rOffset,
|
||||
float margin = float.NaN)
|
||||
{
|
||||
GameObject trajectory = ARMeshFactory.CreateTrajectory(this.Route, segment, lOffset, rOffset, margin);
|
||||
GameObject trajectory = ARGameObjectFactory.CreateTrajectory(this.Route, segment, lOffset, rOffset, margin);
|
||||
trajectory.transform.parent = this.trajectoryObject.transform;
|
||||
//trajectory.layer = 9;
|
||||
trajectory.GetComponent<MeshRenderer>().shadowCastingMode = ShadowCastingMode.Off;
|
||||
File renamed without changes.
@@ -3,7 +3,7 @@ using DG.Tweening;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public class ARLaneObject : ARObject
|
||||
public class ARLaneGameObject : ARGameObject
|
||||
{
|
||||
public Vector3 Lean { get; set; }//偏移量
|
||||
|
||||
File renamed without changes.
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public abstract class ARLaneObjectsController : ARObjectsController
|
||||
public abstract class ARLaneGameObjectsController : ARGameObjectsController
|
||||
{
|
||||
protected const float LaneWidth = 0.7f;
|
||||
protected const float StartRegionDistance = 200f;
|
||||
@@ -12,9 +12,9 @@ namespace Assets.AR
|
||||
private const float StartRowsRandomDistance = 0.4f;
|
||||
private const float StartRowsRandomWidth = 0.15f;
|
||||
private const float MinCollisionDistance = 1.33f;
|
||||
protected readonly Dictionary<int, ARLaneObject> riderObjects = new Dictionary<int, ARLaneObject>();
|
||||
protected readonly Dictionary<int, ARLaneGameObject> riderObjects = new Dictionary<int, ARLaneGameObject>();
|
||||
private readonly Dictionary<int, Vector2> randomizedStartOffsets = new Dictionary<int, Vector2>();
|
||||
private readonly List<ARLaneObject> collisionList = new List<ARLaneObject>();
|
||||
private readonly List<ARLaneGameObject> collisionList = new List<ARLaneGameObject>();
|
||||
|
||||
public bool AllowStartOrder { get; set; } = true;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Assets.AR
|
||||
|
||||
public int FollowedRiderId { get; set; }
|
||||
|
||||
public IReadOnlyDictionary<int, ARLaneObject> ArRiders => (IReadOnlyDictionary<int, ARLaneObject>)this.riderObjects;
|
||||
public IReadOnlyDictionary<int, ARLaneGameObject> ArRiders => (IReadOnlyDictionary<int, ARLaneGameObject>)this.riderObjects;
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
@@ -50,10 +50,10 @@ namespace Assets.AR
|
||||
//检测碰撞
|
||||
private void DetectRidersCollisions(float cameraDistance)
|
||||
{
|
||||
float num1 = cameraDistance - ARObject.MaxDistanceVisibilityModels;
|
||||
float num2 = cameraDistance + ARObject.MaxDistanceVisibilityModels;
|
||||
float num1 = cameraDistance - ARGameObject.MaxDistanceVisibilityModels;
|
||||
float num2 = cameraDistance + ARGameObject.MaxDistanceVisibilityModels;
|
||||
this.collisionList.Clear();
|
||||
foreach (ARLaneObject arLaneObject in this.riderObjects.Values)
|
||||
foreach (ARLaneGameObject arLaneObject in this.riderObjects.Values)
|
||||
{
|
||||
if (arLaneObject.gameObject.activeSelf && !arLaneObject.IsAtFinish)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace Assets.AR
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (ARLaneObject collision in this.collisionList)
|
||||
foreach (ARLaneGameObject collision in this.collisionList)
|
||||
{
|
||||
if ((double)collision.RouteDistance < 200.0)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ namespace Assets.AR
|
||||
collision.DistanceSort = collision.Distance;
|
||||
}
|
||||
}
|
||||
this.collisionList.Sort((Comparison<ARLaneObject>)((r1, r2) =>
|
||||
this.collisionList.Sort((Comparison<ARLaneGameObject>)((r1, r2) =>
|
||||
{
|
||||
int num3 = r1.Lane.CompareTo(r2.Lane);
|
||||
if (num3 == 0)
|
||||
@@ -82,7 +82,7 @@ namespace Assets.AR
|
||||
float deltaTime = Time.deltaTime;
|
||||
for (int index = 0; index < this.collisionList.Count; ++index)
|
||||
{
|
||||
ARLaneObject collision = this.collisionList[index];
|
||||
ARLaneGameObject collision = this.collisionList[index];
|
||||
float lane = collision.Lane;
|
||||
float num4 = this.GetLane(collision.RouteDistance, collision.DistanceSort, index);
|
||||
if ((double)collision.LaneWidth != 0.0)
|
||||
@@ -94,7 +94,7 @@ namespace Assets.AR
|
||||
collision.Lane = num4;
|
||||
}
|
||||
this.CalculateOvertakingParameters();
|
||||
foreach (ARLaneObject collision in this.collisionList)
|
||||
foreach (ARLaneGameObject collision in this.collisionList)
|
||||
{
|
||||
collision.LaneWidth = 0.7f;
|
||||
float num6 = this.Route.LeftHanded ? this.GetRouteLeftOffset(collision.Frame) : this.GetRouteRightOffset(collision.Frame);
|
||||
@@ -109,7 +109,7 @@ namespace Assets.AR
|
||||
float deltaTime = Time.deltaTime;
|
||||
for (int index = 0; index < this.collisionList.Count; ++index)
|
||||
{
|
||||
ARLaneObject collision = this.collisionList[index];
|
||||
ARLaneGameObject collision = this.collisionList[index];
|
||||
bool flag1 = collision.StartPosition == this.FollowedRiderId;
|
||||
float x = Math.Abs(collision.Distance - cameraDistance);
|
||||
float x2 = 4f;
|
||||
@@ -124,7 +124,7 @@ namespace Assets.AR
|
||||
}
|
||||
else
|
||||
{
|
||||
float num1 = VTMath.Lerp(0.0f, 1f, x2, 0.0f, x);
|
||||
float num1 = PFMath.Lerp(0.0f, 1f, x2, 0.0f, x);
|
||||
float num2 = collision.Lane * collision.LaneWidth - collision.BaseOffset;
|
||||
float num3 = 0.75f;
|
||||
if (this.NearViewMode && !flag1)
|
||||
@@ -149,7 +149,7 @@ namespace Assets.AR
|
||||
private void CalculateOvertakingParameters()
|
||||
{
|
||||
float deltaTime = Time.deltaTime;
|
||||
foreach (ARLaneObject laneObject in this.riderObjects.Values)
|
||||
foreach (ARLaneGameObject laneObject in this.riderObjects.Values)
|
||||
{
|
||||
float num1 = laneObject.Speed * deltaTime;
|
||||
if ((double)num1 == 0.0)
|
||||
@@ -166,7 +166,7 @@ namespace Assets.AR
|
||||
if ((double)num1 > 0.0)
|
||||
{
|
||||
float num3 = Mathf.Atan(num2 / num1);
|
||||
curvature = (float)(0.039999999105930328 * (double)VTMath.Lerp(0.0f, 3f, 20f, 1f, laneObject.Speed)) * num3;
|
||||
curvature = (float)(0.039999999105930328 * (double)PFMath.Lerp(0.0f, 3f, 20f, 1f, laneObject.Speed)) * num3;
|
||||
}
|
||||
this.UpdateRiderCurvature(laneObject, curvature, deltaTime);
|
||||
float angle = -57.29578f * Mathf.Atan(num2 / num1);
|
||||
@@ -175,14 +175,14 @@ namespace Assets.AR
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateRiderCurvature(ARLaneObject laneObject, float curvature, float deltaTime)
|
||||
protected void UpdateRiderCurvature(ARLaneGameObject laneObject, float curvature, float deltaTime)
|
||||
{
|
||||
float num = 6f;
|
||||
laneObject.Curvature = Mathf.Lerp(laneObject.Curvature, curvature, num * deltaTime);
|
||||
}
|
||||
|
||||
protected void UpdateLaneChangingDirection(
|
||||
ARLaneObject laneObject,
|
||||
ARLaneGameObject laneObject,
|
||||
float angle,
|
||||
float deltaTime)
|
||||
{
|
||||
@@ -198,10 +198,10 @@ namespace Assets.AR
|
||||
float b = 0.0f;
|
||||
for (int index = count - 1; index >= 0; --index)
|
||||
{
|
||||
ARLaneObject collision = this.collisionList[index];
|
||||
ARLaneGameObject collision = this.collisionList[index];
|
||||
if ((double)collision.Lane + 1.0 >= (double)b)
|
||||
{
|
||||
float collisionParameter = ARLaneObjectsController.GetCollisionParameter(modelDistance, collision.DistanceSort, overtakingThreshold);
|
||||
float collisionParameter = ARLaneGameObjectsController.GetCollisionParameter(modelDistance, collision.DistanceSort, overtakingThreshold);
|
||||
if ((double)collisionParameter > 0.0)
|
||||
b = Mathf.Max(collision.Lane + collisionParameter, b);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ namespace Assets.AR
|
||||
x = -x;
|
||||
if ((double)x < 1.0)
|
||||
return 1f;
|
||||
return (double)x > (double)maxDistance ? 0.0f : VTMath.SmoothStep(1f, 1f, maxDistance, 0.0f, x);
|
||||
return (double)x > (double)maxDistance ? 0.0f : PFMath.SmoothStep(1f, 1f, maxDistance, 0.0f, x);
|
||||
}
|
||||
|
||||
private float GetRouteLeftOffset(float frame) => this.Route == null ? 0.0f : this.Route.GetLeftSideOffset(frame);
|
||||
File renamed without changes.
@@ -205,7 +205,7 @@ namespace Assets.AR
|
||||
return 0.0;
|
||||
if (index == frameDistances.Length)
|
||||
return (double)(frameDistances.Length - 1);
|
||||
double num = VTMath.InverseLerp(frameDistances[index - 1], frameDistances[index], distance);
|
||||
double num = PFMath.InverseLerp(frameDistances[index - 1], frameDistances[index], distance);
|
||||
return (double)index + num - 1.0;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace Assets.AR
|
||||
if (index >= this.FrameCount)
|
||||
return this.FrameDistances[this.FrameDistances.Length - 1];
|
||||
double t = frame - (double)(index - 1);
|
||||
return VTMath.Lerp(this.FrameDistances[index - 1], this.FrameDistances[index], t);
|
||||
return PFMath.Lerp(this.FrameDistances[index - 1], this.FrameDistances[index], t);
|
||||
}
|
||||
|
||||
public CameraProjectionParameters GetCameraProjectionParameters(
|
||||
@@ -558,7 +558,7 @@ namespace Assets.AR
|
||||
Vector3 filteredCameraPosition1 = this.GetFilteredCameraPosition((float)this.GetFrameAtDistance(num - 10.0));
|
||||
Vector3 filteredCameraPosition2 = this.GetFilteredCameraPosition((float)this.GetFrameAtDistance(num + 10.0));
|
||||
Vector3 center;
|
||||
if (!Geometry.CircleCenter(filteredCameraPosition1, aP1, filteredCameraPosition2, out center))
|
||||
if (!GeometryUtil.CircleCenter(filteredCameraPosition1, aP1, filteredCameraPosition2, out center))
|
||||
{
|
||||
numArray[index] = 0.0f;
|
||||
}
|
||||
|
||||
@@ -8,20 +8,20 @@ using Assets.Scenes.Ride.Scripts.Model.RiderModels;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public class ARTrainingController : ARLaneObjectsController
|
||||
public class ARTrainingController : ARLaneGameObjectsController
|
||||
{
|
||||
public MediaPlayer mediaPlayer;
|
||||
private ARData aRData;
|
||||
private RouteDetailData detail;
|
||||
private VideoPointsSync videoPointsSync;
|
||||
private readonly List<ARLaneObject> collisionList = new List<ARLaneObject>();
|
||||
VideoPlayerControl VideoPlayerControl;
|
||||
ARLaneObject[] rides { get; set; }
|
||||
public ARLaneObject mainRiderObject { get; set; }
|
||||
private readonly List<ARLaneGameObject> collisionList = new List<ARLaneGameObject>();
|
||||
ARVideoPlayerControl VideoPlayerControl;
|
||||
ARLaneGameObject[] rides { get; set; }
|
||||
public ARLaneGameObject mainRiderObject { get; set; }
|
||||
private Light arLight;
|
||||
private Light arBackLight;
|
||||
public RiderCameraDistance RiderCameraDistance { get; set; }
|
||||
public VideoControlMode VideoControlMode { get; private set; }
|
||||
public CameraDistance RiderCameraDistance { get; set; }
|
||||
public VideoPlayMode VideoControlMode { get; private set; }
|
||||
private float autoCameraSwitchTimeCounter = 80f;
|
||||
float timers = 0f;
|
||||
private VideoGameManager manager;
|
||||
@@ -55,14 +55,14 @@ namespace Assets.AR
|
||||
//ar数据加载本地,本地没有就下载
|
||||
this.aRData = arData;
|
||||
this.detail = routeDetailData;
|
||||
|
||||
this.RiderCameraDistance = AR.CameraDistance.Middle;
|
||||
videoPointsSync = new VideoPointsSync(detail.VideoPoints.Select(c => new VideoPoint()
|
||||
{
|
||||
Distance = (float)c.Distance,
|
||||
Time = (float)c.VideoTime
|
||||
}));
|
||||
videoSync = videoPointsSync;
|
||||
this.VideoPlayerControl = new VideoPlayerControl();
|
||||
this.VideoPlayerControl = new ARVideoPlayerControl();
|
||||
this.VideoPlayerControl.VideoSyncSource = videoSync;
|
||||
this.videoPlayer = new AVProVideoPlayer();
|
||||
this.videoPlayer.videoPlayer = mediaPlayer;
|
||||
@@ -70,7 +70,7 @@ namespace Assets.AR
|
||||
this.VideoPlayerControl.VideoFrameOffset = this.Route.VideoFrameOffset;
|
||||
this.VideoPlayerControl.Route = Route;
|
||||
this.VideoPlayerControl.SetVideoPlayer(videoPlayer);
|
||||
rides = FindObjectsOfType<ARLaneObject>();
|
||||
rides = FindObjectsOfType<ARLaneGameObject>();
|
||||
SetUpLight();
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Assets.AR
|
||||
{
|
||||
|
||||
var item = dic.Value;
|
||||
if (dic.Key.UserId == App.CurrentUser.Id)
|
||||
if (dic.Key.UserId == manager.CurrentPlayer.userId)
|
||||
{
|
||||
mainRiderObject = item;
|
||||
}
|
||||
@@ -109,14 +109,28 @@ namespace Assets.AR
|
||||
item.IsAtFinish = dic.Key.EndDistance >= manager.GetMapRoute().Distance*1000f;
|
||||
if (!this.arObjects.Contains(item))
|
||||
this.arObjects.Add(item);
|
||||
if (!this.riderObjects.ContainsKey(item.GetInstanceID()))
|
||||
this.riderObjects.Add(item.GetInstanceID(), item);
|
||||
if (!this.riderObjects.ContainsKey(item.UserId))
|
||||
this.riderObjects.Add(item.UserId, item);
|
||||
}
|
||||
this.arObjects.RemoveAll(c => !manager.rideObjs.Select(m => m.Key.UserId.ToString()).Contains(c.UserId.ToString()));
|
||||
|
||||
var keys = riderObjects.Keys.ToList();
|
||||
foreach (var item in keys)
|
||||
{
|
||||
if (!manager.rideObjs.Keys.Where(c => c.UserId == item).Any())
|
||||
{
|
||||
riderObjects.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
timers += 1f;
|
||||
}
|
||||
|
||||
if (mainRiderObject == null || Route == null)
|
||||
if (mainRiderObject == null || Route == null)
|
||||
{
|
||||
videoPlayer?.Pause();
|
||||
return;
|
||||
}
|
||||
var delta = Time.deltaTime;
|
||||
foreach (var obj in this.riderObjects.Values)
|
||||
{
|
||||
@@ -135,12 +149,12 @@ namespace Assets.AR
|
||||
this.UpdateRidersLean();
|
||||
this.UpdateBackLight();
|
||||
if (Input.GetKeyDown(KeyCode.F))
|
||||
this.SetVideoControlMode(VideoControlMode.Front);
|
||||
this.SetVideoControlMode(VideoPlayMode.Front);
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
this.SetVideoControlMode(VideoControlMode.AutoPanorama);
|
||||
this.SetVideoControlMode(VideoPlayMode.AutoPanorama);
|
||||
if (!Input.GetKeyDown(KeyCode.B))
|
||||
return;
|
||||
this.SetVideoControlMode(VideoControlMode.Rear);
|
||||
this.SetVideoControlMode(VideoPlayMode.Rear);
|
||||
}
|
||||
//创建
|
||||
private void SetUpLight()
|
||||
@@ -173,28 +187,27 @@ namespace Assets.AR
|
||||
this.arBackLight.cullingMask = 512;
|
||||
}
|
||||
//设置video显示模式
|
||||
public void SetVideoControlMode(VideoControlMode mode)
|
||||
public void SetVideoControlMode(VideoPlayMode mode)
|
||||
{
|
||||
if (mode == this.VideoControlMode)
|
||||
return;
|
||||
if (!this.AR360Version)
|
||||
mode = VideoControlMode.Front;
|
||||
mode = VideoPlayMode.Front;
|
||||
this.VideoControlMode = mode;
|
||||
this.autoCameraSwitchTimeCounter = 80f;
|
||||
if (mode == VideoControlMode.AutoPanorama)
|
||||
if (mode == VideoPlayMode.AutoPanorama)
|
||||
return;
|
||||
this.videoPlayer.IntendedRear = mode == VideoControlMode.Rear;
|
||||
this.videoPlayer.IntendedRear = mode == VideoPlayMode.Rear;
|
||||
}
|
||||
//更新摄像机的位置
|
||||
private void UpdateCameraFollowDistance()
|
||||
{
|
||||
this.RiderCameraDistance = RiderCameraDistance.Middle;
|
||||
this.NearViewMode = this.RiderCameraDistance == RiderCameraDistance.Near;
|
||||
this.NearViewMode = this.RiderCameraDistance == AR.CameraDistance.Near;
|
||||
float cameraFollowDistance = GetCameraFollowDistance(this.RiderCameraDistance);
|
||||
this.VideoPlayerControl.CameraFollowDistance = cameraFollowDistance;
|
||||
}
|
||||
//人物是否显示
|
||||
protected override bool IsArObjectActive(ARObject arObject)
|
||||
protected override bool IsArObjectActive(ARGameObject arObject)
|
||||
{
|
||||
bool flag = base.IsArObjectActive(arObject);
|
||||
if ((UnityEngine.Object)arObject != (UnityEngine.Object)this.mainRiderObject)
|
||||
@@ -204,17 +217,17 @@ namespace Assets.AR
|
||||
return flag && (double)this.VideoPlayerControl.CameraDistanceError > 5.0;
|
||||
}
|
||||
//获取摄像机的位置
|
||||
public static float GetCameraFollowDistance(RiderCameraDistance distance)
|
||||
public static float GetCameraFollowDistance(CameraDistance distance)
|
||||
{
|
||||
switch (distance)
|
||||
{
|
||||
case RiderCameraDistance.FirstPerson:
|
||||
case AR.CameraDistance.FirstPerson:
|
||||
return 0.0f;
|
||||
case RiderCameraDistance.Near:
|
||||
case AR.CameraDistance.Near:
|
||||
return 1.5f;
|
||||
case RiderCameraDistance.Middle:
|
||||
case AR.CameraDistance.Middle:
|
||||
return 5f;
|
||||
case RiderCameraDistance.Far:
|
||||
case AR.CameraDistance.Far:
|
||||
return 10f;
|
||||
default:
|
||||
throw new ArgumentException("Unknown rider's camera distance.");
|
||||
@@ -237,26 +250,26 @@ namespace Assets.AR
|
||||
this.DestroyRiderTitle(riderId);
|
||||
}
|
||||
//创建人物
|
||||
private BaseRenderer CreateRiderModel(OnlineRiderModel rider, float lane)
|
||||
private AbstractRenderer CreateRiderModel(OnlineRiderModel rider, float lane)
|
||||
{
|
||||
GameObject gameObject;
|
||||
RiderRenderer riderModel;
|
||||
PlayerRenderer riderModel;
|
||||
if (rider.Sex == 1)
|
||||
{
|
||||
gameObject = UnityEngine.Object.Instantiate<GameObject>(this.BikerMalePrefab);
|
||||
gameObject.name = "RiderMale " + rider.UserId.ToString();
|
||||
riderModel = gameObject.AddComponent<RiderRenderer>();
|
||||
riderModel = gameObject.AddComponent<PlayerRenderer>();
|
||||
riderModel.Initialize(true, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject = UnityEngine.Object.Instantiate<GameObject>(this.BikerFemalePrefab);
|
||||
gameObject.name = "RiderFemale " + rider.UserId.ToString();
|
||||
riderModel = gameObject.AddComponent<RiderRenderer>();
|
||||
riderModel = gameObject.AddComponent<PlayerRenderer>();
|
||||
riderModel.Initialize(false, false);
|
||||
}
|
||||
gameObject.transform.parent = this.transform;
|
||||
gameObject.transform.position = ARObjectsController.DefaultObjectPosition;
|
||||
gameObject.transform.position = ARGameObjectsController.DefaultObjectPosition;
|
||||
gameObject.layer = 9;
|
||||
riderModel.Route = this.Route;
|
||||
riderModel.VideoSync = this.videoSync;
|
||||
@@ -269,30 +282,30 @@ namespace Assets.AR
|
||||
//riderModel.BikeTexture = modelTextures.BikeTexture;
|
||||
if ((double)lane != -1.0)
|
||||
riderModel.Lane = lane;
|
||||
this.riderObjects.Add(rider.UserId, (ARLaneObject)riderModel);
|
||||
this.arObjects.Add((ARObject)riderModel);
|
||||
this.riderObjects.Add(rider.UserId, (ARLaneGameObject)riderModel);
|
||||
this.arObjects.Add((ARGameObject)riderModel);
|
||||
//是否
|
||||
if (this.IsMainRider(rider))
|
||||
this.mainRiderObject = (ARLaneObject)riderModel;
|
||||
return (BaseRenderer)riderModel;
|
||||
this.mainRiderObject = (ARLaneGameObject)riderModel;
|
||||
return (AbstractRenderer)riderModel;
|
||||
}
|
||||
|
||||
private ARLaneObject CreateRiderObject(OnlineRiderModel rider, float lane)
|
||||
private ARLaneGameObject CreateRiderObject(OnlineRiderModel rider, float lane)
|
||||
{
|
||||
ARLaneObject riderObject = new GameObject("RiderObject " + rider.UserId.ToString())
|
||||
ARLaneGameObject riderObject = new GameObject("RiderObject " + rider.UserId.ToString())
|
||||
{
|
||||
transform = {
|
||||
parent = this.transform
|
||||
},
|
||||
layer = 9
|
||||
}.AddComponent<ARLaneObject>();
|
||||
}.AddComponent<ARLaneGameObject>();
|
||||
riderObject.Route = this.Route;
|
||||
riderObject.VideoSync = this.videoSync;
|
||||
//riderObject.VideoPlayer = this.videoPlayer;
|
||||
if ((double)lane != -1.0)
|
||||
riderObject.Lane = lane;
|
||||
this.riderObjects.Add(rider.UserId, riderObject);
|
||||
this.arObjects.Add((ARObject)riderObject);
|
||||
this.arObjects.Add((ARGameObject)riderObject);
|
||||
if (this.IsMainRider(rider))
|
||||
this.mainRiderObject = riderObject;
|
||||
return riderObject;
|
||||
@@ -300,13 +313,13 @@ namespace Assets.AR
|
||||
//销毁骑手
|
||||
private void DestroyRider(int riderId)
|
||||
{
|
||||
ARLaneObject arLaneObject;
|
||||
ARLaneGameObject arLaneObject;
|
||||
if (!this.riderObjects.TryGetValue(riderId, out arLaneObject))
|
||||
return;
|
||||
this.arObjects.Remove((ARObject)arLaneObject);
|
||||
this.arObjects.Remove((ARGameObject)arLaneObject);
|
||||
this.riderObjects.Remove(riderId);
|
||||
if ((UnityEngine.Object)arLaneObject == (UnityEngine.Object)this.mainRiderObject)
|
||||
this.mainRiderObject = (ARLaneObject)null;
|
||||
this.mainRiderObject = (ARLaneGameObject)null;
|
||||
UnityEngine.Object.Destroy((UnityEngine.Object)arLaneObject.gameObject);
|
||||
}
|
||||
//创建骑行人员头顶的名字
|
||||
@@ -392,7 +405,7 @@ namespace Assets.AR
|
||||
{
|
||||
if (!this.visibleRiders.ContainsKey(num))
|
||||
{
|
||||
ARLaneObject riderObject = this.riderObjects[num];
|
||||
ARLaneGameObject riderObject = this.riderObjects[num];
|
||||
if (!riderObject.IsAtFinish || (double)riderObject.VisibilityLevel <= 0.0)
|
||||
{
|
||||
this.DestroyRider(num);
|
||||
@@ -405,11 +418,11 @@ namespace Assets.AR
|
||||
{
|
||||
var rider = visibleRiderItem.Rider;
|
||||
bool showModel = visibleRiderItem.ShowModel;
|
||||
ARLaneObject arLaneObject;
|
||||
ARLaneGameObject arLaneObject;
|
||||
//二次检查
|
||||
if (this.riderObjects.TryGetValue(rider.UserId, out arLaneObject))
|
||||
{
|
||||
if (arLaneObject is BaseRenderer)
|
||||
if (arLaneObject is AbstractRenderer)
|
||||
{
|
||||
if (!showModel)
|
||||
{
|
||||
@@ -438,7 +451,7 @@ namespace Assets.AR
|
||||
public int VisibleRiderTitlesLimit => this.VisibleModelsLimit + 10;
|
||||
private void UpdateVisibleRiders()
|
||||
{
|
||||
float visibilityModels = ARObject.MaxDistanceVisibilityModels;
|
||||
float visibilityModels = ARGameObject.MaxDistanceVisibilityModels;
|
||||
float visibilityDistance = this.MaximumVisibilityDistance;
|
||||
float routeDistance = this.CameraDistance;
|
||||
bool flag = this.AllowStartOrder && (double)routeDistance < 200.0;
|
||||
@@ -500,7 +513,7 @@ namespace Assets.AR
|
||||
if ((double)num6 > -(double)num2 && (double)num6 < (double)num1)
|
||||
{
|
||||
float num7 = -1f;
|
||||
ARLaneObject laneObject;
|
||||
ARLaneGameObject laneObject;
|
||||
if (this.riderObjects.TryGetValue(rider.UserId, out laneObject))
|
||||
{
|
||||
if ((double)laneObject.Lane > (double)num4)
|
||||
@@ -630,7 +643,7 @@ namespace Assets.AR
|
||||
{
|
||||
float routeDistance1 = (float)visibleRiderItem.Rider.RouteDistance;
|
||||
float routeDistance2 = (float)sorted.Rider.RouteDistance;
|
||||
float collisionParameter = ARLaneObjectsController.GetCollisionParameter(routeDistance1, routeDistance2, this.GetOvertakingThreshold(routeDistance1));
|
||||
float collisionParameter = ARLaneGameObjectsController.GetCollisionParameter(routeDistance1, routeDistance2, this.GetOvertakingThreshold(routeDistance1));
|
||||
sorted.Lane += collisionParameter;
|
||||
if ((double)sorted.Lane > (double)maxLane)
|
||||
sorted.Lane = float.MaxValue;
|
||||
@@ -647,7 +660,7 @@ namespace Assets.AR
|
||||
//更新骑手的偏移角度
|
||||
private void UpdateRidersLean()
|
||||
{
|
||||
foreach (ARLaneObject riderObject in this.riderObjects.Values)
|
||||
foreach (ARLaneGameObject riderObject in this.riderObjects.Values)
|
||||
{
|
||||
float num1 = this.Route.GetTrajectoryCurvature(riderObject.Frame) + riderObject.Curvature;
|
||||
float z1;
|
||||
|
||||
@@ -7,7 +7,7 @@ using UnityEngine;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public class VideoPlayerControl
|
||||
public class ARVideoPlayerControl
|
||||
{
|
||||
private const float MinVideoPlaybackSpeedChangeInterval = 0.2f;
|
||||
private const float MaxPlaybackSpeed = 1.5f;
|
||||
@@ -123,7 +123,7 @@ namespace Assets.AR
|
||||
}
|
||||
else
|
||||
f = frame - (this.VideoPlayer.CurrentFrame - (float)this.VideoFrameOffset);
|
||||
float num1 = Mathf.Clamp01(VTMath.Lerp(0.0f, 1f, 100f, 0.0f, Mathf.Abs(f)));
|
||||
float num1 = Mathf.Clamp01(PFMath.Lerp(0.0f, 1f, 100f, 0.0f, Mathf.Abs(f)));
|
||||
this.FrameIndexDistanceCorrection = f * num1;
|
||||
this.CameraDistanceError = distance - distanceForVideoFrame;
|
||||
if (this.IsMultilap)
|
||||
@@ -141,12 +141,12 @@ namespace Assets.AR
|
||||
double totalSeconds = DateTime.UtcNow.Subtract(this.lastPlaybackSpeedChange).TotalSeconds;
|
||||
if (totalSeconds >= 0.0 && totalSeconds < 0.20000000298023224)
|
||||
return;
|
||||
float num3 = 1f;
|
||||
float num3 = (float)totalSeconds;
|
||||
float num4 = num3 * speed;
|
||||
var offset = this.VideoSyncSource.GetDistanceForVideoFrame((float)((double)this.VideoPlayer.CurrentFrame - (double)this.VideoFrameOffset + (double)num3 * (double)this.VideoPlayer.PlaybackSpeed * (double)this.VideoPlayer.FrameRate));
|
||||
var left = (double)Math.Abs(distance + num4 - offset);
|
||||
var right = (double)Math.Abs(this.CameraDistanceError);
|
||||
|
||||
|
||||
if (left <= right)
|
||||
return;
|
||||
float videoFrameAtDistance2 = this.VideoSyncSource.GetVideoFrameAtDistance(routeDistance + num4);
|
||||
File renamed without changes.
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public class ARObjectTimeTransform
|
||||
public class ARVideoTransform
|
||||
{
|
||||
public int Frame;
|
||||
public float Distance;
|
||||
File renamed without changes.
@@ -132,17 +132,17 @@ namespace Assets.AR
|
||||
this.videoPlayer.CloseMedia();
|
||||
this.ReleaseRenderTextures();
|
||||
}
|
||||
|
||||
private float pauseSpeed = 0.001f;
|
||||
public bool SetPlaybackSpeed(float playbackSpeed)
|
||||
{
|
||||
if (this.IsSeeking || this.IsPaused || DateTime.UtcNow.Subtract(this.lastPlaybackSpeedChange).TotalSeconds < 1.0)
|
||||
return false;
|
||||
if ((double)playbackSpeed == 0.0 && !this.pausedByPlaybackSpeed)
|
||||
if ((double)playbackSpeed <= pauseSpeed && !this.pausedByPlaybackSpeed)
|
||||
{
|
||||
this.pausedByPlaybackSpeed = true;
|
||||
this.videoPlayer.Pause();
|
||||
}
|
||||
else if ((double)playbackSpeed > 0.0 && this.pausedByPlaybackSpeed)
|
||||
else if ((double)playbackSpeed > pauseSpeed && this.pausedByPlaybackSpeed)
|
||||
{
|
||||
this.pausedByPlaybackSpeed = false;
|
||||
if (!this.pausedByTrainingPause)
|
||||
|
||||
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public abstract class BaseRenderer : ARLaneObject
|
||||
public abstract class AbstractRenderer : ARLaneGameObject
|
||||
{
|
||||
protected Animator animator;
|
||||
protected Shader shaderNormal;
|
||||
File renamed without changes.
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public static class Geometry
|
||||
public static class GeometryUtil
|
||||
{
|
||||
public static bool CircleCenter(Vector3 aP0, Vector3 aP1, Vector3 aP2, out Vector3 center)
|
||||
{
|
||||
File renamed without changes.
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
public static class VTMath
|
||||
public static class PFMath
|
||||
{
|
||||
public const double Deg2Rad = 0.017453292519943295;
|
||||
public const double Rad2Deg = 57.295779513082323;
|
||||
@@ -29,9 +29,9 @@ namespace Assets
|
||||
return (double)value <= (double)max ? value : max;
|
||||
}
|
||||
|
||||
public static float Clamp01(float value) => VTMath.Clamp(value, 0.0f, 1f);
|
||||
public static float Clamp01(float value) => PFMath.Clamp(value, 0.0f, 1f);
|
||||
|
||||
public static double Clamp01(double value) => VTMath.Clamp(value, 0.0, 1.0);
|
||||
public static double Clamp01(double value) => PFMath.Clamp(value, 0.0, 1.0);
|
||||
|
||||
public static bool InBounds(double value, double min, double max) => min <= value && value <= max;
|
||||
|
||||
@@ -39,14 +39,14 @@ namespace Assets
|
||||
|
||||
public static double Lerp(double x1, double y1, double x2, double y2, double x)
|
||||
{
|
||||
double t = x1 != x2 ? VTMath.InverseLerp(x1, x2, x) : 0.5;
|
||||
return VTMath.Lerp(y1, y2, t);
|
||||
double t = x1 != x2 ? PFMath.InverseLerp(x1, x2, x) : 0.5;
|
||||
return PFMath.Lerp(y1, y2, t);
|
||||
}
|
||||
|
||||
public static float Lerp(float x1, float y1, float x2, float y2, float x)
|
||||
{
|
||||
float t = (double)x1 != (double)x2 ? VTMath.InverseLerp(x1, x2, x) : 0.5f;
|
||||
return VTMath.Lerp(y1, y2, t);
|
||||
float t = (double)x1 != (double)x2 ? PFMath.InverseLerp(x1, x2, x) : 0.5f;
|
||||
return PFMath.Lerp(y1, y2, t);
|
||||
}
|
||||
|
||||
public static double Lerp(double a, double b, double t) => (1.0 - t) * a + t * b;
|
||||
@@ -61,23 +61,23 @@ namespace Assets
|
||||
|
||||
public static float SmoothStep(float x) => (float)((double)x * (double)x * (3.0 - 2.0 * (double)x));
|
||||
|
||||
public static double SmoothStep(double a, double b, double t) => VTMath.Lerp(a, b, VTMath.SmoothStep(t));
|
||||
public static double SmoothStep(double a, double b, double t) => PFMath.Lerp(a, b, PFMath.SmoothStep(t));
|
||||
|
||||
public static float SmoothStep(float a, float b, float t) => VTMath.Lerp(a, b, VTMath.SmoothStep(t));
|
||||
public static float SmoothStep(float a, float b, float t) => PFMath.Lerp(a, b, PFMath.SmoothStep(t));
|
||||
|
||||
public static double SmoothStep(double x1, double y1, double x2, double y2, double x)
|
||||
{
|
||||
double t = x1 != x2 ? VTMath.InverseLerp(x1, x2, x) : 0.5;
|
||||
return VTMath.SmoothStep(y1, y2, t);
|
||||
double t = x1 != x2 ? PFMath.InverseLerp(x1, x2, x) : 0.5;
|
||||
return PFMath.SmoothStep(y1, y2, t);
|
||||
}
|
||||
|
||||
public static float SmoothStep(float x1, float y1, float x2, float y2, float x)
|
||||
{
|
||||
float t = (double)x1 != (double)x2 ? VTMath.InverseLerp(x1, x2, x) : 0.5f;
|
||||
return VTMath.SmoothStep(y1, y2, t);
|
||||
float t = (double)x1 != (double)x2 ? PFMath.InverseLerp(x1, x2, x) : 0.5f;
|
||||
return PFMath.SmoothStep(y1, y2, t);
|
||||
}
|
||||
|
||||
public static double InverseSmoothStep(double a, double b, double value) => VTMath.InverseSmoothStep(VTMath.InverseLerp(a, b, value));
|
||||
public static double InverseSmoothStep(double a, double b, double value) => PFMath.InverseSmoothStep(PFMath.InverseLerp(a, b, value));
|
||||
|
||||
public static double InverseSmoothStep(double x)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ namespace Assets
|
||||
Vector3d lineStart,
|
||||
Vector3d lineEnd)
|
||||
{
|
||||
return Vector3d.Magnitude(VTMath.ProjectPointToLineSegment(point, lineStart, lineEnd) - point);
|
||||
return Vector3d.Magnitude(PFMath.ProjectPointToLineSegment(point, lineStart, lineEnd) - point);
|
||||
}
|
||||
|
||||
public static Vector3d ProjectPointToLineSegment(
|
||||
@@ -114,7 +114,7 @@ namespace Assets
|
||||
Vector3d lineStart,
|
||||
Vector3d lineEnd)
|
||||
{
|
||||
double lineParameter = VTMath.ProjectPointToLineParameter(point, lineStart, lineEnd);
|
||||
double lineParameter = PFMath.ProjectPointToLineParameter(point, lineStart, lineEnd);
|
||||
return Vector3d.LerpClamped(lineStart, lineEnd, lineParameter);
|
||||
}
|
||||
|
||||
File renamed without changes.
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public class RiderRenderer : BaseRenderer
|
||||
public class PlayerRenderer : AbstractRenderer
|
||||
{
|
||||
private const int PowerWindowSize = 10;
|
||||
private const float Circumference = 2.13097382f;
|
||||
@@ -83,16 +83,14 @@ namespace Assets.AR
|
||||
{
|
||||
if ((UnityEngine.Object)this.animator != (UnityEngine.Object)null)
|
||||
{
|
||||
if (lastSpeed > 0)
|
||||
if (lastSpeed > 1)
|
||||
{
|
||||
animator.Play("rideLoop");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.Play("idle");
|
||||
}
|
||||
animator.SetFloat("speed", lastSpeed);
|
||||
}
|
||||
}
|
||||
private string LastAnimatorState { get; set; }
|
||||
File renamed without changes.
+25
-25
@@ -9,7 +9,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
public class TestPlayer : ARLaneObjectsController
|
||||
public class TestPlayer : ARLaneGameObjectsController
|
||||
{
|
||||
protected Transform LightTrans { get; set; }
|
||||
public MediaPlayer mediaPlayer;
|
||||
@@ -18,11 +18,11 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
private RouteDetailData detail;
|
||||
private VideoPointsSync videoPointsSync;
|
||||
private int index = 1;
|
||||
private readonly List<ARLaneObject> collisionList = new List<ARLaneObject>();
|
||||
private readonly List<ARLaneGameObject> collisionList = new List<ARLaneGameObject>();
|
||||
///private Dictionary<int, IRouteRider> riders = new Dictionary<int, IRouteRider>();
|
||||
VideoPlayerControl VideoPlayerControl;
|
||||
ARLaneObject[] rides;
|
||||
public ARLaneObject mainObject;
|
||||
ARVideoPlayerControl VideoPlayerControl;
|
||||
ARLaneGameObject[] rides;
|
||||
public ARLaneGameObject mainObject;
|
||||
|
||||
private Light arLight;
|
||||
private Light arBackLight;
|
||||
@@ -45,7 +45,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
|
||||
videoSync = videoPointsSync;
|
||||
|
||||
this.VideoPlayerControl = new VideoPlayerControl();
|
||||
this.VideoPlayerControl = new ARVideoPlayerControl();
|
||||
this.VideoPlayerControl.VideoSyncSource = videoSync;
|
||||
this.videoPlayer = new AVProVideoPlayer();
|
||||
this.videoPlayer.videoPlayer = mediaPlayer;
|
||||
@@ -53,7 +53,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
this.VideoPlayerControl.VideoFrameOffset = this.Route.VideoFrameOffset;
|
||||
this.VideoPlayerControl.Route = Route;
|
||||
this.VideoPlayerControl.SetVideoPlayer(videoPlayer);
|
||||
rides = FindObjectsOfType<ARLaneObject>();
|
||||
rides = FindObjectsOfType<ARLaneGameObject>();
|
||||
CreateBackLight();
|
||||
}
|
||||
|
||||
@@ -134,39 +134,39 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
this.UpdateRidersLean();
|
||||
this.UpdateBackLight();
|
||||
if (Input.GetKeyDown(KeyCode.F))
|
||||
this.SetVideoControlMode(VideoControlMode.Front);
|
||||
this.SetVideoControlMode(VideoPlayMode.Front);
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
this.SetVideoControlMode(VideoControlMode.AutoPanorama);
|
||||
this.SetVideoControlMode(VideoPlayMode.AutoPanorama);
|
||||
if (!Input.GetKeyDown(KeyCode.B))
|
||||
return;
|
||||
this.SetVideoControlMode(VideoControlMode.Rear);
|
||||
this.SetVideoControlMode(VideoPlayMode.Rear);
|
||||
}
|
||||
|
||||
public VideoControlMode VideoControlMode { get; private set; }
|
||||
public VideoPlayMode VideoControlMode { get; private set; }
|
||||
private float autoCameraSwitchTimeCounter = 80f;
|
||||
public void SetVideoControlMode(VideoControlMode mode)
|
||||
public void SetVideoControlMode(VideoPlayMode mode)
|
||||
{
|
||||
if (mode == this.VideoControlMode)
|
||||
return;
|
||||
if (!this.AR360Version)
|
||||
mode = VideoControlMode.Front;
|
||||
mode = VideoPlayMode.Front;
|
||||
this.VideoControlMode = mode;
|
||||
this.autoCameraSwitchTimeCounter = 80f;
|
||||
if (mode == VideoControlMode.AutoPanorama)
|
||||
if (mode == VideoPlayMode.AutoPanorama)
|
||||
return;
|
||||
this.videoPlayer.IntendedRear = mode == VideoControlMode.Rear;
|
||||
this.videoPlayer.IntendedRear = mode == VideoPlayMode.Rear;
|
||||
}
|
||||
|
||||
public RiderCameraDistance RiderCameraDistance { get; set; }
|
||||
public CameraDistance RiderCameraDistance { get; set; }
|
||||
//更新摄像机的位置
|
||||
private void UpdateCameraFollowDistance()
|
||||
{
|
||||
this.RiderCameraDistance = RiderCameraDistance.Middle;
|
||||
this.NearViewMode = this.RiderCameraDistance == RiderCameraDistance.Near;
|
||||
this.RiderCameraDistance = AR.CameraDistance.Middle;
|
||||
this.NearViewMode = this.RiderCameraDistance == AR.CameraDistance.Near;
|
||||
float cameraFollowDistance = GetCameraFollowDistance(this.RiderCameraDistance);
|
||||
this.VideoPlayerControl.CameraFollowDistance = cameraFollowDistance;
|
||||
}
|
||||
protected override bool IsArObjectActive(ARObject arObject)
|
||||
protected override bool IsArObjectActive(ARGameObject arObject)
|
||||
{
|
||||
bool flag = base.IsArObjectActive(arObject);
|
||||
if ((UnityEngine.Object)arObject != (UnityEngine.Object)this.mainObject)
|
||||
@@ -176,17 +176,17 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
return flag && (double)this.VideoPlayerControl.CameraDistanceError > 5.0;
|
||||
}
|
||||
//获取摄像机的位置
|
||||
public static float GetCameraFollowDistance(RiderCameraDistance distance)
|
||||
public static float GetCameraFollowDistance(CameraDistance distance)
|
||||
{
|
||||
switch (distance)
|
||||
{
|
||||
case RiderCameraDistance.FirstPerson:
|
||||
case AR.CameraDistance.FirstPerson:
|
||||
return 0.0f;
|
||||
case RiderCameraDistance.Near:
|
||||
case AR.CameraDistance.Near:
|
||||
return 2.5f;
|
||||
case RiderCameraDistance.Middle:
|
||||
case AR.CameraDistance.Middle:
|
||||
return 5f;
|
||||
case RiderCameraDistance.Far:
|
||||
case AR.CameraDistance.Far:
|
||||
return 10f;
|
||||
default:
|
||||
throw new ArgumentException("Unknown rider's camera distance.");
|
||||
@@ -248,7 +248,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
//更新骑手的偏移角度
|
||||
private void UpdateRidersLean()
|
||||
{
|
||||
foreach (ARLaneObject riderObject in this.riderObjects.Values)
|
||||
foreach (ARLaneGameObject riderObject in this.riderObjects.Values)
|
||||
{
|
||||
float num1 = this.Route.GetTrajectoryCurvature(riderObject.Frame) + riderObject.Curvature;
|
||||
float z1;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Assets
|
||||
|
||||
public static Vector3d LerpClamped(Vector3d a, Vector3d b, double t)
|
||||
{
|
||||
t = VTMath.Clamp01(t);
|
||||
t = PFMath.Clamp01(t);
|
||||
return Vector3d.Lerp(a, b, t);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user