use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class PipeWireRenderer method getQuads.
private static MutableQuad[] getQuads(EnumWireBetween between) {
// 4 rather than 6 -- don't render the end caps
MutableQuad[] quads = new MutableQuad[4];
int i = 0;
Vec3d center;
Vec3d radius;
boolean ax = between.mainAxis == Axis.X;
boolean ay = between.mainAxis == Axis.Y;
boolean az = between.mainAxis == Axis.Z;
if (between.to == null) {
double cL = 0.5f - 4.51f / 16f;
double cU = 0.5f + 4.51f / 16f;
center = new //
Vec3d(//
ax ? 0.5f : (between.xy ? cU : cL), //
ay ? 0.5f : ((ax ? between.xy : between.yz) ? cU : cL), //
az ? 0.5f : (between.yz ? cU : cL));
double rC = 4.01f / 16f;
double rN = 1f / 16f / 2;
radius = new //
Vec3d(//
ax ? rC : rN, //
ay ? rC : rN, //
az ? rC : rN);
} else {
// we are a connection
double cL = (8 - 4.51) / 16;
double cU = (8 + 4.51) / 16;
radius = new //
Vec3d(//
ax ? 2.99 / 32 : 1 / 32.0, //
ay ? 2.99 / 32 : 1 / 32.0, //
az ? 2.99 / 32 : 1 / 32.0);
center = new //
Vec3d(//
ax ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetX()) : (between.xy ? cU : cL), //
ay ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetY()) : ((ax ? between.xy : between.yz) ? cU : cL), //
az ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetZ()) : (between.yz ? cU : cL));
}
UvFaceData uvBase = new UvFaceData();
uvBase.minU = (float) VecUtil.getValue(center.subtract(radius), between.mainAxis);
uvBase.maxU = (float) VecUtil.getValue(center.add(radius), between.mainAxis);
uvBase.minV = 0;
uvBase.maxV = 1 / 16f;
Tuple3f centerFloat = VecUtil.convertFloat(center);
Tuple3f radiusFloat = VecUtil.convertFloat(radius);
for (EnumFacing face : EnumFacing.VALUES) {
if (face.getAxis() == between.mainAxis) {
continue;
}
UvFaceData uvs = new UvFaceData(uvBase);
Axis aAxis = between.mainAxis;
Axis fAxis = face.getAxis();
boolean fPositive = face.getAxisDirection() == AxisDirection.POSITIVE;
int rotations = 0;
boolean swapU = false;
boolean swapV = false;
if (aAxis == Axis.X) {
swapV = fPositive;
} else if (aAxis == Axis.Y) {
rotations = 1;
swapU = (fAxis == Axis.X) != fPositive;
swapV = fAxis == Axis.Z;
} else {
// aAxis == Axis.Z
if (fAxis == Axis.Y) {
rotations = 1;
}
swapU = face == EnumFacing.DOWN;
swapV = face != EnumFacing.EAST;
}
if (swapU) {
float t = uvs.minU;
uvs.minU = uvs.maxU;
uvs.maxU = t;
}
if (swapV) {
float t = uvs.minV;
uvs.minV = uvs.maxV;
uvs.maxV = t;
}
MutableQuad quad = ModelUtil.createFace(face, centerFloat, radiusFloat, uvs);
if (rotations > 0)
quad.rotateTextureUp(rotations);
quads[i++] = quad;
}
return quads;
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class PlugBakerSimple method bake.
@Override
public List<BakedQuad> bake(K key) {
MutableQuad[] quads = provider.getCutoutQuads();
if (quads != lastSeen) {
cached.clear();
MutableQuad copy = new MutableQuad();
for (EnumFacing to : EnumFacing.VALUES) {
List<BakedQuad> list = new ArrayList<>();
for (MutableQuad q : quads) {
copy.copyFrom(q);
copy.rotate(EnumFacing.WEST, to, 0.5f, 0.5f, 0.5f);
copy.multShade();
list.add(copy.toBakedBlock());
}
cached.put(to, list);
}
lastSeen = quads;
}
return cached.get(key.side);
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class MutableQuadTest method testRotations.
@Test
public void testRotations() {
for (EnumFacing from : EnumFacing.VALUES) {
for (EnumFacing to : EnumFacing.VALUES) {
Vec3i vec = from.getDirectionVec();
MutableQuad q = new MutableQuad();
q.vertex_0.positionf(vec.getX(), vec.getY(), vec.getZ());
q.rotate(from, to, 0, 0, 0);
float ex = to.getFrontOffsetX();
float ey = to.getFrontOffsetY();
float ez = to.getFrontOffsetZ();
Assert.assertEquals(from + " -> " + to + " [X]", ex, q.vertex_0.position_x, 0.001f);
Assert.assertEquals(from + " -> " + to + " [Y]", ey, q.vertex_0.position_y, 0.001f);
Assert.assertEquals(from + " -> " + to + " [Z]", ez, q.vertex_0.position_z, 0.001f);
}
}
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class GatePluggableModel method renderGate.
public List<MutableQuad> renderGate(KeyPlugGate gate, VertexFormat format) {
TextureAtlasSprite logicSprite = gate.lit ? gate.logic.getIconLit() : gate.logic.getIconDark();
TextureAtlasSprite materialSprite = gate.material.getIconBlock();
IModel main = modelMain();
IModel material = modelMaterial();
List<MutableQuad> quads = Lists.newArrayList();
IFlexibleBakedModel baked = main.bake(ModelRotation.X0_Y0, format, singleTextureFunction(logicSprite));
for (BakedQuad quad : baked.getGeneralQuads()) {
MutableQuad mutable = MutableQuad.create(quad, format);
quads.add(mutable);
}
if (materialSprite != null) {
// Its null for redstone (As we don't render any material for redstone gates)
baked = material.bake(ModelRotation.X0_Y0, format, singleTextureFunction(materialSprite));
for (BakedQuad quad : baked.getGeneralQuads()) {
quads.add(MutableQuad.create(quad, format));
}
}
for (GateExpansionModelKey<?> expansion : gate.expansions) {
generate(quads, expansion);
}
return quads;
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class ModelPowerAdapter method bakeCutout.
private List<BakedQuad> bakeCutout(EnumFacing face, VertexFormat format) {
IModel model = modelPowerAdapter();
TextureAtlasSprite sprite = spritePowerAdapter;
List<BakedQuad> quads = Lists.newArrayList();
List<BakedQuad> bakedQuads = renderAdapter(model, sprite, format);
Matrix4f matrix = MatrixUtil.rotateTowardsFace(face);
for (BakedQuad quad : bakedQuads) {
MutableQuad mutable = MutableQuad.create(quad);
mutable.transform(matrix);
ModelUtil.appendBakeQuads(quads, format, mutable);
}
return quads;
}
Aggregations