Esempio n. 1
0
        private static WaterCustomSurfaceMeshes.Edge[] BuildManifoldEdges(Mesh mesh)
        {
            WaterCustomSurfaceMeshes.Edge[]      array = WaterCustomSurfaceMeshes.BuildEdges(mesh.vertexCount, mesh.triangles);
            List <WaterCustomSurfaceMeshes.Edge> list  = new List <WaterCustomSurfaceMeshes.Edge>();

            foreach (WaterCustomSurfaceMeshes.Edge item in array)
            {
                if (item.FaceIndex0 == item.FaceIndex1)
                {
                    list.Add(item);
                }
            }
            return(list.ToArray());
        }
Esempio n. 2
0
 public void OnDrawGizmos()
 {
     if (this._Geometry != null && this._Geometry.GeometryType == WaterGeometry.Type.CustomMeshes)
     {
         WaterCustomSurfaceMeshes customSurfaceMeshes = this._Geometry.CustomSurfaceMeshes;
         for (int i = 0; i < customSurfaceMeshes.Meshes.Length; i++)
         {
             Gizmos.matrix = base.transform.localToWorldMatrix;
             Gizmos.color  = Color.cyan * 0.2f;
             Gizmos.DrawMesh(customSurfaceMeshes.Meshes[i]);
             Gizmos.color = Color.cyan * 0.4f;
             Gizmos.DrawWireMesh(customSurfaceMeshes.Meshes[i]);
         }
     }
 }
Esempio n. 3
0
        private Mesh CreateBoundaryMesh(Mesh sourceMesh)
        {
            Mesh mesh = new Mesh
            {
                hideFlags = HideFlags.DontSave
            };

            Vector3[]      vertices = sourceMesh.vertices;
            List <Vector3> list     = new List <Vector3>();
            List <int>     list2    = new List <int>();

            WaterCustomSurfaceMeshes.Edge[] array = WaterCustomSurfaceMeshes.BuildManifoldEdges(sourceMesh);
            Vector3 vector = default(Vector3);
            int     item   = array.Length * 4;

            for (int i = 0; i < array.Length; i++)
            {
                int     count   = list.Count;
                Vector3 vector2 = vertices[array[i].VertexIndex0];
                Vector3 vector3 = vertices[array[i].VertexIndex1];
                list.Add(vector2);
                list.Add(vector3);
                vector2.y -= 1000f;
                vector3.y -= 1000f;
                list.Add(vector2);
                list.Add(vector3);
                list2.Add(count + 3);
                list2.Add(count + 2);
                list2.Add(count);
                list2.Add(count + 3);
                list2.Add(count);
                list2.Add(count + 1);
                list2.Add(count + 3);
                list2.Add(count + 2);
                list2.Add(item);
                vector += vector2;
                vector += vector3;
            }
            int num = list.Count / 2;

            vector /= (float)num;
            list.Add(vector);
            mesh.vertices = list.ToArray();
            mesh.SetIndices(list2.ToArray(), MeshTopology.Triangles, 0);
            return(mesh);
        }