Skip to content
Snippets Groups Projects
Commit 762112cc authored by Clem's avatar Clem
Browse files

bla bla bla

parent 868515eb
Branches
No related tags found
No related merge requests found
fileFormatVersion: 2
guid: c72c868a564ccf34490890be8c2318b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-6269116704956453700
MonoBehaviour:
m_ObjectHideFlags: 11
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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CubeMaterial
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_BuildTextureStacks: []
fileFormatVersion: 2
guid: 22d7a8a62c660b6418bd5ab05fb4e7a9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
...@@ -30,13 +30,15 @@ public class V7 : MonoBehaviour ...@@ -30,13 +30,15 @@ public class V7 : MonoBehaviour
public int[] ptProches; public int[] ptProches;
int ptsChemAbscisse; int ptsChemAbscisse;
int ptsChemIndex; int ptsChemIndex;
public Rigidbody Cube;
int cmptCubes = 0;
//public float offsetX = 100f; //public float offsetX = 100f;
//public float offsetY = 100f; //public float offsetY = 100f;
void Start() void Start()
{ {
// Création du tableau des points aléatoires (chemin) // Création du tableau des points aléatoires (chemin)
pointsDuChemin = new int[2, nombreDePointsAGenerer]; pointsDuChemin = new int[2, nombreDePointsAGenerer];
// Récupère les dimensions du tableau de manière optimisée // Récupère les dimensions du tableau de manière optimisée
...@@ -144,6 +146,8 @@ public class V7 : MonoBehaviour ...@@ -144,6 +146,8 @@ public class V7 : MonoBehaviour
{ {
int x = x1; int x = x1;
int y = y1; int y = y1;
float xPositionMultiplier = terrain.terrainData.size.x / heightmapWidth;
float yPositionMultiplier = terrain.terrainData.size.z / heightmapHeight;
// On va faire un lerp entre les points // On va faire un lerp entre les points
float lerp = 0f; float lerp = 0f;
while(lerp < 1f) while(lerp < 1f)
...@@ -155,20 +159,25 @@ public class V7 : MonoBehaviour ...@@ -155,20 +159,25 @@ public class V7 : MonoBehaviour
float hauteur, hauteurAvant, hauteurApres; float hauteur, hauteurAvant, hauteurApres;
// On va tracer le chemin en largeur // On va tracer le chemin en largeur
for(int i=0; i<largeurDuChemin; i++) for(int indexLargeur=0; indexLargeur<largeurDuChemin; indexLargeur++)
{ {
if(x+i < heightmapWidth && y+i < heightmapHeight) if(x+indexLargeur < heightmapWidth && y+indexLargeur < heightmapHeight)
{ {
// On va calculer la hauteur du point par rapport aux coordonées d'avant, et d'après // On va calculer la hauteur du point par rapport aux coordonées d'avant, et d'après
if(x+i-1 < 0 || y+i-1 < 0){ if(x+indexLargeur-1 < 0 || y+indexLargeur-1 < 0){
hauteurAvant = 0; hauteurAvant = 0;
}else{
hauteurAvant = terrain.terrainData.GetHeight(x+i-1, y+i-1);
}
else{
hauteurAvant = terrain.terrainData.GetHeight(x+indexLargeur-1, y+indexLargeur-1);
} }
if(x+i+1 >= heightmapWidth || y+i+1 >= heightmapHeight){ if(x+indexLargeur+1 >= heightmapWidth || y+indexLargeur+1 >= heightmapHeight){
hauteurApres = 0; hauteurApres = 0;
}else{ }
hauteurApres = terrain.terrainData.GetHeight(x+i+1, y+i+1); else
{
hauteurApres = terrain.terrainData.GetHeight(x+indexLargeur+1, y+indexLargeur+1);
} }
// On va faire la moyenne des deux hauteurs si elles sont != 0 // On va faire la moyenne des deux hauteurs si elles sont != 0
if(hauteurAvant != 0 && hauteurApres != 0){ if(hauteurAvant != 0 && hauteurApres != 0){
...@@ -186,7 +195,19 @@ public class V7 : MonoBehaviour ...@@ -186,7 +195,19 @@ public class V7 : MonoBehaviour
hauteur = hauteur / terrain.terrainData.size.y; hauteur = hauteur / terrain.terrainData.size.y;
Debug.Log("hauteur = " + hauteur); Debug.Log("hauteur = " + hauteur);
terrain.terrainData.SetHeights(x+i, y+i, new float[,] { { hauteur, hauteur }}); terrain.terrainData.SetHeights(x+indexLargeur, y+indexLargeur, new float[,] { { hauteur, hauteur }});
if (indexLargeur == 3)
{
cmptCubes++;
if (cmptCubes == 5)
{
Rigidbody instance;
instance = Instantiate(Cube, new Vector3((x + indexLargeur) * xPositionMultiplier, hauteur * terrain.terrainData.size.y, (y + indexLargeur) * yPositionMultiplier), Quaternion.identity);
instance.GetComponent<Renderer>().material.color = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
cmptCubes = 0;
}
}
} }
} }
} }
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment