diff --git a/Assets/Scenes/CourseAPieds/sceneCourseAPied.unity b/Assets/Scenes/CourseAPieds/sceneCourseAPied.unity index a574d0efda6c03da236a0cf7b59ea28680b285a4..84753ba5e7124cc1616d3e8a274c71987c9a481b 100644 --- a/Assets/Scenes/CourseAPieds/sceneCourseAPied.unity +++ b/Assets/Scenes/CourseAPieds/sceneCourseAPied.unity @@ -178,7 +178,7 @@ Terrain: m_DrawTreesAndFoliage: 1 m_StaticShadowCaster: 0 m_ReflectionProbeUsage: 1 - m_MaterialTemplate: {fileID: 10652, guid: 0000000000000000f000000000000000, type: 0} + m_MaterialTemplate: {fileID: 2100000, guid: 594ea882c5a793440b60ff72d896021e, type: 2} m_BakeLightProbesForTrees: 1 m_PreserveTreePrototypeLayers: 0 m_DeringLightProbesForTrees: 1 @@ -211,14 +211,14 @@ MonoBehaviour: m_GameObject: {fileID: 460623921} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fd4883b8303617d4992553ff7503d039, type: 3} + m_Script: {fileID: 11500000, guid: 86c7bfd105ba6e14180f833234cbc0b8, type: 3} m_Name: m_EditorClassIdentifier: depth: 20 width: 256 height: 256 scale: 2 - values: + ptProches: --- !u!1 &705507993 GameObject: m_ObjectHideFlags: 0 @@ -229,6 +229,7 @@ GameObject: m_Component: - component: {fileID: 705507995} - component: {fileID: 705507994} + - component: {fileID: 705507996} m_Layer: 0 m_Name: Directional Light m_TagString: Untagged @@ -313,6 +314,26 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!114 &705507996 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 1 + m_UsePipelineSettings: 1 + m_AdditionalLightsShadowResolutionTier: 2 + m_LightLayerMask: 1 + m_CustomShadowLayers: 0 + m_ShadowLayerMask: 1 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} --- !u!1 &963194225 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CourseAPieds/V7.cs b/Assets/Scripts/CourseAPieds/V7.cs index 61393d7f88b2a954659f79073403e51e11049c70..123ffd6a9f979f9944ec6b44dce94d1149a182f0 100644 --- a/Assets/Scripts/CourseAPieds/V7.cs +++ b/Assets/Scripts/CourseAPieds/V7.cs @@ -9,6 +9,7 @@ public class V7 : MonoBehaviour public float scale = 2f; public int[,] values; + public int[] ptProches; int dim1; int dim2; @@ -18,17 +19,17 @@ public class V7 : MonoBehaviour void Start() { - values = new int[2,5]; + values = new int[2, 5]; dim1 = values.GetLength(0); dim2 = values.GetLength(1); - for (int i = 0; i <dim1; i++) + for (int i = 0; i < dim1; i++) { for (int j = 0; j < dim2; j++) { values[i, j] = Random.Range(0, width); } } - + } void Update() @@ -51,10 +52,16 @@ public class V7 : MonoBehaviour bool PisteTest(int x, int y) { + int ptLePlusProche; for (int i = 0; i < dim2; i++) { - if (x == values[0,i] && y == values[1,i]) + if (x == values[0, i] && y == values[1, i]) { + int x1 = values[0, i]; + int y1 = values[1, i]; + int x2 = values[0, ptProches[i]]; + int y2 = values[1, ptProches[i]]; + return true; } } @@ -62,24 +69,57 @@ public class V7 : MonoBehaviour return false; } + void ptLePlusProche() + { + int ptProche = -1; + double resultPtProche = 256; + double resultPtActuel = 256; + for (int i = 0; i < dim2; i++) + { + for (int j = 0; j < dim2; j++) + { + if (values[0, j] != values[0, i] || values[1, j] != values[1, i]) + { + int x1 = values[0, i]; + int y1 = values[1, i]; + int x2 = values[0, j]; + int y2 = values[1, j]; + resultPtActuel = Mathf.Sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2); + if (resultPtActuel < resultPtProche) + { + resultPtProche = resultPtActuel; + ptProche = j; + } + } + } + ptProches[i] = ptProche; + } + } + + bool tracerChemin(int x1, int y1, int x2, int y2, int x, int y) + { + double m = (y2 - y1) / (x2 - x1); + double p = y - m * x; + bool equation = m == (p - y) / x; + return equation; + } + float[,] GenerateHeights() { float[,] heights = new float[width, height]; + for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { - if (PisteTest(x, y)) - { - heights[x, y] = 0; - } - else - { - heights[x, y] = CalculateHeight(x, y); - } + heights[x, y] = CalculateHeight(x, y); } } + for (int i = 0; i < dim2; i++) + { + heights[values[0, i], values[1, i]] = 0; + } return heights; } diff --git a/Assets/Terrains/terrainCourseAPied.asset b/Assets/Terrains/terrainCourseAPied.asset index 8ef9eb741bc93558c652027c0cd0a3e5ddb899f5..3c6110f37d3c7078cb9f0d0d97339bb3ca1a57b0 100644 Binary files a/Assets/Terrains/terrainCourseAPied.asset and b/Assets/Terrains/terrainCourseAPied.asset differ diff --git a/Assets/Third Party Assets/CourseAPieds/sceneCourseAPied.unity b/Assets/Third Party Assets/CourseAPieds/sceneCourseAPied.unity index a574d0efda6c03da236a0cf7b59ea28680b285a4..84753ba5e7124cc1616d3e8a274c71987c9a481b 100644 --- a/Assets/Third Party Assets/CourseAPieds/sceneCourseAPied.unity +++ b/Assets/Third Party Assets/CourseAPieds/sceneCourseAPied.unity @@ -178,7 +178,7 @@ Terrain: m_DrawTreesAndFoliage: 1 m_StaticShadowCaster: 0 m_ReflectionProbeUsage: 1 - m_MaterialTemplate: {fileID: 10652, guid: 0000000000000000f000000000000000, type: 0} + m_MaterialTemplate: {fileID: 2100000, guid: 594ea882c5a793440b60ff72d896021e, type: 2} m_BakeLightProbesForTrees: 1 m_PreserveTreePrototypeLayers: 0 m_DeringLightProbesForTrees: 1 @@ -211,14 +211,14 @@ MonoBehaviour: m_GameObject: {fileID: 460623921} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fd4883b8303617d4992553ff7503d039, type: 3} + m_Script: {fileID: 11500000, guid: 86c7bfd105ba6e14180f833234cbc0b8, type: 3} m_Name: m_EditorClassIdentifier: depth: 20 width: 256 height: 256 scale: 2 - values: + ptProches: --- !u!1 &705507993 GameObject: m_ObjectHideFlags: 0 @@ -229,6 +229,7 @@ GameObject: m_Component: - component: {fileID: 705507995} - component: {fileID: 705507994} + - component: {fileID: 705507996} m_Layer: 0 m_Name: Directional Light m_TagString: Untagged @@ -313,6 +314,26 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!114 &705507996 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 1 + m_UsePipelineSettings: 1 + m_AdditionalLightsShadowResolutionTier: 2 + m_LightLayerMask: 1 + m_CustomShadowLayers: 0 + m_ShadowLayerMask: 1 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} --- !u!1 &963194225 GameObject: m_ObjectHideFlags: 0