public static Vector3 GetPlaneCenter(PlacenotePlaneMeshRender plane) { Mesh m = plane.GetComponent <MeshFilter> ().mesh; Vector3 meshCenter = Vector3.zero; // Mesh m = planes [i].GetComponent<MeshFilter> ().mesh; for (int k = 0; k < Mathf.Min(10, m.vertexCount); k++) { meshCenter += m.vertices [k]; // planes [i].transform.TransformPoint (m.vertices [k]); } meshCenter /= Mathf.Min(10, m.vertexCount); return(plane.transform.TransformPoint(meshCenter)); }
public static PlaneType DeterminePlaneType(PlacenotePlaneMeshRender plane) { Vector3[] tri = new Vector3[] { plane.GetComponent <MeshFilter>().mesh.vertices[plane.GetComponent <MeshFilter>().mesh.triangles[0]], plane.GetComponent <MeshFilter>().mesh.vertices[plane.GetComponent <MeshFilter>().mesh.triangles[1]], plane.GetComponent <MeshFilter>().mesh.vertices[plane.GetComponent <MeshFilter>().mesh.triangles[2]] }; if (tri[0].y == tri[1].y && tri[1].y == tri[2].y) { return(PlaneType.Horizontal); } else { return(PlaneType.Vertical); } // return PlaneType.Horizontal; }