Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public void MovePoint (int i, Vector3 pointPos, bool suppressPathModifiedEvent =
points[i] = pointPos;

if (controlMode == ControlMode.Automatic) {
AutoSetAllAffectedControlPoints (i);
AutoSetAllControlPoints();
} else {
// Move control points with anchor point
if (isAnchorPoint) {
Expand Down
16 changes: 14 additions & 2 deletions autocopylot/Assets/Resources/Floors/floor_pattern.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions autocopylot/Assets/Scenes/RandomizedTrack.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ Mesh:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: pb_Mesh-21298
m_Name: pb_Mesh-1368
serializedVersion: 10
m_SubMeshes:
- serializedVersion: 2
Expand Down Expand Up @@ -1638,10 +1638,10 @@ Light:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 0.5
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Strength: 1
m_Bias: 0.01
m_NormalBias: 0
m_NearPlane: 0.1
m_CullingMatrixOverride:
e00: 1
e01: 0
Expand Down
390 changes: 197 additions & 193 deletions autocopylot/Assets/Scenes/RenaultDigital.unity

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions autocopylot/Assets/Scripts/Car.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,17 @@ void Update()
counter += timesteps;
if (counter > RandomizeEvery)
{
Vector3 pos = transform.position;
Randomize();

// get time from position
t = carPath.CarSpline.path.GetClosestTimeOnPath(pos);
carPath.t = t;
carPath.prevDist = carPath.CarSpline.path.GetClosestDistanceAlongPath(pos);

t += timesteps;
carPath.UpdateTransform(t);

counter = 0.0f;
}
else
Expand Down
53 changes: 42 additions & 11 deletions autocopylot/Assets/Scripts/CarPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,69 @@ public class CarPath : MonoBehaviour
public float turnTh = 20f;
public bool doDrawTurns = true;

private float t = 0.0f;
public float t = 0.0f;
private float dt = 0.0f;
private float prevDist = 0.0f;
public float prevDist = 0.0f;
private int laneRes = 10;
private float laneDist = 2.0f;

private (float, Vector3)[] zones;
private float[] averagedAngles;

public int numObstacles = 1;
private (int, Vector3)[] previous_offsets;


public void Start()
{
if (RoadSpline == null || TrajectorySpline == null || CarSpline == null)
throw new ArgumentNullException("RoadSpline, TrajectorySpline or CarSpline is null");

if (previous_offsets == null)
previous_offsets = new (int, Vector3)[numObstacles];

CreateObstacles();
CreateCarSpline();
CreateZone();
}
public void CreateObstacles()
{

foreach ((int index, Vector3 prevoffset) in previous_offsets)
{
TrajectorySpline.bezierPath.SetPoint(index, TrajectorySpline.bezierPath.GetPoint(index) - prevoffset);
}

for (int i = 0; i < numObstacles; i++)
{
// Offset a random point to insert an obstacle on the road
int randomPoint = UnityEngine.Random.Range(0, TrajectorySpline.bezierPath.NumSegments) * 3;
float offset = UnityEngine.Random.Range(0.3f, 0.5f);
bool sign = UnityEngine.Random.Range(0, 2) == 0 ? true : false;
if (sign)
offset = -offset;

Vector3 point = TrajectorySpline.bezierPath.GetPoint(randomPoint);
Vector3 normal = TrajectorySpline.path.GetNormalAtDistance(TrajectorySpline.path.GetClosestDistanceAlongPath(point));
Vector3 offsetPoint = offset * normal;
previous_offsets[i] = (randomPoint, offsetPoint);
TrajectorySpline.bezierPath.MovePoint(randomPoint, point + offsetPoint);
}
}

public void CreateCarSpline()
{
int step = 6;
int numPoints = RoadSpline.path.NumPoints / step;
int numPoints = TrajectorySpline.path.NumPoints / step;
Vector3[] points = new Vector3[numPoints];
for (int i = 0; i < points.Length; i++)
{
points[i] = RoadSpline.path.GetPoint(i * step) - RoadSpline.transform.position + RoadSpline.path.GetNormal(i) * UnityEngine.Random.Range(-RandomDist, RandomDist);
points[i] = TrajectorySpline.path.GetPoint(i * step) - TrajectorySpline.transform.position + TrajectorySpline.path.GetNormal(i) * UnityEngine.Random.Range(-RandomDist, RandomDist);
points[i] += Vector3.up * UnityEngine.Random.Range(minSpeed, maxSpeed);
}
BezierPath bezierPath = new BezierPath(points, true, PathSpace.xyz);
CarSpline.bezierPath = bezierPath;
// TODO do the same with
}

public void CreateZone()
Expand Down Expand Up @@ -159,7 +191,7 @@ public void UpdateTransform(float t)
transform.rotation = Quaternion.LookRotation(diff);

speed = (v1.y + v2.y) / 2.0f;
prevDist = dist; ;
prevDist = dist;
this.t = t;
}

Expand Down Expand Up @@ -275,13 +307,12 @@ public void OnDrawGizmos()
if (averagedAngles[i] > turnTh)
Gizmos.DrawSphere(RoadSpline.path.GetPointAtDistance(i * pointsEvery), averagedAngles[i] / 180.0f);
}
}

