當前位置: 首頁>>代碼示例>>Java>>正文


Java ChunkManager類代碼示例

本文整理匯總了Java中com.protolambda.blocktopograph.chunk.ChunkManager的典型用法代碼示例。如果您正苦於以下問題:Java ChunkManager類的具體用法?Java ChunkManager怎麽用?Java ChunkManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ChunkManager類屬於com.protolambda.blocktopograph.chunk包,在下文中一共展示了ChunkManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    int x, z, i, j, tX, tY;

    int offsetX = chunkX * dimension.chunkW;
    int offsetZ = chunkZ * dimension.chunkL;

    for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {
            for(i = 0; i < pL; i++){
                for(j = 0; j < pW; j++){
                    bm.setRGB(tX + j, tY + i, 0xff000000 | ((offsetX + x) ^ (offsetZ + z)));
                }
            }
        }
    }


    return bm;
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:40,代碼來源:DebugRenderer.java

示例2: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
    //System.out.println("chunkX:"+chunkX+", chunkZ:"+chunkZ+", bX:"+bX+", bZ:"+bZ+", eX:"+eX+", eZ:"+eZ+", pX:"+pX+", pY:"+pY+", pW:"+pW+", pL:"+pL);
    int x, z, i, j, tX, tY;
    int color;

    for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {
            color = ((x + z) & 1) == 1 ? darkShade : lightShade;
            for (i = 0; i < pL; i++) {
                for (j = 0; j < pW; j++) {
                    bm.setRGB(tX + j, tY + i, color);
                }
            }
        }
    }


    return bm;
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:39,代碼來源:ChessPatternRenderer.java

示例3: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    int x, z, i, j, tX, tY;

    int offsetX = chunkX * dimension.chunkW;
    int offsetZ = chunkZ * dimension.chunkL;

    for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {
            for(i = 0; i < pL; i++){
                for(j = 0; j < pW; j++){
                    bm.setPixel(tX + j, tY + i, 0xff000000 | ((offsetX + x) ^ (offsetZ + z)));
                }
            }
        }
    }


    return bm;
}
 
開發者ID:protolambda,項目名稱:blocktopograph,代碼行數:40,代碼來源:DebugRenderer.java

示例4: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    int x, z, i, j, tX, tY;
    int color;

    for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {
            color = ((x + z) & 1) == 1 ? darkShade : lightShade;
            for (i = 0; i < pL; i++) {
                for (j = 0; j < pW; j++) {
                    bm.setPixel(tX + j, tY + i, color);
                }
            }
        }
    }


    return bm;
}
 
開發者ID:protolambda,項目名稱:blocktopograph,代碼行數:39,代碼來源:ChessPatternRenderer.java

示例5: getChunkManager

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
public ChunkManager getChunkManager(Dimension d) {
    switch (d) {
        case OVERWORLD:
            return cmOverworld;
        case NETHER:
            return cmNether;
        case END:
            return cmEnd;
        default:
            return cmOverworld;
    }
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:13,代碼來源:WorldProvider.java

示例6: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    int x, z, i, j, tX, tY;

    MapType.OVERWORLD_SATELLITE.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);

    boolean isSlimeChunk = isSlimeChunk(chunkX, chunkZ);
    int color, r, g, b, avg;

    //make slimeChunks much more green
    for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {
            color = bm.getRGB(tX, tY);
            r = (color >> 16) & 0xff;
            g = (color >> 8) & 0xff;
            b = color & 0xff;
            avg = (r + g + b) / 3;
            if(isSlimeChunk){
                r = b = avg;
                g = (g + 0xff) >> 1;
            } else {
                r = g = b = avg;
            }
            color = (color & 0xFF000000) | (r << 16) | (g << 8) | b;

            for(i = 0; i < pL; i++){
                for(j = 0; j < pW; j++){
                    bm.setRGB(tX + j, tY + i, color);
                }
            }

        }
    }

    return bm;
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:56,代碼來源:SlimeChunkRenderer.java

示例7: removeMarker

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
public void removeMarker(AbstractMarker marker, boolean dirty){

        long chunkKey = ChunkManager.xzToKey(marker.x >> 4, marker.z >> 4);
        Set<AbstractMarker> chunk = chunks.get(chunkKey);
        if(chunk != null) chunk.remove(marker);

        //only set it to dirty if the marker is removed.
        this.dirty |= markers.remove(marker) && dirty;
    }
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:10,代碼來源:MarkerManager.java

