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


Java LightUtil.unpack方法代码示例

本文整理汇总了Java中net.minecraftforge.client.model.pipeline.LightUtil.unpack方法的典型用法代码示例。如果您正苦于以下问题:Java LightUtil.unpack方法的具体用法?Java LightUtil.unpack怎么用?Java LightUtil.unpack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.client.model.pipeline.LightUtil的用法示例。


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

示例1: shadeQuadFaces

import net.minecraftforge.client.model.pipeline.LightUtil; //导入方法依赖的package包/类
public static List<BakedQuad> shadeQuadFaces(List<BakedQuad> quads) {
    LinkedList<BakedQuad> shadedQuads = new LinkedList<>();
    for (BakedQuad quad : quads) {
        int[] rawData = quad.getVertexData();
        for (int v = 0; v < 4; v++) {
            for (int e = 0; e < quad.getFormat().getElementCount(); e++) {
                VertexFormatElement element = quad.getFormat().getElement(e);
                if (element.getUsage() == EnumUsage.COLOR) {
                    float[] data = new float[4];
                    LightUtil.unpack(rawData, data, quad.getFormat(), v, e);

                    data = diffuseFaceLight(quad.getFace(), data);

                    LightUtil.pack(data, rawData, quad.getFormat(), v, e);
                }
            }
        }
        shadedQuads.add(new BakedQuad(rawData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat()));
    }

    return shadedQuads;
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:23,代码来源:VertexDataUtils.java

示例2: transformQuad

import net.minecraftforge.client.model.pipeline.LightUtil; //导入方法依赖的package包/类
public final UnpackedBakedQuad transformQuad(BakedQuad quad) {
    // Fetch required information
    final VertexFormat format = quad.getFormat();
    final float[][][] vertexData = new float[4][format.getElementCount()][4];

    // Objects to be reused in the loop
    final Vector4f temp = new Vector4f();

    //unpack and transform vertex data
    for (int v = 0; v < 4; v++) {
        for (int e = 0; e < format.getElementCount(); e++) {
            LightUtil.unpack(quad.getVertexData(), vertexData[v][e], format, v, e);
            transformUnpackedVertexDataElement(format.getElement(e).getUsage(), vertexData[v][e], temp);
        }
    }
    //create new quad with the transformed vertex data
    return new UnpackedBakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), format);
}
 
开发者ID:InfinityRaider,项目名称:InfinityLib,代码行数:19,代码来源:TessellatorAbstractBase.java

示例3: checkDepth

import net.minecraftforge.client.model.pipeline.LightUtil; //导入方法依赖的package包/类
protected boolean checkDepth(BakedQuad quad, Vector3 hit, EnumFacing hitFace) {
    int[] quadData = quad.getVertexData();
    VertexFormat format = quad.getFormat();
    int e = VertexDataUtils.getPositionElement(format);

    Vector3 posVec = new Vector3();
    float[] pos = new float[4];
    for (int v = 0; v < 4; v++) {
        LightUtil.unpack(quadData, pos, format, v, e);
        posVec.add(pos[0], pos[1], pos[2]);
    }
    posVec.divide(4);

    double diff = 0;
    switch (hitFace.getAxis()) {
        case X:
            diff = Math.abs(hit.x - posVec.x);
            break;
        case Y:
            diff = Math.abs(hit.y - posVec.y);
            break;
        case Z:
            diff = Math.abs(hit.z - posVec.z);
            break;
    }
    return !(diff > 0.01);
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:28,代码来源:AbstractBakedPropertiesModel.java

示例4: fullyUnPackQuads

import net.minecraftforge.client.model.pipeline.LightUtil; //导入方法依赖的package包/类
public static void fullyUnPackQuads(int[] packedData, float[][][] unpackedData, VertexFormat format) {
    for (int e = 0; e < format.getElementCount(); e++) {
        for (int v = 0; v < 4; v++) {
            LightUtil.unpack(packedData, unpackedData[v][e], format, v, e);
        }
    }
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:8,代码来源:VertexDataUtils.java

示例5: bake

import net.minecraftforge.client.model.pipeline.LightUtil; //导入方法依赖的package包/类
/**
 * Bakes the data inside the VertexBuffer to a baked quad.
 *
 * @return The list of quads baked.
 */
public List<BakedQuad> bake() {
    if (isDrawing) {
        CCLLog.log(Level.WARN, new IllegalStateException("Bake called before finishDrawing!"), "Someone is calling bake before finishDrawing!");
        finishDrawing();
    }
    State state = getVertexState();
    VertexFormat format = state.getVertexFormat();
    if (!format.hasUvOffset(0)) {
        throw new IllegalStateException("Unable to bake format that does not have UV mappings!");
    }
    int[] rawBuffer = Arrays.copyOf(state.getRawBuffer(), state.getRawBuffer().length);

    List<BakedQuad> quads = new LinkedList<>();
    TextureAtlasSprite sprite = TextureUtils.getMissingSprite();

    int curr = 0;
    int next = format.getNextOffset();
    int i = 0;
    while (rawBuffer.length >= next) {
        int[] quadData = Arrays.copyOfRange(rawBuffer, curr, next);
        Vector3 normal = new Vector3();
        if (format.hasNormal()) {
            //Grab first normal.
            float[] normalData = new float[4];
            LightUtil.unpack(quadData, normalData, format, 0, VertexDataUtils.getNormalElement(format));
            normal = Vector3.fromArray(normalData);
        } else {
            //No normal provided in format, so we calculate.
            float[][] posData = new float[4][4];
            for (int v = 0; v < 4; v++) {
                LightUtil.unpack(quadData, posData[v], format, v, VertexDataUtils.getPositionElement(format));
            }
            normal.set(VectorUtils.calculateNormal(Vector3.fromArray(posData[0]), Vector3.fromArray(posData[1]), Vector3.fromArray(posData[3])));
        }
        if (useSprites) {
            //Attempt to get sprite for vertex.
            if (spriteMap.containsKey(i)) {
                //Use provided sprite for vertex.
                sprite = spriteMap.get(i);
            } else {
                //Sprite not found for vertex, so we attempt to calculate the sprite.
                float[] uvData = new float[4];
                LightUtil.unpack(quadData, uvData, format, 0, VertexDataUtils.getUVElement(format));
                UV uv = new UV(uvData[0], uvData[1]);
                sprite = VertexDataUtils.getSpriteForUV(TextureUtils.getTextureMap(), uv);
            }
        }
        //Use normal to calculate facing.
        EnumFacing facing = VectorUtils.calcNormalSide(normal);
        if (facing == null) {
            facing = EnumFacing.UP;
        }
        BakedQuad quad = new BakedQuad(quadData, -1, facing, sprite, useDiffuseLighting, format);
        quads.add(quad);
        curr = next;
        next += format.getNextOffset();
        i++;
    }
    return ImmutableList.copyOf(quads);
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:66,代码来源:BakingVertexBuffer.java


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