int[] heightBlock4 = new int[newBlockSize]; count = 0; for (int i = split - 1; i < size; i++) { for (int j = split - 1; j < size; j++) { heightBlock4[count++] = heightMap[j + (i * size)]; } } Vector3f origin4 = new Vector3f(size / 4 * stepScale.x, 0, size / 4 * stepScale.z);
TerrainBlock block3 = new TerrainBlock(name + "Block3", split, stepScale, heightBlock3, origin3, clod, totalSize, tempOffset, offsetAmount); this.attachChild(block3); block3.setModelBound(new BoundingBox()); block3.updateModelBound();
    private void createQuadBlock(int size, Vector3f stepScale, int[] heightMap,            boolean clod) {        Vector2f tempOffset = new Vector2f();        offsetAmount += size / 4;        //create 4 terrain blocks        int split = (size + 1) / 2;        int newBlockSize = split * split;        int[] heightBlock1 = new int[newBlockSize];        int count = 0;        for (int i = 0; i < split; i++) {            for (int j = 0; j < split; j++) {                heightBlock1[count++] = heightMap[j + (i * size)];            }        }        Vector3f origin1 = new Vector3f(-size / 4 * stepScale.x, 0, -size / 4                * stepScale.z);        tempOffset.x = offset.x;        tempOffset.y = offset.y;        tempOffset.x += origin1.x;        tempOffset.y += origin1.z;        TerrainBlock block1 = new TerrainBlock(name + "Block1", split,                stepScale, heightBlock1, origin1, clod, totalSize, tempOffset,                offsetAmount);        this.attachChild(block1);        block1.setModelBound(new BoundingBox());        block1.updateModelBound();        //2 lower left        int[] heightBlock2 = new int[newBlockSize];        count = 0;        for (int i = split - 1; i < size; i++) {            for (int j = 0; j < split; j++) {                heightBlock2[count++] = heightMap[j + (i * size)];            }        }        Vector3f origin2 = new Vector3f(-size / 4 * stepScale.x, 0, size / 4                * stepScale.z);        tempOffset.x = offset.x;        tempOffset.y = offset.y;        tempOffset.x += origin2.x;        tempOffset.y += origin2.z;        TerrainBlock block2 = new TerrainBlock(name + "Block2", split,                stepScale, heightBlock2, origin2, clod, totalSize, tempOffset,                offsetAmount);        this.attachChild(block2);        block2.setModelBound(new BoundingBox());        block2.updateModelBound();        //3 lower right        int[] heightBlock3 = new int[newBlockSize];        count = 0;        for (int i = 0; i < split; i++) {            for (int j = split - 1; j < size; j++) {                heightBlock3[count++] = heightMap[j + (i * size)];            }        }        Vector3f origin3 = new Vector3f(size / 4 * stepScale.x, 0, -size / 4                * stepScale.z);        tempOffset.x = offset.x;        tempOffset.y = offset.y;        tempOffset.x += origin3.x;        tempOffset.y += origin3.z;        TerrainBlock block3 = new TerrainBlock(name + "Block3", split,                stepScale, heightBlock3, origin3, clod, totalSize, tempOffset,                offsetAmount);        this.attachChild(block3);        block3.setModelBound(new BoundingBox());        block3.updateModelBound();        //4 upper right        int[] heightBlock4 = new int[newBlockSize];        count = 0;        for (int i = split - 1; i < size; i++) {            for (int j = split - 1; j < size; j++) {                heightBlock4[count++] = heightMap[j + (i * size)];            }        }        Vector3f origin4 = new Vector3f(size / 4 * stepScale.x, 0, size / 4                * stepScale.z);        tempOffset.x = offset.x;        tempOffset.y = offset.y;        tempOffset.x += origin4.x;        tempOffset.y += origin4.z;        TerrainBlock block4 = new TerrainBlock(name + "Block4", split,                stepScale, heightBlock4, origin4, clod, totalSize, tempOffset,                offsetAmount);        this.attachChild(block4);        block4.setModelBound(new BoundingBox());        block4.updateModelBound();    }