コード例 #1
0
        public Vector3[] GetPointsArray(Transform transform, FreeformMesh mesh)
        {
            List <Vector3> points = new List <Vector3>();

            foreach (var v in vertices)
            {
                Vector3 pos = mesh.vertices[v].position;
                pos = transform.TransformPoint(pos);
                points.Add(pos);
            }

            return(points.ToArray());
        }
コード例 #2
0
        public Vector3 GetNormal(FreeformMesh mesh)
        {
            if (vertices == null || vertices.Count < 3)
            {
                return(Vector3.zero);
            }

            Vector3 normal = Vector3.zero;

            for (int i = 0; i < vertices.Count; i++)
            {
                int j = (i + 1) % vertices.Count;

                Vector3 v1 = mesh.vertices[vertices[i]].position;
                Vector3 v2 = mesh.vertices[vertices[j]].position;

                normal.x += (v1.y - v2.y) * (v1.z + v2.z);
                normal.y += (v1.z - v2.z) * (v1.x + v2.x);
                normal.z += (v1.x - v2.x) * (v1.y + v2.y);
            }

            return(normal.normalized);
        }
コード例 #3
0
 public Vector3 GetCenter(FreeformMesh mesh)
 {
     return(mesh.GetVerticesCenter(vertices));
 }