Java Code Examples for com.badlogic.gdx.graphics.g3d.utils.MeshBuilder#setUVRange()

The following examples show how to use com.badlogic.gdx.graphics.g3d.utils.MeshBuilder#setUVRange() . 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: NormalBlockRenderer.java    From Radix with MIT License 6 votes vote down vote up
@Override
public void renderNorth(int atlasIndex, float x1, float y1, float x2, float y2, float z, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
    // POSITIVE Z
    float u = getU(atlasIndex);
    float v = getV(atlasIndex);
    builder.setUVRange(u, v, u, v);

    c00.setPos(x1, y1, z).setNor(0, 0, 1);
    c01.setPos(x1, y2, z).setNor(0, 0, 1);
    c10.setPos(x2, y1, z).setNor(0, 0, 1);
    c11.setPos(x2, y2, z).setNor(0, 0, 1);

    Color c = getColor((int) x1, (int) y1, (int) z - 1);
    if(pcld == null) {
        builder.setColor(c.r*lightLevel, c.g*lightLevel, c.b*lightLevel, c.a);
    } else {
        c00.setCol(c.r*pcld.l00, c.g*pcld.l00, c.b*pcld.l00, c.a);
        c01.setCol(c.r*pcld.l01, c.g*pcld.l01, c.b*pcld.l01, c.a);
        c10.setCol(c.r*pcld.l10, c.g*pcld.l10, c.b*pcld.l10, c.a);
        c11.setCol(c.r*pcld.l11, c.g*pcld.l11, c.b*pcld.l11, c.a);
    }

    builder.rect(c00, c10, c11, c01);
}
 
Example 2
Source File: NormalBlockRenderer.java    From Radix with MIT License 6 votes vote down vote up
@Override
public void renderSouth(int atlasIndex, float x1, float y1, float x2, float y2, float z, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
    // NEGATIVE Z
    float u = getU(atlasIndex);
    float v = getV(atlasIndex);
    builder.setUVRange(u, v, u, v);

    c00.setPos(x1, y1, z).setNor(0, 0, -1);
    c01.setPos(x1, y2, z).setNor(0, 0, -1);
    c10.setPos(x2, y1, z).setNor(0, 0, -1);
    c11.setPos(x2, y2, z).setNor(0, 0, -1);

    Color c = getColor((int) x1, (int) y1, (int) z);
    if(pcld == null) {
        builder.setColor(c.r*lightLevel, c.g*lightLevel, c.b*lightLevel, c.a);
    } else {
        c00.setCol(c.r*pcld.l00, c.g*pcld.l00, c.b*pcld.l00, c.a);
        c01.setCol(c.r*pcld.l01, c.g*pcld.l01, c.b*pcld.l01, c.a);
        c10.setCol(c.r*pcld.l10, c.g*pcld.l10, c.b*pcld.l10, c.a);
        c11.setCol(c.r*pcld.l11, c.g*pcld.l11, c.b*pcld.l11, c.a);
    }

    builder.rect(c01, c11, c10, c00);
}
 
Example 3
Source File: NormalBlockRenderer.java    From Radix with MIT License 6 votes vote down vote up
@Override
public void renderWest(int atlasIndex, float z1, float y1, float z2, float y2, float x, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
    // NEGATIVE X
    float u = getU(atlasIndex);
    float v = getV(atlasIndex);
    builder.setUVRange(u, v, u, v);

    c00.setPos(x, y1, z1).setNor(-1, 0, 0);
    c01.setPos(x, y1, z2).setNor(-1, 0, 0);
    c10.setPos(x, y2, z1).setNor(-1, 0, 0);
    c11.setPos(x, y2, z2).setNor(-1, 0, 0);

    Color c = getColor((int) x, (int) y1, (int) z1);
    if(pcld == null) {
        builder.setColor(c.r*lightLevel, c.g*lightLevel, c.b*lightLevel, c.a);
    } else {
        c00.setCol(c.r*pcld.l00, c.g*pcld.l00, c.b*pcld.l00, c.a);
        c01.setCol(c.r*pcld.l01, c.g*pcld.l01, c.b*pcld.l01, c.a);
        c10.setCol(c.r*pcld.l10, c.g*pcld.l10, c.b*pcld.l10, c.a);
        c11.setCol(c.r*pcld.l11, c.g*pcld.l11, c.b*pcld.l11, c.a);
    }

    builder.rect(c01, c11, c10, c00);
}
 
Example 4
Source File: NormalBlockRenderer.java    From Radix with MIT License 6 votes vote down vote up
@Override
public void renderEast(int atlasIndex, float z1, float y1, float z2, float y2, float x, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
    // POSITIVE X
    float u = getU(atlasIndex);
    float v = getV(atlasIndex);
    builder.setUVRange(u, v, u, v);

    c00.setPos(x, y1, z1).setNor(1, 0, 0);
    c01.setPos(x, y1, z2).setNor(1, 0, 0);
    c10.setPos(x, y2, z1).setNor(1, 0, 0);
    c11.setPos(x, y2, z2).setNor(1, 0, 0);

    Color c = getColor((int) x - 1, (int) y1, (int) z1);
    if(pcld == null) {
        builder.setColor(c.r*lightLevel, c.g*lightLevel, c.b*lightLevel, c.a);
    } else {
        c00.setCol(c.r*pcld.l00, c.g*pcld.l00, c.b*pcld.l00, c.a);
        c01.setCol(c.r*pcld.l01, c.g*pcld.l01, c.b*pcld.l01, c.a);
        c10.setCol(c.r*pcld.l10, c.g*pcld.l10, c.b*pcld.l10, c.a);
        c11.setCol(c.r*pcld.l11, c.g*pcld.l11, c.b*pcld.l11, c.a);
    }

    builder.rect(c00, c10, c11, c01);
}
 
