Rendering fixes and improvements

This commit is contained in:
Ben Spiers 2014-01-06 21:49:39 +00:00
parent 1129a33bf6
commit b299ad436d
2 changed files with 37 additions and 10 deletions

View file

@ -242,6 +242,21 @@ public class MekanismRenderer
GL11.glPopAttrib(); 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. * Cleaned-up snip of ItemRenderer.renderItem() -- meant to render 2D items as equipped.
* @param item - ItemStack to render * @param item - ItemStack to render

View file

@ -45,6 +45,7 @@ import codechicken.lib.colour.ColourRGBA;
import codechicken.lib.lighting.LazyLightMatrix; import codechicken.lib.lighting.LazyLightMatrix;
import codechicken.lib.lighting.LightMatrix; import codechicken.lib.lighting.LightMatrix;
import codechicken.lib.lighting.LightModel; import codechicken.lib.lighting.LightModel;
import codechicken.lib.lighting.LightModel.Light;
import codechicken.lib.render.CCModel; import codechicken.lib.render.CCModel;
import codechicken.lib.render.CCRenderState; import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.ColourMultiplier; 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); 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()) for(CCModel c : contents_models.values())
{ {
c.apply(new Translation(.5, .5, .5)); c.apply(new Translation(.5, .5, .5));
c.computeLighting(LightModel.standardLightModel); c.computeLighting(interiorLightModel);
c.shrinkUVs(0.0005); c.shrinkUVs(0.0005);
} }
} }
@ -230,15 +237,16 @@ public class RenderPartTransmitter implements IIconRegister
GL11.glTranslated(pos.x, pos.y, pos.z); GL11.glTranslated(pos.x, pos.y, pos.z);
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
if(cable.getConnectionType(side) != ConnectionType.NONE)
{ {
renderEnergySide(side, cable); renderEnergySide(side, cable);
} }
}
MekanismRenderer.glowOn(); MekanismRenderer.glowOn();
MekanismRenderer.cullFrontFace();
CCRenderState.draw(); CCRenderState.draw();
MekanismRenderer.disableCullFace();
MekanismRenderer.glowOff(); MekanismRenderer.glowOff();
GL11.glPopMatrix(); GL11.glPopMatrix();
@ -453,15 +461,17 @@ public class RenderPartTransmitter implements IIconRegister
GL11.glTranslated(pos.x, pos.y, pos.z); GL11.glTranslated(pos.x, pos.y, pos.z);
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) 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(); CCRenderState.draw();
MekanismRenderer.disableCullFace();
MekanismRenderer.glowOff();
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@ -495,12 +505,14 @@ public class RenderPartTransmitter implements IIconRegister
public void renderEnergySide(ForgeDirection side, PartUniversalCable cable) public void renderEnergySide(ForgeDirection side, PartUniversalCable cable)
{ {
CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture());
boolean connected = PartTransmitter.connectionMapContainsSide(cable.getAllCurrentConnections(), side); boolean connected = PartTransmitter.connectionMapContainsSide(cable.getAllCurrentConnections(), side);
renderTransparency(MekanismRenderer.energyIcon, cable.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower)); renderTransparency(MekanismRenderer.energyIcon, cable.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower));
} }
public void renderGasSide(ForgeDirection side, PartPressurizedTube tube) public void renderGasSide(ForgeDirection side, PartPressurizedTube tube)
{ {
CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture());
boolean connected = PartTransmitter.connectionMapContainsSide(tube.getAllCurrentConnections(), side); 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)); renderTransparency(tube.getTransmitterNetwork().refGas.getIcon(), tube.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale));
} }