public void DoAutoCenter(Vector3 center) { for (int i = 0; i < MeshObjectList.Count; i++) { NullMeshObject meshObject = MeshObjectList[i]; for (int j = 0; j < meshObject.GetVertexCount(); j++) { Vector3 v = Vector3.zero; meshObject.GetVertex(j, ref v); v -= center; meshObject.SetVertex(j, v); } } }
public void GetCenter(ref Vector3 result) { result = Vector3.zero; int totalCount = 0; for (int i = 0; i < MeshObjectList.Count; i++) { NullMeshObject meshObject = MeshObjectList[i]; meshObject.GetCenter(ref result); totalCount += meshObject.GetVertexCount(); } if (totalCount == 0) { return; } result = result * (1.0f / totalCount); }