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