use of codechicken.lib.render.pipeline.IVertexOperation 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.render.pipeline.IVertexOperation in project GregTech by GregTechCE.
the class TileEntityCrusherBladeRenderer method draw.
@Override
protected void draw(TileEntityCrusherBlade tileEntity, CCRenderState renderState, Matrix4 translation, float partialTicks) {
translation.translate(0.5, 0.5, 0.5);
IBlockState blockState = tileEntity.getBlockState();
switch(blockState.getValue(BlockCrusherBlade.AXIS)) {
case Y:
break;
case X:
translation.rotate(Math.toRadians(90.0), Rotation.axes[3]);
break;
case Z:
translation.rotate(Math.toRadians(90.0), Rotation.axes[5]);
break;
}
if (blockState.getValue(BlockCrusherBlade.ACTIVE)) {
long currentWorldTime = tileEntity.hasWorld() ? tileEntity.getWorld().getTotalWorldTime() : 0;
translation.rotate(Math.toRadians(currentWorldTime * 12.0 % 180), Rotation.axes[1]);
}
translation.translate(-0.5, -0.5, -0.5);
TextureAtlasSprite ironBlockTexture = TextureUtils.getBlockTexture("iron_block");
IVertexOperation[] operations = {};
for (Cuboid6 cuboid6 : BlockCrusherBlade.basicModel) {
for (EnumFacing renderSide : EnumFacing.VALUES) {
Textures.renderFace(renderState, translation, operations, renderSide, cuboid6, ironBlockTexture);
}
}
}
use of codechicken.lib.render.pipeline.IVertexOperation in project LogisticsPipes by RS485.
the class Model3D method renderToQuads.
@Override
@SideOnly(Side.CLIENT)
@SneakyThrows({ IllegalAccessException.class })
public List<BakedQuad> renderToQuads(VertexFormat format, I3DOperation... i3dOperations) {
List<IVertexOperation> list = new ArrayList<>();
Set<String> hash = new HashSet<>();
hash.add(String.valueOf(format.hashCode()));
boolean cachable = true;
for (I3DOperation op : i3dOperations) {
IVertexOperation iVertexOperation = (IVertexOperation) op.getOriginal();
list.add(iVertexOperation);
if (iVertexOperation instanceof IconTransformation) {
hash.add(((IconTransformation) iVertexOperation).icon.toString());
} else if (iVertexOperation instanceof Rotation) {
hash.add(iVertexOperation.toString());
} else if (iVertexOperation instanceof Scale) {
hash.add(iVertexOperation.toString());
} else if (iVertexOperation instanceof Translation) {
hash.add(iVertexOperation.toString());
} else {
cachable = false;
}
}
if (cachable) {
List<BakedQuad> content = renderCache.getIfPresent(hash.hashCode());
if (content != null) {
return content;
}
}
BakingVertexBuffer buffer = BakingVertexBuffer.create();
CCRenderState ccrs = CCRenderState.instance();
ccrs.reset();
ccrs.startDrawing(0x7, format, buffer);
model.render(ccrs, list.toArray(new IVertexOperation[0]));
buffer.finishDrawing();
emptyHashMap.clear();
if (spiteMap != null) {
spiteMap.set(buffer, emptyHashMap);
}
List<BakedQuad> quads = buffer.bake();
if (cachable) {
renderCache.put(hash.hashCode(), quads);
}
return quads;
}
Aggregations