Java Code Examples for codechicken.lib.vec.Matrix4#translate()
The following examples show how to use
codechicken.lib.vec.Matrix4#translate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StoneRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@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; }
Example 2
Source File: MetaTileEntityQuantumTank.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { Textures.VOLTAGE_CASINGS[tier].render(renderState, translation, ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())))); translation.translate(0.5, 0.001, 0.5); translation.rotate(Math.toRadians(rotations[getFrontFacing().getIndex() - 2]), new Vector3(0.0, 1.0, 0.0)); translation.translate(-0.5, 0.0, -0.5); Textures.SCREEN.renderSided(EnumFacing.UP, renderState, translation, pipeline); }
Example 3
Source File: MetaTileEntityQuantumChest.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { Textures.VOLTAGE_CASINGS[tier].render(renderState, translation, ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())))); translation.translate(0.5, 0.001, 0.5); translation.rotate(Math.toRadians(rotations[getFrontFacing().getIndex() - 2]), new Vector3(0.0, 1.0, 0.0)); translation.translate(-0.5, 0.0, -0.5); Textures.SCREEN.renderSided(EnumFacing.UP, renderState, translation, pipeline); }
Example 4
Source File: TileEntityCrusherBladeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@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); } } }
Example 5
Source File: TankLayerRenderer.java From EnderStorage with MIT License | 5 votes |
@Override public void render(MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, AbstractClientPlayerEntity entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { if (UUIDS.contains(entity.getUniqueID())) { CCRenderState ccrs = CCRenderState.instance(); ccrs.brightness = packedLight; ccrs.overlay = OverlayTexture.NO_OVERLAY; Matrix4 mat = new Matrix4(mStack); mat.rotate(MathHelper.torad * 180, Vector3.X_POS); mat.scale(0.5); if (entity.isShiftKeyDown()) { mat.translate(0, -0.5, 0); } if (entity.isElytraFlying()) { headPitch = -45; } mat.rotate(netHeadYaw * MathHelper.torad, Vector3.Y_NEG); mat.rotate(headPitch * MathHelper.torad, Vector3.X_POS); mat.translate(-0.5, 1, -0.5); RenderTileEnderTank.renderTank(ccrs, mat, getter, 0, (float) (MathHelper.torad * 90F), 0, BLANK, 0); FluidStack stack = FluidUtils.water.copy(); float bob = 0.45F + RenderUtils.getPearlBob(ClientUtils.getRenderTime()) * 2; stack.setAmount((int) MathHelper.map(bob, 0.2, 0.6, 1000, 14000)); mat.translate(-0.5, 0, -0.5); RenderTileEnderTank.renderFluid(ccrs, mat, getter, stack); } }
Example 6
Source File: RenderTileEnderChest.java From EnderStorage with MIT License | 5 votes |
public static void renderChest(CCRenderState ccrs, MatrixStack mStack, IRenderTypeBuffer getter, int rotation, double yToCamera, Frequency freq, float lidAngle, int pearlOffset) { Matrix4 mat = new Matrix4(mStack); if (lidAngle != 0) {//Micro optimization, lid closed, dont render starfield. renderEndPortal.render(mat, getter, yToCamera); } ccrs.reset(); mStack.push(); mStack.translate(0, 1.0, 1.0); mStack.scale(1.0F, -1.0F, -1.0F); mStack.translate(0.5, 0.5, 0.5); mStack.rotate(new Quaternion(0, rotation * 90, 0, true)); mStack.translate(-0.5, -0.5, -0.5); model.chestLid.rotateAngleX = lidAngle; model.render(mStack, getter.getBuffer(chestType), ccrs.brightness, ccrs.overlay, freq.hasOwner()); mStack.pop(); //Buttons ccrs.bind(buttonType, getter); EnumColour[] colours = freq.toArray(); for (int i = 0; i < 3; i++) { CCModel button = ButtonModelLibrary.button.copy(); button.apply(BlockEnderChest.buttonT[i]); button.apply(new Translation(0.5, 0, 0.5)); button.apply(new Rotation(lidAngle, 1, 0, 0).at(new Vector3(0, 9D / 16D, 1 / 16D))); button.apply(new Rotation((-90 * (rotation)) * MathHelper.torad, Vector3.Y_POS).at(new Vector3(0.5, 0, 0.5))); button.render(ccrs, mat, new UVTranslation(0.25 * (colours[i].getWoolMeta() % 4), 0.25 * (colours[i].getWoolMeta() / 4))); } mat.translate(0.5, 0, 0.5); //Pearl if (lidAngle != 0) {//Micro optimization, lid closed, dont render pearl. double time = ClientUtils.getRenderTime() + pearlOffset; Matrix4 pearlMat = RenderUtils.getMatrix(mat.copy(), new Vector3(0, 0.2 + lidAngle * -0.5 + RenderUtils.getPearlBob(time), 0), new Rotation(time / 3, new Vector3(0, 1, 0)), 0.04); ccrs.brightness = 15728880; ccrs.bind(pearlType, getter); CCModelLibrary.icosahedron4.render(ccrs, pearlMat); } ccrs.reset(); }
Example 7
Source File: EnderTankItemRender.java From EnderStorage with MIT License | 5 votes |
@Override public void renderItem(ItemStack stack, TransformType transformType, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay) { CCRenderState ccrs = CCRenderState.instance(); ccrs.reset(); ccrs.brightness = packedLight; ccrs.overlay = packedOverlay; Frequency freq = Frequency.readFromStack(stack); FluidStack fluid = TankSynchroniser.getClientLiquid(freq); Matrix4 mat = new Matrix4(mStack); RenderTileEnderTank.renderTank(ccrs, mat, getter, 2, (float) (MathHelper.torad * 90F), 0, freq, 0); mat.translate(-0.5, 0, -0.5); RenderTileEnderTank.renderFluid(ccrs, mat, getter, fluid); }
Example 8
Source File: CCRenderEventHandler.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@OnlyIn (Dist.CLIENT) @SubscribeEvent (priority = EventPriority.LOW) public void onBlockHighlight(DrawHighlightEvent.HighlightBlock event) { //We have found a CuboidRayTraceResult, Lets render it properly.. BlockRayTraceResult hit = event.getTarget(); if (hit instanceof CuboidRayTraceResult) { CuboidRayTraceResult cuboidHit = (CuboidRayTraceResult) hit; event.setCanceled(true); Matrix4 mat = new Matrix4(event.getMatrix()); mat.translate(cuboidHit.getPos()); RenderUtils.bufferHitbox(mat, event.getBuffers(), event.getInfo(), cuboidHit.cuboid6); } }