codechicken.lib.colour.Colour Java Examples

The following examples show how to use codechicken.lib.colour.Colour. 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: FacadeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static List<CCQuad> applyItemTint(List<CCQuad> quads, ItemStack stack) {
    List<CCQuad> retQuads = new LinkedList<>();
    for (CCQuad quad : quads) {
        int colour = -1;

        if (quad.hasTint()) {
            colour = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, quad.tintIndex);

            if (EntityRenderer.anaglyphEnable) {
                colour = TextureUtil.anaglyphColor(colour);
            }
            colour = colour | 0xFF000000;
        }
        CCQuad copyQuad = quad.copy();

        Colour c = new ColourARGB(colour);
        for (Colour qC : copyQuad.colours) {
            qC.multiply(c);
        }
        retQuads.add(copyQuad);
    }

    return retQuads;
}
 
Example #2
Source File: BakedVertexSource.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void onFull() {
    if (vertexIndex == -1) {
        vertexIndex = 0;
    }
    ensureSpace(availableVertices() + 4);
    for (int i = 0; i < 4; i++) {
        int v = vertexIndex++;
        Quad.Vertex vertex = unpacker.vertices[i];
        Vertex5 vertex5 = vertices[v];
        vertex5.vec.set(vertex.vec);
        vertex5.uv.set(vertex.uv);

        Vector3 normal = getAttr(NormalAttribute.attributeKey)[v];
        normal.set(vertex.normal);
        getAttr(LightCoordAttribute.attributeKey)[v].compute(vertex5.vec, normal);

        getAttr(ColourAttribute.attributeKey)[v] = Colour.packRGBA(vertex.color);
    }
}
 
Example #3
Source File: VertexDataUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static BakedQuad buildQuad(VertexFormat format, TextureAtlasSprite sprite, Direction face, Colour colour, UVTransformation t, Vertex5 v1, Vertex5 v2, Vertex5 v3, Vertex5 v4) {
    //        BakedQuadBuilder builder = new BakedQuadBuilder(format);
    //        builder.setQuadTint(-1);
    //        builder.setQuadOrientation(face);
    //        builder.setTexture(sprite);
    //
    //        t.apply(v1.uv);
    //        t.apply(v2.uv);
    //        t.apply(v3.uv);
    //        t.apply(v4.uv);
    //        putVertex(builder, format, face, v1, colour);
    //        putVertex(builder, format, face, v2, colour);
    //        putVertex(builder, format, face, v3, colour);
    //        putVertex(builder, format, face, v4, colour);
    //
    //        return copyQuad(builder.build());
    return null;
}
 
Example #4
Source File: VertexDataUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void putVertex(BakedQuadBuilder builder, VertexFormat format, Direction face, Vertex5 vert, Colour colour) {
    //        for (int e = 0; e < format.getElementCount(); e++) {
    //            VertexFormatElement element = format.getElement(e);
    //            switch (element.getUsage()) {
    //
    //                case POSITION:
    //                    Vector3 vec = vert.vec;
    //                    builder.put(e, (float) vec.x, (float) vec.y, (float) vec.z, 1);
    //                    break;
    //                case NORMAL:
    //                    builder.put(e, face.getXOffset(), face.getYOffset(), face.getZOffset(), 0);
    //                    break;
    //                case COLOR:
    //                    builder.put(e, (colour.r & 0xFF) / 255F, (colour.g & 0xFF) / 255F, (colour.b & 0xFF) / 255F, (colour.a & 0xFF) / 255F);
    //                    break;
    //                case UV:
    //                    UV uv = vert.uv;
    //                    builder.put(e, (float) uv.u, (float) uv.v, 0, 1);
    //                    break;
    //                default:
    //                    builder.put(e);
    //                    break;
    //            }
    //        }
}
 
