0
我有一個網格是從一個房間的點雲掃描生成的,這取決於房間的大小,頂點的數量有時可能會大於單位的最大支持的最大值(650000間)。Unity中的大型非分割網格的運行時負載
我可以將這些網格導入到編輯器中,並且unity將它們自動分解爲子網格。有沒有辦法在運行時在腳本中訪問此例程?
我有一個網格是從一個房間的點雲掃描生成的,這取決於房間的大小,頂點的數量有時可能會大於單位的最大支持的最大值(650000間)。Unity中的大型非分割網格的運行時負載
我可以將這些網格導入到編輯器中,並且unity將它們自動分解爲子網格。有沒有辦法在運行時在腳本中訪問此例程?
正如你所說的,網格在運行時或編輯器中不能包含超過650,000個頂點。
在運行時,應該分段生成網格。例如,給定10萬點的頂點,然後創建網格像以下:
// Your mesh data from the point cloud scan of a room
long[] indices = ...;
Vector3[] positions = = ...;
// Split your mesh data into two parts:
// one that have 60000 vertices and another that have 40000 vertices.
// create meshes
{
Mesh mesh = new Mesh();
GameObject obj = new GameObject();
obj.AddComponent<MeshFilter>().sharedMesh = mesh;
var positions = new Vector3[60000];
var indices = new int[count_of_indices];//The value of count_of_indices depends on how you split the mesh data.
// copy first 60000 vertices to positions and indices
mesh.vertices = positions;
mesh.triangles = indices;
}
{
Mesh mesh = new Mesh();
GameObject obj = new GameObject();
obj.AddComponent<MeshFilter>().sharedMesh = mesh;
var positions = new Vector3[4000];
var indices = new int[count_of_indices];
// copy the remaining 40000 vertices to positions and indices
mesh.vertices = positions;
mesh.triangles = indices;
}
剛剛有了一個快速瀏覽一下鏈接的類, 是否有可能在運行時在應用程序中使用這些,或者是他們嚴格的編輯? – Rampartisan
它們僅在編輯器中可用。我會更新答案。 – zwcloud
啊,我希望我不需要手動去做,因爲決定如何分割網格並不重要。 到目前爲止,感謝您的幫助,您有關於如何分割網格數據的建議嗎? – Rampartisan