public void Reserve <Builder>(Builder builder, int count) where Builder : IDebugVoxelMeshBuilder
        {
            int meshes;
            int voxelsPerSubmesh;

            if (Use32BitIndices)
            {
                voxelsPerSubmesh = count;
                meshes           = 1;
            }
            else
            {
                voxelsPerSubmesh = MaxVerticesPerSubmesh / builder.VerticesPerVoxel;
                meshes           = count / voxelsPerSubmesh + 1;
            }

            indicesPerSubmesh  = voxelsPerSubmesh * builder.PrimitivesPerVoxel * IndicesPerPrimitive(builder.Topology);
            verticesPerSubmesh = voxelsPerSubmesh * builder.VerticesPerVoxel;
            nextVertexCount    = verticesPerSubmesh;
            verticesPerVoxel   = builder.VerticesPerVoxel;

            int nVertices = count * builder.VerticesPerVoxel;

            if (Vertices.Capacity < nVertices)
            {
                Vertices.Capacity = nVertices;
            }

            SetupNestedList(Indices, meshes, indicesPerSubmesh);
            SetupNestedList(Uvs, builder.UVChannels, nVertices);

            FARLogger.InfoFormat("Reserved {0} voxels in {1} submeshes", count.ToString(), meshes.ToString());
        }
Ejemplo n.º 2
0
 private static void OnRequestComplete(RenderResult <GameObject> result)
 {
     if (!Application.isEditor)
     {
         return;
     }
     foreach (KeyValuePair <GameObject, double> pair in result)
     {
         FARLogger.InfoFormat("{0}: {1}", pair.Key, pair.Value);
     }
 }
Ejemplo n.º 3
0
        public void Apply <Builder>(Builder builder) where Builder : IDebugVoxelMeshBuilder
        {
            Mesh.Clear();
            FARLogger.InfoFormat("Built voxel mesh with {0} voxels in {1} submeshes",
                                 (Data.Vertices.Count / verticesPerVoxel).ToString(),
                                 Data.SubmeshIndices.Count.ToString());

            Mesh.SetVertices(Data.Vertices);
            Mesh.SetColors(Data.Colors);
            for (int i = 0; i < Data.Uvs.Count; i++)
            {
                if (Data.Uvs[i].Count == 0)
                {
                    continue;
                }
                Mesh.SetUVs(i, Data.Uvs[i]);
            }

            //TODO: replace with Mesh.SetIndices(List<int>, ...) when using Unity 2019.3+

            if (uInt32BitIndices)
            {
                // only 1 submesh
                Renderer.material = builder.MeshMaterial;
                Mesh.SetIndices(Data.SubmeshIndices[0].ToArray(), builder.Topology, 0);
            }
            else
            {
                // ignore empty index lists
                int count = Data.SubmeshIndices.Sum(list => list.Count == 0 ? 0 : 1);
                Mesh.subMeshCount = count;
                var materials = new Material[count];

                int offset = 0;
                int j      = 0;
                foreach (List <int> t in Data.SubmeshIndices)
                {
                    if (t.Count == 0)
                    {
                        continue;
                    }
                    Mesh.SetIndices(t.ToArray(), builder.Topology, j, false, offset);
                    offset      += verticesPerSubmesh;
                    materials[j] = builder.MeshMaterial;
                    j++;
                }

                Renderer.materials = materials;
            }
        }
Ejemplo n.º 4
0
 public void LoadAssets()
 {
     FARLogger.InfoFormat("Loading {0} bundle", BundleType);
     MainThread.StartCoroutine(Load);
 }