mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-12 00:07:33 +00:00
Added FullBlock side masked render function
Fixed bug with Vertex5 constructor not passing tex to UV
This commit is contained in:
1 parent
f9287f696b
commit
645919daa9
2 files changed
+38
-34
No files matched your search
@@ -138,17 +138,32 @@ public class BlockRenderer
|
||||
}
|
||||
|
||||
public static FullBlock fullBlock = new FullBlock();
|
||||
public static void renderFullBlock(int sideMask) {
|
||||
CCRenderState.setModel(fullBlock);
|
||||
renderFaces(sideMask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders faces of a block-like model based on a sideMask. Eg for side 2, verts 8-11 will be rendered
|
||||
* @param sideMask A mask of faces not to render
|
||||
*/
|
||||
public static void renderFaces(int sideMask) {
|
||||
if(sideMask == 0x3F) return;
|
||||
for(int s = 0; s < 6; s++)
|
||||
if((sideMask & 1<<s) == 0) {
|
||||
CCRenderState.setVertexRange(s*4, (s+1)*4);
|
||||
CCRenderState.render();
|
||||
}
|
||||
}
|
||||
|
||||
private static BlockFace face = new BlockFace();
|
||||
|
||||
/**
|
||||
* Renders faces of a cuboid with texture coordinates mapped to match a standard minecraft block
|
||||
* @param bounds The bounding cuboid to render
|
||||
* @param sideMask A mask of faces not to render
|
||||
*/
|
||||
public static void renderCuboid(Cuboid6 bounds, int sideMask) {
|
||||
if(sideMask == 0x3F)
|
||||
return;
|
||||
if(sideMask == 0x3F) return;
|
||||
|
||||
CCRenderState.setModel(face);
|
||||
for(int s = 0; s < 6; s++)
|
||||
|
||||
@@ -14,42 +14,35 @@ public class Vertex5 implements Copyable<Vertex5>
|
||||
{
|
||||
public Vector3 vec;
|
||||
public UV uv;
|
||||
|
||||
public Vertex5()
|
||||
{
|
||||
|
||||
public Vertex5() {
|
||||
this(new Vector3(), new UV());
|
||||
}
|
||||
|
||||
public Vertex5(Vector3 vert, UV uv)
|
||||
{
|
||||
|
||||
public Vertex5(Vector3 vert, UV uv) {
|
||||
this.vec = vert;
|
||||
this.uv = uv;
|
||||
}
|
||||
|
||||
public Vertex5(Vector3 vert, double u, double v)
|
||||
{
|
||||
|
||||
public Vertex5(Vector3 vert, double u, double v) {
|
||||
this(vert, new UV(u, v));
|
||||
}
|
||||
|
||||
public Vertex5(double x, double y, double z, double u, double v)
|
||||
{
|
||||
public Vertex5(double x, double y, double z, double u, double v) {
|
||||
this(x, y, z, u, v, 0);
|
||||
}
|
||||
|
||||
public Vertex5(double x, double y, double z, double u, double v, int tex)
|
||||
{
|
||||
this(new Vector3(x, y, z), new UV(u, v));
|
||||
public Vertex5(double x, double y, double z, double u, double v, int tex) {
|
||||
this(new Vector3(x, y, z), new UV(u, v, tex));
|
||||
}
|
||||
|
||||
public Vertex5 set(double x, double y, double z, double u, double v)
|
||||
{
|
||||
public Vertex5 set(double x, double y, double z, double u, double v) {
|
||||
vec.set(x, y, z);
|
||||
uv.set(u, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vertex5 set(double x, double y, double z, double u, double v, int tex)
|
||||
{
|
||||
public Vertex5 set(double x, double y, double z, double u, double v, int tex) {
|
||||
vec.set(x, y, z);
|
||||
uv.set(u, v, tex);
|
||||
return this;
|
||||
@@ -61,30 +54,26 @@ public class Vertex5 implements Copyable<Vertex5>
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vertex5(Vertex5 vertex5)
|
||||
{
|
||||
public Vertex5(Vertex5 vertex5) {
|
||||
this(vertex5.vec.copy(), vertex5.uv.copy());
|
||||
}
|
||||
|
||||
public Vertex5 copy()
|
||||
{
|
||||
public Vertex5 copy() {
|
||||
return new Vertex5(this);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
|
||||
public String toString() {
|
||||
MathContext cont = new MathContext(4, RoundingMode.HALF_UP);
|
||||
return "Vertex: ("+new BigDecimal(vec.x, cont)+", "+new BigDecimal(vec.y, cont)+", "+new BigDecimal(vec.z, cont)+") ("+new BigDecimal(uv.u, cont)+", "+new BigDecimal(uv.v, cont)+")";
|
||||
return "Vertex: (" + new BigDecimal(vec.x, cont) + ", " + new BigDecimal(vec.y, cont) + ", " + new BigDecimal(vec.z, cont) + ") " +
|
||||
"(" + new BigDecimal(uv.u, cont) + ", " + new BigDecimal(uv.v, cont) + ") ("+uv.tex+")";
|
||||
}
|
||||
|
||||
public Vertex5 apply(Transformation t)
|
||||
{
|
||||
public Vertex5 apply(Transformation t) {
|
||||
vec.apply(t);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vertex5 apply(UVTransformation t)
|
||||
{
|
||||
|
||||
public Vertex5 apply(UVTransformation t) {
|
||||
uv.apply(t);
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user