Quantcast
Viewing all articles
Browse latest Browse all 92

joining heightmap on planes

I've got a cube which consist of 6 planes i created. to those planes i attach some height map. i created them myself and the edges of the different height maps are copied to adjacent planes. now because of some rounding errors or something the seems between the two planes have gaps in them. eventually i want to make the planes so big that simply joining meshes wont work my question, how can i weld two vertices's i tried putting them on the same spot in space, but i still have some distance between them. void Connectsectors(GameObject bottom,GameObject front,GameObject left,GameObject rear, GameObject right,GameObject top){ int[] topSide=new int[Size+1]; int[] bottomSide=new int[Size+1]; int[] leftSide=new int[Size+1]; int[] rightSide=new int[Size+1]; for (int i=0;i<(Size+1);i++) { Debug.Log(i); leftSide[i]=i; rightSide[i]=(Size+1)*Size+i; bottomSide[i]=i*(Size+1); topSide[i]=(i+1)*(Size+1)-1; Debug.Log("left"+leftSide[i]); Debug.Log("right"+rightSide[i]); Debug.Log("top"+topSide[i]); Debug.Log("bottom"+bottomSide[i]); } Vector3[] verticesBottom=new Vector3[(Size+1)*(Size+1)]; Vector3[] verticesFront=new Vector3[(Size+1)*(Size+1)]; Vector3[] verticesLeft=new Vector3[(Size+1)*(Size+1)]; Vector3[] verticesRear=new Vector3[(Size+1)*(Size+1)]; Vector3[] verticesRight=new Vector3[(Size+1)*(Size+1)]; Vector3[] verticesTop=new Vector3[(Size+1)*(Size+1)]; verticesBottom=bottom.GetComponent().mesh.vertices; verticesFront=front.GetComponent().mesh.vertices; verticesLeft=left.GetComponent().mesh.vertices; verticesRear=rear.GetComponent().mesh.vertices; verticesRight=right.GetComponent().mesh.vertices; verticesTop=top.GetComponent().mesh.vertices; for (int j=0;j<(Size+1);j++){ verticesFront[leftSide[j]]=verticesLeft[rightSide[j]]; verticesLeft[leftSide[j]]=verticesRear[rightSide[j]]; verticesRear[leftSide[j]]=verticesRight[rightSide[j]]; verticesRight[leftSide[j]]=verticesFront[rightSide[j]]; verticesBottom[bottomSide[j]]=verticesRear[bottomSide[Size+1-j]]; verticesBottom[leftSide[j]]=verticesLeft[bottomSide[j]]; verticesBottom[rightSide[j]]=verticesRight[bottomSide[Size+1-j]]; verticesBottom[topSide[j]]=verticesFront[bottomSide[j]]; verticesTop[bottomSide[j]]=verticesFront[topSide[j]]; verticesTop[leftSide[j]]=verticesLeft[topSide[Size+1-j]]; verticesTop[rightSide[j]]=verticesRight[topSide[j]]; verticesTop[topSide[j]]=verticesRear[topSide[Size+1-j]]; } bottom.GetComponent().mesh.vertices = verticesBottom; bottom.GetComponent().mesh.RecalculateBounds(); bottom.GetComponent().mesh.RecalculateNormals(); front.GetComponent().mesh.vertices = verticesFront; front.GetComponent().mesh.RecalculateBounds(); front.GetComponent().mesh.RecalculateNormals(); left.GetComponent().mesh.vertices = verticesLeft; left.GetComponent().mesh.RecalculateBounds(); left.GetComponent().mesh.RecalculateNormals(); rear.GetComponent().mesh.vertices = verticesRear; rear.GetComponent().mesh.RecalculateBounds(); rear.GetComponent().mesh.RecalculateNormals(); right.GetComponent().mesh.vertices = verticesRight; right.GetComponent().mesh.RecalculateBounds(); right.GetComponent().mesh.RecalculateNormals(); top.GetComponent().mesh.vertices = verticesTop; top.GetComponent().mesh.RecalculateBounds(); top.GetComponent().mesh.RecalculateNormals(); }

Viewing all articles
Browse latest Browse all 92

Trending Articles