AR变量命名
This commit is contained in:
parent
94637d5980
commit
573aa2ff4c
@ -73,7 +73,7 @@ namespace Assets.AR
|
||||
get => this.distance;
|
||||
set
|
||||
{
|
||||
if ((double)this.distance == (double)value)
|
||||
if (this.distance == value)
|
||||
return;
|
||||
this.distance = value;
|
||||
this.SetFrame();
|
||||
@ -84,8 +84,8 @@ namespace Assets.AR
|
||||
{
|
||||
if (this.Route == null)
|
||||
return;
|
||||
Quaternion cameraRotation = this.GetCameraRotation(this.frame);
|
||||
Vector3 filteredCameraPosition = this.GetFilteredCameraPosition(this.frame);
|
||||
var cameraRotation = this.GetCameraRotation(this.frame);
|
||||
var filteredCameraPosition = this.GetFilteredCameraPosition(this.frame);
|
||||
this.transform.rotation = cameraRotation * Quaternion.Euler(this.RotationOffset);
|
||||
this.transform.position = filteredCameraPosition + cameraRotation * this.PositionOffset;
|
||||
this.transform.localScale = this.Scale;
|
||||
@ -96,12 +96,16 @@ namespace Assets.AR
|
||||
{
|
||||
if (this.TimeTransforms == null || this.TimeTransforms.Length == 0)
|
||||
return;
|
||||
|
||||
if (this.nextTimeDefIndex > this.TimeTransforms.Length - 1)
|
||||
this.nextTimeDefIndex = 0;
|
||||
|
||||
if (this.nextTimeDefIndex > 0 && (double)this.TimeTransforms[this.nextTimeDefIndex - 1].Frame > (double)currentFrame)
|
||||
this.nextTimeDefIndex = 0;
|
||||
|
||||
while (this.nextTimeDefIndex < this.TimeTransforms.Length - 1 && (double)this.TimeTransforms[this.nextTimeDefIndex].Frame <= (double)currentFrame)
|
||||
++this.nextTimeDefIndex;
|
||||
|
||||
if (this.nextTimeDefIndex == 0)
|
||||
{
|
||||
this.Distance = this.TimeTransforms[0].Distance;
|
||||
@ -111,7 +115,7 @@ namespace Assets.AR
|
||||
}
|
||||
else
|
||||
{
|
||||
float t = Mathf.Clamp01((currentFrame - (float)this.TimeTransforms[this.nextTimeDefIndex - 1].Frame) / (float)(this.TimeTransforms[this.nextTimeDefIndex].Frame - this.TimeTransforms[this.nextTimeDefIndex - 1].Frame));
|
||||
var t = Mathf.Clamp01((currentFrame - (float)this.TimeTransforms[this.nextTimeDefIndex - 1].Frame) / (float)(this.TimeTransforms[this.nextTimeDefIndex].Frame - this.TimeTransforms[this.nextTimeDefIndex - 1].Frame));
|
||||
this.Distance = Mathf.Lerp(this.TimeTransforms[this.nextTimeDefIndex - 1].Distance, this.TimeTransforms[this.nextTimeDefIndex].Distance, t);
|
||||
this.PositionOffset = Vector3.Lerp(this.TimeTransforms[this.nextTimeDefIndex - 1].PositionOffset, this.TimeTransforms[this.nextTimeDefIndex].PositionOffset, t);
|
||||
this.Scale = Vector3.Lerp(this.TimeTransforms[this.nextTimeDefIndex - 1].Scale, this.TimeTransforms[this.nextTimeDefIndex].Scale, t);
|
||||
@ -124,8 +128,8 @@ namespace Assets.AR
|
||||
{
|
||||
if (this.Route == null || this.VideoSync == null)
|
||||
return;
|
||||
Quaternion quaternion = Quaternion.Inverse(this.GetCameraRotation(this.frame));
|
||||
Vector3 filteredCameraPosition = this.GetFilteredCameraPosition(this.frame);
|
||||
var quaternion = Quaternion.Inverse(this.GetCameraRotation(this.frame));
|
||||
var filteredCameraPosition = this.GetFilteredCameraPosition(this.frame);
|
||||
this.RotationOffset = (quaternion * this.transform.rotation).eulerAngles;
|
||||
this.PositionOffset = quaternion * (this.transform.position - filteredCameraPosition);
|
||||
this.Scale = this.transform.localScale;
|
||||
@ -137,16 +141,16 @@ namespace Assets.AR
|
||||
float visibilityFront,
|
||||
bool multiLap)
|
||||
{
|
||||
if ((double)this.ManualVisibility > 0.0)
|
||||
if (this.ManualVisibility > 0.0)
|
||||
{
|
||||
visibilityFront = this.ManualVisibility;
|
||||
visibilityRear = this.ManualVisibility;
|
||||
}
|
||||
float deltaVisibility = Time.deltaTime * 5f;
|
||||
float a = this.GetVisibilityParameter(this.frame, videoFrame, visibilityRear, visibilityFront, deltaVisibility);
|
||||
var deltaVisibility = Time.deltaTime * 5f;
|
||||
var a = this.GetVisibilityParameter(this.frame, videoFrame, visibilityRear, visibilityFront, deltaVisibility);
|
||||
if (multiLap && (double)a <= 0.0)
|
||||
{
|
||||
float visibilityParameter = this.GetVisibilityParameter(this.frame + this.videoSync.LastVideoFrame, videoFrame, visibilityRear, visibilityFront, deltaVisibility);
|
||||
var visibilityParameter = this.GetVisibilityParameter(this.frame + this.videoSync.LastVideoFrame, videoFrame, visibilityRear, visibilityFront, deltaVisibility);
|
||||
a = Mathf.Max(a, visibilityParameter);
|
||||
if ((double)a > 0.0)
|
||||
this.useMultilapTransform = true;
|
||||
@ -185,24 +189,24 @@ namespace Assets.AR
|
||||
float visibilityFront,
|
||||
float deltaVisibility)
|
||||
{
|
||||
if ((double)objectFrame < (double)videoFrame - (double)visibilityRear)
|
||||
if (objectFrame < videoFrame - visibilityRear)
|
||||
return 0.0f;
|
||||
if ((double)visibilityFront <= 0.0)
|
||||
if (visibilityFront <= 0.0)
|
||||
return 1f;
|
||||
if ((double)this.ManualVisibility == -1.0)
|
||||
if (this.ManualVisibility == -1.0)
|
||||
return Mathf.Clamp(0.0f, this.lastVisibilityLevel - deltaVisibility, this.lastVisibilityLevel + deltaVisibility);
|
||||
float num1;
|
||||
if ((double)objectFrame > (double)videoFrame)
|
||||
if (objectFrame > videoFrame)
|
||||
{
|
||||
float num2 = (float)((double)videoFrame + (double)visibilityFront - 0.5 * (double)this.FrameRate);
|
||||
float num3 = videoFrame + visibilityFront;
|
||||
num1 = 1f - Mathf.Clamp01((float)(((double)objectFrame - (double)num2) / ((double)num3 - (double)num2)));
|
||||
var num2 = (float)(videoFrame + visibilityFront - 0.5 * this.FrameRate);
|
||||
var num3 = videoFrame + visibilityFront;
|
||||
num1 = 1f - Mathf.Clamp01((float)((objectFrame - num2) / (num3 - num2)));
|
||||
}
|
||||
else
|
||||
{
|
||||
float num4 = videoFrame - visibilityRear;
|
||||
float num5 = (float)((double)videoFrame - (double)visibilityRear + 0.5 * (double)this.FrameRate);
|
||||
num1 = Mathf.Clamp01((float)(((double)objectFrame - (double)num4) / ((double)num5 - (double)num4)));
|
||||
var num4 = videoFrame - visibilityRear;
|
||||
var num5 = (float)(videoFrame - visibilityRear + 0.5 *this.FrameRate);
|
||||
num1 = Mathf.Clamp01((float)((objectFrame - num4) / (num5 - num4)));
|
||||
}
|
||||
return Mathf.Clamp(num1, this.lastVisibilityLevel - deltaVisibility, this.lastVisibilityLevel + deltaVisibility);
|
||||
}
|
||||
|
||||
@ -8,81 +8,94 @@ namespace Assets.AR
|
||||
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);
|
||||
//创建轨迹
|
||||
public static GameObject CreateTrajectory(
|
||||
ARRoute route,
|
||||
int segment,
|
||||
float lOffset,
|
||||
float rOffset,
|
||||
float margin = float.NaN)
|
||||
ARRoute route,
|
||||
int segment,
|
||||
float lOffset,
|
||||
float rOffset,
|
||||
float margin = float.NaN)
|
||||
{
|
||||
int start;
|
||||
int end;
|
||||
route.GetSlamSegmentRange(segment, out start, out end);
|
||||
int num1 = end - start + 1;
|
||||
int[] indices = new int[(num1 - 1) * 6];
|
||||
Vector3[] vector3Array1 = new Vector3[num1 * 2];
|
||||
Vector3 left;
|
||||
Vector3 right;
|
||||
ARGameObjectFactory.CreateVertices(start, route, lOffset, rOffset, out left, out right, margin);
|
||||
|
||||
var num1 = end - start + 1;
|
||||
var indices = new int[(num1 - 1) * 6];
|
||||
var vector3Array1 = new Vector3[num1 * 2];
|
||||
|
||||
Vector3 left, right;
|
||||
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)
|
||||
|
||||
var num2 = 2;
|
||||
var num3 = 0;
|
||||
for (var frame = start + 1; frame <= end; ++frame)
|
||||
{
|
||||
ARGameObjectFactory.CreateVertices(frame, route, lOffset, rOffset, out left, out right, margin);
|
||||
if (ARGameObjectFactory.IsValidVertex(left) && ARGameObjectFactory.IsValidVertex(right))
|
||||
CreateVertices(frame, route, lOffset, rOffset, out left, out right, margin);
|
||||
if (IsValidVertex(left) && IsValidVertex(right))
|
||||
{
|
||||
var vector3Array2 = vector3Array1;
|
||||
var index1 = num2;
|
||||
|
||||
var num4 = index1 + 1;
|
||||
var vector3_1 = left;
|
||||
vector3Array2[index1] = vector3_1;
|
||||
var vector3Array3 = vector3Array1;
|
||||
|
||||
var index2 = num4;
|
||||
num2 = index2 + 1;
|
||||
Vector3 vector3_2 = right;
|
||||
var vector3_2 = right;
|
||||
vector3Array3[index2] = vector3_2;
|
||||
var numArray1 = indices;
|
||||
|
||||
var index3 = num3;
|
||||
var num5 = index3 + 1;
|
||||
var num6 = num2 - 3;
|
||||
numArray1[index3] = num6;
|
||||
var numArray2 = indices;
|
||||
|
||||
var index4 = num5;
|
||||
var num7 = index4 + 1;
|
||||
var num8 = num2 - 4;
|
||||
numArray2[index4] = num8;
|
||||
var numArray3 = indices;
|
||||
|
||||
var index5 = num7;
|
||||
var num9 = index5 + 1;
|
||||
var num10 = num2 - 1;
|
||||
numArray3[index5] = num10;
|
||||
var numArray4 = indices;
|
||||
|
||||
var index6 = num9;
|
||||
var num11 = index6 + 1;
|
||||
var num12 = num2 - 4;
|
||||
numArray4[index6] = num12;
|
||||
var numArray5 = indices;
|
||||
|
||||
var index7 = num11;
|
||||
var num13 = index7 + 1;
|
||||
var num14 = num2 - 2;
|
||||
numArray5[index7] = num14;
|
||||
var numArray6 = indices;
|
||||
|
||||
var index8 = num13;
|
||||
num3 = index8 + 1;
|
||||
var num15 = num2 - 1;
|
||||
numArray6[index8] = num15;
|
||||
}
|
||||
}
|
||||
Mesh mesh = new Mesh();
|
||||
mesh.vertices = vector3Array1;
|
||||
mesh.indexFormat = IndexFormat.UInt32;
|
||||
mesh.SetIndices(indices, MeshTopology.Triangles, 0);
|
||||
GameObject trajectory = new GameObject(string.Format("Segment {0}", (object)segment), new System.Type[3]
|
||||
|
||||
var mesh = new Mesh
|
||||
{
|
||||
typeof (MeshFilter),
|
||||
typeof (MeshRenderer),
|
||||
typeof (MeshCollider)
|
||||
vertices = vector3Array1,
|
||||
indexFormat = IndexFormat.UInt32
|
||||
};
|
||||
mesh.SetIndices(indices, MeshTopology.Triangles, 0);
|
||||
var trajectory = new GameObject(string.Format("Segment {0}", (object)segment), new System.Type[3]
|
||||
{
|
||||
typeof(MeshFilter),
|
||||
typeof(MeshRenderer),
|
||||
typeof(MeshCollider)
|
||||
});
|
||||
trajectory.GetComponent<MeshFilter>().sharedMesh = mesh;
|
||||
trajectory.GetComponent<MeshCollider>().sharedMesh = trajectory.GetComponent<MeshFilter>().sharedMesh;
|
||||
@ -98,21 +111,27 @@ namespace Assets.AR
|
||||
out Vector3 right,
|
||||
float margin = float.NaN)
|
||||
{
|
||||
Quaternion trajectoryOrientationAt = route.GetTrajectoryOrientationAt(frame);
|
||||
Vector3 vector3 = route.GetCameraPositionAt(frame) - trajectoryOrientationAt * Vector3.up * route.CameraHeight;
|
||||
if ((double)lOffset == 0.0)
|
||||
var trajectoryOrientationAt = route.GetTrajectoryOrientationAt(frame);
|
||||
var vector3 = route.GetCameraPositionAt(frame) - trajectoryOrientationAt * Vector3.up * route.CameraHeight;
|
||||
|
||||
if (lOffset == 0.0)
|
||||
lOffset = route.GetLeftSideOffset((float)frame);
|
||||
|
||||
if (float.IsNaN(margin))
|
||||
lOffset += route.RouteMargin;
|
||||
else
|
||||
lOffset += margin;
|
||||
|
||||
left = vector3 + trajectoryOrientationAt * Vector3.left * lOffset;
|
||||
if ((double)rOffset == 0.0)
|
||||
|
||||
if (rOffset == 0.0)
|
||||
rOffset = route.GetRightSideOffset((float)frame);
|
||||
|
||||
if (float.IsNaN(margin))
|
||||
rOffset += route.RouteMargin;
|
||||
else
|
||||
rOffset += margin;
|
||||
|
||||
right = vector3 - trajectoryOrientationAt * Vector3.left * rOffset;
|
||||
left.y = right.y = vector3.y;
|
||||
}
|
||||
|
||||
@ -6,17 +6,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
public enum ARGameObjectType
|
||||
{
|
||||
Sign,
|
||||
Box,
|
||||
Sphere,
|
||||
SplitGate,
|
||||
FinishGate,
|
||||
Bariccade,
|
||||
Custom,
|
||||
}
|
||||
|
||||
public enum CameraDistance
|
||||
{
|
||||
FirstPerson,
|
||||
|
||||
@ -47,7 +47,6 @@ namespace Assets.AR
|
||||
{
|
||||
this.ambientIntensity = RenderSettings.ambientIntensity;
|
||||
this.matShadow = Resources.Load<Material>("UI/Material/TransparentPlane");
|
||||
//this.matModelMask = Resources.Load<Material>("Materials/ModelDepth");
|
||||
this.arObjects.Clear();
|
||||
this.arObjects.AddRange(FindObjectsOfType<ARGameObject>());
|
||||
SetupCamera();
|
||||
@ -82,9 +81,14 @@ namespace Assets.AR
|
||||
arObject.VideoSync = videoSync;
|
||||
arObject.Route = route;
|
||||
}
|
||||
this.trajectoryObject = new GameObject("TrajectoryMesh");
|
||||
this.trajectoryObject.transform.parent = this.transform;
|
||||
//this.trajectoryObject.layer = 9;
|
||||
|
||||
this.trajectoryObject = new GameObject("TrajectoryMesh")
|
||||
{
|
||||
transform =
|
||||
{
|
||||
parent = this.transform
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual void UpdateGameObjects(
|
||||
@ -92,7 +96,7 @@ namespace Assets.AR
|
||||
float visibilityRear,
|
||||
float visibilityFront)
|
||||
{
|
||||
foreach (ARGameObject arObject in this.arObjects)
|
||||
foreach (var arObject in this.arObjects)
|
||||
{
|
||||
arObject.CameraPositionOffset = this.cameraPositionOffset;
|
||||
if (arObject is ARLaneGameObject arLaneObject)
|
||||
@ -119,50 +123,52 @@ namespace Assets.AR
|
||||
this.cameraPositionOffset = this.Route.GetCameraPosition(num1) - this.CameraOriginOffset;
|
||||
UnityCamera.transform.position = this.CameraOriginOffset;
|
||||
UnityCamera.transform.rotation = this.Route.GetCameraRotation(num1);
|
||||
//this.Route.SetCameraProjection(num1, Camera.main); //TODO:暂时注释掉
|
||||
}
|
||||
this.CameraDistance = this.videoSync.GetDistanceForVideoFrame(num1 + this.FrameIndexDistanceCorrection);
|
||||
var num2 = Mathf.Min(float.MaxValue, this.Route.GetVisibility(num1));
|
||||
var num3 = num2;
|
||||
var visibilityRear = 200f;
|
||||
if ((double)num3 == 0.0)
|
||||
if (num3 == 0.0)
|
||||
num3 = 600f;
|
||||
if ((double)visibilityRear == 0.0)
|
||||
if (visibilityRear == 0.0)
|
||||
visibilityRear = 600f;
|
||||
this.UpdateTrajectory(num1, num3);//更新轨迹
|
||||
this.UpdateGameObjects(num1, visibilityRear, num3);//更新骑手等位置
|
||||
}
|
||||
|
||||
|
||||
//更新当前可见轨迹
|
||||
/// <summary>
|
||||
/// 更新当前可见轨迹
|
||||
/// </summary>
|
||||
/// <param name="frame">帧数</param>
|
||||
/// <param name="defaultVisibility">默认可视距离</param>
|
||||
private void UpdateTrajectory(float frame, float defaultVisibility)
|
||||
{
|
||||
int start;
|
||||
int end;
|
||||
this.Route.GetVisibleSlamSegments((int)frame, out start, out end, defaultVisibility);
|
||||
List<int> intList = new List<int>();
|
||||
foreach (int key in this.trajectorySegments.Keys)
|
||||
var intList = new List<int>();
|
||||
foreach (var key in this.trajectorySegments.Keys)
|
||||
{
|
||||
if (key < start || key > end)
|
||||
intList.Add(key);
|
||||
}
|
||||
foreach (int key in intList)
|
||||
foreach (var key in intList)
|
||||
{
|
||||
UnityEngine.Object.Destroy((UnityEngine.Object)this.trajectorySegments[key].GameObject);
|
||||
UnityEngine.Object.Destroy(this.trajectorySegments[key].GameObject);
|
||||
this.trajectorySegments.Remove(key);
|
||||
}
|
||||
for (int index = start; index <= end; ++index)
|
||||
{
|
||||
if (!this.trajectorySegments.ContainsKey(index))
|
||||
{
|
||||
GameObject trajectory = this.CreateTrajectory(index, 0.0f, 0.0f);
|
||||
ARGameObjectsController.Segment segment = new ARGameObjectsController.Segment(trajectory, trajectory.transform.position);
|
||||
var trajectory = this.CreateTrajectory(index, 0.0f, 0.0f);
|
||||
var segment = new Segment(trajectory, trajectory.transform.position);
|
||||
this.trajectorySegments.Add(index, segment);
|
||||
}
|
||||
}
|
||||
foreach (int key in this.trajectorySegments.Keys)
|
||||
foreach (var key in this.trajectorySegments.Keys)
|
||||
{
|
||||
ARGameObjectsController.Segment trajectorySegment = this.trajectorySegments[key];
|
||||
var trajectorySegment = this.trajectorySegments[key];
|
||||
trajectorySegment.GameObject.transform.position = trajectorySegment.Position - this.cameraPositionOffset;
|
||||
}
|
||||
}
|
||||
@ -174,9 +180,8 @@ namespace Assets.AR
|
||||
float rOffset,
|
||||
float margin = float.NaN)
|
||||
{
|
||||
GameObject trajectory = ARGameObjectFactory.CreateTrajectory(this.Route, segment, lOffset, rOffset, margin);
|
||||
var trajectory = ARGameObjectFactory.CreateTrajectory(this.Route, segment, lOffset, rOffset, margin);
|
||||
trajectory.transform.parent = this.trajectoryObject.transform;
|
||||
//trajectory.layer = 9;
|
||||
trajectory.GetComponent<MeshRenderer>().shadowCastingMode = ShadowCastingMode.Off;
|
||||
trajectory.GetComponent<MeshRenderer>().material = this.GetTrajectoryMaterial();
|
||||
return trajectory;
|
||||
|
||||
@ -57,8 +57,10 @@ namespace Assets.AR
|
||||
PositionOffset = Vector3.up * route.CameraHeight * (-1);
|
||||
var cameraRotation = this.GetCameraRotation(this.frame - this.FrameIndexDistanceCorrection);
|
||||
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);
|
||||
|
||||
this.transform.position = targetPos;
|
||||
this.transform.rotation = cameraRotation * Quaternion.Euler(this.RotationOffset) * Quaternion.Euler(this.Lean);
|
||||
this.transform.localScale = this.Scale;
|
||||
|
||||
@ -32,7 +32,7 @@ namespace Assets.AR
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
float frame = 100f;
|
||||
var frame = 100f;
|
||||
this.StartRegionRouteWidth = this.GetRouteLeftOffset(frame) + this.GetRouteRightOffset(frame);
|
||||
this.RiderCountInStartRow = Mathf.Max(1, Mathf.CeilToInt(this.StartRegionRouteWidth / 0.7f));
|
||||
}
|
||||
@ -50,10 +50,10 @@ namespace Assets.AR
|
||||
//检测碰撞
|
||||
private void DetectRidersCollisions(float cameraDistance)
|
||||
{
|
||||
float num1 = cameraDistance - ARGameObject.MaxDistanceVisibilityModels;
|
||||
float num2 = cameraDistance + ARGameObject.MaxDistanceVisibilityModels;
|
||||
var num1 = cameraDistance - ARGameObject.MaxDistanceVisibilityModels;
|
||||
var num2 = cameraDistance + ARGameObject.MaxDistanceVisibilityModels;
|
||||
this.collisionList.Clear();
|
||||
foreach (ARLaneGameObject arLaneObject in this.riderObjects.Values)
|
||||
foreach (var arLaneObject in this.riderObjects.Values)
|
||||
{
|
||||
if (arLaneObject.gameObject.activeSelf && !arLaneObject.IsAtFinish)
|
||||
{
|
||||
@ -79,12 +79,12 @@ namespace Assets.AR
|
||||
num3 = r2.DistanceSort.CompareTo(r1.DistanceSort);
|
||||
return num3;
|
||||
}));
|
||||
float deltaTime = Time.deltaTime;
|
||||
var deltaTime = Time.deltaTime;
|
||||
for (int index = 0; index < this.collisionList.Count; ++index)
|
||||
{
|
||||
ARLaneGameObject collision = this.collisionList[index];
|
||||
float lane = collision.Lane;
|
||||
float num4 = this.GetLane(collision.RouteDistance, collision.DistanceSort, index);
|
||||
var collision = this.collisionList[index];
|
||||
var lane = collision.Lane;
|
||||
var num4 = this.GetLane(collision.RouteDistance, collision.DistanceSort, index);
|
||||
if ((double)collision.LaneWidth != 0.0)
|
||||
{
|
||||
float num5 = 0.02f * deltaTime * Mathf.Log(collision.Speed + 5f, 1.1f);
|
||||
@ -97,8 +97,8 @@ namespace Assets.AR
|
||||
foreach (ARLaneGameObject collision in this.collisionList)
|
||||
{
|
||||
collision.LaneWidth = 0.7f;
|
||||
float num6 = this.Route.LeftHanded ? this.GetRouteLeftOffset(collision.Frame) : this.GetRouteRightOffset(collision.Frame);
|
||||
float num7 = Mathf.Lerp(this.GetStartOffset(collision.StartPosition).x, 0.0f, collision.Distance / 200f);
|
||||
var num6 = this.Route.LeftHanded ? this.GetRouteLeftOffset(collision.Frame) : this.GetRouteRightOffset(collision.Frame);
|
||||
var num7 = Mathf.Lerp(this.GetStartOffset(collision.StartPosition).x, 0.0f, collision.Distance / 200f);
|
||||
collision.BaseOffset = num6 + num7;
|
||||
}
|
||||
this.CalculateCameraAvoidance(cameraDistance);
|
||||
@ -106,13 +106,13 @@ namespace Assets.AR
|
||||
//摄像机障碍物避免
|
||||
private void CalculateCameraAvoidance(float cameraDistance)
|
||||
{
|
||||
float deltaTime = Time.deltaTime;
|
||||
for (int index = 0; index < this.collisionList.Count; ++index)
|
||||
var deltaTime = Time.deltaTime;
|
||||
for (var index = 0; index < this.collisionList.Count; ++index)
|
||||
{
|
||||
ARLaneGameObject collision = this.collisionList[index];
|
||||
bool flag1 = collision.StartPosition == this.FollowedRiderId;
|
||||
float x = Math.Abs(collision.Distance - cameraDistance);
|
||||
float x2 = 4f;
|
||||
var collision = this.collisionList[index];
|
||||
var flag1 = collision.StartPosition == this.FollowedRiderId;
|
||||
var x = Math.Abs(collision.Distance - cameraDistance);
|
||||
var x2 = 4f;
|
||||
if (this.NearViewMode && !flag1)
|
||||
x2 = 5.5f;
|
||||
if ((double)x > (double)x2)
|
||||
@ -124,20 +124,20 @@ namespace Assets.AR
|
||||
}
|
||||
else
|
||||
{
|
||||
float num1 = PFMath.Lerp(0.0f, 1f, x2, 0.0f, x);
|
||||
float num2 = collision.Lane * collision.LaneWidth - collision.BaseOffset;
|
||||
float num3 = 0.75f;
|
||||
var num1 = PFMath.Lerp(0.0f, 1f, x2, 0.0f, x);
|
||||
var num2 = collision.Lane * collision.LaneWidth - collision.BaseOffset;
|
||||
var num3 = 0.75f;
|
||||
if (this.NearViewMode && !flag1)
|
||||
{
|
||||
num2 += num3 / 2f;
|
||||
num3 *= 1.5f;
|
||||
}
|
||||
bool flag2 = (double)collision.LaneCamera < 0.0 || (double)collision.LaneCamera <= 0.0 && (double)num2 < 0.0;
|
||||
float a1 = (float)(-(double)num2 - (double)num1 * (double)num3) / collision.LaneWidth;
|
||||
float a2 = (num1 * num3 - num2) / collision.LaneWidth;
|
||||
var flag2 = (double)collision.LaneCamera < 0.0 || (double)collision.LaneCamera <= 0.0 && (double)num2 < 0.0;
|
||||
var a1 = (float)(-(double)num2 - (double)num1 * (double)num3) / collision.LaneWidth;
|
||||
var a2 = (num1 * num3 - num2) / collision.LaneWidth;
|
||||
if (this.NearViewMode & flag1)
|
||||
{
|
||||
float num4 = Mathf.Max(a1 - collision.LaneCamera, -deltaTime);
|
||||
var num4 = Mathf.Max(a1 - collision.LaneCamera, -deltaTime);
|
||||
collision.LaneCamera = Mathf.Min(collision.LaneCamera + num4, -1.401298E-45f);
|
||||
}
|
||||
else
|
||||
@ -148,10 +148,10 @@ namespace Assets.AR
|
||||
|
||||
private void CalculateOvertakingParameters()
|
||||
{
|
||||
float deltaTime = Time.deltaTime;
|
||||
var deltaTime = Time.deltaTime;
|
||||
foreach (ARLaneGameObject laneObject in this.riderObjects.Values)
|
||||
{
|
||||
float num1 = laneObject.Speed * deltaTime;
|
||||
var num1 = laneObject.Speed * deltaTime;
|
||||
if ((double)num1 == 0.0)
|
||||
{
|
||||
laneObject.Curvature = 0.0f;
|
||||
@ -159,17 +159,17 @@ namespace Assets.AR
|
||||
}
|
||||
else
|
||||
{
|
||||
float num2 = (this.Route.LeftHanded ? -1f : 1f) * laneObject.DeltaLane * laneObject.LaneWidth * deltaTime;
|
||||
var num2 = (this.Route.LeftHanded ? -1f : 1f) * laneObject.DeltaLane * laneObject.LaneWidth * deltaTime;
|
||||
if ((double)laneObject.LaneCamera != 0.0)
|
||||
num2 = 0.0f;
|
||||
float curvature = 0.0f;
|
||||
var curvature = 0.0f;
|
||||
if ((double)num1 > 0.0)
|
||||
{
|
||||
float num3 = Mathf.Atan(num2 / num1);
|
||||
var num3 = Mathf.Atan(num2 / num1);
|
||||
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);
|
||||
var angle = -57.29578f * Mathf.Atan(num2 / num1);
|
||||
this.UpdateLaneChangingDirection(laneObject, angle, deltaTime);
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ namespace Assets.AR
|
||||
|
||||
protected void UpdateRiderCurvature(ARLaneGameObject laneObject, float curvature, float deltaTime)
|
||||
{
|
||||
float num = 6f;
|
||||
var num = 6f;
|
||||
laneObject.Curvature = Mathf.Lerp(laneObject.Curvature, curvature, num * deltaTime);
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ namespace Assets.AR
|
||||
float angle,
|
||||
float deltaTime)
|
||||
{
|
||||
float num = 10f * deltaTime;
|
||||
var num = 10f * deltaTime;
|
||||
laneObject.LaneChangingDirection = Mathf.Clamp(angle, laneObject.LaneChangingDirection - num, laneObject.LaneChangingDirection + num);
|
||||
}
|
||||
|
||||
@ -194,14 +194,14 @@ namespace Assets.AR
|
||||
{
|
||||
if (count == -1)
|
||||
count = this.collisionList.Count;
|
||||
float overtakingThreshold = this.GetOvertakingThreshold(routeDistance);
|
||||
float b = 0.0f;
|
||||
var overtakingThreshold = this.GetOvertakingThreshold(routeDistance);
|
||||
var b = 0.0f;
|
||||
for (int index = count - 1; index >= 0; --index)
|
||||
{
|
||||
ARLaneGameObject collision = this.collisionList[index];
|
||||
var collision = this.collisionList[index];
|
||||
if ((double)collision.Lane + 1.0 >= (double)b)
|
||||
{
|
||||
float collisionParameter = ARLaneGameObjectsController.GetCollisionParameter(modelDistance, collision.DistanceSort, overtakingThreshold);
|
||||
var collisionParameter = ARLaneGameObjectsController.GetCollisionParameter(modelDistance, collision.DistanceSort, overtakingThreshold);
|
||||
if ((double)collisionParameter > 0.0)
|
||||
b = Mathf.Max(collision.Lane + collisionParameter, b);
|
||||
}
|
||||
@ -213,7 +213,7 @@ namespace Assets.AR
|
||||
|
||||
protected float GetOvertakingThreshold(float routeDistance)
|
||||
{
|
||||
float b = this.OvertakingThreshold;
|
||||
var b = this.OvertakingThreshold;
|
||||
if (this.AllowStartOrder && (double)routeDistance < 200.0)
|
||||
b = Mathf.Lerp(1.33f, b, routeDistance / 200f);
|
||||
return b;
|
||||
@ -233,7 +233,7 @@ namespace Assets.AR
|
||||
{
|
||||
if (!this.AllowStartOrder || (double)routeDistance >= 200.0)
|
||||
return routeDistance;
|
||||
float 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 num = Mathf.Lerp((float)((double)(RiderCountInStartRow == 0 ? 0 :(startPosition - 1) / this.RiderCountInStartRow) * 2.2000000476837158 + 6.0) + this.GetStartOffset(startPosition).y, 0.0f, routeDistance / 200f);
|
||||
return routeDistance + num;
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ namespace Assets.AR
|
||||
float distOther,
|
||||
float maxDistance)
|
||||
{
|
||||
float x = distSource - distOther;
|
||||
var x = distSource - distOther;
|
||||
if ((double)x < 0.0)
|
||||
x = -x;
|
||||
if ((double)x < 1.0)
|
||||
@ -251,8 +251,8 @@ namespace Assets.AR
|
||||
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);
|
||||
private float GetRouteLeftOffset(float frame) => this.Route?.GetLeftSideOffset(frame) ?? 0.0f;
|
||||
|
||||
private float GetRouteRightOffset(float frame) => this.Route == null ? 0.0f : this.Route.GetRightSideOffset(frame);
|
||||
private float GetRouteRightOffset(float frame) => this.Route?.GetRightSideOffset(frame) ?? 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ namespace Assets.AR
|
||||
return (float)this.Visibility[0];
|
||||
if (index >= this.Visibility.Length)
|
||||
return (float)this.Visibility[this.Visibility.Length - 1];
|
||||
float t = frame - (float)(index - 1);
|
||||
var t = frame - (float)(index - 1);
|
||||
return Mathf.Lerp((float)this.Visibility[index - 1], (float)this.Visibility[index], t);
|
||||
}
|
||||
|
||||
@ -106,12 +106,12 @@ namespace Assets.AR
|
||||
|
||||
public Vector3 GetCameraPosition(float frame)
|
||||
{
|
||||
int index = (int)Math.Ceiling((double)frame);
|
||||
var index = (int)Math.Ceiling((double)frame);
|
||||
if (index <= 0)
|
||||
return this.CameraPositions[0];
|
||||
if (index >= this.FrameCount)
|
||||
return this.CameraPositions[this.CameraPositions.Length - 1];
|
||||
float t = frame - (float)(index - 1);
|
||||
var t = frame - (float)(index - 1);
|
||||
return Vector3.Lerp(this.CameraPositions[index - 1], this.CameraPositions[index], t);
|
||||
}
|
||||
|
||||
@ -124,12 +124,12 @@ namespace Assets.AR
|
||||
|
||||
public Vector3 GetFilteredCameraPosition(float frame)
|
||||
{
|
||||
int index = (int)Math.Ceiling((double)frame);
|
||||
var index = (int)Math.Ceiling((double)frame);
|
||||
if (index <= 0)
|
||||
return this.FilteredCameraPositions[0];
|
||||
if (index >= this.FrameCount)
|
||||
return this.FilteredCameraPositions[this.FilteredCameraPositions.Length - 1];
|
||||
float t = frame - (float)(index - 1);
|
||||
var t = frame - (float)(index - 1);
|
||||
return Vector3.Lerp(this.FilteredCameraPositions[index - 1], this.FilteredCameraPositions[index], t);
|
||||
}
|
||||
|
||||
@ -142,29 +142,29 @@ namespace Assets.AR
|
||||
|
||||
public Quaternion GetCameraRotation(float frame)
|
||||
{
|
||||
int index = (int)Math.Ceiling((double)frame);
|
||||
var index = (int)Math.Ceiling((double)frame);
|
||||
if (index <= 0)
|
||||
return this.CameraRotations[0];
|
||||
if (index >= this.FrameCount)
|
||||
return this.CameraRotations[this.CameraRotations.Length - 1];
|
||||
float t = frame - (float)(index - 1);
|
||||
var t = frame - (float)(index - 1);
|
||||
return Quaternion.Slerp(this.CameraRotations[index - 1], this.CameraRotations[index], t);
|
||||
}
|
||||
|
||||
public Quaternion GetCameraRotationRear(float frame)
|
||||
{
|
||||
int index = (int)Math.Ceiling((double)frame);
|
||||
var index = (int)Math.Ceiling((double)frame);
|
||||
if (index <= 0)
|
||||
return this.CameraRotationsRear[0];
|
||||
if (index >= this.FrameCount)
|
||||
return this.CameraRotationsRear[this.CameraRotationsRear.Length - 1];
|
||||
float t = frame - (float)(index - 1);
|
||||
var t = frame - (float)(index - 1);
|
||||
return Quaternion.Slerp(this.CameraRotationsRear[index - 1], this.CameraRotationsRear[index], t);
|
||||
}
|
||||
|
||||
public int GetSlamSegmentIndex(float frame)
|
||||
{
|
||||
for (int index = 1; index < this.SlamSegments.Length; ++index)
|
||||
for (var index = 1; index < this.SlamSegments.Length; ++index)
|
||||
{
|
||||
if ((double)this.SlamSegments[index] > (double)frame)
|
||||
return index - 1;
|
||||
@ -188,7 +188,7 @@ namespace Assets.AR
|
||||
out int end,
|
||||
float defultVisibility = 0.0f)
|
||||
{
|
||||
float num = (float)this.GetVisibilityAt(frame);
|
||||
var num = (float)this.GetVisibilityAt(frame);
|
||||
if ((double)num == 0.0)
|
||||
num = defultVisibility;
|
||||
start = this.GetSlamSegmentIndex((float)frame);
|
||||
@ -197,15 +197,15 @@ namespace Assets.AR
|
||||
|
||||
public double GetFrameAtDistance(double distance)
|
||||
{
|
||||
double[] frameDistances = this.FrameDistances;
|
||||
int index = Array.BinarySearch<double>(frameDistances, distance);
|
||||
var frameDistances = this.FrameDistances;
|
||||
var index = Array.BinarySearch<double>(frameDistances, distance);
|
||||
if (index < 0)
|
||||
index = ~index;
|
||||
if (index == 0)
|
||||
return 0.0;
|
||||
if (index == frameDistances.Length)
|
||||
return (double)(frameDistances.Length - 1);
|
||||
double num = PFMath.InverseLerp(frameDistances[index - 1], frameDistances[index], distance);
|
||||
var num = PFMath.InverseLerp(frameDistances[index - 1], frameDistances[index], distance);
|
||||
return (double)index + num - 1.0;
|
||||
}
|
||||
|
||||
@ -216,33 +216,33 @@ namespace Assets.AR
|
||||
|
||||
public double GetDistanceForFrame(double frame)
|
||||
{
|
||||
int index = (int)Math.Ceiling(frame);
|
||||
var index = (int)Math.Ceiling(frame);
|
||||
if (index <= 0)
|
||||
return this.FrameDistances[0];
|
||||
if (index >= this.FrameCount)
|
||||
return this.FrameDistances[this.FrameDistances.Length - 1];
|
||||
double t = frame - (double)(index - 1);
|
||||
var t = frame - (double)(index - 1);
|
||||
return PFMath.Lerp(this.FrameDistances[index - 1], this.FrameDistances[index], t);
|
||||
}
|
||||
|
||||
public CameraProjectionParameters GetCameraProjectionParameters(
|
||||
float frame)
|
||||
{
|
||||
int index = Mathf.Clamp(this.GetSlamSegmentIndex(frame), 0, this.ProjectionParameters.Length - 1);
|
||||
CameraProjectionParameters projectionParameter1 = this.ProjectionParameters[index];
|
||||
int slamSegment1 = this.SlamSegments[index];
|
||||
var index = Mathf.Clamp(this.GetSlamSegmentIndex(frame), 0, this.ProjectionParameters.Length - 1);
|
||||
var projectionParameter1 = this.ProjectionParameters[index];
|
||||
var slamSegment1 = this.SlamSegments[index];
|
||||
if (index > 0 && (double)frame < (double)slamSegment1 + 15.0)
|
||||
{
|
||||
float t = (float)(0.5 + ((double)frame - (double)slamSegment1) / 30.0);
|
||||
var t = (float)(0.5 + ((double)frame - (double)slamSegment1) / 30.0);
|
||||
return CameraProjectionParameters.Lerp(this.ProjectionParameters[index - 1], projectionParameter1, t);
|
||||
}
|
||||
if (index < this.SlamSegments.Length - 1)
|
||||
{
|
||||
int slamSegment2 = this.SlamSegments[index + 1];
|
||||
if ((double)frame > (double)slamSegment2 - 15.0)
|
||||
var slamSegment2 = this.SlamSegments[index + 1];
|
||||
if (frame > slamSegment2 - 15.0)
|
||||
{
|
||||
float t = (float)(0.5 - ((double)slamSegment2 - (double)frame) / 30.0);
|
||||
CameraProjectionParameters projectionParameter2 = this.ProjectionParameters[index + 1];
|
||||
var t = (float)(0.5 - ((double)slamSegment2 - (double)frame) / 30.0);
|
||||
var projectionParameter2 = this.ProjectionParameters[index + 1];
|
||||
return CameraProjectionParameters.Lerp(projectionParameter1, projectionParameter2, t);
|
||||
}
|
||||
}
|
||||
@ -251,13 +251,13 @@ namespace Assets.AR
|
||||
//设置摄像机投影矩阵
|
||||
public void SetCameraProjection(float frame, Camera camera, bool fitInside = false)
|
||||
{
|
||||
CameraProjectionParameters projectionParameters = this.GetCameraProjectionParameters(frame);
|
||||
if ((double)projectionParameters.alpha == 0.0)
|
||||
var projectionParameters = this.GetCameraProjectionParameters(frame);
|
||||
if (projectionParameters.alpha == 0.0)
|
||||
return;
|
||||
float num1 = projectionParameters.cx / projectionParameters.cy;
|
||||
float num2 = (float)Screen.width / (float)Screen.height;
|
||||
float cx = projectionParameters.cx;
|
||||
float cy = projectionParameters.cy;
|
||||
var num1 = projectionParameters.cx / projectionParameters.cy;
|
||||
var num2 = (float)Screen.width / (float)Screen.height;
|
||||
var cx = projectionParameters.cx;
|
||||
var cy = projectionParameters.cy;
|
||||
if (fitInside)
|
||||
{
|
||||
if ((double)num2 > (double)num1)
|
||||
@ -283,9 +283,9 @@ namespace Assets.AR
|
||||
float nearClipPlane,
|
||||
float farClipPlane)
|
||||
{
|
||||
Matrix4x4 projectionMatrix = new Matrix4x4();
|
||||
float z = (float)(-((double)farClipPlane + (double)nearClipPlane) / ((double)farClipPlane - (double)nearClipPlane));
|
||||
float w = (float)(-2.0 * (double)farClipPlane * (double)nearClipPlane / ((double)farClipPlane - (double)nearClipPlane));
|
||||
var projectionMatrix = new Matrix4x4();
|
||||
var z = (float)(-((double)farClipPlane + (double)nearClipPlane) / ((double)farClipPlane - (double)nearClipPlane));
|
||||
var w = (float)(-2.0 * (double)farClipPlane * (double)nearClipPlane / ((double)farClipPlane - (double)nearClipPlane));
|
||||
projectionMatrix.SetRow(0, new Vector4(alpha / cx, 0.0f, 0.0f, 0.0f));
|
||||
projectionMatrix.SetRow(1, new Vector4(0.0f, beta / cy, 0.0f, 0.0f));
|
||||
projectionMatrix.SetRow(2, new Vector4(0.0f, 0.0f, z, w));
|
||||
@ -295,13 +295,13 @@ namespace Assets.AR
|
||||
//处理摄像机3d位置
|
||||
public void CreateFilteredCameraPositions()
|
||||
{
|
||||
int length = this.CameraPositions.Length;
|
||||
Vector3[] vector3Array = new Vector3[length];
|
||||
for (int index = 0; index < length; ++index)
|
||||
var length = this.CameraPositions.Length;
|
||||
var vector3Array = new Vector3[length];
|
||||
for (var index = 0; index < length; ++index)
|
||||
vector3Array[index] = this.CameraPositions[index];
|
||||
for (int index1 = 0; index1 < 3; ++index1)
|
||||
for (var index1 = 0; index1 < 3; ++index1)
|
||||
{
|
||||
for (int index2 = 1; index2 < vector3Array.Length - 1; ++index2)
|
||||
for (var index2 = 1; index2 < vector3Array.Length - 1; ++index2)
|
||||
vector3Array[index2] = (vector3Array[index2 - 1] + vector3Array[index2] + vector3Array[index2 + 1]) / 3f;
|
||||
}
|
||||
this.FilteredCameraPositions = vector3Array;
|
||||
@ -309,11 +309,11 @@ namespace Assets.AR
|
||||
//创建摄像机在3d空间的距离
|
||||
private void CreateFrameDistances()
|
||||
{
|
||||
int length = this.CameraPositions.Length;
|
||||
var length = this.CameraPositions.Length;
|
||||
this.FrameDistances = new double[length];
|
||||
this.FrameDistances[0] = 0.0;
|
||||
double num = 0.0;
|
||||
for (int index = 1; index < length; ++index)
|
||||
var num = 0.0;
|
||||
for (var index = 1; index < length; ++index)
|
||||
{
|
||||
num += (double)Vector3.Distance(this.CameraPositions[index - 1], this.CameraPositions[index]);
|
||||
this.FrameDistances[index] = num;
|
||||
@ -333,7 +333,7 @@ namespace Assets.AR
|
||||
//获取轨迹上某帧的转向
|
||||
public Quaternion GetTrajectoryOrientationAt(int frame)
|
||||
{
|
||||
int index = Mathf.Clamp(frame, 0, this.FrameCount);
|
||||
var index = Mathf.Clamp(frame, 0, this.FrameCount);
|
||||
if (index <= 0)
|
||||
return this.TrajectoryOrientation[0];
|
||||
return index >= this.FrameCount ? this.TrajectoryOrientation[this.TrajectoryOrientation.Length - 1] : this.TrajectoryOrientation[index];
|
||||
@ -342,23 +342,23 @@ namespace Assets.AR
|
||||
public Quaternion GetTrajectoryOrientation(float frame)
|
||||
{
|
||||
frame = Mathf.Clamp(frame, 0.0f, (float)this.FrameCount);
|
||||
int index = (int)Math.Ceiling((double)frame);
|
||||
var index = (int)Math.Ceiling((double)frame);
|
||||
if (index <= 0)
|
||||
return this.TrajectoryOrientation[0];
|
||||
if (index >= this.FrameCount)
|
||||
return this.TrajectoryOrientation[this.TrajectoryOrientation.Length - 1];
|
||||
float t = frame - (float)(index - 1);
|
||||
var t = frame - (float)(index - 1);
|
||||
return Quaternion.Slerp(this.TrajectoryOrientation[index - 1], this.TrajectoryOrientation[index], t);
|
||||
}
|
||||
|
||||
public float GetTrajectoryCurvature(float frame)
|
||||
{
|
||||
int index = (int)Math.Ceiling((double)frame);
|
||||
var index = (int)Math.Ceiling((double)frame);
|
||||
if (index <= 0)
|
||||
return this.TrajectoryCurvatures[0];
|
||||
if (index >= this.FrameCount)
|
||||
return this.TrajectoryCurvatures[this.TrajectoryCurvatures.Length - 1];
|
||||
float t = frame - (float)(index - 1);
|
||||
var t = frame - (float)(index - 1);
|
||||
return Mathf.Lerp(this.TrajectoryCurvatures[index - 1], this.TrajectoryCurvatures[index], t);
|
||||
}
|
||||
|
||||
@ -366,8 +366,8 @@ namespace Assets.AR
|
||||
{
|
||||
if (this.LightRotations == null || this.LightRotations.Length == 0)
|
||||
return Quaternion.Euler(new Vector3(90f, 0.0f, 0.0f));
|
||||
int index1 = 0;
|
||||
for (int index2 = 0; index2 < this.LightRotationFrames.Length; ++index2)
|
||||
var index1 = 0;
|
||||
for (var index2 = 0; index2 < this.LightRotationFrames.Length; ++index2)
|
||||
{
|
||||
if ((double)this.LightRotationFrames[index2] < (double)distance)
|
||||
index1 = index2;
|
||||
@ -382,8 +382,8 @@ namespace Assets.AR
|
||||
{
|
||||
if (this.ShadowIntensities == null || this.ShadowIntensities.Length == 0)
|
||||
return 1f;
|
||||
int index1 = 0;
|
||||
for (int index2 = 0; index2 < this.ShadowIntensityFrames.Length; ++index2)
|
||||
var index1 = 0;
|
||||
for (var index2 = 0; index2 < this.ShadowIntensityFrames.Length; ++index2)
|
||||
{
|
||||
if ((double)this.ShadowIntensityFrames[index2] < (double)distance)
|
||||
index1 = index2;
|
||||
@ -391,7 +391,7 @@ namespace Assets.AR
|
||||
if (index1 + 1 == this.ShadowIntensities.Length)
|
||||
return this.ShadowIntensities[this.ShadowIntensities.Length - 1];
|
||||
|
||||
float t = Mathf.InverseLerp(this.ShadowIntensityFrames[index1], this.ShadowIntensityFrames[index1 + 1], distance);
|
||||
var t = Mathf.InverseLerp(this.ShadowIntensityFrames[index1], this.ShadowIntensityFrames[index1 + 1], distance);
|
||||
return Mathf.Lerp(this.ShadowIntensities[index1], this.ShadowIntensities[index1 + 1], t);
|
||||
}
|
||||
|
||||
@ -399,14 +399,14 @@ namespace Assets.AR
|
||||
{
|
||||
if (!this.HasLeftSideOffsets)
|
||||
return this.DefaultLeftSideOffset;
|
||||
int index = Array.BinarySearch<int>(this.LeftSideOffsetFrames, (int)Math.Ceiling((double)frame));
|
||||
var index = Array.BinarySearch<int>(this.LeftSideOffsetFrames, (int)Math.Ceiling((double)frame));
|
||||
if (index < 0)
|
||||
index = ~index;
|
||||
if (index == 0)
|
||||
return this.LeftSideOffsets[0];
|
||||
if (index == this.LeftSideOffsetFrames.Length)
|
||||
return this.LeftSideOffsets[this.LeftSideOffsetFrames.Length - 1];
|
||||
float t = Mathf.InverseLerp((float)this.LeftSideOffsetFrames[index - 1], (float)this.LeftSideOffsetFrames[index], frame);
|
||||
var t = Mathf.InverseLerp((float)this.LeftSideOffsetFrames[index - 1], (float)this.LeftSideOffsetFrames[index], frame);
|
||||
return Mathf.Lerp(this.LeftSideOffsets[index - 1], this.LeftSideOffsets[index], t);
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ namespace Assets.AR
|
||||
{
|
||||
if (!this.HasRightSideOffsets)
|
||||
return this.DefaultRightSideOffset;
|
||||
int index = Array.BinarySearch<int>(this.RightSideOffsetFrames, (int)Math.Ceiling((double)frame));
|
||||
var index = Array.BinarySearch<int>(this.RightSideOffsetFrames, (int)Math.Ceiling((double)frame));
|
||||
if (index < 0)
|
||||
index = ~index;
|
||||
if (index == 0)
|
||||
@ -437,7 +437,7 @@ namespace Assets.AR
|
||||
this.CameraPositions = ((IEnumerable<VectorData>)data.CameraPositions).Select<VectorData, Vector3>((Func<VectorData, Vector3>)(x => x.ToUnityVector())).ToArray<Vector3>();
|
||||
this.ProjectionParameters = data.CameraProjectionParameters;
|
||||
this.CameraRotations = ((IEnumerable<VectorData>)data.CameraRotations).Select<VectorData, Quaternion>((Func<VectorData, Quaternion>)(x => Quaternion.Euler(x.ToUnityVector()))).ToArray<Quaternion>();
|
||||
VectorData[] cameraRotationsRear = data.CameraRotationsRear;
|
||||
var cameraRotationsRear = data.CameraRotationsRear;
|
||||
this.CameraRotationsRear = cameraRotationsRear != null ? ((IEnumerable<VectorData>)cameraRotationsRear).Select<VectorData, Quaternion>((Func<VectorData, Quaternion>)(x => Quaternion.Euler(x.ToUnityVector()))).ToArray<Quaternion>() : (Quaternion[])null;
|
||||
this.LeftSideOffsetFrames = data.LeftSideOffsetFrames;
|
||||
this.LeftSideOffsets = data.LeftSideOffsets;
|
||||
@ -472,7 +472,7 @@ namespace Assets.AR
|
||||
|
||||
public ARRouteData ToARRouteData()
|
||||
{
|
||||
ARRouteData arRouteData = new ARRouteData();
|
||||
var arRouteData = new ARRouteData();
|
||||
arRouteData.Visibility = this.Visibility;
|
||||
arRouteData.VideoFrameOffset = this.VideoFrameOffset;
|
||||
arRouteData.LeftHanded = this.LeftHanded;
|
||||
@ -516,13 +516,13 @@ namespace Assets.AR
|
||||
return (SphericalHarmonicsL2[])null;
|
||||
if (coefficients.Length % 27 != 0)
|
||||
throw new ArgumentException("An array of SH coefficients must be divisible by 27.");
|
||||
int num = 0;
|
||||
SphericalHarmonicsL2[] sphericalHarmonicsL2Array = new SphericalHarmonicsL2[coefficients.Length / 27];
|
||||
for (int index = 0; index < coefficients.Length / 27; ++index)
|
||||
var num = 0;
|
||||
var sphericalHarmonicsL2Array = new SphericalHarmonicsL2[coefficients.Length / 27];
|
||||
for (var index = 0; index < coefficients.Length / 27; ++index)
|
||||
{
|
||||
for (int rgb = 0; rgb < 3; ++rgb)
|
||||
for (var rgb = 0; rgb < 3; ++rgb)
|
||||
{
|
||||
for (int coefficient = 0; coefficient < 9; ++coefficient)
|
||||
for (var coefficient = 0; coefficient < 9; ++coefficient)
|
||||
sphericalHarmonicsL2Array[index][rgb, coefficient] = coefficients[num++];
|
||||
}
|
||||
}
|
||||
@ -533,13 +533,13 @@ namespace Assets.AR
|
||||
{
|
||||
if (sphericalHarmonics == null || sphericalHarmonics.Length == 0)
|
||||
return (float[])null;
|
||||
int num = 0;
|
||||
float[] numArray = new float[sphericalHarmonics.Length * 27];
|
||||
for (int index = 0; index < sphericalHarmonics.Length; ++index)
|
||||
var num = 0;
|
||||
var numArray = new float[sphericalHarmonics.Length * 27];
|
||||
for (var index = 0; index < sphericalHarmonics.Length; ++index)
|
||||
{
|
||||
for (int rgb = 0; rgb < 3; ++rgb)
|
||||
for (var rgb = 0; rgb < 3; ++rgb)
|
||||
{
|
||||
for (int coefficient = 0; coefficient < 9; ++coefficient)
|
||||
for (var coefficient = 0; coefficient < 9; ++coefficient)
|
||||
numArray[num++] = sphericalHarmonics[index][rgb, coefficient];
|
||||
}
|
||||
}
|
||||
@ -548,16 +548,16 @@ namespace Assets.AR
|
||||
|
||||
private void CreateTrajectoryCurvatures()
|
||||
{
|
||||
Vector3[] cameraPositions = this.CameraPositions;
|
||||
double[] frameDistances = this.FrameDistances;
|
||||
int length = cameraPositions.Length;
|
||||
float[] numArray = new float[length];
|
||||
for (int index = 0; index < length; ++index)
|
||||
var cameraPositions = this.CameraPositions;
|
||||
var frameDistances = this.FrameDistances;
|
||||
var length = cameraPositions.Length;
|
||||
var numArray = new float[length];
|
||||
for (var index = 0; index < length; ++index)
|
||||
{
|
||||
Vector3 aP1 = cameraPositions[index];
|
||||
double num = frameDistances[index];
|
||||
Vector3 filteredCameraPosition1 = this.GetFilteredCameraPosition((float)this.GetFrameAtDistance(num - 10.0));
|
||||
Vector3 filteredCameraPosition2 = this.GetFilteredCameraPosition((float)this.GetFrameAtDistance(num + 10.0));
|
||||
var aP1 = cameraPositions[index];
|
||||
var num = frameDistances[index];
|
||||
var filteredCameraPosition1 = this.GetFilteredCameraPosition((float)this.GetFrameAtDistance(num - 10.0));
|
||||
var filteredCameraPosition2 = this.GetFilteredCameraPosition((float)this.GetFrameAtDistance(num + 10.0));
|
||||
Vector3 center;
|
||||
if (!GeometryUtil.CircleCenter(filteredCameraPosition1, aP1, filteredCameraPosition2, out center))
|
||||
{
|
||||
@ -565,16 +565,16 @@ namespace Assets.AR
|
||||
}
|
||||
else
|
||||
{
|
||||
float magnitude = (center - filteredCameraPosition1).magnitude;
|
||||
Vector3 normalized = Vector3.Cross(aP1 - filteredCameraPosition1, Vector3.up).normalized;
|
||||
var magnitude = (center - filteredCameraPosition1).magnitude;
|
||||
var normalized = Vector3.Cross(aP1 - filteredCameraPosition1, Vector3.up).normalized;
|
||||
if (((double)center.x - (double)filteredCameraPosition1.x) * (double)normalized.x + ((double)center.y - (double)filteredCameraPosition1.y) * (double)normalized.y + ((double)center.z - (double)filteredCameraPosition1.z) * (double)normalized.z < 0.0)
|
||||
magnitude *= -1f;
|
||||
numArray[index] = 1f / magnitude;
|
||||
}
|
||||
}
|
||||
for (int index1 = 0; index1 < 2; ++index1)
|
||||
for (var index1 = 0; index1 < 2; ++index1)
|
||||
{
|
||||
for (int index2 = 1; index2 < numArray.Length - 1; ++index2)
|
||||
for (var index2 = 1; index2 < numArray.Length - 1; ++index2)
|
||||
numArray[index2] = (float)(((double)numArray[index2 - 1] + (double)numArray[index2] + (double)numArray[index2 + 1]) / 3.0);
|
||||
}
|
||||
this.TrajectoryCurvatures = numArray;
|
||||
|
||||
@ -19,13 +19,13 @@ namespace Assets.AR
|
||||
public long UserRecord;
|
||||
public static RouteDetailData LoadFromFile(string path)
|
||||
{
|
||||
JsonSerializer jsonSerializer = new JsonSerializer();
|
||||
var jsonSerializer = new JsonSerializer();
|
||||
jsonSerializer.Converters.Add((JsonConverter)new VectorDataConverter());
|
||||
using (FileStream fileStream = File.Open(path, FileMode.Open))
|
||||
using (var fileStream = File.Open(path, FileMode.Open))
|
||||
{
|
||||
using (StreamReader reader1 = new StreamReader(fileStream))
|
||||
using (var reader1 = new StreamReader(fileStream))
|
||||
{
|
||||
using (JsonTextReader reader2 = new JsonTextReader((TextReader)reader1))
|
||||
using (var reader2 = new JsonTextReader((TextReader)reader1))
|
||||
return jsonSerializer.Deserialize<RouteDetailData>((JsonReader)reader2);
|
||||
}
|
||||
}
|
||||
@ -53,13 +53,13 @@ namespace Assets.AR
|
||||
{
|
||||
if (obj == null || !this.GetType().Equals(obj.GetType()))
|
||||
return false;
|
||||
RouteDetailSplitData routeDetailSplitData = obj as RouteDetailSplitData;
|
||||
var routeDetailSplitData = obj as RouteDetailSplitData;
|
||||
return this.Distance == routeDetailSplitData.Distance && string.Equals(this.Name, routeDetailSplitData.Name);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = 23 * 31 + this.Distance.GetHashCode();
|
||||
var hashCode = 23 * 31 + this.Distance.GetHashCode();
|
||||
if (this.Name != null)
|
||||
hashCode = hashCode * 31 + this.Name.GetHashCode();
|
||||
return hashCode;
|
||||
@ -71,6 +71,7 @@ namespace Assets.AR
|
||||
public double Distance;
|
||||
public double VideoTime;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class RouteInfoData
|
||||
{
|
||||
@ -95,8 +96,6 @@ namespace Assets.AR
|
||||
public bool IsMultiLap;
|
||||
public int LiveSegmentsCount;
|
||||
|
||||
|
||||
|
||||
public bool HasVideo => this.Videos != null && this.Videos.Count > 0;
|
||||
|
||||
public bool IsAr => !string.IsNullOrEmpty(this.ARFileUrl);
|
||||
@ -123,19 +122,20 @@ namespace Assets.AR
|
||||
|
||||
public static int[] AllQualitites() => new int[4]
|
||||
{
|
||||
540,
|
||||
720,
|
||||
1080,
|
||||
1440
|
||||
540,
|
||||
720,
|
||||
1080,
|
||||
1440
|
||||
};
|
||||
|
||||
public static int[] StreamingQualities() => new int[3]
|
||||
{
|
||||
540,
|
||||
720,
|
||||
1080
|
||||
540,
|
||||
720,
|
||||
1080
|
||||
};
|
||||
}
|
||||
|
||||
public class RouteGeometryPointData
|
||||
{
|
||||
public double Latitude;
|
||||
@ -143,6 +143,7 @@ namespace Assets.AR
|
||||
public double Distance;
|
||||
public double Altitude;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ARData
|
||||
{
|
||||
@ -156,13 +157,13 @@ namespace Assets.AR
|
||||
|
||||
public static ARData LoadFromFile(string path)
|
||||
{
|
||||
JsonSerializer jsonSerializer = new JsonSerializer();
|
||||
var jsonSerializer = new JsonSerializer();
|
||||
jsonSerializer.Converters.Add((JsonConverter)new VectorDataConverter());
|
||||
using (FileStream fileStream = File.Open(path, FileMode.Open))
|
||||
using (var fileStream = File.Open(path, FileMode.Open))
|
||||
{
|
||||
using (StreamReader reader1 = new StreamReader((Stream)fileStream))
|
||||
using (var reader1 = new StreamReader((Stream)fileStream))
|
||||
{
|
||||
using (JsonTextReader reader2 = new JsonTextReader((TextReader)reader1))
|
||||
using (var reader2 = new JsonTextReader((TextReader)reader1))
|
||||
return jsonSerializer.Deserialize<ARData>((JsonReader)reader2);
|
||||
}
|
||||
}
|
||||
@ -179,7 +180,7 @@ namespace Assets.AR
|
||||
object existingValue,
|
||||
JsonSerializer serializer)
|
||||
{
|
||||
VectorData vectorData = new VectorData();
|
||||
var vectorData = new VectorData();
|
||||
reader.Read();
|
||||
vectorData.x = (float)reader.ReadAsDouble().Value;
|
||||
reader.Read();
|
||||
|
||||
@ -156,12 +156,9 @@ namespace Assets.AR
|
||||
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)
|
||||
foreach (var item in keys.Where(item => manager.rideObjs.Keys.All(c => c.UserId != item)))
|
||||
{
|
||||
if (!manager.rideObjs.Keys.Where(c => c.UserId == item).Any())
|
||||
{
|
||||
riderObjects.Remove(item);
|
||||
}
|
||||
riderObjects.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -83,6 +83,12 @@ namespace Assets.AR
|
||||
private void SkipVideoToFrame(long frame) => this.VideoPlayer.Seek(frame);
|
||||
|
||||
private const float TimerInterval = 0.2f;
|
||||
|
||||
/// <summary>
|
||||
/// update video play rate
|
||||
/// </summary>
|
||||
/// <param name="speed">播放速度</param>
|
||||
/// <param name="routeDistance">骑行距离</param>
|
||||
public void UpdateVideoPlayRate(float speed, float routeDistance)
|
||||
{
|
||||
if (!this.AllowUpdate)
|
||||
@ -95,10 +101,9 @@ namespace Assets.AR
|
||||
this.fixedTimeSeekFinished = DateTime.UtcNow;
|
||||
if (DateTime.UtcNow.Subtract(this.fixedTimeSeekFinished).TotalSeconds < 0.25)
|
||||
return;
|
||||
if ((double)this.VideoPlayer.CurrentFrame > (double)this.fixedTimeFrame)
|
||||
if (this.VideoPlayer.CurrentFrame > this.fixedTimeFrame)
|
||||
this.VideoPlayer.Pause();
|
||||
//if (this.VideoPlayer is RouvyVideoPlayer.RouvyVideoPlayer videoPlayer)
|
||||
// videoPlayer.TargetFrame = this.fixedTimeFrame;
|
||||
|
||||
this.VideoPlayer.UpdateCurrentFrame();
|
||||
this.FrameIndexDistanceCorrection = 0.0f;
|
||||
}
|
||||
@ -106,34 +111,32 @@ namespace Assets.AR
|
||||
{
|
||||
var videoFrameAtDistance1 = this.VideoSyncSource.GetVideoFrameAtDistance(routeDistance);
|
||||
var val2 = routeDistance - this.CameraFollowDistance;
|
||||
//if (this.IsMultilap && (double)this.RiderDistance.RouteDistance > (double)this.RiderDistance.LapDistance && (double)val2 < 0.0)
|
||||
// val2 += (float)this.lapLength;
|
||||
|
||||
var distance = Math.Max(0.0f, val2);
|
||||
var frame = this.VideoSyncSource.GetVideoFrameAtDistance(distance) + (float)this.VideoFrameOffset;
|
||||
if (this.Route != null && (double)this.Route.GetVisibility(frame) > 10.0)
|
||||
frame = (float)this.Route.GetFrameAtDistance(Math.Max(0.0, this.Route.GetDistanceForFrame((double)videoFrameAtDistance1) - (double)this.CameraFollowDistance)) + (float)this.VideoFrameOffset;
|
||||
//if (this.VideoPlayer is RouvyLib.Video.RouvyVideoPlayer.RouvyVideoPlayer videoPlayer)
|
||||
// videoPlayer.TargetFrame = frame;
|
||||
var frame = this.VideoSyncSource.GetVideoFrameAtDistance(distance) + this.VideoFrameOffset;
|
||||
if (this.Route != null && this.Route.GetVisibility(frame) > 10.0)
|
||||
frame = (float)this.Route.GetFrameAtDistance(Math.Max(0.0, this.Route.GetDistanceForFrame(videoFrameAtDistance1) - this.CameraFollowDistance)) + this.VideoFrameOffset;
|
||||
|
||||
this.VideoPlayer.UpdateCurrentFrame();
|
||||
var distanceForVideoFrame = this.VideoSyncSource.GetDistanceForVideoFrame(this.VideoPlayer.CurrentFrame - (float)this.VideoFrameOffset);
|
||||
float f;
|
||||
float frameOffset;
|
||||
if (this.Route != null)
|
||||
{
|
||||
var frameAtDistance = this.Route.GetFrameAtDistance(this.Route.GetDistanceForFrame((double)this.VideoPlayer.CurrentFrame - (double)this.VideoFrameOffset) + (double)Mathf.Min(routeDistance, this.CameraFollowDistance));
|
||||
f = videoFrameAtDistance1 - (float)frameAtDistance;
|
||||
var frameAtDistance = this.Route.GetFrameAtDistance(this.Route.GetDistanceForFrame(this.VideoPlayer.CurrentFrame - this.VideoFrameOffset) + Mathf.Min(routeDistance, this.CameraFollowDistance));
|
||||
frameOffset = videoFrameAtDistance1 - (float)frameAtDistance;
|
||||
}
|
||||
else
|
||||
f = frame - (this.VideoPlayer.CurrentFrame - (float)this.VideoFrameOffset);
|
||||
var num1 = Mathf.Clamp01(PFMath.Lerp(0.0f, 1f, 100f, 0.0f, Mathf.Abs(f)));
|
||||
this.FrameIndexDistanceCorrection = f * num1;
|
||||
frameOffset = frame - (this.VideoPlayer.CurrentFrame - this.VideoFrameOffset);
|
||||
var num1 = Mathf.Clamp01(PFMath.Lerp(0.0f, 1f, 100f, 0.0f, Mathf.Abs(frameOffset)));
|
||||
this.FrameIndexDistanceCorrection = frameOffset * num1;
|
||||
this.CameraDistanceError = distance - distanceForVideoFrame;
|
||||
if (this.IsMultilap)
|
||||
{
|
||||
var num2 = distance - (distanceForVideoFrame + (float)this.lapLength);
|
||||
if ((double)Math.Abs(num2) < (double)Math.Abs(this.CameraDistanceError) && (double)Math.Abs(num2) < 200.0)
|
||||
if (Math.Abs(num2) < Math.Abs(this.CameraDistanceError) && Math.Abs(num2) < 200.0)
|
||||
return;
|
||||
}
|
||||
if ((double)Math.Abs(this.CameraDistanceError) > 200.0)
|
||||
if (Math.Abs(this.CameraDistanceError) > 200.0)
|
||||
{
|
||||
this.SkipVideoToDistance(distance);
|
||||
}
|
||||
@ -144,7 +147,7 @@ namespace Assets.AR
|
||||
return;
|
||||
var num3 = (float)totalSeconds;
|
||||
var 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 offset = this.VideoSyncSource.GetDistanceForVideoFrame((this.VideoPlayer.CurrentFrame - this.VideoFrameOffset + num3 * this.VideoPlayer.PlaybackSpeed * this.VideoPlayer.FrameRate));
|
||||
var left = (double)Math.Abs(distance + num4 - offset);
|
||||
var right = (double)Math.Abs(this.CameraDistanceError);
|
||||
|
||||
@ -152,11 +155,11 @@ namespace Assets.AR
|
||||
return;
|
||||
var videoFrameAtDistance2 = this.VideoSyncSource.GetVideoFrameAtDistance(routeDistance + num4);
|
||||
var num5 = this.VideoSyncSource.AverageVideoSpeed(videoFrameAtDistance1, videoFrameAtDistance2);
|
||||
var ratio = ((double)num5 != 0.0 ? speed / num5 : 0.0f);
|
||||
var deltaRatio = (float)(((double)frame - ((double)this.VideoPlayer.CurrentFrame - (double)this.VideoFrameOffset)) / 2.0) / this.VideoPlayer.FrameRate;
|
||||
var ratio = (num5 != 0.0 ? speed / num5 : 0.0f);
|
||||
var deltaRatio = (float)((frame - (this.VideoPlayer.CurrentFrame - this.VideoFrameOffset)) / 2.0) / this.VideoPlayer.FrameRate;
|
||||
var playbackSpeed = Mathf.Clamp(ratio + deltaRatio, 0.0f, 1.5f);
|
||||
//Debug.Log(playbackSpeed);
|
||||
if ((double)playbackSpeed == (double)this.VideoPlayer.PlaybackSpeed || !this.VideoPlayer.SetPlaybackSpeed(playbackSpeed))
|
||||
|
||||
if (playbackSpeed == this.VideoPlayer.PlaybackSpeed || !this.VideoPlayer.SetPlaybackSpeed(playbackSpeed))
|
||||
return;
|
||||
this.lastPlaybackSpeedChange = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ namespace Assets.AR
|
||||
|
||||
public void UpdateCurrentFrame()
|
||||
{
|
||||
this.localCurrentFrame = (float)(this.videoPlayer.Control.GetCurrentTime() * 29.97f);
|
||||
this.localCurrentFrame = (float)(this.videoPlayer.Control.GetCurrentTime() * DefaultFps);
|
||||
}
|
||||
|
||||
public float FrameRate { get; private set; } = 29.97f;
|
||||
|
||||
@ -6,19 +6,13 @@ namespace Assets.AR
|
||||
public abstract class AbstractRenderer : ARLaneGameObject
|
||||
{
|
||||
protected Animator animator;
|
||||
protected Shader shaderNormal;
|
||||
protected Shader shaderAplha;
|
||||
|
||||
protected MaterialPropertyBlock materialPropertyBlock;
|
||||
|
||||
private bool paused = true;
|
||||
|
||||
public bool Male { get; protected set; }
|
||||
|
||||
public Texture2D JerseyTexture { get; set; }
|
||||
|
||||
public Color ColorSkin { get; set; }
|
||||
|
||||
public Color ColorUser { get; set; }
|
||||
|
||||
|
||||
public bool Paused
|
||||
{
|
||||
get => this.paused;
|
||||
@ -35,8 +29,6 @@ namespace Assets.AR
|
||||
{
|
||||
base.Awake();
|
||||
this.animator = this.GetComponent<Animator>();
|
||||
//this.shaderAplha = Shader.Find("Rouvy/RiderShaderOneAlpha");
|
||||
//this.shaderNormal = Shader.Find("Rouvy/RiderShaderOne");
|
||||
this.materialPropertyBlock = new MaterialPropertyBlock();
|
||||
}
|
||||
|
||||
@ -44,7 +36,7 @@ namespace Assets.AR
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.animator.avatar = (Avatar)null;
|
||||
this.animator.avatar = null;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -62,14 +54,5 @@ namespace Assets.AR
|
||||
foreach (Component component in obj.transform)
|
||||
this.SetLayerRecursively(component.gameObject, layer);
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = 1)]
|
||||
public struct ShaderID
|
||||
{
|
||||
public static int mainTex = Shader.PropertyToID("_MainTex");
|
||||
public static int opacity = Shader.PropertyToID("_Opacity");
|
||||
public static int colorCustom = Shader.PropertyToID("_ColorCustom");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,9 +7,9 @@ namespace Assets.AR
|
||||
{
|
||||
public static bool CircleCenter(Vector3 aP0, Vector3 aP1, Vector3 aP2, out Vector3 center)
|
||||
{
|
||||
Vector3 lhs = aP1 - aP0;
|
||||
Vector3 vector3 = aP2 - aP0;
|
||||
Vector3 rhs = Vector3.Cross(lhs, vector3);
|
||||
var lhs = aP1 - aP0;
|
||||
var vector3 = aP2 - aP0;
|
||||
var rhs = Vector3.Cross(lhs, vector3);
|
||||
if ((double)rhs.sqrMagnitude < 9.9999998245167E-15)
|
||||
{
|
||||
center = Vector3.zero;
|
||||
@ -21,12 +21,12 @@ namespace Assets.AR
|
||||
center = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
Vector3 normalized1 = Vector3.Cross(lhs, rhs).normalized;
|
||||
Vector3 normalized2 = Vector3.Cross(vector3, rhs).normalized;
|
||||
Vector3 from = (lhs - vector3) * 0.5f;
|
||||
float num1 = Vector3.Angle(normalized1, normalized2);
|
||||
float num2 = Vector3.Angle(from, normalized1);
|
||||
float num3 = from.magnitude * Mathf.Sin(num2 * ((float)Math.PI / 180f)) / Mathf.Sin(num1 * ((float)Math.PI / 180f));
|
||||
var normalized1 = Vector3.Cross(lhs, rhs).normalized;
|
||||
var normalized2 = Vector3.Cross(vector3, rhs).normalized;
|
||||
var from = (lhs - vector3) * 0.5f;
|
||||
var num1 = Vector3.Angle(normalized1, normalized2);
|
||||
var num2 = Vector3.Angle(from, normalized1);
|
||||
var num3 = from.magnitude * Mathf.Sin(num2 * ((float)Math.PI / 180f)) / Mathf.Sin(num1 * ((float)Math.PI / 180f));
|
||||
center = (double)Vector3.Dot(lhs, aP2 - aP1) <= 0.0 ? aP0 + vector3 * 0.5f + normalized2 * num3 : aP0 + vector3 * 0.5f - normalized2 * num3;
|
||||
return !float.IsInfinity(center.x) && !float.IsNaN(center.x) && !float.IsInfinity(center.y) && !float.IsNaN(center.y) && !float.IsInfinity(center.z) && !float.IsNaN(center.z);
|
||||
}
|
||||
|
||||
@ -39,13 +39,13 @@ namespace Assets.AR
|
||||
|
||||
public static double Lerp(double x1, double y1, double x2, double y2, double x)
|
||||
{
|
||||
double t = x1 != x2 ? PFMath.InverseLerp(x1, x2, x) : 0.5;
|
||||
var 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 ? PFMath.InverseLerp(x1, x2, x) : 0.5f;
|
||||
var t = (double)x1 != (double)x2 ? PFMath.InverseLerp(x1, x2, x) : 0.5f;
|
||||
return PFMath.Lerp(y1, y2, t);
|
||||
}
|
||||
|
||||
@ -67,13 +67,13 @@ namespace Assets.AR
|
||||
|
||||
public static double SmoothStep(double x1, double y1, double x2, double y2, double x)
|
||||
{
|
||||
double t = x1 != x2 ? PFMath.InverseLerp(x1, x2, x) : 0.5;
|
||||
var 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 ? PFMath.InverseLerp(x1, x2, x) : 0.5f;
|
||||
var t = (double)x1 != (double)x2 ? PFMath.InverseLerp(x1, x2, x) : 0.5f;
|
||||
return PFMath.SmoothStep(y1, y2, t);
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ namespace Assets.AR
|
||||
Vector3d lineStart,
|
||||
Vector3d lineEnd)
|
||||
{
|
||||
double lineParameter = PFMath.ProjectPointToLineParameter(point, lineStart, lineEnd);
|
||||
var lineParameter = PFMath.ProjectPointToLineParameter(point, lineStart, lineEnd);
|
||||
return Vector3d.LerpClamped(lineStart, lineEnd, lineParameter);
|
||||
}
|
||||
|
||||
@ -123,8 +123,8 @@ namespace Assets.AR
|
||||
Vector3d lineStart,
|
||||
Vector3d lineEnd)
|
||||
{
|
||||
Vector3d rhs = point - lineStart;
|
||||
Vector3d vector3d = lineEnd - lineStart;
|
||||
var rhs = point - lineStart;
|
||||
var vector3d = lineEnd - lineStart;
|
||||
return Vector3d.Dot(vector3d, rhs) / Vector3d.SqrMagnitude(vector3d);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,15 +105,15 @@ namespace Assets.AR
|
||||
if (this.route == null)
|
||||
return;
|
||||
base.Update();
|
||||
float num = this.Speed;
|
||||
var num = this.Speed;
|
||||
this.Paused = this.Speed == 0;
|
||||
bool flag = this.Paused;
|
||||
var flag = this.Paused;
|
||||
if (this.IsAtFinish)
|
||||
{
|
||||
if ((double)this.afterFinishTime < 5.0)
|
||||
{
|
||||
this.ManualVisibility = 1000f;
|
||||
float videoSpeedAtDistance = this.videoSync.GetVideoSpeedAtDistance(this.Distance - 5f);
|
||||
var videoSpeedAtDistance = this.videoSync.GetVideoSpeedAtDistance(this.Distance - 5f);
|
||||
if ((double)this.afterFinishFrame == 0.0 && (double)this.afterFinishOffsetZ == 0.0)
|
||||
{
|
||||
this.finishPassSpeed = (double)this.lastSpeed > 0.0 ? this.lastSpeed : 10f;
|
||||
@ -173,12 +173,17 @@ namespace Assets.AR
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
////if (this.Paused || (double)this.Speed <= 0.0)
|
||||
//if ((double)this.Speed <= 0.0)
|
||||
// return;
|
||||
//float angle = (float)VTMath.Clamp(VTMath.Lerp(0.0, 0.0, 1689.3684817282528, 6.5, 360.0 * ((double)this.Speed < 10.0 ? (double)this.Speed : 2.3463451135114624)), 0.0, 6.5);
|
||||
//this.wheelFront.transform.Rotate(Vector3.right, angle);
|
||||
//this.wheelRear.transform.Rotate(Vector3.right, angle);
|
||||
//if (this.Paused || (double)this.Speed <= 0.0)
|
||||
if ((double)this.Speed <= 0.0)
|
||||
return;
|
||||
//ControlWheelRotation();
|
||||
}
|
||||
|
||||
private void ControlWheelRotation()
|
||||
{
|
||||
var angle = (float)PFMath.Clamp(PFMath.Lerp(0.0, 0.0, 1689.3684817282528, 6.5, 360.0 * ((double)this.Speed < 10.0 ? (double)this.Speed : 2.3463451135114624)), 0.0, 6.5);
|
||||
this.wheelFront.transform.Rotate(Vector3.right, angle);
|
||||
this.wheelRear.transform.Rotate(Vector3.right, angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user