use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class FluidPipeRenderer method renderPipeBlock.
public boolean renderPipeBlock(Material material, FluidPipeType pipeType, int insulationColor, CCRenderState state, IVertexOperation[] pipeline, int connectMask) {
int pipeColor = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(material, insulationColor));
ColourMultiplier multiplier = new ColourMultiplier(pipeColor);
PipeTextureInfo textureInfo = this.pipeTextures.get(pipeType);
PipeModelInfo modelInfo = this.pipeModels.get(pipeType);
IVertexOperation[] openingTexture = ArrayUtils.addAll(pipeline, new IconTransformation(textureInfo.inTexture), multiplier);
IVertexOperation[] sideTexture = ArrayUtils.addAll(pipeline, new IconTransformation(textureInfo.sideTexture), multiplier);
int sidedConnMask = connectMask & 0b111111;
CCModel fullBlockModel = null;
if (sidedConnMask == 0b000011) {
fullBlockModel = modelInfo.fullBlockModels[0];
} else if (sidedConnMask == 0b001100) {
fullBlockModel = modelInfo.fullBlockModels[1];
} else if (sidedConnMask == 0b110000) {
fullBlockModel = modelInfo.fullBlockModels[2];
}
if (fullBlockModel != null) {
state.setPipeline(fullBlockModel, 0, fullBlockModel.verts.length, sideTexture);
state.render();
return true;
}
Cuboid6 centerCuboid = BlockFluidPipe.getSideBox(null, pipeType.getThickness());
state.setPipeline(openingTexture);
BlockRenderer.renderCuboid(state, centerCuboid, 0);
for (EnumFacing side : EnumFacing.VALUES) {
if ((connectMask & 1 << side.getIndex()) > 0) {
CCModel model = modelInfo.connectionModels[side.getIndex()];
state.setPipeline(model, 0, model.verts.length, sideTexture);
state.render();
}
}
return true;
}
use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class FluidPipeRenderer method registerIcons.
public void registerIcons(TextureMap map) {
for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
ResourceLocation inLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/pipe/pipe_%s_in", fluidPipeType.name));
ResourceLocation sideLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/pipe/pipe_%s_side", fluidPipeType.name));
TextureAtlasSprite inTexture = map.registerSprite(inLocation);
TextureAtlasSprite sideTexture = map.registerSprite(sideLocation);
this.pipeTextures.put(fluidPipeType, new PipeTextureInfo(inTexture, sideTexture));
}
for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
float thickness = fluidPipeType.getThickness();
double height = (1.0f - thickness) / 2.0f;
int angles = 5 + fluidPipeType.ordinal();
CCModel model = ShapeModelGenerator.generateModel(angles, height, thickness / 3.0f, height);
CCModel fullBlockModel = ShapeModelGenerator.generateModel(angles, 1.0f, thickness / 3.0f, height);
CCModel[] rotatedVariants = ShapeModelGenerator.generateRotatedVariants(model);
CCModel[] fullBlockVariants = ShapeModelGenerator.generateFullBlockVariants(fullBlockModel);
this.pipeModels.put(fluidPipeType, new PipeModelInfo(rotatedVariants, fullBlockVariants));
}
}
use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class InvPipeRenderer method registerIcons.
public void registerIcons(TextureMap map) {
this.jointTextureSprite = map.registerSprite(new ResourceLocation(GTValues.MODID, "blocks/inv_pipe/joint"));
this.pipeTextureSprite = map.registerSprite(new ResourceLocation(GTValues.MODID, "blocks/inv_pipe/pipe"));
InventoryPipeType pipeType = InventoryPipeType.NORMAL;
float thickness = pipeType.getThickness();
double height = (1.0f - thickness) / 2.0f;
CCModel connectionModel = ShapeModelGenerator.generateModel(3, height, thickness / 3.0f, height);
CCModel fullBlockModel = ShapeModelGenerator.generateModel(3, 1.0f, thickness / 3.0f, height);
this.fullBlockVariants = ShapeModelGenerator.generateFullBlockVariants(fullBlockModel);
this.connectionModels = ShapeModelGenerator.generateRotatedVariants(connectionModel);
}
use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class StonePileModelGenerator method generatePebblePileModel.
public static CCModel generatePebblePileModel(Random random) {
List<IndexedCuboid6> cuboid6s = generateCuboidList(random);
CCModel ccModel = CCModel.quadModel(cuboid6s.size() * 24);
for (int i = 0; i < cuboid6s.size(); i++) {
IndexedCuboid6 cuboid6 = cuboid6s.get(i);
ccModel.generateBlock(i * 24, cuboid6);
int b = (int) cuboid6.data;
int[] colours = ccModel.getOrAllocate(ColourAttribute.attributeKey);
int color = (b & 0xFF) << 24 | (b & 0xFF) << 16 | (b & 0xFF) << 8 | (0xFF);
Arrays.fill(colours, i * 24, i * 24 + 24, color);
}
return ccModel.computeNormals();
}
use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class StoneRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
// otherwise, we are in solid rendering layer and render primary stone
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
Matrix4 translation = new Matrix4();
translation.translate(pos.getX(), pos.getY(), pos.getZ());
TextureAtlasSprite stoneSprite = TextureUtils.getBlockTexture("stone");
Material material = ((BlockSurfaceRock) state.getBlock()).getStoneMaterial(world, pos, state);
int renderingColor = GTUtility.convertRGBtoOpaqueRGBA_CL(material.materialRGB);
IVertexOperation[] operations = new IVertexOperation[] { new IconTransformation(stoneSprite), new ColourMultiplier(renderingColor), new TransformationList(translation) };
if (world != null) {
renderState.setBrightness(world, pos);
}
renderState.setPipeline(operations);
CCModel actualModel = getActualModel(world, pos);
renderState.setModel(actualModel);
renderState.render();
return true;
}
Aggregations