Failed Getting triangles & Failed setting Triangles - Using Quixel Voxel Terrain
I am trying to use the Quixel Voxel terrain engine found here: https://forum.unity3d.com/threads/open-source-quixel-terrain-engine-smooth-voxel-terrain.240645/
It was made for unity 4.6 but I am trying to update it to unity 5; however, some things have changed with how submeshes work and it is giving me the error:
&Failed getting triangles. Submesh topology is lines or points.
Failed setting triangles. Some indices are referencing out of bounds vertices. IndexCount: 3, VertexCount: 0
When using
if (mesh.GetTriangles(i).Length < 3)
{
mesh.SetTriangles(new int[3] { 0, 0, 0 }, i);
}
Without using this code snippet it gives me the error:
Failed getting triangles. Submesh 1 has no indices. Mesh asset path "Assets/Testing.unity" Mesh name ""
public void setMesh(MeshData meshData)
{
densityData.setChangeData(densityChangeData);
regenReq = false;
if (regenFlag)
{
regenFlag = false;
regenReq = true;
MeshFactory.requestMesh(this);
}
hasMesh = true;
if (meshData.indexArray.Length == 0)
return;
if (chunk == null)
{
chunk = ChunkPool.getChunk();
if (LOD > 2)
chunk.transform.position = position - new Vector3(0f, (NodeManager.LODSize[LOD] / 2f), 0f);
else
chunk.transform.position = position;
chunk.GetComponent<MeshFilter>().mesh.subMeshCount = QuixelEngine.materials.Length;
chunk.GetComponent<MeshRenderer>().materials = QuixelEngine.materials;
}
empty = false;
Mesh mesh = new Mesh();
mesh.subMeshCount = QuixelEngine.materials.Length;
mesh.vertices = meshData.triangleArray;
for (int i = 0; i < QuixelEngine.materials.Length; i++)
{
if (meshData.indexArray[i].Length > 0)
{
mesh.SetTriangles(meshData.indexArray[i], i);
}
if (mesh.GetTriangles(i).Length < 3)
{
mesh.SetTriangles(new int[3] { 0, 0, 0 }, i);
}
}
//mesh.triangles = meshData.indexArray;
mesh.uv = meshData.uvArray;
mesh.normals = meshData.normalArray;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
mesh.Optimize();
chunk.GetComponent<MeshFilter>().mesh = mesh;
if (LOD == 0 && collides)
chunk.GetComponent<MeshCollider>().sharedMesh = null;
chunk.GetComponent<MeshCollider>().sharedMesh = mesh;
meshData.dispose();
mesh.Clear();
renderCheck();
switch (renderType)
{
case RenderType.BACK:
if (chunk != null)
chunk.layer = 9;
break;
case RenderType.FRONT:
if (chunk != null)
chunk.layer = 8;
break;
}
if (parent != null)
parent.renderCheck();
}
Any Help would be very much appriciated
Your answer
Follow this Question
Related Questions
I can see the outline of my objects but there invisible? 2 Answers
Best way to display a 2D shape from x,y positions 0 Answers
2d Mesh with texture 0 Answers
Why is my mesh not showing outside of an area? 0 Answers
Code generated mesh not visible 1 Answer