Exemplo n.º 1
0
    void RegenerateMesh(MeshDataEntry meshData)
    {
        // Unfold the 2d array of verticies into a 1d array.
        Vector3[] unfolded_verts = UnfoldVertices(meshData.verts);

        // Set mesh data.
        meshArray[meshData.sector].mesh.vertices = unfolded_verts;

        // Assign the mesh object and update it.
        meshArray[meshData.sector].mesh.RecalculateBounds();
        meshArray[meshData.sector].mesh.RecalculateNormals();
    }
Exemplo n.º 2
0
    void UpdateFinishMesh()
    {
        gameObjectArray[currentSector].AddComponent <MeshDataEntry>();
        MeshDataEntry mde = gameObjectArray[currentSector].GetComponent <MeshDataEntry>();

        mde.row    = currentRow;
        mde.column = currentColumn;
        mde.sector = currentSector;
        mde.verts  = verts;

        meshes.Add(mde);
        if (!meshMatrix.ContainsKey(mde.row))
        {
            meshMatrix[mde.row] = new Dictionary <int, MeshDataEntry>();
        }
        meshMatrix[mde.row][mde.column] = mde;

        // Unfold the 2d array of verticies into a 1d array.
        Vector3[] unfolded_verts = UnfoldVertices(verts);

        // Set mesh data.
        meshArray[currentSector].mesh.vertices  = unfolded_verts;
        meshArray[currentSector].mesh.triangles = tris.ToArray();
        meshArray[currentSector].mesh.uv        = uvs.ToArray();

        // Assign the mesh object and update it.
        meshArray[currentSector].mesh.RecalculateBounds();
        meshArray[currentSector].mesh.RecalculateNormals();
        gameObjectArray[currentSector].GetComponent <MeshCollider>().sharedMesh = meshArray[currentSector].mesh;

        // Finished Building Mesh
        buildingMesh = false;

        //Remove generation entry
        meshGenerationList.RemoveAt(0);
    }