示例8: addMarker

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
public void addMarker(AbstractMarker marker, boolean dirty){
    markers.add(marker);

    long chunkKey = ChunkManager.xzToKey(marker.x >> 4, marker.z >> 4);
    Set<AbstractMarker> chunk = chunks.get(chunkKey);
    if(chunk == null) chunks.put(chunkKey, chunk = new HashSet<>());
    chunk.add(marker);

    this.dirty |= dirty;
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:11,代碼來源:MarkerManager.java

示例9: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    int x, z, i, j, tX, tY;

    MapType.OVERWORLD_SATELLITE.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);

    boolean isSlimeChunk = isSlimeChunk(chunkX, chunkZ);
    int color, r, g, b, avg;

    //make slimeChunks much more green
    for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {
            color = bm.getPixel(tX, tY);
            r = (color >> 16) & 0xff;
            g = (color >> 8) & 0xff;
            b = color & 0xff;
            avg = (r + g + b) / 3;
            if(isSlimeChunk){
                r = b = avg;
                g = (g + 0xff) >> 1;
            } else {
                r = g = b = avg;
            }
            color = (color & 0xFF000000) | (r << 16) | (g << 8) | b;

            for(i = 0; i < pL; i++){
                for(j = 0; j < pW; j++){
                    bm.setPixel(tX + j, tY + i, color);
                }
            }

        }
    }

    return bm;
}
 
開發者ID:protolambda,項目名稱:blocktopograph,代碼行數:56,代碼來源:SlimeChunkRenderer.java

示例10: WorldProvider

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
public WorldProvider(World world) {
    this.world = world;
    cmOverworld = new ChunkManager(world.getWorldData(), Dimension.OVERWORLD);
    cmNether = new ChunkManager(world.getWorldData(), Dimension.NETHER);
    cmEnd = new ChunkManager(world.getWorldData(), Dimension.END);
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:7,代碼來源:WorldProvider.java

示例11: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    Chunk chunk = cm.getChunk(chunkX, chunkZ);
    if(chunk == null) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
    Version cVersion = chunk.getVersion();

    if(cVersion == Version.ERROR) return MapType.ERROR.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);


    int x, y, z, subChunk, color, i, j, tX, tY;

    //render width in blocks
    int rW = eX - bX;
    int[] light = new int[rW * (eZ - bZ)];

    for(subChunk = 0; subChunk < cVersion.subChunks; subChunk++) {
        TerrainChunkData data = chunk.getTerrain((byte) subChunk);
        if (data == null || !data.loadTerrain()) break;

        for (z = bZ; z < eZ; z++) {
            for (x = bX; x < eX; x++) {
                for (y = 0; y < cVersion.subChunkHeight; y++) {
                    light[(z * rW) + x] += data.getBlockLightValue(x, y, z) & 0xff;
                }
            }
        }
    }

    int l;
    for (z = bZ, tY = pY; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {

            l = light[(z * rW) + x];
            l = l < 0 ? 0 : ((l > 0xff) ? 0xff : l);

            color = (l << 16) | (l << 8) | (l) | 0xff000000;

            for(i = 0; i < pL; i++){
                for(j = 0; j < pW; j++){
                    bm.setRGB(tX + j, tY + i, color);
                }
            }

        }

    }

    if(subChunk == 0) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);

    return bm;
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:71,代碼來源:BlockLightRenderer.java

示例12: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    Chunk chunk = cm.getChunk(chunkX, chunkZ);
    if(chunk == null) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
    Version cVersion = chunk.getVersion();

    if(cVersion == Version.ERROR) return MapType.ERROR.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);

    //the bottom sub-chunk is sufficient to get heightmap data.
    TerrainChunkData data = chunk.getTerrain((byte) 0);
    if(data == null || !data.load2DData()) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);

    boolean west = true, north = true;
    TerrainChunkData dataW = null, dataN = null;
    
    Chunk dataWC = cm.getChunk(chunkX - 1, chunkZ);
    if(dataWC != null)
        dataW = dataWC.getTerrain((byte) 0);
    else
        west = false;
    
    Chunk dataNC = cm.getChunk(chunkX, chunkZ-1);
    if(dataNC != null)
        dataN = dataNC.getTerrain((byte) 0);
    else
        north = false;
    

    west &= dataW != null && dataW.load2DData();
    north &= dataN != null && dataN.load2DData();

    int x, y, z, color, i, j, tX, tY;
    for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {

            y = data.getHeightMapValue(x, z);

            color = getColumnColour(chunk, data, x, y, z,
                    (x == 0) ? (west ? dataW.getHeightMapValue(dimension.chunkW - 1, z) : y)//chunk edge
                             : data.getHeightMapValue(x - 1, z),//within chunk
                    (z == 0) ? (north ? dataN.getHeightMapValue(x, dimension.chunkL - 1) : y)//chunk edge
                             : data.getHeightMapValue(x, z - 1)//within chunk
            );
            //System.out.println(chunkX+" "+chunkZ);
            for(i = 0; i < pL; i++){
                for(j = 0; j < pW; j++){
                    bm.setRGB(tX + j, tY + i, color);
                }
            }


        }
    }

    return bm;
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:76,代碼來源:SatelliteRenderer.java

示例13: getMarkersOfChunk

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
public Collection<AbstractMarker> getMarkersOfChunk(int chunkX, int chunkZ){
    long key = ChunkManager.xzToKey(chunkX, chunkZ);
    Set<AbstractMarker> chunk = chunks.get(key);
    if(chunk == null) chunks.put(key, chunk = new HashSet<>());
    return chunk;
}
 
開發者ID:jocopa3,項目名稱:blocktopograph-library,代碼行數:7,代碼來源:MarkerManager.java

示例14: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    Chunk chunk = cm.getChunk(chunkX, chunkZ);
    Version cVersion = chunk.getVersion();

    if(cVersion == Version.ERROR) return MapType.ERROR.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
    if(cVersion == Version.NULL) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);


    int x, y, z, subChunk, color, i, j, tX, tY;

    //render width in blocks
    int rW = eX - bX;
    int[] light = new int[rW * (eZ - bZ)];

    for(subChunk = 0; subChunk < cVersion.subChunks; subChunk++) {
        TerrainChunkData data = chunk.getTerrain((byte) subChunk);
        if (data == null || !data.loadTerrain()) break;

        for (z = bZ; z < eZ; z++) {
            for (x = bX; x < eX; x++) {
                for (y = 0; y < cVersion.subChunkHeight; y++) {
                    light[((z - bZ) * rW) + (x - bX)] += data.getBlockLightValue(x, y, z) & 0xff;
                }
            }
        }
    }

    int l;
    for (z = bZ, tY = pY; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {

            l = light[((z - bZ) * rW) + (x - bX)];
            l = l < 0 ? 0 : ((l > 0xff) ? 0xff : l);

            color = (l << 16) | (l << 8) | (l) | 0xff000000;

            for(i = 0; i < pL; i++){
                for(j = 0; j < pW; j++){
                    bm.setPixel(tX + j, tY + i, color);
                }
            }

        }

    }

    if(subChunk == 0) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);

    return bm;
}
 
開發者ID:protolambda,項目名稱:blocktopograph,代碼行數:71,代碼來源:BlockLightRenderer.java

示例15: renderToBitmap

import com.protolambda.blocktopograph.chunk.ChunkManager; //導入依賴的package包/類
/**
 * Render a single chunk to provided bitmap (bm)
 * @param cm ChunkManager, provides chunks, which provide chunk-data
 * @param bm Bitmap to render to
 * @param dimension Mapped dimension
 * @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
 * @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
 * @param bX begin block X coordinate, relative to chunk edge
 * @param bZ begin block Z coordinate, relative to chunk edge
 * @param eX end block X coordinate, relative to chunk edge
 * @param eZ end block Z coordinate, relative to chunk edge
 * @param pX texture X pixel coord to start rendering to
 * @param pY texture Y pixel coord to start rendering to
 * @param pW width (X) of one block in pixels
 * @param pL length (Z) of one block in pixels
 * @return bm is returned back
 *
 * @throws Version.VersionException when the version of the chunk is unsupported.
 */
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {

    Chunk chunk = cm.getChunk(chunkX, chunkZ);
    Version cVersion = chunk.getVersion();

    if(cVersion == Version.ERROR) return MapType.ERROR.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
    if(cVersion == Version.NULL) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);

    //the bottom sub-chunk is sufficient to get heightmap data.
    TerrainChunkData data = chunk.getTerrain((byte) 0);
    if(data == null || !data.load2DData()) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);


    TerrainChunkData dataW = cm.getChunk(chunkX - 1, chunkZ).getTerrain((byte) 0);
    TerrainChunkData dataN = cm.getChunk(chunkX, chunkZ-1).getTerrain((byte) 0);

    boolean west = dataW != null && dataW.load2DData(),
            north = dataN != null && dataN.load2DData();

    int x, y, z, color, i, j, tX, tY;
    for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
        for (x = bX, tX = pX; x < eX; x++, tX += pW) {

            y = data.getHeightMapValue(x, z);

            color = getColumnColour(chunk, data, x, y, z,
                    (x == 0) ? (west ? dataW.getHeightMapValue(dimension.chunkW - 1, z) : y)//chunk edge
                             : data.getHeightMapValue(x - 1, z),//within chunk
                    (z == 0) ? (north ? dataN.getHeightMapValue(x, dimension.chunkL - 1) : y)//chunk edge
                             : data.getHeightMapValue(x, z - 1)//within chunk
            );

            for(i = 0; i < pL; i++){
                for(j = 0; j < pW; j++){
                    bm.setPixel(tX + j, tY + i, color);
                }
            }


        }
    }

    return bm;
}
 
開發者ID:protolambda,項目名稱:blocktopograph,代碼行數:64,代碼來源:SatelliteRenderer.java


注:本文中的com.protolambda.blocktopograph.chunk.ChunkManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。