Java Code Examples for net.minecraft.client.renderer.texture.TextureAtlasSprite#getInterpolatedV()

The following examples show how to use net.minecraft.client.renderer.texture.TextureAtlasSprite#getInterpolatedV() . 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: AbstractBakedModel.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void putVertex(UnpackedBakedQuad.Builder builder, Vec3d normal, TextureAtlasSprite sprite, double x, double y, double z, float u, float v, int rgbaColor) {
    for (int e = 0; e < format.getElementCount(); e++) {
        switch (format.getElement(e).getUsage()) {
            case POSITION:
                builder.put(e, (float) x, (float) y, (float) z, 1.0f);
                break;
            case COLOR:
                float red = ((rgbaColor >> 16) & 0xFF) / 255.0f;
                float green = ((rgbaColor >> 8) & 0xFF) / 255.0f;
                float blue = ((rgbaColor) & 0xFF) / 255.0f;
                builder.put(e, red, green, blue, 1.0f);
                break;
            case UV:
                if (format.getElement(e).getIndex() == 0) {
                    u = sprite.getInterpolatedU(u);
                    v = sprite.getInterpolatedV(v);
                    builder.put(e, u, v, 0f, 1f);
                    break;
                }
            case NORMAL:
                builder.put(e, (float) normal.x, (float) normal.y, (float) normal.z, 0f);
                break;
            default:
                builder.put(e);
                break;
        }
    }
}
 
Example 2
Source File: IconVertexRangeUVTransform.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void operate(CCRenderState ccrs) {
    UV uv = ccrs.vert.uv;
    int index = ccrs.vertexIndex;
    TextureAtlasSprite sprite = getSpriteForVertexIndex(index);
    if (sprite == null) {
        return;
    }
    uv.u = sprite.getInterpolatedU(uv.u * 16);
    uv.v = sprite.getInterpolatedV(uv.v * 16);
    ccrs.sprite = getSpriteForVertexIndex(ccrs.vertexIndex);
}
 
Example 3
Source File: FacadeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static List<CCQuad> sliceQuads(List<CCQuad> quads, int side, Cuboid6 bounds) {
    boolean flag, flag2;

    double[][] quadPos = new double[4][3];
    boolean[] flat = new boolean[3];
    int verticesPerFace = 4;
    List<CCQuad> finalQuads = new LinkedList<>();

    for (CCQuad quad : quads) {

        flag = flag2 = false;
        for (int i = 0; i < 3; i++) {
            flat[i] = true;
        }

        Vector3 first = quad.vertices[0].vec;

        for (int v = 0; v < 4; v++) {
            quadPos[v] = quad.vertices[v].vec.toArrayD();

            flag = flag || quadPos[v][sideOffsets[side]] != sideSoftBounds[side];
            flag2 = flag2 || quadPos[v][sideOffsets[side]] != (1 - sideSoftBounds[side]);

            if (v != 0) {
                flat[0] = flat[0] && quad.vertices[v].vec.x == first.x;
                flat[1] = flat[1] && quad.vertices[v].vec.y == first.y;
                flat[2] = flat[2] && quad.vertices[v].vec.z == first.z;
            }
        }

        int s = -1;

        if (flag && flag2) {
            for (int vi = 0; vi < 3; vi++) {
                if (flat[vi]) {
                    if (vi != sideOffsets[side]) {
                        s = vi;
                        break;
                    } else {
                        flag = false;
                    }
                }
            }
        }

        for (int k2 = 0; k2 < verticesPerFace; k2++) {
            boolean flag3 = quadPos[k2][sideOffsets[side]] != sideSoftBounds[side];
            for (int j = 0; j < 3; j++) {
                if (j == sideOffsets[side]) {
                    quadPos[k2][j] = clampF(quadPos[k2][j], bounds, j);
                } else {
                    if (flag && flag2 && flag3) {
                        quadPos[k2][j] = MathHelper.clamp(quadPos[k2][j], FACADE_RENDER_OFFSET, FACADE_RENDER_OFFSET2);
                    }
                }
            }

            if (s != -1) {
                double u, v;

                if (s == 0) {
                    u = quadPos[k2][1];
                    v = quadPos[k2][2];
                } else if (s == 1) {
                    u = quadPos[k2][0];
                    v = quadPos[k2][2];
                } else {
                    u = quadPos[k2][0];
                    v = quadPos[k2][1];
                }

                u = MathHelper.clamp(u, 0, 1) * 16;
                v = MathHelper.clamp(v, 0, 1) * 16;

                TextureAtlasSprite sideTexture = quad.sprite;
                u = sideTexture.getInterpolatedU(u);
                v = sideTexture.getInterpolatedV(v);
                quad.vertices[k2].uv.set(u, v);
                quad.tintIndex = -1;
            }
            quad.vertices[k2].vec.set(quadPos[k2]);
        }
        finalQuads.add(quad);
    }

    return finalQuads;
}
 
Example 4
Source File: MultiIconTransformation.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void apply(UV uv) {
    TextureAtlasSprite icon = icons[uv.tex % icons.length];
    uv.u = icon.getInterpolatedU(uv.u * 16);
    uv.v = icon.getInterpolatedV(uv.v * 16);
}