Пример #1
0
    void buildGround()
    {
        PlaneBuilder pBuilder = new PlaneBuilder();
        for (int x =0; x < mapSize -1; x++) //-1 as the bottom left of the quad is x/y but top left is x+1/y+1
        {
            for (int y =0; y < mapSize -1; y++)
            {
                Vector3[] verts = new Vector3[4];
                verts[0] = getHeight(x,y);
                verts[1] = getHeight(x +1,y);
                verts[2] = getHeight(x,y +1);
                verts[3] = getHeight(x +1,y +1);
                pBuilder.addQuad(verts);

            }
        }
        GetComponent<MeshFilter> ().mesh = pBuilder.compileMesh();//low polly map
    }
    Mesh getHighPollyQuad(int x, int y)
    {
        if(x < 0 || y < 0 || x > cityW.mapSize|| y > cityW.mapSize)
            Debug.LogError("the quad specified at " + x +", "+ y+" can not be found");

        x *= quadResolution;
        y *= quadResolution;
        PlaneBuilder plane = new PlaneBuilder();

        for(int xIndex =0; xIndex < quadResolution -1; xIndex++)
        {
            for(int yIndex =0; yIndex < quadResolution -1; yIndex++)
            {
                 //detailedHeightMap[x + xIndex,y + yIndex];
                addQuad(x + xIndex,y + yIndex, ref plane);
            }
        }
        return plane.compileMesh();
    }