Example #5
Source File: RenderParticle.java    From Translocators with MIT License 6 votes vote down vote up
public static void render(double x, double y, double z, Colour colour, double s, double u1, double v1, double u2, double v2)
{
    x-=EntityFX.interpPosX;
    y-=EntityFX.interpPosY;
    z-=EntityFX.interpPosZ;
    //TODO: check
    
    float par3 = ActiveRenderInfo.rotationX;
    float par4 = ActiveRenderInfo.rotationXZ;
    float par5 = ActiveRenderInfo.rotationZ;
    float par6 = ActiveRenderInfo.rotationYZ;
    float par7 = ActiveRenderInfo.rotationXY;
    
    Tessellator t = Tessellator.instance;
    t.setColorRGBA(colour.r&0xFF, colour.g&0xFF, colour.b&0xFF, colour.a&0xFF);
    t.addVertexWithUV((x - par3 * s - par6 * s), (y - par4 * s), (z - par5 * s - par7 * s), u2, v2);
    t.addVertexWithUV((x - par3 * s + par6 * s), (y + par4 * s), (z - par5 * s + par7 * s), u2, v1);
    t.addVertexWithUV((x + par3 * s + par6 * s), (y + par4 * s), (z + par5 * s + par7 * s), u1, v1);
    t.addVertexWithUV((x + par3 * s - par6 * s), (y - par4 * s), (z + par5 * s - par7 * s), u1, v2);
}
 
Example #6
Source File: AdvCCRSConsumer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void put(int e, float... data) {
    VertexFormat format = getVertexFormat();

    VertexFormatElement fmte = format.getElement(e);
    switch (fmte.getUsage()) {
        case POSITION:
            ccrs.vert.vec.set(data).apply(translation);
            break;
        case UV:
            if (fmte.getIndex() == 0) {
                ccrs.vert.uv.set(data[0], data[1]);
            } else {
                ccrs.brightness = (int) (data[1] * 0xFFFF / 2) << 16 | (int) (data[0] * 0xFFFF / 2);
            }
            break;
        case COLOR:
            ccrs.colour = Colour.packRGBA(data);
            break;
        case NORMAL:
            ccrs.normal.set(data);
            break;
        case PADDING:
            break;
        default:
            throw new UnsupportedOperationException("Generic vertex format element");
    }
    if (e == format.getElementCount() - 1) {
        ccrs.writeVert();
    }
}
 
Example #7
Source File: GuiWirelessSniffer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public Colour getColour(int freq)
{
    if(RedstoneEther.get(true).isPlayerJammed(mc.thePlayer) || !RedstoneEther.get(true).canBroadcastOnFrequency(mc.thePlayer, freq))
        return colourJammed;
    
    return colourOff.copy().interpolate(colourOn, brightness[freq-1] / 64F);
}
 
Example #8
Source File: GuiWirelessSniffer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public Colour getBorder(int freq)
{
    if(RedstoneEther.get(true).isPlayerJammed(mc.thePlayer) || !RedstoneEther.get(true).canBroadcastOnFrequency(mc.thePlayer, freq))
    {
        return borderJammed;
    }
    else if(RedstoneEther.get(true).getFreqColourId(freq) != -1)
    {
        return new ColourARGB(RedstoneEther.get(true).getFreqColour(freq));
    }
    else
    {
        return borderOff.copy().interpolate(borderOn, brightness[freq-1] / 64F);
    }
}
 
Example #9
Source File: GuiPrivateSniffer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
@Override
public Colour getColour(int freq)
{
    if(RedstoneEther.get(true).isPlayerJammed(mc.thePlayer) || !RedstoneEther.get(true).canBroadcastOnFrequency(mc.thePlayer, freq))
        return colourJammed;

    if(RedstoneEther.get(true).isFreqPrivate(freq) && RedstoneEther.get(true).getFreqOwner(freq).equalsIgnoreCase(mc.thePlayer.getCommandSenderName()))
        return colourPOff.copy().interpolate(colourPOn, brightness[freq-1] / 64F);
        
    Colour colour = colourOff.copy().interpolate(colourOn, brightness[freq-1] / 64F);
    if(freq <= RedstoneEther.get(true).getLastPublicFrequency())
        colour.interpolate(colourJammed, 0.5);

    return colour;
}
 
Example #10
Source File: TriangTexManager.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private static void mergeTexturesWithColour(ColourARGB texcolour)
{
    for(int i = 0; i < 256; i++)
    {
        Colour colour;
        if(texGrad[i].a == 0)
            colour = texRing[i];
        else
            colour = texGrad[i].copy().multiply(texcolour);
        
        imageData[i] = colour.argb();
    }
}
 
