Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GameObject clone = UnityObjectPool.GetObject();
- Color c = UtilFuncs.SinColor(chunk.LOD * 3f);
- clone.GetComponent<MeshRenderer>().material.color = new Color(c.r, c.g, c.b, 0.9f);
- clone.GetComponent<MeshRenderer>().material.SetInt("_LOD", chunk.LOD);
- clone.GetComponent<MeshRenderer>().material.SetVector("_ChunkPosition", new Vector4(chunk.Position.x, chunk.Position.y, chunk.Position.z));
- clone.name = "Node " + chunk.Key + ", LOD " + chunk.LOD;
- MeshFilter mf = clone.GetComponent<MeshFilter>();
- mf.mesh.SetVertices(chunk.Vertices);
- mf.mesh.SetNormals(chunk.Normals);
- mf.mesh.SetUVs(0, chunk.LOD1Vertices);
- mf.mesh.SetUVs(1, chunk.LOD1Normals);
- mf.mesh.triangles = chunk.Triangles;
- clone.GetComponent<Transform>().SetParent(Parent);
- clone.GetComponent<Transform>().SetPositionAndRotation(chunk.Position, Quaternion.identity);
- clone.GetComponent<Transform>().localScale = Vector3.one * ((float)MinimumChunkSize / (float)Resolution) * Mathf.Pow(2, chunk.LOD);
- chunk.State = ChunkState.Completed;
- chunk.UnityObject = clone;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement