use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class VariablePartCuboidBase method addQuads.
@Override
public void addQuads(List<MutableQuad> addTo, ITextureGetter spriteLookup) {
if (visible.evaluate()) {
float[] f = bakePosition(from);
float[] t = bakePosition(to);
boolean s = shade.evaluate();
int l = (int) (light.evaluate() & 15);
int rgba = RenderUtil.swapARGBforABGR((int) colour.evaluate());
for (EnumFacing face : EnumFacing.VALUES) {
VariableFaceData data = getFaceData(face, spriteLookup);
if (data != null) {
Vector3f radius = new Vector3f(t[0] - f[0], t[1] - f[1], t[2] - f[2]);
radius.scale(0.5f);
Vector3f center = new Vector3f(f);
center.add(radius);
MutableQuad quad = ModelUtil.createFace(face, center, radius, data.uvs);
quad.rotateTextureUp(data.rotations);
quad.lighti(l, 0);
quad.colouri(rgba);
quad.texFromSprite(data.sprite);
quad.setSprite(data.sprite);
quad.setShade(s);
if (data.bothSides) {
addTo.add(quad.copyAndInvertNormal());
} else if (data.invertNormal) {
quad = quad.copyAndInvertNormal();
}
addTo.add(quad);
}
}
}
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class ItemRenderUtil method renderItemStack.
/**
* Used to render a lot of items in sequential order. Assumes that you don't change the glstate inbetween calls.
* You must call {@link #endItemBatch()} after your have rendered all of the items.
*/
public static void renderItemStack(double x, double y, double z, ItemStack stack, int lightc, EnumFacing dir, BufferBuilder bb) {
if (stack.isEmpty()) {
return;
}
if (dir == null) {
dir = EnumFacing.EAST;
}
dir = BCLibConfig.rotateTravelingItems.changeFacing(dir);
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
model = model.getOverrides().handleItemState(model, stack, null, null);
boolean requireGl = stack.hasEffect() || model.isBuiltInRenderer();
if (bb != null && !requireGl) {
bb.setTranslation(x, y, z);
float scale = 0.30f;
MutableQuad q = new MutableQuad(-1, null);
for (EnumPipePart part : EnumPipePart.VALUES) {
for (BakedQuad quad : model.getQuads(null, part.face, 0)) {
q.fromBakedItem(quad);
q.translated(-0.5, -0.5, -0.5);
q.scaled(scale);
q.rotate(EnumFacing.SOUTH, dir, 0, 0, 0);
if (quad.hasTintIndex()) {
int colour = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, quad.getTintIndex());
if (EntityRenderer.anaglyphEnable) {
colour = TextureUtil.anaglyphColor(colour);
}
q.multColouri(colour, colour >> 8, colour >> 16, 0xFF);
}
q.lighti(lightc);
Vector3f normal = q.getCalculatedNormal();
q.normalvf(normal);
q.multShade();
q.render(bb);
}
}
bb.setTranslation(0, 0, 0);
return;
}
if (!inBatch) {
inBatch = true;
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
GL11.glScaled(0.3, 0.3, 0.3);
RenderHelper.disableStandardItemLighting();
}
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightc % (float) 0x1_00_00, lightc / (float) 0x1_00_00);
Minecraft.getMinecraft().getRenderItem().renderItem(stack, model);
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class BuildCraftBakedModel method createQuadsItemLayer.
public static List<MutableQuad> createQuadsItemLayer(final List<TextureAtlasSprite> sprites) {
ImmutableList.Builder<ResourceLocation> builder = ImmutableList.builder();
for (int i = 0; i < sprites.size(); i++) {
builder.add(new ResourceLocation("buildcraftbakedmodel:spriteindex" + i));
}
final ImmutableList<ResourceLocation> locations = builder.build();
ItemLayerModel model = new ItemLayerModel(locations);
IBakedModel baked = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.BLOCK, new Function<ResourceLocation, TextureAtlasSprite>() {
@Override
public TextureAtlasSprite apply(ResourceLocation input) {
return sprites.get(locations.indexOf(input));
}
});
Matrix4f itemToEdge = new Matrix4f();
itemToEdge.setIdentity();
itemToEdge.setRotation(new AxisAngle4f(0, 1, 0, (float) (Math.PI / 2)));
Matrix4f translation = new Matrix4f();
translation.setIdentity();
translation.setTranslation(new Vector3f(-15 / 32f, 0, 1));
translation.mul(itemToEdge);
List<MutableQuad> mutableQuads = ModelUtil.toMutableQuadList(baked, false);
for (MutableQuad mutable : mutableQuads) {
mutable.transform(translation);
mutable.setTint(-1);
}
return mutableQuads;
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class RenderResizableCuboid method bakeCuboidFace.
private static void bakeCuboidFace(List<MutableQuad> quads, EntityResizableCuboid cuboid, EnumFacing face, TextureAtlasSprite[] sprites, int[] flips, Vec3d textureStart, Vec3d textureSize, Vec3d size, Vec3d textureOffset, boolean out, boolean in) {
int ordinal = face.ordinal();
if (sprites[ordinal] == null) {
return;
}
Vec3d textureEnd = textureStart.add(textureSize);
float[] uv = getUVArray(sprites[ordinal], flips[ordinal], face, textureStart, textureEnd);
List<RenderInfo> renderInfoList = getRenderInfos(uv, face, size, textureSize, textureOffset);
Axis u = face.getAxis() == Axis.X ? Axis.Z : Axis.X;
Axis v = face.getAxis() == Axis.Y ? Axis.Z : Axis.Y;
double other = face.getAxisDirection() == AxisDirection.POSITIVE ? VecUtil.getValue(size, face.getAxis()) : 0;
/* Swap the face if this is positive: the renderer returns indexes that ALWAYS are for the negative face, so
* light it properly this way */
// face = face.getAxisDirection() == AxisDirection.NEGATIVE ? face : face.getOpposite();
EnumFacing opposite = face.getOpposite();
boolean flip = ModelUtil.shouldInvertForRender(face);
for (RenderInfo ri : renderInfoList) {
ri = ri.offset(cuboid, face.getAxis());
double otherMoved = other + VecUtil.getValue(cuboid.getPositionVector(), face.getAxis());
if (flip ? out : in) {
MutableQuad mutable = new MutableQuad(-1, face);
bakePoint(mutable.vertex_0, face, u, v, otherMoved, ri, true, false);
bakePoint(mutable.vertex_1, face, u, v, otherMoved, ri, true, true);
bakePoint(mutable.vertex_2, face, u, v, otherMoved, ri, false, true);
bakePoint(mutable.vertex_3, face, u, v, otherMoved, ri, false, false);
quads.add(mutable);
}
if (flip ? in : out) {
MutableQuad mutable = new MutableQuad(-1, face);
bakePoint(mutable.vertex_0, opposite, u, v, otherMoved, ri, false, false);
bakePoint(mutable.vertex_1, opposite, u, v, otherMoved, ri, false, true);
bakePoint(mutable.vertex_2, opposite, u, v, otherMoved, ri, true, true);
bakePoint(mutable.vertex_3, opposite, u, v, otherMoved, ri, true, false);
quads.add(mutable);
}
}
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class PipeWireRenderer method getQuads.
private static MutableQuad[] getQuads(EnumWirePart part) {
MutableQuad[] quads = new MutableQuad[6];
Tuple3f center = new //
Point3f(//
0.5f + (part.x.getOffset() * 4.51f / 16f), //
0.5f + (part.y.getOffset() * 4.51f / 16f), //
0.5f + (part.z.getOffset() * 4.51f / 16f));
Tuple3f radius = new Point3f(1 / 32f, 1 / 32f, 1 / 32f);
UvFaceData uvs = new UvFaceData();
int off = func(part.x) * 4 + func(part.y) * 2 + func(part.z);
uvs.minU = off / 16f;
uvs.maxU = (off + 1) / 16f;
uvs.minV = 0;
uvs.maxV = 1 / 16f;
for (EnumFacing face : EnumFacing.VALUES) {
quads[face.ordinal()] = ModelUtil.createFace(face, center, radius, uvs);
}
return quads;
}
Aggregations