Example #11
Source File: RemoteTexManager.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private static void mergeTexturesWithColour(Colour texcolour, boolean on)
{
    for(int i = 0; i < 256; i++)
    {
        Colour colour;
        if(texGrad[i].a == 0)
            colour = on ? texOn[i] : texOff[i];
        else
            colour = texGrad[i].copy().multiply(texcolour);
        
        imageData[i] = colour.argb();
    }
}
 
Example #12
Source File: TextureUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Colour[] loadTextureColours(ResourceLocation resource) {
    int[] idata = loadTextureData(resource);
    Colour[] data = new Colour[idata.length];
    for (int i = 0; i < data.length; i++)
        data[i] = new ColourARGB(idata[i]);
    return data;
}
 
Example #13
Source File: CCRenderState.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void setColour(Colour colour) {
    this.colour = colour.rgba();
}
 
Example #14
Source File: PlanarFaceBakery.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static BakedQuad bakeFace(Direction face, TextureAtlasSprite sprite, VertexFormat format, Colour colour) {
    UVTransformation t = new IconTransformation(sprite);

    double x1 = Cuboid6.full.min.x;
    double x2 = Cuboid6.full.max.x;
    double y1 = Cuboid6.full.min.y;
    double y2 = Cuboid6.full.max.y;
    double z1 = Cuboid6.full.min.z;
    double z2 = Cuboid6.full.max.z;
    double u1;
    double u2;
    double v1;
    double v2;
    Vertex5 vert1;
    Vertex5 vert2;
    Vertex5 vert3;
    Vertex5 vert4;

    switch (face) {
        case DOWN:
            u1 = x1;
            v1 = z1;
            u2 = x2;
            v2 = z2;
            vert1 = new Vertex5(x1, y1, z2, u1, v2);
            vert2 = new Vertex5(x1, y1, z1, u1, v1);
            vert3 = new Vertex5(x2, y1, z1, u2, v1);
            vert4 = new Vertex5(x2, y1, z2, u2, v2);
            return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4);
        case UP:
            u1 = x1;
            v1 = z1;
            u2 = x2;
            v2 = z2;
            vert1 = new Vertex5(x2, y2, z2, u2, v2);
            vert2 = new Vertex5(x2, y2, z1, u2, v1);
            vert3 = new Vertex5(x1, y2, z1, u1, v1);
            vert4 = new Vertex5(x1, y2, z2, u1, v2);
            return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4);
        case NORTH:
            u1 = 1 - x1;
            v1 = 1 - y2;
            u2 = 1 - x2;
            v2 = 1 - y1;
            vert1 = new Vertex5(x1, y1, z1, u1, v2);
            vert2 = new Vertex5(x1, y2, z1, u1, v1);
            vert3 = new Vertex5(x2, y2, z1, u2, v1);
            vert4 = new Vertex5(x2, y1, z1, u2, v2);
            return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4);
        case SOUTH:
            u1 = x1;
            v1 = 1 - y2;
            u2 = x2;
            v2 = 1 - y1;
            vert1 = new Vertex5(x2, y1, z2, u2, v2);
            vert2 = new Vertex5(x2, y2, z2, u2, v1);
            vert3 = new Vertex5(x1, y2, z2, u1, v1);
            vert4 = new Vertex5(x1, y1, z2, u1, v2);
            return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4);
        case WEST:
            u1 = z1;
            v1 = 1 - y2;
            u2 = z2;
            v2 = 1 - y1;
            vert1 = new Vertex5(x1, y1, z2, u2, v2);
            vert2 = new Vertex5(x1, y2, z2, u2, v1);
            vert3 = new Vertex5(x1, y2, z1, u1, v1);
            vert4 = new Vertex5(x1, y1, z1, u1, v2);
            return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4);

        case EAST:
            u1 = 1 - z1;
            v1 = 1 - y2;
            u2 = 1 - z2;
            v2 = 1 - y1;
            vert1 = new Vertex5(x2, y1, z1, u1, v2);
            vert2 = new Vertex5(x2, y2, z1, u1, v1);
            vert3 = new Vertex5(x2, y2, z2, u2, v1);
            vert4 = new Vertex5(x2, y1, z2, u2, v2);
            return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4);
    }
    return null;
}