From b783cf6b5cac315b51a107dd3fc686e8d8cbfb1a Mon Sep 17 00:00:00 2001 From: ganymedes01 Date: Fri, 19 Dec 2014 16:19:23 -0200 Subject: [PATCH] Gates and wires now glow in the dark when active Note: Some texture re-work might be necessary... I think the current lit texture are far too bright. Found a bug: popping a gate out of the pipe doesn't update it on the client side (a.k.a. the gate pops out but is still rendered on the pipe) --- .../textures/blocks/gates/gate_and.png | Bin 0 -> 156 bytes .../textures/blocks/gates/gate_and_dark.png | Bin 0 -> 200 bytes .../textures/blocks/gates/gate_and_lit.png | Bin 0 -> 194 bytes .../textures/blocks/gates/gate_dark_and.png | Bin 150 -> 0 bytes .../textures/blocks/gates/gate_dark_or.png | Bin 150 -> 0 bytes .../textures/blocks/gates/gate_lit_and.png | Bin 126 -> 0 bytes .../textures/blocks/gates/gate_lit_or.png | Bin 126 -> 0 bytes .../textures/blocks/gates/gate_or.png | Bin 0 -> 156 bytes .../textures/blocks/gates/gate_or_dark.png | Bin 0 -> 200 bytes .../textures/blocks/gates/gate_or_lit.png | Bin 0 -> 194 bytes .../buildcraft/core/render/RenderRobot.java | 2 +- .../transport/gates/GateDefinition.java | 14 ++- .../transport/render/PipeRendererTESR.java | 87 ++++++++---------- 13 files changed, 52 insertions(+), 51 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and_dark.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and_lit.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_dark_and.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_dark_or.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_and.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_or.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_or.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_or_dark.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_or_lit.png diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and.png new file mode 100644 index 0000000000000000000000000000000000000000..2669779bd064b9efe34c01442b0d48f969dcde55 GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPqkFXGfNZOIaH$WjxPZ!4!i_^&|2?;;WJ1{0BEfDCD tI&k1XlY5_F@BjK4ZH$jIykuB_cInSxmVeZv$_UiN;OXk;vd$@?2>@w^Do_9b literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and_dark.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..fbb86a5a8f0199388c0aa3c568b7aa0548f0bd99 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPqkFXGnV9}v~bf8eEr;B5V#p$;fH*z)@Ft}V?p2Em| zP;!mR>>ZmrxOX(n?VZ4=Q_{o{7WHI%c@1CRq33|y-Kli4a oJ;J)a{V&%lC?y_`TKCV=yhxv$C-8UObf5(cp00i_>zopr08>am_W%F@ literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and_lit.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_and_lit.png new file mode 100644 index 0000000000000000000000000000000000000000..e73bcb261a0ffd24eda8093f795f2f71f88c6ad1 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPqkFXHC3V+P;cA${Ir;B5V#p$=_4EY=!BwQZ$7qF~V zwrKio?zgajNo6)i@3;8QwxoFDqdsc=hrWjd8WyVMyf9$7t!9<6G2z%e!xhC}Qf1IW{B+H*C7V`huCkwvI{u=ZsA`K$Q%hu6{1-oD!M;M1%B^VgI7#PeL7_1l= zG8q`E7#PGD80;7rbb%@v7_=D}G8h=*85sN+7)%)$tQi>IXy_*cwaa1g8EosA@g8AE*ET diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_and.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_and.png deleted file mode 100644 index 910fd3def108bec302780ade09b59c03d0d75759..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 126 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPGa3-AeX1=2qm7(OvDJY`_`&%kht zfnhrX!)*qJEes4_7#Mc0K6ebLLfX^CF@$4ga)N?5$4m#wbuR|r9E97LpWw8Cn$(ZSUO2AdKu7`pgcuU#dF(AhU&MB VYjt-NO8}KIc)I$ztaD0e0s!wq(9E})R6r;B5V#p&cf|NsB5XX9cJW^PTm u!obERW>eIY@#nv?0nfjFH5DsK1_rA$Z1UIcE7$`yF?hQAxvX>ZmrxOX(n?VZ4=Q_{o{7WHI%c@1CRq33|y-Kli4a oJ;J)a{V&%lC?y_`TKCV=yhxv$C-8UObf5(cp00i_>zopr08>am_W%F@ literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_or_lit.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_or_lit.png new file mode 100644 index 0000000000000000000000000000000000000000..e73bcb261a0ffd24eda8093f795f2f71f88c6ad1 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPqkFXHC3V+P;cA${Ir;B5V#p$=_4EY=!BwQZ$7qF~V zwrKio?zgajNo6)i@3;8QwxoFDqdsc=hrWjd8WyVMyf9$7t!9<6G2z%e!xhC 0; + // Z render if (minZ != CoreConstants.PIPE_MIN_POS || maxZ != CoreConstants.PIPE_MAX_POS || !found) { renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, maxZ); - RenderEntityBlock.INSTANCE.renderBlock(renderBox); + renderLitBox(renderBox, isLit); } // X render @@ -454,7 +439,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { if (minX != CoreConstants.PIPE_MIN_POS || maxX != CoreConstants.PIPE_MAX_POS || !found) { renderBox.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(renderBox); + renderLitBox(renderBox, isLit); } // Y render @@ -462,18 +447,15 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { if (minY != CoreConstants.PIPE_MIN_POS || maxY != CoreConstants.PIPE_MAX_POS || !found) { renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, maxY, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(renderBox); + renderLitBox(renderBox, isLit); } if (center || !found) { renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(renderBox); + renderLitBox(renderBox, isLit); } - RenderHelper.enableStandardItemLighting(); - - GL11.glPopAttrib(); GL11.glPopMatrix(); } @@ -487,29 +469,24 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { private void renderGate(TileGenericPipe pipe, double x, double y, double z, GatePluggable gate, ForgeDirection direction) { GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); -// GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_CULL_FACE); -// GL11.glDisable(GL11.GL_TEXTURE_2D); - RenderHelper.disableStandardItemLighting(); - GL11.glColor3f(1, 1, 1); GL11.glTranslatef((float) x, (float) y, (float) z); bindTexture(TextureMap.locationBlocksTexture); - IIcon iconLogic; + IIcon lightIcon; + IIcon gateIcon = gate.getLogic().getGateIcon(); if (gate.isLit) { - iconLogic = gate.getLogic().getIconLit(); + lightIcon = gate.getLogic().getIconLit(); } else { - iconLogic = gate.getLogic().getIconDark(); + lightIcon = gate.getLogic().getIconDark(); } float translateCenter = 0; // Render base gate - renderGate(pipe, iconLogic, 0, 0.1F, 0, 0, direction); + renderGate(pipe, gateIcon, 0, 0.1F, 0, 0, direction, false); + renderGate(pipe, lightIcon, 0, 0.1F, 0, 0, direction, gate.isLit); float pulseStage = gate.getPulseStage() * 2F; @@ -524,27 +501,23 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { translateCenter = amplitude - ((pulseStage - 1F) * amplitude) + start; } - renderGate(pipe, iconLogic, 0, 0.13F, translateCenter, translateCenter, direction); + renderGate(pipe, gateIcon, 0, 0.13F, translateCenter, translateCenter, direction, false); + renderGate(pipe, lightIcon, 0, 0.13F, translateCenter, translateCenter, direction, gate.isLit); } IIcon materialIcon = gate.getMaterial().getIconBlock(); if (materialIcon != null) { - renderGate(pipe, materialIcon, 1, 0.13F, translateCenter, translateCenter, direction); + renderGate(pipe, materialIcon, 1, 0.13F, translateCenter, translateCenter, direction, false); } for (IGateExpansion expansion : gate.getExpansions()) { - renderGate(pipe, expansion.getOverlayBlock(), 2, 0.13F, translateCenter, translateCenter, direction); + renderGate(pipe, expansion.getOverlayBlock(), 2, 0.13F, translateCenter, translateCenter, direction, false); } - RenderHelper.enableStandardItemLighting(); - - GL11.glPopAttrib(); GL11.glPopMatrix(); } - private void renderGate(TileGenericPipe tile, IIcon icon, int layer, float trim, float translateCenter, float extraDepth, ForgeDirection direction) { - PipeRenderState state = tile.renderState; - + private void renderGate(TileGenericPipe tile, IIcon icon, int layer, float trim, float translateCenter, float extraDepth, ForgeDirection direction, boolean isLit) { RenderInfo renderBox = new RenderInfo(); renderBox.texture = icon; @@ -577,9 +550,29 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { } renderBox.setBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); - RenderEntityBlock.INSTANCE.renderBlock(renderBox); + renderLitBox(renderBox, isLit); GL11.glPopMatrix(); } + + private void renderLitBox(RenderInfo info, boolean isLit) { + RenderEntityBlock.INSTANCE.renderBlock(info); + + float lastX = OpenGlHelper.lastBrightnessX; + float lastY = OpenGlHelper.lastBrightnessY; + if (isLit) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glDepthMask(true); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 61680, 0); + RenderEntityBlock.INSTANCE.renderBlock(info); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastX, lastY); + } public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) { int connections = 0; @@ -791,7 +784,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { private void renderSolids(Pipe pipe, double x, double y, double z) { GL11.glPushMatrix(); - GL11.glDisable(2896 /* GL_LIGHTING */); float light = pipe.container.getWorldObj().getLightBrightness(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); @@ -805,7 +797,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { count++; } - GL11.glEnable(2896 /* GL_LIGHTING */); GL11.glPopMatrix(); }