Vector3[] trajectory = GetTrajectory();
foreach (Vector3 trajectoryPoint in trajectory)
{
Gizmos.DrawSphere(trajectoryPoint + pos, 0.1f);
// Debug.Log(trajectoryPoint);
Vector3[] trajectory = GetTrajectory();
foreach (Vector3 trajectoryPoint in trajectory)
{
Gizmos.DrawSphere(trajectoryPoint + pos, 0.1f);
}
}
}
}
2 changes: 1 addition & 1 deletion autocopylot/Assets/Scripts/GenerateEnv.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion autocopylot/Assets/Scripts/GenerateRoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void GenerateSplines()

private void PathUpdated()
{
if (DoBuildRoad && RoadSpline != null)
if (DoBuildRoad)
{
AssignMeshComponents();
AssignMaterials();
Expand Down
2 changes: 1 addition & 1 deletion autocopylot/Assets/Scripts/GenerateRoad.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions autocopylot/ProjectSettings/QualitySettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ QualitySettings:
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 1
skinWeights: 1
textureQuality: 1
anisotropicTextures: 0
antiAliasing: 0
Expand All @@ -40,6 +40,7 @@ QualitySettings:
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 0}
excludedTargetPlatforms: []
- serializedVersion: 2
name: Low
Expand All @@ -53,7 +54,7 @@ QualitySettings:
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 2
skinWeights: 2
textureQuality: 0
anisotropicTextures: 0
antiAliasing: 0
Expand All @@ -75,6 +76,7 @@ QualitySettings:
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 0}
excludedTargetPlatforms: []
- serializedVersion: 2
name: Medium
Expand All @@ -88,7 +90,7 @@ QualitySettings:
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 2
skinWeights: 2
textureQuality: 0
anisotropicTextures: 1
antiAliasing: 0
Expand All @@ -110,6 +112,7 @@ QualitySettings:
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 0}
excludedTargetPlatforms: []
- serializedVersion: 2
name: High
Expand All @@ -123,7 +126,7 @@ QualitySettings:
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
blendWeights: 2
skinWeights: 2
textureQuality: 0
anisotropicTextures: 1
antiAliasing: 0
Expand All @@ -145,6 +148,7 @@ QualitySettings:
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 0}
excludedTargetPlatforms: []
- serializedVersion: 2
name: Very High
Expand All @@ -158,7 +162,7 @@ QualitySettings:
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
blendWeights: 4
skinWeights: 4
textureQuality: 0
anisotropicTextures: 2
antiAliasing: 2
Expand All @@ -180,24 +184,25 @@ QualitySettings:
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 0}
excludedTargetPlatforms: []
- serializedVersion: 2
name: Ultra
pixelLightCount: 4
shadows: 2
shadowResolution: 2
shadowResolution: 3
shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
blendWeights: 4
skinWeights: 4
textureQuality: 0
anisotropicTextures: 2
antiAliasing: 2
softParticles: 1
antiAliasing: 4
softParticles: 0
softVegetation: 1
realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
Expand All @@ -215,6 +220,7 @@ QualitySettings:
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 0}
excludedTargetPlatforms: []
m_PerPlatformDefaultQuality:
Android: 2
Expand Down
15 changes: 15 additions & 0 deletions autocopylot/ProjectSettings/TimelineSettings.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
m_Name:
m_EditorClassIdentifier:
assetDefaultFramerate: 60