Implemented spatial pylon rendering.
This commit is contained in:
@@ -7,6 +7,8 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
@@ -19,257 +21,421 @@ import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
/**
|
||||
* Builds the quads for a cube.
|
||||
*/
|
||||
public class CubeBuilder {
|
||||
public class CubeBuilder
|
||||
{
|
||||
|
||||
private VertexFormat format;
|
||||
private VertexFormat format;
|
||||
|
||||
private final List<BakedQuad> output;
|
||||
private final List<BakedQuad> output;
|
||||
|
||||
private final EnumMap<EnumFacing, TextureAtlasSprite> textures = new EnumMap<>(EnumFacing.class);
|
||||
private final EnumMap<EnumFacing, TextureAtlasSprite> textures = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
private EnumSet<EnumFacing> drawFaces = EnumSet.allOf(EnumFacing.class);
|
||||
private EnumSet<EnumFacing> drawFaces = EnumSet.allOf( EnumFacing.class );
|
||||
|
||||
private final EnumMap<EnumFacing, Vector4f> customUv = new EnumMap<>(EnumFacing.class);
|
||||
private final EnumMap<EnumFacing, Vector4f> customUv = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
private int color = 0xFFFFFFFF;
|
||||
private byte[] uvRotations = new byte[EnumFacing.values().length];
|
||||
|
||||
private boolean renderFullBright;
|
||||
private int color = 0xFFFFFFFF;
|
||||
|
||||
public CubeBuilder(VertexFormat format, List<BakedQuad> output) {
|
||||
this.output = output;
|
||||
this.format = format;
|
||||
}
|
||||
private boolean renderFullBright;
|
||||
|
||||
public CubeBuilder(VertexFormat format) {
|
||||
this(format, new ArrayList<>(6));
|
||||
}
|
||||
public CubeBuilder( VertexFormat format, List<BakedQuad> output )
|
||||
{
|
||||
this.output = output;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public void addCube(float x1, float y1, float z1, float x2, float y2, float z2) {
|
||||
x1 /= 16.0f;
|
||||
y1 /= 16.0f;
|
||||
z1 /= 16.0f;
|
||||
x2 /= 16.0f;
|
||||
y2 /= 16.0f;
|
||||
z2 /= 16.0f;
|
||||
public CubeBuilder( VertexFormat format )
|
||||
{
|
||||
this( format, new ArrayList<>( 6 ) );
|
||||
}
|
||||
|
||||
// If brightness is forced to specific values, extend the vertex format to contain the multi-texturing lightmap offset
|
||||
VertexFormat savedFormat = null;
|
||||
if (renderFullBright) {
|
||||
savedFormat = format;
|
||||
format = new VertexFormat(savedFormat);
|
||||
if (!format.getElements().contains(DefaultVertexFormats.TEX_2S)) {
|
||||
format.addElement(DefaultVertexFormats.TEX_2S);
|
||||
}
|
||||
}
|
||||
public void addCube( float x1, float y1, float z1, float x2, float y2, float z2 )
|
||||
{
|
||||
x1 /= 16.0f;
|
||||
y1 /= 16.0f;
|
||||
z1 /= 16.0f;
|
||||
x2 /= 16.0f;
|
||||
y2 /= 16.0f;
|
||||
z2 /= 16.0f;
|
||||
|
||||
for (EnumFacing face : drawFaces) {
|
||||
putFace(face, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
// If brightness is forced to specific values, extend the vertex format to contain the multi-texturing lightmap offset
|
||||
VertexFormat savedFormat = null;
|
||||
if( renderFullBright )
|
||||
{
|
||||
savedFormat = format;
|
||||
format = new VertexFormat( savedFormat );
|
||||
if( !format.getElements().contains( DefaultVertexFormats.TEX_2S ) )
|
||||
{
|
||||
format.addElement( DefaultVertexFormats.TEX_2S );
|
||||
}
|
||||
}
|
||||
|
||||
// Restore old format
|
||||
if (savedFormat != null) {
|
||||
format = savedFormat;
|
||||
}
|
||||
}
|
||||
for( EnumFacing face : drawFaces )
|
||||
{
|
||||
putFace( face, x1, y1, z1, x2, y2, z2 );
|
||||
}
|
||||
|
||||
private void putFace(EnumFacing face,
|
||||
float x1, float y1, float z1,
|
||||
float x2, float y2, float z2
|
||||
) {
|
||||
// Restore old format
|
||||
if( savedFormat != null )
|
||||
{
|
||||
format = savedFormat;
|
||||
}
|
||||
}
|
||||
|
||||
TextureAtlasSprite texture = textures.get(face);
|
||||
private static final class UvVector
|
||||
{
|
||||
float u1;
|
||||
float u2;
|
||||
float v1;
|
||||
float v2;
|
||||
}
|
||||
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
|
||||
builder.setTexture(texture);
|
||||
builder.setQuadOrientation(face);
|
||||
private void putFace( EnumFacing face,
|
||||
float x1, float y1, float z1,
|
||||
float x2, float y2, float z2
|
||||
)
|
||||
{
|
||||
|
||||
float u1 = 0;
|
||||
float v1 = 0;
|
||||
float u2 = 0;
|
||||
float v2 = 0;
|
||||
TextureAtlasSprite texture = textures.get( face );
|
||||
|
||||
// The user might have set specific UV coordinates for this face
|
||||
Vector4f customUv = this.customUv.get( face );
|
||||
if( customUv != null )
|
||||
{
|
||||
u1 = texture.getInterpolatedU( customUv.x );
|
||||
v1 = texture.getInterpolatedV( customUv.y );
|
||||
u2 = texture.getInterpolatedU( customUv.z );
|
||||
v2 = texture.getInterpolatedV( customUv.w );
|
||||
}
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder( format );
|
||||
builder.setTexture( texture );
|
||||
builder.setQuadOrientation( face );
|
||||
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
v1 = texture.getInterpolatedV( z1 * 16 );
|
||||
u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
v2 = texture.getInterpolatedV( z2 * 16 );
|
||||
}
|
||||
UvVector uv = new UvVector();
|
||||
|
||||
putVertex(builder, face, x2, y1, z1, u2, v1);
|
||||
putVertex(builder, face, x2, y1, z2, u2, v2);
|
||||
putVertex(builder, face, x1, y1, z2, u1, v2);
|
||||
putVertex(builder, face, x1, y1, z1, u1, v1);
|
||||
break;
|
||||
case UP:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
v1 = texture.getInterpolatedV( z1 * 16 );
|
||||
u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
v2 = texture.getInterpolatedV( z2 * 16 );
|
||||
}
|
||||
// The user might have set specific UV coordinates for this face
|
||||
Vector4f customUv = this.customUv.get( face );
|
||||
if( customUv != null )
|
||||
{
|
||||
uv.u1 = texture.getInterpolatedU( customUv.x );
|
||||
uv.v1 = texture.getInterpolatedV( customUv.y );
|
||||
uv.u2 = texture.getInterpolatedU( customUv.z );
|
||||
uv.v2 = texture.getInterpolatedV( customUv.w );
|
||||
}
|
||||
else
|
||||
{
|
||||
uv = getDefaultUv( face, texture, x1, y1, z1, x2, y2, z2 );
|
||||
}
|
||||
|
||||
putVertex(builder, face, x1, y2, z1, u1, v1);
|
||||
putVertex(builder, face, x1, y2, z2, u1, v2);
|
||||
putVertex(builder, face, x2, y2, z2, u2, v2);
|
||||
putVertex(builder, face, x2, y2, z1, u2, v1);
|
||||
break;
|
||||
case NORTH:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
}
|
||||
switch( face )
|
||||
{
|
||||
case DOWN:
|
||||
putVertexTR( builder, face, x2, y1, z1, uv );
|
||||
putVertexBR( builder, face, x2, y1, z2, uv );
|
||||
putVertexBL( builder, face, x1, y1, z2, uv );
|
||||
putVertexTL( builder, face, x1, y1, z1, uv );
|
||||
break;
|
||||
case UP:
|
||||
putVertexTL( builder, face, x1, y2, z1, uv );
|
||||
putVertexBL( builder, face, x1, y2, z2, uv );
|
||||
putVertexBR( builder, face, x2, y2, z2, uv );
|
||||
putVertexTR( builder, face, x2, y2, z1, uv );
|
||||
break;
|
||||
case NORTH:
|
||||
putVertexBR( builder, face, x2, y2, z1, uv );
|
||||
putVertexTR( builder, face, x2, y1, z1, uv );
|
||||
putVertexTL( builder, face, x1, y1, z1, uv );
|
||||
putVertexBL( builder, face, x1, y2, z1, uv );
|
||||
break;
|
||||
case SOUTH:
|
||||
putVertexBL( builder, face, x1, y2, z2, uv );
|
||||
putVertexTL( builder, face, x1, y1, z2, uv );
|
||||
putVertexTR( builder, face, x2, y1, z2, uv );
|
||||
putVertexBR( builder, face, x2, y2, z2, uv );
|
||||
break;
|
||||
case WEST:
|
||||
putVertexTL( builder, face, x1, y1, z1, uv );
|
||||
putVertexTR( builder, face, x1, y1, z2, uv );
|
||||
putVertexBR( builder, face, x1, y2, z2, uv );
|
||||
putVertexBL( builder, face, x1, y2, z1, uv );
|
||||
break;
|
||||
case EAST:
|
||||
putVertexBR( builder, face, x2, y2, z1, uv );
|
||||
putVertexBL( builder, face, x2, y2, z2, uv );
|
||||
putVertexTL( builder, face, x2, y1, z2, uv );
|
||||
putVertexTR( builder, face, x2, y1, z1, uv );
|
||||
break;
|
||||
}
|
||||
|
||||
putVertex(builder, face, x2, y2, z1, u2, v2);
|
||||
putVertex(builder, face, x2, y1, z1, u2, v1);
|
||||
putVertex(builder, face, x1, y1, z1, u1, v1);
|
||||
putVertex(builder, face, x1, y2, z1, u1, v2);
|
||||
break;
|
||||
case SOUTH:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
}
|
||||
int[] vertexData = builder.build().getVertexData();
|
||||
output.add( new BakedQuad( vertexData, -1, face, texture, true, format ) );
|
||||
}
|
||||
|
||||
putVertex(builder, face, x1, y2, z2, u1, v2);
|
||||
putVertex(builder, face, x1, y1, z2, u1, v1);
|
||||
putVertex(builder, face, x2, y1, z2, u2, v1);
|
||||
putVertex(builder, face, x2, y2, z2, u2, v2);
|
||||
break;
|
||||
case WEST:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( z1 * 16 );
|
||||
v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
u2 = texture.getInterpolatedU( z2 * 16 );
|
||||
v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
}
|
||||
private UvVector getDefaultUv( EnumFacing face, TextureAtlasSprite texture,
|
||||
float x1, float y1, float z1,
|
||||
float x2, float y2, float z2 )
|
||||
{
|
||||
|
||||
putVertex(builder, face, x1, y1, z1, u1, v1);
|
||||
putVertex(builder, face, x1, y1, z2, u2, v1);
|
||||
putVertex(builder, face, x1, y2, z2, u2, v2);
|
||||
putVertex(builder, face, x1, y2, z1, u1, v2);
|
||||
break;
|
||||
case EAST:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( z2 * 16 );
|
||||
v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
u2 = texture.getInterpolatedU( z1 * 16 );
|
||||
v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
}
|
||||
UvVector uv = new UvVector();
|
||||
|
||||
putVertex(builder, face, x2, y2, z1, u2, v2);
|
||||
putVertex(builder, face, x2, y2, z2, u1, v2);
|
||||
putVertex(builder, face, x2, y1, z2, u1, v1);
|
||||
putVertex(builder, face, x2, y1, z1, u2, v1);
|
||||
break;
|
||||
}
|
||||
switch( face )
|
||||
{
|
||||
case DOWN:
|
||||
uv.u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
uv.v1 = texture.getInterpolatedV( z1 * 16 );
|
||||
uv.u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
uv.v2 = texture.getInterpolatedV( z2 * 16 );
|
||||
break;
|
||||
case UP:
|
||||
uv.u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
uv.v1 = texture.getInterpolatedV( z1 * 16 );
|
||||
uv.u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
uv.v2 = texture.getInterpolatedV( z2 * 16 );
|
||||
break;
|
||||
case NORTH:
|
||||
uv.u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
uv.u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
break;
|
||||
case SOUTH:
|
||||
uv.u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
uv.u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
break;
|
||||
case WEST:
|
||||
uv.u1 = texture.getInterpolatedU( z1 * 16 );
|
||||
uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
uv.u2 = texture.getInterpolatedU( z2 * 16 );
|
||||
uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
break;
|
||||
case EAST:
|
||||
uv.u1 = texture.getInterpolatedU( z2 * 16 );
|
||||
uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
uv.u2 = texture.getInterpolatedU( z1 * 16 );
|
||||
uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
break;
|
||||
}
|
||||
|
||||
int[] vertexData = builder.build().getVertexData();
|
||||
output.add(new BakedQuad(vertexData, -1, face, texture, true, format));
|
||||
}
|
||||
return uv;
|
||||
}
|
||||
|
||||
private void putVertex(UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, float u, float v) {
|
||||
VertexFormat format = builder.getVertexFormat();
|
||||
// uv.u1, uv.v1
|
||||
private void putVertexTL( UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, UvVector uv )
|
||||
{
|
||||
float u, v;
|
||||
|
||||
for (int i = 0; i < format.getElementCount(); i++) {
|
||||
VertexFormatElement e = format.getElement(i);
|
||||
switch (e.getUsage()) {
|
||||
case POSITION:
|
||||
builder.put(i, x, y, z);
|
||||
break;
|
||||
case NORMAL:
|
||||
builder.put(i,
|
||||
face.getFrontOffsetX(),
|
||||
face.getFrontOffsetY(),
|
||||
face.getFrontOffsetZ());
|
||||
break;
|
||||
case COLOR:
|
||||
// Color format is RGBA
|
||||
float r = (color >> 16 & 0xFF) / 255f;
|
||||
float g = (color >> 8 & 0xFF) / 255f;
|
||||
float b = (color & 0xFF) / 255f;
|
||||
float a = (color >> 24 & 0xFF) / 255f;
|
||||
builder.put(i, r, g, b, a);
|
||||
break;
|
||||
case UV:
|
||||
if (e.getIndex() == 0) {
|
||||
builder.put(i, u, v);
|
||||
} else {
|
||||
// Force Brightness to 15, this is for full bright mode
|
||||
// this vertex element will only be present in that case
|
||||
final float lightMapU = (float) (15 * 0x20) / 0xFFFF;
|
||||
final float lightMapV = (float) (15 * 0x20) / 0xFFFF;
|
||||
builder.put(i, lightMapU, lightMapV);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
builder.put(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (uvRotations[face.ordinal()]) {
|
||||
default:
|
||||
case 0:
|
||||
u = uv.u1;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 1: // 90° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 2: // 180° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 3: // 270° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v1;
|
||||
break;
|
||||
}
|
||||
|
||||
public void setTexture(TextureAtlasSprite texture) {
|
||||
for (EnumFacing face : EnumFacing.values()) {
|
||||
textures.put(face, texture);
|
||||
}
|
||||
}
|
||||
putVertex(builder, face, x, y, z, u, v );
|
||||
}
|
||||
|
||||
public void setTextures(TextureAtlasSprite up, TextureAtlasSprite down, TextureAtlasSprite north, TextureAtlasSprite south, TextureAtlasSprite east, TextureAtlasSprite west) {
|
||||
textures.put(EnumFacing.UP, up);
|
||||
textures.put(EnumFacing.DOWN, down);
|
||||
textures.put(EnumFacing.NORTH, north);
|
||||
textures.put(EnumFacing.SOUTH, south);
|
||||
textures.put(EnumFacing.EAST, east);
|
||||
textures.put(EnumFacing.WEST, west);
|
||||
}
|
||||
// uv.u2, uv.v1
|
||||
private void putVertexTR( UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, UvVector uv )
|
||||
{
|
||||
float u;
|
||||
float v;
|
||||
|
||||
public void setDrawFaces(EnumSet<EnumFacing> drawFaces) {
|
||||
this.drawFaces = drawFaces;
|
||||
}
|
||||
switch (uvRotations[face.ordinal()]) {
|
||||
default:
|
||||
case 0:
|
||||
u = uv.u2;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 1: // 90° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 2: // 180° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 3: // 270° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v2;
|
||||
break;
|
||||
}
|
||||
putVertex(builder, face, x, y, z, u, v );
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
// uv.u2, uv.v2
|
||||
private void putVertexBR( UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, UvVector uv )
|
||||
{
|
||||
|
||||
/**
|
||||
* Sets the vertex color for future vertices to the given RGB value, and forces the alpha component to 255.
|
||||
*/
|
||||
public void setColorRGB(int color) {
|
||||
setColor(color | 0xFF000000);
|
||||
}
|
||||
float u;
|
||||
float v;
|
||||
|
||||
public void setRenderFullBright(boolean renderFullBright) {
|
||||
this.renderFullBright = renderFullBright;
|
||||
}
|
||||
switch (uvRotations[face.ordinal()]) {
|
||||
default:
|
||||
case 0:
|
||||
u = uv.u2;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 1: // 90° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 2: // 180° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 3: // 270° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v2;
|
||||
break;
|
||||
}
|
||||
|
||||
public void setCustomUv( EnumFacing facing, float u1, float v1, float u2, float v2 )
|
||||
{
|
||||
customUv.put( facing, new Vector4f( u1, v1, u2, v2 ) );
|
||||
}
|
||||
putVertex(builder, face, x, y, z, u, v );
|
||||
}
|
||||
|
||||
public List<BakedQuad> getOutput() {
|
||||
return output;
|
||||
}
|
||||
// uv.u1, uv.v2
|
||||
private void putVertexBL( UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, UvVector uv )
|
||||
{
|
||||
|
||||
float u;
|
||||
float v;
|
||||
|
||||
switch (uvRotations[face.ordinal()]) {
|
||||
default:
|
||||
case 0:
|
||||
u = uv.u1;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 1: // 90° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 2: // 180° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 3: // 270° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v1;
|
||||
break;
|
||||
}
|
||||
|
||||
putVertex(builder, face, x, y, z, u, v );
|
||||
}
|
||||
|
||||
private void putVertex( UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, float u, float v )
|
||||
{
|
||||
VertexFormat format = builder.getVertexFormat();
|
||||
|
||||
for( int i = 0; i < format.getElementCount(); i++ )
|
||||
{
|
||||
VertexFormatElement e = format.getElement( i );
|
||||
switch( e.getUsage() )
|
||||
{
|
||||
case POSITION:
|
||||
builder.put( i, x, y, z );
|
||||
break;
|
||||
case NORMAL:
|
||||
builder.put( i,
|
||||
face.getFrontOffsetX(),
|
||||
face.getFrontOffsetY(),
|
||||
face.getFrontOffsetZ() );
|
||||
break;
|
||||
case COLOR:
|
||||
// Color format is RGBA
|
||||
float r = ( color >> 16 & 0xFF ) / 255f;
|
||||
float g = ( color >> 8 & 0xFF ) / 255f;
|
||||
float b = ( color & 0xFF ) / 255f;
|
||||
float a = ( color >> 24 & 0xFF ) / 255f;
|
||||
builder.put( i, r, g, b, a );
|
||||
break;
|
||||
case UV:
|
||||
if( e.getIndex() == 0 )
|
||||
{
|
||||
builder.put( i, u, v );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Force Brightness to 15, this is for full bright mode
|
||||
// this vertex element will only be present in that case
|
||||
final float lightMapU = (float) ( 15 * 0x20 ) / 0xFFFF;
|
||||
final float lightMapV = (float) ( 15 * 0x20 ) / 0xFFFF;
|
||||
builder.put( i, lightMapU, lightMapV );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
builder.put( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTexture( TextureAtlasSprite texture )
|
||||
{
|
||||
for( EnumFacing face : EnumFacing.values() )
|
||||
{
|
||||
textures.put( face, texture );
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextures( TextureAtlasSprite up, TextureAtlasSprite down, TextureAtlasSprite north, TextureAtlasSprite south, TextureAtlasSprite east, TextureAtlasSprite west )
|
||||
{
|
||||
textures.put( EnumFacing.UP, up );
|
||||
textures.put( EnumFacing.DOWN, down );
|
||||
textures.put( EnumFacing.NORTH, north );
|
||||
textures.put( EnumFacing.SOUTH, south );
|
||||
textures.put( EnumFacing.EAST, east );
|
||||
textures.put( EnumFacing.WEST, west );
|
||||
}
|
||||
|
||||
public void setDrawFaces( EnumSet<EnumFacing> drawFaces )
|
||||
{
|
||||
this.drawFaces = drawFaces;
|
||||
}
|
||||
|
||||
public void setColor( int color )
|
||||
{
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vertex color for future vertices to the given RGB value, and forces the alpha component to 255.
|
||||
*/
|
||||
public void setColorRGB( int color )
|
||||
{
|
||||
setColor( color | 0xFF000000 );
|
||||
}
|
||||
|
||||
public void setRenderFullBright( boolean renderFullBright )
|
||||
{
|
||||
this.renderFullBright = renderFullBright;
|
||||
}
|
||||
|
||||
public void setCustomUv( EnumFacing facing, float u1, float v1, float u2, float v2 )
|
||||
{
|
||||
customUv.put( facing, new Vector4f( u1, v1, u2, v2 ) );
|
||||
}
|
||||
|
||||
public void setUvRotation( EnumFacing facing, int rotation )
|
||||
{
|
||||
if ( rotation == 2 ) {
|
||||
rotation = 3;
|
||||
} else if ( rotation == 3 ) {
|
||||
rotation = 2;
|
||||
}
|
||||
Preconditions.checkArgument( rotation >= 0 && rotation <= 3, "rotation" );
|
||||
uvRotations[facing.ordinal()] = (byte) rotation;
|
||||
}
|
||||
|
||||
public List<BakedQuad> getOutput()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user