Java Code Examples for net.minecraftforge.client.model.pipeline.LightUtil#unpack()

The following examples show how to use net.minecraftforge.client.model.pipeline.LightUtil#unpack() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractBakedPropertiesModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected boolean checkDepth(BakedQuad quad, Vector3 hit, Direction hitFace) {
    int[] quadData = quad.getVertexData();
    CachedFormat format = CachedFormat.lookup(DefaultVertexFormats.BLOCK);

    Vector3 posVec = new Vector3();
    float[] pos = new float[4];
    for (int v = 0; v < 4; v++) {
        LightUtil.unpack(quadData, pos, format.format, v, format.positionIndex);
        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);
}
 
Example 2
Source File: VertexDataUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void fullyUnPackQuads(int[] packedData, float[][][] unpackedData, VertexFormat format) {
    List<VertexFormatElement> elements = format.getElements();
    for (int e = 0; e < elements.size(); e++) {
        for (int v = 0; v < 4; v++) {
            LightUtil.unpack(packedData, unpackedData[v][e], format, v, e);
        }
    }
}
 
Example 3
Source File: VertexDataUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static float[][] unpackElements(int[] packed, VertexFormat format, VertexFormatElement element) {
    float[][] data = new float[4][4];
    int e = getElement(format, element);
    for (int v = 0; v < 4; v++) {
        LightUtil.unpack(packed, data[v], format, v, e);
    }
    return data;
}