use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class ModelPowerAdapter method renderAdapter.
public static List<BakedQuad> renderAdapter(IModel model, TextureAtlasSprite sprite, VertexFormat format) {
List<BakedQuad> quads = Lists.newArrayList();
IFlexibleBakedModel baked = model.bake(ModelRotation.X0_Y0, format, singleTextureFunction(sprite));
for (BakedQuad quad : baked.getGeneralQuads()) {
MutableQuad mutable = MutableQuad.create(quad);
mutable.colouri(0xFF_FF_FF_FF);
ModelUtil.appendBakeQuads(quads, format, mutable);
}
return quads;
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class PipeItemModel method create.
public static PipeItemModel create(ItemPipe item, int colorIndex) {
TextureAtlasSprite sprite = item.getSprite();
if (sprite == null) {
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
}
Vec3d center = Utils.VEC_HALF;
Vec3d radius = new Vec3d(0.25, 0.5, 0.25);
EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
cuboid.texture = sprite;
cuboid.setTextureOffset(new Vec3d(4, 0, 4));
cuboid.setPosition(center.subtract(radius));
cuboid.setSize(Utils.multiply(radius, 2));
List<MutableQuad> unprocessed = Lists.newArrayList();
List<BakedQuad> quads = Lists.newArrayList();
RenderResizableCuboid.bakeCube(unprocessed, cuboid, true, false);
for (MutableQuad quad : unprocessed) {
quad.normalf(0, 1, 0);
ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, quad);
}
unprocessed.clear();
// Set up the colour
if (colorIndex != 0) {
// Very sligthly smaller
radius = new Vec3d(0.249, 0.499, 0.249);
cuboid = new EntityResizableCuboid(null);
cuboid.setTextureOffset(new Vec3d(4, 0, 4));
cuboid.texture = PipeIconProvider.TYPE.PipeStainedOverlay.getIcon();
cuboid.setPosition(center.subtract(radius));
cuboid.setSize(Utils.multiply(radius, 2));
// Render it into a different list
RenderResizableCuboid.bakeCube(unprocessed, cuboid, true, false);
EnumDyeColor dye = EnumDyeColor.byDyeDamage(colorIndex - 1);
int quadColor = ColorUtils.getLightHex(dye);
// Add all of the quads we just rendered to the main list
for (MutableQuad quad : unprocessed) {
quad.normalf(0, 1, 0);
quad.setTint(quadColor);
ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, quad);
}
unprocessed.clear();
}
return new PipeItemModel(ImmutableList.copyOf(quads), sprite);
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class PlugPluggableModel method renderPlug.
public static List<BakedQuad> renderPlug(IModel model, TextureAtlasSprite sprite, VertexFormat format) {
List<BakedQuad> quads = Lists.newArrayList();
IFlexibleBakedModel baked = model.bake(ModelRotation.X0_Y0, format, singleTextureFunction(sprite));
for (BakedQuad quad : baked.getGeneralQuads()) {
MutableQuad mutable = MutableQuad.create(quad);
mutable.colouri(0xFF_FF_FF_FF);
ModelUtil.appendBakeQuads(quads, format, mutable);
}
return quads;
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class GateItemModel method handleItemState.
@Override
public GateItemModel handleItemState(ItemStack stack) {
KeyPlugGate key = getState(stack);
if (!map.containsKey(key)) {
List<BakedQuad> quads = Lists.newArrayList();
List<MutableQuad> mutableQuads = GatePluggableModel.INSTANCE.renderGate(key, DefaultVertexFormats.ITEM);
Matrix4f rotation = MatrixUtil.rotateTowardsFace(EnumFacing.SOUTH);
Matrix4f matScale = new Matrix4f();
matScale.setIdentity();
matScale.setScale(2);
matScale.setTranslation(new Vector3f(-0.5f, -0.5f, -0.5f));
Matrix4f translateToItem = new Matrix4f();
translateToItem.setIdentity();
translateToItem.setTranslation(new Vector3f(0, 0, -0.4f));
Matrix4f totalMatrix = new Matrix4f();
totalMatrix.setIdentity();
totalMatrix.mul(translateToItem);
totalMatrix.mul(matScale);
totalMatrix.mul(rotation);
for (MutableQuad quad : mutableQuads) {
quad.transform(totalMatrix);
quad.colouri(0xFF_FF_FF_FF);
quads.add(quad.toUnpacked(DefaultVertexFormats.ITEM));
}
map.put(key, new GateItemModel(ImmutableList.copyOf(quads), null, DefaultVertexFormats.ITEM));
}
return map.get(key);
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class FacadeItemModel method createFacadeItemModel.
private FacadeItemModel createFacadeItemModel(FacadeState state) {
List<BakedQuad> quads = Lists.newArrayList();
IModel model;
if (state.hollow)
model = FacadePluggableModel.INSTANCE.modelHollow();
else
model = FacadePluggableModel.INSTANCE.modelFilled();
TextureAtlasSprite sprite = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state.state);
if (sprite == null) {
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
}
List<BakedQuad> bakedQuads = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.ITEM, singleTextureFunction(sprite)).getGeneralQuads();
Matrix4f rotation = MatrixUtil.rotateTowardsFace(EnumFacing.EAST);
Matrix4f translateToItem = new Matrix4f();
translateToItem.setIdentity();
translateToItem.setTranslation(new Vector3f(0.4f, 0, 0));
Matrix4f totalMatrix = new Matrix4f();
totalMatrix.setIdentity();
// The last one is applied FIRST
totalMatrix.mul(rotation);
totalMatrix.mul(translateToItem);
for (BakedQuad quad : bakedQuads) {
MutableQuad mutable = MutableQuad.create(quad);
mutable.transform(totalMatrix);
mutable.colouri(0xFF_FF_FF_FF);
ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, mutable);
}
return new FacadeItemModel(ImmutableList.copyOf(quads), sprite, DefaultVertexFormats.ITEM);
}
Aggregations