use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.
the class TileEntityConnectorStructural method applyTransformations.
@Override
public Optional<TRSRTransformation> applyTransformations(IBlockState object, String group, Optional<TRSRTransformation> transform) {
Matrix4 mat = transform.isPresent() ? new Matrix4(transform.get().getMatrix()) : new Matrix4();
mat = mat.translate(.5, 0, .5).rotate(Math.toRadians(rotation), 0, 1, 0).translate(-.5, 0, -.5);
transform = Optional.of(new TRSRTransformation(mat.toMatrix4f()));
return transform;
}
use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.
the class ConveyorExtract method modifyQuads.
// private static final TextureAtlasSprite texture_steel = ClientUtils.getSprite(new ResourceLocation("immersiveengineering:blocks/storage_steel"));
// private static final TextureAtlasSprite texture_casing = ClientUtils.getSprite(new ResourceLocation("immersiveengineering:blocks/wooden_device_turntable_bottom"));
// private static final TextureAtlasSprite texture_curtain = ClientUtils.getSprite(new ResourceLocation("immersiveengineering:blocks/cloth_device_stripcurtain"));
// private static final TextureAtlasSprite texture_assembler = ClientUtils.getSprite(new ResourceLocation("immersiveengineering:blocks/metal_multiblock_assembler"));
@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> modifyQuads(List<BakedQuad> baseModel, @Nullable TileEntity tile, EnumFacing facing) {
final TextureAtlasSprite texture_steel = ClientUtils.getSprite(new ResourceLocation("immersiveengineering:blocks/storage_steel"));
final TextureAtlasSprite texture_casing = ClientUtils.getSprite(new ResourceLocation("immersiveengineering:blocks/wooden_device_turntable_bottom"));
final TextureAtlasSprite texture_curtain = ClientUtils.getSprite(new ResourceLocation("immersiveengineering:blocks/cloth_device_stripcurtain"));
final TextureAtlasSprite texture_assembler = ClientUtils.getSprite(new ResourceLocation("immersiveengineering:blocks/metal_multiblock_assembler"));
float[] colour = { 1, 1, 1, 1 };
Matrix4 matrix = new Matrix4(this.extractDirection);
final float extend = getExtensionIntoBlock(tile);
this.extension = extend;
Function<EnumFacing, TextureAtlasSprite> getCasingSprite = enumFacing -> enumFacing.getAxis() == Axis.Z ? texture_steel : texture_casing;
Function<Vector3f[], Vector3f[]> vertexTransformer = vertices -> {
if (extend == 0)
return vertices;
Vector3f[] ret = new Vector3f[vertices.length];
for (int i = 0; i < ret.length; i++) ret[i] = new Vector3f(vertices[i].x, vertices[i].y, vertices[i].z - extend);
return ret;
};
Function<Vector3f[], Vector3f[]> casingTransformer = vertices -> {
Vector3f[] ret = new Vector3f[vertices.length];
for (int i = 0; i < ret.length; i++) ret[i] = new Vector3f(vertices[i].x, vertices[i].y - .25f, vertices[i].z - .625f - extend);
return ret;
};
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.0625f, .375f, .625f), new Vector3f(.1875f, 1f, 1f), matrix, facing, casingTransformer, getCasingSprite, colour));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.8125f, .375f, .625f), new Vector3f(.9375f, 1f, 1f), matrix, facing, casingTransformer, getCasingSprite, colour));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.1875f, .875f, .625f), new Vector3f(.8125f, 1f, 1f), matrix, facing, casingTransformer, getCasingSprite, colour));
if (tile != null && extend > 0) {
TextureAtlasSprite tex_conveyor = ClientUtils.getSprite(isActive(tile) ? ConveyorBasic.texture_on : ConveyorBasic.texture_off);
Function<EnumFacing, TextureAtlasSprite> getExtensionSprite = enumFacing -> enumFacing.getAxis() == Axis.Y ? null : enumFacing.getAxis() == Axis.Z ? texture_steel : texture_casing;
Vector3f[] vertices = { new Vector3f(.0625f, 0, -extend), new Vector3f(.0625f, 0, 0), new Vector3f(.9375f, 0, 0), new Vector3f(.9375f, 0, -extend) };
baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.DOWN, facing), tex_conveyor, new double[] { 15, extend * 16, 1, 0 }, colour, true));
for (Vector3f vec : vertices) vec.setY(.125f);
baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_conveyor, new double[] { 15, (1 - extend) * 16, 1, 16 }, colour, false));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.0625f, .25f, .625f), new Vector3f(.9375f, .375f, .625f + extend), matrix, facing, casingTransformer, getExtensionSprite, colour));
}
Vector3f[] vertices = new Vector3f[] { new Vector3f(.8125f, .625f, .03125f), new Vector3f(.8125f, .125f, .03125f), new Vector3f(.1875f, .125f, .03125f), new Vector3f(.1875f, .625f, .03125f) };
baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.NORTH, facing), texture_assembler, new double[] { 15.25, 13.25, 12.75, 15.25 }, colour, false));
for (Vector3f vec : vertices) vec.setZ(.0625f);
baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.SOUTH, facing), texture_assembler, new double[] { 12.75, 13.25, 15.25, 15.25 }, colour, true));
for (int i = 0; i < 5; i++) {
float off = i * .125f;
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.203125f + off, .1875f, .09375f), new Vector3f(.296875f + off, .625f, .125f), matrix, facing, vertexTransformer, (facing1) -> texture_curtain, colour));
}
return baseModel;
}
use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.
the class ConveyorVerticalCovered method modifyQuads.
@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> modifyQuads(List<BakedQuad> baseModel, @Nullable TileEntity tile, EnumFacing facing) {
boolean renderBottom = tile != null && this.renderBottomBelt(tile, facing);
boolean[] walls;
if (renderBottom) {
TextureAtlasSprite sprite = ClientUtils.getSprite(isActive(tile) ? ConveyorBasic.texture_on : ConveyorBasic.texture_off);
TextureAtlasSprite spriteColour = ClientUtils.getSprite(getColouredStripesTexture());
walls = new boolean[] { renderBottomWall(tile, facing, 0), renderBottomWall(tile, facing, 1) };
baseModel.addAll(ModelConveyor.getBaseConveyor(facing, .875f, new Matrix4(facing), ConveyorDirection.HORIZONTAL, sprite, walls, new boolean[] { true, false }, spriteColour, getDyeColour()));
} else
walls = new boolean[] { true, true };
ItemStack cover = !this.cover.isEmpty() ? this.cover : ConveyorCovered.defaultCover;
Block b = Block.getBlockFromItem(cover.getItem());
IBlockState state = !cover.isEmpty() ? b.getStateFromMeta(cover.getMetadata()) : Blocks.STONE.getDefaultState();
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
if (model != null) {
TextureAtlasSprite sprite = model.getParticleTexture();
HashMap<EnumFacing, TextureAtlasSprite> sprites = new HashMap<>();
for (EnumFacing f : EnumFacing.VALUES) for (BakedQuad q : model.getQuads(state, f, 0)) if (q != null && q.getSprite() != null)
sprites.put(f, q.getSprite());
for (BakedQuad q : model.getQuads(state, null, 0)) if (q != null && q.getSprite() != null && q.getFace() != null)
sprites.put(q.getFace(), q.getSprite());
Function<EnumFacing, TextureAtlasSprite> getSprite = f -> sprites.containsKey(f) ? sprites.get(f) : sprite;
float[] colour = { 1, 1, 1, 1 };
Matrix4 matrix = new Matrix4(facing);
if (// just vertical
!renderBottom) {
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, 0, .75f), new Vector3f(1, 1, 1), matrix, facing, getSprite, colour));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, 0, .1875f), new Vector3f(.0625f, 1, .75f), matrix, facing, getSprite, colour));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, 0, .1875f), new Vector3f(1, 1, .75f), matrix, facing, getSprite, colour));
} else {
boolean straightInput = tile != null && isInwardConveyor(tile, facing.getOpposite());
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .9375f, .75f), new Vector3f(1, 1, 1), matrix, facing, getSprite, colour));
if (!straightInput)
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, .9375f), new Vector3f(1, 1f, 1), matrix, facing, getSprite, colour));
else // has direct input, needs a cutout
{
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .75f, .9375f), new Vector3f(1, 1, 1), matrix, facing, getSprite, colour));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, .9375f), new Vector3f(.0625f, .75f, 1), matrix, facing, getSprite, colour));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, .9375f), new Vector3f(1, .75f, 1), matrix, facing, getSprite, colour));
}
if (// wall to the left
walls[0])
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, .1875f), new Vector3f(.0625f, 1, .9375f), matrix, facing, getSprite, colour));
else
// cutout to the left
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .75f, .1875f), new Vector3f(.0625f, 1, .9375f), matrix, facing, getSprite, colour));
if (// wall to the right
walls[1])
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, .1875f), new Vector3f(1, 1, .9375f), matrix, facing, getSprite, colour));
else
// cutout to the right
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .75f, .1875f), new Vector3f(1, 1, .9375f), matrix, facing, getSprite, colour));
}
}
return baseModel;
}
use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.
the class TileEntityRedstoneBreaker method getBlockBounds.
@Override
public float[] getBlockBounds() {
Vec3d start = new Vec3d(0, .125f, 0);
Vec3d end = new Vec3d(1, .875f, 1);
Matrix4 mat = new Matrix4(facing);
mat.translate(.5, .5, 0).rotate(Math.PI / 2 * rotation, 0, 0, 1).translate(-.5, -.5, 0);
start = mat.apply(start);
end = mat.apply(end);
return new float[] { (float) start.x, (float) start.y, (float) start.z, (float) end.x, (float) end.y, (float) end.z };
}
use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.
the class TileEntityRedstoneBreaker method getConnectionOffset.
@Override
public Vec3d getConnectionOffset(Connection con) {
Matrix4 mat = new Matrix4(facing);
mat.translate(.5, .5, 0).rotate(Math.PI / 2 * rotation, 0, 0, 1).translate(-.5, -.5, 0);
if (endOfLeftConnection == null)
calculateLeftConn(mat);
boolean isLeft = con.end.equals(endOfLeftConnection) || con.start.equals(endOfLeftConnection);
Vec3d ret = mat.apply(isLeft ? new Vec3d(.125, .5, 1) : new Vec3d(.875, .5, 1));
return ret;
}
Aggregations