Example 5
Source File: NormalBlockRenderer.java    From Radix with MIT License 6 votes vote down vote up
@Override
public void renderTop(int atlasIndex, float x1, float z1, float x2, float z2, float y, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
    // POSITIVE Y
    float u = getU(atlasIndex);
    float v = getV(atlasIndex);
    builder.setUVRange(u, v, u, v);

    c00.setPos(x1, y, z1).setNor(0, 1, 0);
    c01.setPos(x1, y, z2).setNor(0, 1, 0);
    c10.setPos(x2, y, z1).setNor(0, 1, 0);
    c11.setPos(x2, y, z2).setNor(0, 1, 0);

    Color c = getColor((int) x1, (int) y - 1, (int) z1);
    if(pcld == null) {
        builder.setColor(c.r*lightLevel, c.g*lightLevel, c.b*lightLevel, c.a);
    } else {
        c00.setCol(c.r*pcld.l00, c.g*pcld.l00, c.b*pcld.l00, c.a);
        c01.setCol(c.r*pcld.l01, c.g*pcld.l01, c.b*pcld.l01, c.a);
        c10.setCol(c.r*pcld.l10, c.g*pcld.l10, c.b*pcld.l10, c.a);
        c11.setCol(c.r*pcld.l11, c.g*pcld.l11, c.b*pcld.l11, c.a);
    }

    builder.rect(c01, c11, c10, c00);
}
 
Example 6
Source File: NormalBlockRenderer.java    From Radix with MIT License 6 votes vote down vote up
@Override
public void renderBottom(int atlasIndex, float x1, float z1, float x2, float z2, float y, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
    // NEGATIVE Y
    float u = getU(atlasIndex);
    float v = getV(atlasIndex);
    builder.setUVRange(u, v, u, v);

    c00.setPos(x1, y, z1).setNor(0, -1, 0);
    c01.setPos(x1, y, z2).setNor(0, -1, 0);
    c10.setPos(x2, y, z1).setNor(0, -1, 0);
    c11.setPos(x2, y, z2).setNor(0, -1, 0);

    Color c = getColor((int) x1, (int) y, (int) z1);
    if(pcld == null) {
        builder.setColor(c.r*lightLevel, c.g*lightLevel, c.b*lightLevel, c.a);
    } else {
        c00.setCol(c.r*pcld.l00, c.g*pcld.l00, c.b*pcld.l00, c.a);
        c01.setCol(c.r*pcld.l01, c.g*pcld.l01, c.b*pcld.l01, c.a);
        c10.setCol(c.r*pcld.l10, c.g*pcld.l10, c.b*pcld.l10, c.a);
        c11.setCol(c.r*pcld.l11, c.g*pcld.l11, c.b*pcld.l11, c.a);
    }

    builder.rect(c00, c10, c11, c01);
}
 
Example 7
Source File: GrassRenderer.java    From Radix with MIT License 5 votes vote down vote up
@Override
public void renderTop(int atlasIndex, float x1, float z1, float x2, float z2, float y, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
    float u = getU(atlasIndex);
    float v = getV(atlasIndex);
    builder.setUVRange(u, v, u, v);

    MeshPartBuilder.VertexInfo c00 = new MeshPartBuilder.VertexInfo().setPos(x1, y, z1).setNor(0, 1, 0);
    MeshPartBuilder.VertexInfo c01 = new MeshPartBuilder.VertexInfo().setPos(x1, y, z2).setNor(0, 1, 0);
    MeshPartBuilder.VertexInfo c10 = new MeshPartBuilder.VertexInfo().setPos(x2, y, z1).setNor(0, 1, 0);
    MeshPartBuilder.VertexInfo c11 = new MeshPartBuilder.VertexInfo().setPos(x2, y, z2).setNor(0, 1, 0);

    IChunk chunk = RadixClient.getInstance().getWorld().getChunk((int) x1, (int) z1);
    Biome biome;
    if(chunk != null) {
        biome = chunk.getBiome();
    } else {
        biome = RadixAPI.instance.getBiomeByID(0);
    }
    int[] color = biome.getGrassColor((int) y - 1);
    float r = color[0]/255f;
    float g = color[1]/255f;
    float b = color[2]/255f;
    if(pcld == null) {
        builder.setColor(r*lightLevel, g*lightLevel, b*lightLevel, 1);
    } else {
        c00.setCol(r*pcld.l00, g*pcld.l00, b*pcld.l00, 1);
        c01.setCol(r*pcld.l01, g*pcld.l01, b*pcld.l01, 1);
        c10.setCol(r*pcld.l10, g*pcld.l10, b*pcld.l10, 1);
        c11.setCol(r*pcld.l11, g*pcld.l11, b*pcld.l11, 1);
    }

    builder.rect(c01, c11, c10, c00);
}