use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.
the class CTCubeRenderer method render.
@SideOnly(Side.CLIENT)
public void render(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, int connectionMask) {
for (EnumFacing renderSide : EnumFacing.VALUES) {
if (hasFaceBit(connectionMask, renderSide)) {
// do not render faces occluded by connections
continue;
}
int resultTextureMask = 0b1111;
if (renderSide.getAxis().isHorizontal()) {
if (hasFaceBit(connectionMask, EnumFacing.UP))
resultTextureMask &= ~TextureDirection.TOP;
if (hasFaceBit(connectionMask, EnumFacing.DOWN))
resultTextureMask &= ~TextureDirection.BOTTOM;
EnumFacing leftFacing = renderSide.rotateY();
EnumFacing rightFacing = renderSide.rotateYCCW();
if (hasFaceBit(connectionMask, leftFacing))
resultTextureMask &= ~TextureDirection.LEFT;
if (hasFaceBit(connectionMask, rightFacing))
resultTextureMask &= ~TextureDirection.RIGHT;
} else {
if (hasFaceBit(connectionMask, EnumFacing.NORTH))
resultTextureMask &= ~TextureDirection.TOP;
if (hasFaceBit(connectionMask, EnumFacing.SOUTH))
resultTextureMask &= ~TextureDirection.BOTTOM;
if (hasFaceBit(connectionMask, EnumFacing.WEST))
resultTextureMask &= ~TextureDirection.LEFT;
if (hasFaceBit(connectionMask, EnumFacing.EAST))
resultTextureMask &= ~TextureDirection.RIGHT;
}
TextureAtlasSprite sideSprite = ctSprites[resultTextureMask];
Textures.renderFace(renderState, translation, pipeline, renderSide, Cuboid6.full, sideSprite);
Matrix4 backTranslation = translation.copy();
backTranslation.translate(renderSide.getXOffset(), renderSide.getYOffset() * 0.999, renderSide.getZOffset());
int backFaceTextureMask;
if (renderSide.getAxis().isHorizontal()) {
backFaceTextureMask = resultTextureMask & ~(TextureDirection.RIGHT | TextureDirection.LEFT);
if ((resultTextureMask & TextureDirection.RIGHT) > 0)
backFaceTextureMask |= TextureDirection.LEFT;
if ((resultTextureMask & TextureDirection.LEFT) > 0)
backFaceTextureMask |= TextureDirection.RIGHT;
} else {
backFaceTextureMask = resultTextureMask;
}
TextureAtlasSprite backSideSprite = ctSprites[backFaceTextureMask];
Textures.renderFace(renderState, backTranslation, pipeline, renderSide.getOpposite(), Cuboid6.full, backSideSprite);
}
}
use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.
the class InvPipeRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setBrightness(world, pos);
IVertexOperation[] pipeline = { new Translation(pos) };
BlockInventoryPipe block = (BlockInventoryPipe) state.getBlock();
TileEntityInventoryPipe tileEntity = (TileEntityInventoryPipe) block.getPipeTileEntity(world, pos);
if (tileEntity == null) {
return false;
}
int paintingColor = tileEntity.getInsulationColor();
int connectedSidesMask = block.getActualConnections(tileEntity, world);
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
if (renderLayer == BlockRenderLayer.SOLID) {
renderPipe(renderState, pipeline, paintingColor, connectedSidesMask);
}
ICoverable coverable = tileEntity.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
return true;
}
use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.
the class TileEntityRendererBase method renderTileEntityFast.
@Override
public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
if (te.getWorld() != null) {
renderState.setBrightness(te.getWorld(), te.getPos());
}
Matrix4 translation = new Matrix4().translate(x, y, z);
draw(te, renderState, translation, partialTicks);
}
Aggregations