Last active
August 8, 2017 17:53
-
-
Save kaorun55/85e395ec823dc3d2bd827ed7762e8ff0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IEnumerator UpdateMesh() | |
{ | |
while (true) | |
{ | |
Vector3 min = Vector3.zero; | |
Vector3 max = Vector3.zero; | |
var filters = mapping.GetMeshFilters(); | |
text.text = ""; | |
text.text += string.Format("Mesh Count : {0}\n", filters.Count); | |
foreach (var filter in filters) | |
{ | |
var mesh = filter.sharedMesh; | |
foreach (var vertex in mesh.vertices) | |
{ | |
// ローカル座標をワールド座標に変換する | |
var v = filter.transform.TransformPoint(vertex); | |
// 最小、最大値を取得 | |
min.x = Mathf.Min(v.x, min.x); | |
min.y = Mathf.Min(v.y, min.y); | |
min.z = Mathf.Min(v.z, min.z); | |
max.x = Mathf.Max(v.x, max.x); | |
max.y = Mathf.Max(v.y, max.y); | |
max.z = Mathf.Max(v.z, max.z); | |
} | |
} | |
text.text += string.Format("Min Point : {0},{1},{2}\n", min.x, min.y, min.z); | |
text.text += string.Format("Max Point : {0},{1},{2}\n", max.x, max.y, max.z); | |
cubes[0].transform.localPosition = new Vector3(min.x, min.y, min.z); | |
cubes[1].transform.localPosition = new Vector3(min.x, min.y, max.z); | |
cubes[2].transform.localPosition = new Vector3(max.x, min.y, max.z); | |
cubes[3].transform.localPosition = new Vector3(max.x, min.y, min.z); | |
cubes[4].transform.localPosition = new Vector3(min.x, max.y, min.z); | |
cubes[5].transform.localPosition = new Vector3(min.x, max.y, max.z); | |
cubes[6].transform.localPosition = new Vector3(max.x, max.y, max.z); | |
cubes[7].transform.localPosition = new Vector3(max.x, max.y, min.z); | |
yield return SaveMesh(); | |
yield return new WaitForSeconds(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment