当前位置: 首页>>代码示例>>Java>>正文


Java Version类代码示例

本文整理汇总了Java中com.protolambda.blocktopograph.chunk.Version的典型用法代码示例。如果您正苦于以下问题:Java Version类的具体用法?Java Version怎么用?Java Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Version类属于com.protolambda.blocktopograph.chunk包,在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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.Version; //导入依赖的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.Version; //导入依赖的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.Version; //导入依赖的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: getChunkEntityNBT

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的package包/类
public NBTChunkData getChunkEntityNBT(int x, int z, Dimension d) {
    try {
        return getChunkManager(d).getChunk(x, z).getEntity();
    } catch (Version.VersionException ex) {
        return null;
    }
}
 
开发者ID:jocopa3,项目名称:blocktopograph-library,代码行数:8,代码来源:WorldProvider.java

示例6: getChunkBlockEntityNBT

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的package包/类
public NBTChunkData getChunkBlockEntityNBT(int x, int z, Dimension d) {
    try {
        return getChunkManager(d).getChunk(x, z).getBlockEntity();
    } catch (Version.VersionException ex) {
        return null;
    }
}
 
开发者ID:jocopa3,项目名称:blocktopograph-library,代码行数:8,代码来源:WorldProvider.java

示例7: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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

示例8: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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

示例9: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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

示例10: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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

示例11: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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

示例12: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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

示例13: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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 grass 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);


    int x, 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) {

            color = ((data.getGrassR(x, z) & 0xff) << 16) | ((data.getGrassG(x, z) & 0xff) << 8) | (data.getGrassB(x, z) & 0xff) | 0xff000000;

            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,代码行数:53,代码来源:GrassRenderer.java

示例14: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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 grass 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);


    int x, 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) {

            color = ((data.getGrassR(x, z) & 0xff) << 16) | ((data.getGrassG(x, z) & 0xff) << 8) | (data.getGrassB(x, z) & 0xff) | 0xff000000;

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


        }
    }

    return bm;
}
 
开发者ID:protolambda,项目名称:blocktopograph,代码行数:52,代码来源:GrassRenderer.java

示例15: renderToBitmap

import com.protolambda.blocktopograph.chunk.Version; //导入依赖的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 biome 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);


    int x, z, biomeID, color, i, j, tX, tY;
    Biome biome;

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


            biomeID = data.getBiome(x, z) & 0xff;
            biome = Biome.getBiome(biomeID);

            color = biome == null ? 0xff000000 : (biome.color.red << 16) | (biome.color.green << 8) | (biome.color.blue) | 0xff000000;

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


        }
    }

    return bm;
}
 
开发者ID:protolambda,项目名称:blocktopograph,代码行数:57,代码来源:BiomeRenderer.java


注:本文中的com.protolambda.blocktopograph.chunk.Version类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。