From b299ad436d4dfd89ba92d6edfd7363d335c3db8a Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Mon, 6 Jan 2014 21:49:39 +0000 Subject: [PATCH] Rendering fixes and improvements --- .../client/render/MekanismRenderer.java | 15 +++++++++ .../client/render/RenderPartTransmitter.java | 32 +++++++++++++------ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/common/mekanism/client/render/MekanismRenderer.java b/common/mekanism/client/render/MekanismRenderer.java index a6ffc360f..2fb5d0353 100644 --- a/common/mekanism/client/render/MekanismRenderer.java +++ b/common/mekanism/client/render/MekanismRenderer.java @@ -241,6 +241,21 @@ public class MekanismRenderer { GL11.glPopAttrib(); } + + /** + * Blender .objs have a different handedness of coordinate system to MC, so faces are wound backwards. + */ + public static void cullFrontFace() + { + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glCullFace(GL11.GL_FRONT); + } + + public static void disableCullFace() + { + GL11.glCullFace(GL11.GL_BACK); + GL11.glDisable(GL11.GL_CULL_FACE); + } /** * Cleaned-up snip of ItemRenderer.renderItem() -- meant to render 2D items as equipped. diff --git a/common/mekanism/client/render/RenderPartTransmitter.java b/common/mekanism/client/render/RenderPartTransmitter.java index 7a433a5f3..cfe24d834 100644 --- a/common/mekanism/client/render/RenderPartTransmitter.java +++ b/common/mekanism/client/render/RenderPartTransmitter.java @@ -45,6 +45,7 @@ import codechicken.lib.colour.ColourRGBA; import codechicken.lib.lighting.LazyLightMatrix; import codechicken.lib.lighting.LightMatrix; import codechicken.lib.lighting.LightModel; +import codechicken.lib.lighting.LightModel.Light; import codechicken.lib.render.CCModel; import codechicken.lib.render.CCRenderState; import codechicken.lib.render.ColourMultiplier; @@ -110,11 +111,17 @@ public class RenderPartTransmitter implements IIconRegister } contents_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), 7, null); - + LightModel interiorLightModel = new LightModel() + .setAmbient(new Vector3(0.6, 0.6, 0.6)) + .addLight(new Light(new Vector3(0.3, 1, -0.7)) + .setDiffuse(new Vector3(0.6, 0.6, 0.6))) + .addLight(new Light(new Vector3(-0.3, 1, 0.7)) + .setDiffuse(new Vector3(0.6, 0.6, 0.6))); + for(CCModel c : contents_models.values()) { c.apply(new Translation(.5, .5, .5)); - c.computeLighting(LightModel.standardLightModel); + c.computeLighting(interiorLightModel); c.shrinkUVs(0.0005); } } @@ -231,14 +238,15 @@ public class RenderPartTransmitter implements IIconRegister for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if(cable.getConnectionType(side) != ConnectionType.NONE) - { - renderEnergySide(side, cable); - } + renderEnergySide(side, cable); } MekanismRenderer.glowOn(); + MekanismRenderer.cullFrontFace(); + CCRenderState.draw(); + + MekanismRenderer.disableCullFace(); MekanismRenderer.glowOff(); GL11.glPopMatrix(); @@ -454,14 +462,16 @@ public class RenderPartTransmitter implements IIconRegister for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if(tube.getConnectionType(side) != ConnectionType.NONE) - { - renderGasSide(side, tube); - } + renderGasSide(side, tube); } + MekanismRenderer.glowOn(0); + MekanismRenderer.cullFrontFace(); + CCRenderState.draw(); + MekanismRenderer.disableCullFace(); + MekanismRenderer.glowOff(); GL11.glPopMatrix(); } @@ -495,12 +505,14 @@ public class RenderPartTransmitter implements IIconRegister public void renderEnergySide(ForgeDirection side, PartUniversalCable cable) { + CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); boolean connected = PartTransmitter.connectionMapContainsSide(cable.getAllCurrentConnections(), side); renderTransparency(MekanismRenderer.energyIcon, cable.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower)); } public void renderGasSide(ForgeDirection side, PartPressurizedTube tube) { + CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); boolean connected = PartTransmitter.connectionMapContainsSide(tube.getAllCurrentConnections(), side); renderTransparency(tube.getTransmitterNetwork().refGas.getIcon(), tube.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale)); }