public void Absorb(TS_Mesh input) { if (vertices.Length != input.vertexCount) { vertices = new Vector3[input.vertexCount]; } if (normals.Length != input.normals.Length) { normals = new Vector3[input.normals.Length]; } if (colors.Length != input.colors.Length) { colors = new Color[input.colors.Length]; } if (uv.Length != input.uv.Length) { uv = new Vector2[input.uv.Length]; } if (tangents.Length != input.tangents.Length) { tangents = new Vector4[input.tangents.Length]; } if (triangles.Length != input.triangles.Length) { triangles = new int[input.triangles.Length]; } input.vertices.CopyTo(vertices, 0); input.normals.CopyTo(normals, 0); input.colors.CopyTo(colors, 0); input.uv.CopyTo(uv, 0); input.tangents.CopyTo(tangents, 0); input.triangles.CopyTo(triangles, 0); if (subMeshes.Count == input.subMeshes.Count) { for (int i = 0; i < subMeshes.Count; i++) { if (input.subMeshes[i].Length != subMeshes[i].Length) { subMeshes[i] = new int[input.subMeshes[i].Length]; } input.subMeshes[i].CopyTo(subMeshes[i], 0); } } else { subMeshes = new List <int[]>(); for (int i = 0; i < input.subMeshes.Count; i++) { subMeshes.Add(new int[input.subMeshes[i].Length]); input.subMeshes[i].CopyTo(subMeshes[i], 0); } } bounds = new TS_Bounds(input.bounds.center, input.bounds.size); }
public void Clear() { vertices = new Vector3[0]; normals = new Vector3[0]; tangents = new Vector4[0]; colors = new Color[0]; uv = new Vector2[0]; triangles = new int[0]; subMeshes = new List <int[]>(); bounds = new TS_Bounds(Vector3.zero, Vector3.zero); }
public void CreateFromMesh(Mesh mesh) { vertices = mesh.vertices; normals = mesh.normals; tangents = mesh.tangents; colors = mesh.colors; uv = mesh.uv; triangles = mesh.triangles; bounds = new TS_Bounds(mesh.bounds); for (int i = 0; i < mesh.subMeshCount; i++) { subMeshes.Add(mesh.GetTriangles(i)); } }