codechicken.lib.vec.Rotation Java Examples
The following examples show how to use
codechicken.lib.vec.Rotation.
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: RenderTracker.java From WirelessRedstone with MIT License | 6 votes |
public void renderTracker(int freq) { GL11.glDisable(GL11.GL_LIGHTING); TextureUtils.bindAtlas(0); CCRenderState.reset(); CCRenderState.startDrawing(7); CCRenderState.setColour(0xFFFFFFFF); model.render(new IconTransformation(Blocks.obsidian.getIcon(0, 0))); CCRenderState.draw(); Matrix4 pearlMat = CCModelLibrary.getRenderMatrix( new Vector3(0, 0.44+RedstoneEther.getSineWave(ClientUtils.getRenderTime(), 7)*0.02, 0), new Rotation(RedstoneEther.getRotation(ClientUtils.getRenderTime(), freq), new Vector3(0, 1, 0)), 0.04); CCRenderState.changeTexture("wrcbe_core:textures/hedronmap.png"); CCRenderState.startDrawing(4); CCRenderState.setColour(freq == 0 ? 0xC0C0C0FF : 0xFFFFFFFF); CCModelLibrary.icosahedron4.render(pearlMat); CCRenderState.draw(); GL11.glEnable(GL11.GL_LIGHTING); }
Example #2
Source File: BlockCraftingGrid.java From Translocators with MIT License | 6 votes |
public List<IndexedCuboid6> getParts(World world, int x, int y, int z) { LinkedList<IndexedCuboid6> parts = new LinkedList<IndexedCuboid6>(); parts.add(new IndexedCuboid6(0, new Cuboid6(0, 0, 0, 1, 0.005, 1) .add(new Vector3(x, y, z)) )); TileCraftingGrid tcraft = (TileCraftingGrid) world.getTileEntity(x, y, z); for (int i = 0; i < 9; i++) { Cuboid6 box = new Cuboid6(1 / 16D, 0, 1 / 16D, 5 / 16D, 0.01, 5 / 16D) .apply(new Translation((i % 3) * 5 / 16D, 0, (i / 3) * 5 / 16D) .with(Rotation.quarterRotations[tcraft.rotation].at(center)) .with(new Translation(x, y, z))); parts.add(new IndexedCuboid6(i + 1, box)); } return parts; }
Example #3
Source File: LC.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public LC computeO(Vector3 vec, int side) { Vector3 v1 = Rotation.axes[((side & 0xE) + 3) % 6]; Vector3 v2 = Rotation.axes[((side & 0xE) + 5) % 6]; float d1 = (float) vec.scalarProject(v1); float d2 = 1 - d1; float d3 = (float) vec.scalarProject(v2); float d4 = 1 - d3; return set(side, d2 * d4, d2 * d3, d1 * d4, d1 * d3); }
Example #4
Source File: TextureArea.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static Transformation createOrientation(Size areaSize, int orientation) { Transformation transformation = new Rotation(Math.toRadians(orientation * 90.0), 0.0, 0.0, 1.0) .at(new Vector3(areaSize.width / 2.0, areaSize.height / 2.0, 0.0)); Size orientedSize = transformSize(transformation, areaSize); double offsetX = (areaSize.width - orientedSize.width) / 2.0; double offsetY = (areaSize.height - orientedSize.height) / 2.0; return transformation.with(new Translation(-offsetX, -offsetY, 0.0)); }
Example #5
Source File: CCRenderState.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void operate() { if(normalRef != null) setNormal(normalRef[vertexIndex]); else setNormal(Rotation.axes[side]); }
Example #6
Source File: WirelessPart.java From WirelessRedstone with MIT License | 5 votes |
public int getInternalPower() { TMultiPart part = tile().partMap(Rotation.rotateSide(side(), rotation())); if (part instanceof IRedstonePart) { IRedstonePart rp = (IRedstonePart) part; return Math.max(rp.strongPowerLevel(side()), rp.weakPowerLevel(side())) << 4; } return 0; }
Example #7
Source File: WirelessPart.java From WirelessRedstone with MIT License | 5 votes |
public int getPoweringLevel() { int s = RedstoneInteractions.getPowerTo(this, Rotation.rotateSide(side(), rotation())); int i = getInternalPower(); if (i > s) s = i; return s; }
Example #8
Source File: ReceiverPart.java From WirelessRedstone with MIT License | 5 votes |
@Override public void setActive(boolean on) { super.setActive(on); updateChange(); tile().notifyNeighborChange(Rotation.rotateSide(side(), rotation())); }
Example #9
Source File: TileEnderTank.java From EnderStorage with MIT License | 5 votes |
@Override public void addTraceableCuboids(List<IndexedCuboid6> cuboids) { Vector3 pos = new Vector3(xCoord, yCoord, zCoord); cuboids.add(new IndexedCuboid6(0, new Cuboid6(0.15, 0, 0.15, 0.85, 0.916, 0.85).add(pos))); for (int i = 0; i < 4; i++) cuboids.add(new IndexedCuboid6(i + 1, selectionBoxes[i].copy() .apply(Rotation.quarterRotations[rotation ^ 2].at(center)).add(pos))); }
Example #10
Source File: EnderChestRenderer.java From EnderStorage with MIT License | 5 votes |
public static void renderChest(int rotation, int freq, boolean owned, double x, double y, double z, int offset, float lidAngle) { TileEntityRendererDispatcher info = TileEntityRendererDispatcher.instance; renderEndPortal.render(x, y, z, 0, info.field_147560_j, info.field_147560_j, info.field_147561_k, info.field_147553_e); GL11.glColor4f(1, 1, 1, 1); CCRenderState.changeTexture("enderstorage:textures/enderchest.png"); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1, 1, 1, 1); GL11.glTranslated(x, y + 1.0, z + 1.0F); GL11.glScalef(1.0F, -1F, -1F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); GL11.glRotatef(rotation * 90, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); model.chestLid.rotateAngleX = lidAngle; model.render(owned); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslated(x, y, z); renderButtons(freq, rotation, lidAngle); GL11.glPopMatrix(); double time = ClientUtils.getRenderTime() + offset; Matrix4 pearlMat = CCModelLibrary.getRenderMatrix( new Vector3(x + 0.5, y + 0.2 + lidAngle * -0.5 + EnderStorageClientProxy.getPearlBob(time), z + 0.5), new Rotation(time / 3, new Vector3(0, 1, 0)), 0.04); GL11.glDisable(GL11.GL_LIGHTING); CCRenderState.changeTexture("enderstorage:textures/hedronmap.png"); CCRenderState.startDrawing(4); CCModelLibrary.icosahedron4.render(pearlMat); CCRenderState.draw(); GL11.glEnable(GL11.GL_LIGHTING); }
Example #11
Source File: LC.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public LC computeO(Vector3 vec, int side) { Vector3 v1 = Rotation.axes[((side & 0xE) + 3) % 6]; Vector3 v2 = Rotation.axes[((side & 0xE) + 5) % 6]; float d1 = (float) vec.scalarProject(v1); float d2 = 1 - d1; float d3 = (float) vec.scalarProject(v2); float d4 = 1 - d3; return set(side, d2 * d4, d2 * d3, d1 * d4, d1 * d3); }
Example #12
Source File: LightModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public PlanarLightModel reducePlanar() { int[] colours = new int[6]; for (int i = 0; i < 6; i++) { colours[i] = apply(-1, Rotation.axes[i]); } return new PlanarLightModel(colours); }
Example #13
Source File: NormalAttribute.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void operate(CCRenderState ccrs) { if (normalRef != null) { ccrs.normal.set(normalRef[ccrs.vertexIndex]); } else { ccrs.normal.set(Rotation.axes[ccrs.side]); } }
Example #14
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 #15
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 #16
Source File: TileChunkLoaderRenderer.java From ChickenChunks with MIT License | 4 votes |
@Override public void renderTileEntityAt(TileEntity tile, double d, double d1, double d2, float f) { CCRenderState.reset(); CCRenderState.setBrightness(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); double rot = ClientUtils.getRenderTime()*2; double height; double size; double updown = (ClientUtils.getRenderTime()%50) / 25F; updown = (float) Math.sin(updown*3.141593); updown *= 0.2; TileChunkLoaderBase chunkLoader = (TileChunkLoaderBase)tile; if(chunkLoader instanceof TileChunkLoader) { TileChunkLoader ctile = (TileChunkLoader)chunkLoader; rot /= Math.pow(ctile.radius, 0.2); height = 0.9; size = 0.08; } else if(chunkLoader instanceof TileSpotLoader) { height = 0.5; size = 0.05; } else return; RenderInfo renderInfo = chunkLoader.renderInfo; double active = (renderInfo.activationCounter)/20D; if(chunkLoader.active && renderInfo.activationCounter < 20) active += f/20D; else if(!chunkLoader.active && renderInfo.activationCounter > 0) active -= f/20D; if(renderInfo.showLasers) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); drawRays(d, d1, d2, rot, updown, tile.xCoord, tile.yCoord, tile.zCoord, chunkLoader.getChunks()); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_FOG); } rot = ClientUtils.getRenderTime()*active / 3F; Matrix4 pearlMat = CCModelLibrary.getRenderMatrix( new Vector3(d+0.5, d1+height+(updown + 0.3)*active, d2+0.5), new Rotation(rot, new Vector3(0, 1, 0)), size); GL11.glDisable(GL11.GL_LIGHTING); CCRenderState.changeTexture("chickenchunks:textures/hedronmap.png"); CCRenderState.startDrawing(4); CCModelLibrary.icosahedron4.render(pearlMat); CCRenderState.draw(); GL11.glEnable(GL11.GL_LIGHTING); }
Example #17
Source File: TileCraftingGridRenderer.java From Translocators with MIT License | 4 votes |
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) { TileCraftingGrid tcraft = (TileCraftingGrid)tile; TextureUtils.bindAtlas(0); IIcon icon = Translocator.blockCraftingGrid.gridIcon; Tessellator t = Tessellator.instance; t.setTranslation(x, y+0.001, z); t.startDrawingQuads(); t.setNormal(0, 1, 0); t.addVertexWithUV(1, 0, 0, icon.getMinU(), icon.getMinV()); t.addVertexWithUV(0, 0, 0, icon.getMinU(), icon.getMaxV()); t.addVertexWithUV(0, 0, 1, icon.getMaxU(), icon.getMaxV()); t.addVertexWithUV(1, 0, 1, icon.getMaxU(), icon.getMinV()); t.draw(); t.setTranslation(0, 0, 0); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); GL11.glTranslated(x+0.5, y, z+0.5); Transformation orient = Rotation.quarterRotations[tcraft.rotation]; for(int i = 0; i < 9; i++) { ItemStack item = tcraft.items[i]; if(item == null) continue; int row = i/3; int col = i%3; Vector3 pos = new Vector3((col-1)*5/16D, 0.1+0.01*Math.sin(i*1.7+ClientUtils.getRenderTime()/5), (row-1)*5/16D).apply(orient); GL11.glPushMatrix(); GL11.glTranslated(pos.x, pos.y, pos.z); GL11.glScaled(0.5, 0.5, 0.5); RenderUtils.renderItemUniform(item); GL11.glPopMatrix(); } if(tcraft.result != null) { GL11.glPushMatrix(); GL11.glTranslated(0, 0.6 + 0.02 * Math.sin(ClientUtils.getRenderTime() / 10), 0); GL11.glScaled(0.8, 0.8, 0.8); RenderUtils.renderItemUniform(tcraft.result, ClientUtils.getRenderTime()); GL11.glPopMatrix(); } GL11.glPopMatrix(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); }
Example #18
Source File: EnderTankRenderer.java From EnderStorage with MIT License | 4 votes |
public static void renderTank(int rotation, float valve, int freq, boolean owned, double x, double y, double z, int offset) { TileEntityRendererDispatcher info = TileEntityRendererDispatcher.instance; renderEndPortal.render(x, y, z, 0, info.field_147560_j, info.field_147560_j, info.field_147561_k, info.field_147553_e); GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); GL11.glTranslated(x+0.5, y, z+0.5); GL11.glRotatef(-90*(rotation+2), 0, 1, 0); CCRenderState.changeTexture("enderstorage:textures/endertank.png"); CCRenderState.startDrawing(4); tankModel.render(); CCRenderState.draw(); CCRenderState.changeTexture("enderstorage:textures/buttons.png"); CCRenderState.startDrawing(7); for(int i = 0; i < 3; i++) { int colour = EnderStorageManager.getColourFromFreq(freq, i); buttons[i].render(new UVTranslation(0.25 * (colour % 4), 0.25 * (colour / 4))); } CCRenderState.draw(); new Rotation(valve, new Vector3(0, 0, 1)).at(new Vector3(0, 0.4165, 0)).glApply(); CCRenderState.changeTexture("enderstorage:textures/endertank.png"); CCRenderState.startDrawing(4); valveModel.render(new UVTranslation(0, owned ? 13/64D : 0)); CCRenderState.draw(); GL11.glPopMatrix(); double time = ClientUtils.getRenderTime()+offset; Matrix4 pearlMat = CCModelLibrary.getRenderMatrix( new Vector3(x+0.5, y+0.45+EnderStorageClientProxy.getPearlBob(time)*2, z+0.5), new Rotation(time/3, new Vector3(0, 1, 0)), 0.04); GL11.glDisable(GL11.GL_LIGHTING); CCRenderState.changeTexture("enderstorage:textures/hedronmap.png"); CCRenderState.startDrawing(4); CCModelLibrary.icosahedron4.render(pearlMat); CCRenderState.draw(); GL11.glEnable(GL11.GL_LIGHTING); }
Example #19
Source File: ReceiverPart.java From WirelessRedstone with MIT License | 4 votes |
@Override public int strongPowerLevel(int side) { return side == Rotation.rotateSide(side(), rotation()) && active() ? 15 : 0; }
Example #20
Source File: ReceiverPart.java From WirelessRedstone with MIT License | 4 votes |
@Override public Transformation getPearlRotation() { return new Rotation(0.7854, 1, 0, 0); }
Example #21
Source File: WirelessPart.java From WirelessRedstone with MIT License | 4 votes |
public void setupPlacement(EntityPlayer player, int side) { setSide(side ^ 1); setRotation(Rotation.getSidedRotation(player, side) ^ 2); owner = player.getCommandSenderName(); }
Example #22
Source File: LightModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public PlanarLightModel reducePlanar() { int[] colours = new int[6]; for (int i = 0; i < 6; i++) colours[i] = apply(-1, Rotation.axes[i]); return new PlanarLightModel(colours); }