2017-03-16 3 views
0

部屋のサイズに応じて、部屋の点群スキャンから生成されるメッシュがあります。頂点の数は、 (650,000)。ユニティで大規模でセグメント化されていないメッシュのランタイムロード

私はこれらのメッシュをエディタにインポートすることができ、ユニティはそれらを自動的にサブメッシュに分割します。実行時にこのルーチンにスクリプトでアクセスする方法はありますか?

答えて

0

あなたが言ったように、メッシュは、実行時またはエディタで650,000を超える頂点を含むことはできません。

実行時にメッシュを生成する必要があります。例えば、100000の頂点与えられ、その後、次のようなメッシュを作成します。

// 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; 
} 
+0

ちょうど は、実行時にアプリ内でこれらを使用することが可能です、または彼らは厳密にあり、リンクされたクラスで簡単に見ていました編集者? – Rampartisan

+0

エディターでのみ利用可能です。私は答えを更新します。 – zwcloud

+0

ああ、メッシュを分割する方法を決めるのは簡単ではないので、手動で行う必要はないと思っていました。 これまでのおかげで、メッシュデータを分割する方法についてのアドバイスはありますか? – Rampartisan

関連する問題