阴影强度以及视频播放速度最大值

This commit is contained in:
lishuo 2022-11-29 18:42:29 +08:00
parent 158fab27ab
commit 3c64109090
6 changed files with 68 additions and 44553 deletions

View File

@ -49,16 +49,20 @@ 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<ARObject>());
SetupCamera();
}
protected virtual void SetupCamera()
{
this.camGo = new GameObject("ARCamera");
this.camGo.transform.parent = this.transform;
this.UnityCamera = this.camGo.AddComponent<Camera>();
this.UnityCamera.cullingMask = 512;
this.UnityCamera.clearFlags = CameraClearFlags.Nothing;
this.UnityCamera.depth = 1f;
//this.camGo = new GameObject("ARCamera");
//this.camGo.transform.parent = this.transform;
//this.UnityCamera = this.camGo.AddComponent<Camera>();
//this.UnityCamera.cullingMask = 512;
//this.UnityCamera.clearFlags = CameraClearFlags.Nothing;
//this.UnityCamera.depth = 1f;
this.UnityCamera = Camera.main;
}
public virtual void SetArRoute(ARRoute route, VideoPointsSync videoSync,AVProVideoPlayer mediaPlayer)
@ -125,8 +129,7 @@ namespace Assets.AR
{
if (this.Route == null)
return;
this.arObjects.Clear();
this.arObjects.AddRange(FindObjectsOfType<ARObject>());
float num1 = this.videoPlayer.CurrentFrame - (float)this.Route.VideoFrameOffset;
{
this.cameraPositionOffset = this.Route.GetCameraPosition(num1) - this.CameraOriginOffset;

View File

@ -211,6 +211,11 @@ namespace Assets
return (double)index + num - 1.0;
}
public double GetTotalDistance()
{
return FrameDistances[FrameDistances.Length-1];
}
public double GetDistanceForFrame(double frame)
{
int index = (int)Math.Ceiling(frame);

View File

@ -116,7 +116,7 @@ namespace Assets.AR
this.afterFinishTime += Time.deltaTime;
this.afterFinishTime = Math.Min(5f, this.afterFinishTime);
num = Mathf.Lerp(this.finishPassSpeed, 0.0f, this.afterFinishTime / 5f);
//this.afterFinishFrame += num / videoSpeedAtDistance * Time.deltaTime * this.VideoPlayer.FrameRate;
this.afterFinishFrame += num / videoSpeedAtDistance * Time.deltaTime * 29.97f;
this.frame = Math.Min((float)(this.route.CameraPositions.Length - 1), this.videoSync.GetVideoFrameAtDistance(this.Distance) + this.afterFinishFrame);
if ((double)this.frame == (double)(this.route.CameraPositions.Length - 1))
this.afterFinishOffsetZ += num * Time.deltaTime;

View File

@ -60,6 +60,23 @@ namespace Assets.Scripts.Scenes.VideoRide
private void CreateBackLight()
{
GameObject gameObject1 = new GameObject("ARLight");
gameObject1.layer = this.gameObject.layer;
gameObject1.transform.SetParent(this.transform);
this.arLight = gameObject1.AddComponent<Light>();
this.arLight.type = LightType.Directional;
this.arLight.transform.rotation = Quaternion.Euler(90f, 0.0f, 0.0f);
//if (this.BuildConfig.IsIOs || this.BuildConfig.IsTvOs)
//{
// this.arLight.shadows = LightShadows.Hard;
// this.arLight.shadowStrength = 0.5f;
//}
//else
{
this.arLight.shadows = LightShadows.Soft;
this.arLight.shadowStrength = 1f;
}
this.arLight.cullingMask = 512;
GameObject gameObject2 = new GameObject("ARBackLight");
gameObject2.layer = this.gameObject.layer;
gameObject2.transform.SetParent(this.transform);
@ -86,10 +103,11 @@ namespace Assets.Scripts.Scenes.VideoRide
{
if (item.StartPosition == 1)
{
item.TestPower = new System.Random().Next(90, 120);
item.TestPower = new System.Random().Next(500, 720);
}
item.Speed = (float)(Assets.Scenes.Ride.Scripts.Helper.CalculateSpeed(0, 0, item.TestPower, weight, bikeWeight) / 3.6d);
item.DeltaDistance = item.Speed;
item.Route = Route;
item.VideoSync = videoPointsSync;
if (!this.riderObjects.ContainsKey(item.GetInstanceID()))
@ -103,6 +121,10 @@ namespace Assets.Scripts.Scenes.VideoRide
{
item.Distance += item.DeltaDistance * Time.deltaTime;
item.RouteDistance += item.DeltaDistance * Time.deltaTime;
if (item.Distance >= Route.GetTotalDistance())
{
item.IsAtFinish = true;
}
}
this.UpdateCameraFollowDistance();
VideoPlayerControl.UpdateVideoPlaybackSpeed(mainObject.Speed, mainObject.distance);
@ -111,7 +133,7 @@ namespace Assets.Scripts.Scenes.VideoRide
base.Update();
this.UpdateRidersVisibility();
this.UpdateRidersLean();
this.UpdateBackLight();
if (Input.GetKeyDown(KeyCode.F))
this.SetVideoControlMode(VideoControlMode.Front);
if (Input.GetKeyDown(KeyCode.P))
@ -263,6 +285,23 @@ namespace Assets.Scripts.Scenes.VideoRide
riderObject.Lean = new Vector3(0.0f, y, z1);
}
}
//更新后背的光线
private void UpdateBackLight()
{
//if (this.SelectedPanorama != null)
//{
// this.arBackLight.transform.position = this.PanoramaCamera.transform.position;
// this.arBackLight.transform.rotation = this.PanoramaCamera.transform.rotation;
//}
//else
{
this.arBackLight.transform.position = this.UnityCamera.transform.position;
this.arBackLight.transform.rotation = this.UnityCamera.transform.rotation;
}
this.arLight.transform.rotation = this.Route.GetLightDirection(this.videoPlayer.CurrentFrame);
this.arLight.shadowStrength = this.Route.GetShadowIntensity(this.videoPlayer.CurrentFrame);
}
#endif
//人物状态
private string ConfigPath = Application.streamingAssetsPath + "/newdirection.txt";

View File

@ -153,8 +153,8 @@ namespace Assets.AR
float 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;
float playbackSpeed = Mathf.Clamp(ratio + deltaRatio, 0.0f, 1.5f);
float playbackSpeed = Mathf.Clamp(ratio + deltaRatio, 0.0f, 1.8f);
Debug.Log(playbackSpeed);
if ((double)playbackSpeed == (double)this.VideoPlayer.PlaybackSpeed || !this.VideoPlayer.SetPlaybackSpeed(playbackSpeed))
return;
this.lastPlaybackSpeedChange = DateTime.UtcNow;

File diff suppressed because it is too large Load Diff