Some minor improvements to the Engine Renderer
Note: it still needs to be rewritten to use a single texture sheet.
This commit is contained in:
parent
d2e7279498
commit
52ffd07bb3
1 changed files with 46 additions and 47 deletions
|
@ -1,12 +1,10 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) SpaceToad, 2011
|
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||||
* http://www.mod-buildcraft.com
|
|
||||||
*
|
*
|
||||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
* 1.0, or MMPL. Please check the contents of the license located in
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package buildcraft.energy.render;
|
package buildcraft.energy.render;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
|
@ -25,17 +23,27 @@ import buildcraft.core.IInventoryRenderer;
|
||||||
import buildcraft.energy.Engine;
|
import buildcraft.energy.Engine;
|
||||||
import buildcraft.energy.Engine.EnergyStage;
|
import buildcraft.energy.Engine.EnergyStage;
|
||||||
import buildcraft.energy.IEngineProvider;
|
import buildcraft.energy.IEngineProvider;
|
||||||
|
import static net.minecraftforge.common.ForgeDirection.*;
|
||||||
|
|
||||||
public class RenderEngine extends TileEntitySpecialRenderer implements IInventoryRenderer {
|
public class RenderEngine extends TileEntitySpecialRenderer implements IInventoryRenderer {
|
||||||
|
|
||||||
private ModelBase model = new ModelBase() {
|
private ModelBase model = new ModelBase() {
|
||||||
};
|
};
|
||||||
|
|
||||||
private ModelRenderer box;
|
private ModelRenderer box;
|
||||||
private ModelRenderer trunk;
|
private ModelRenderer trunk;
|
||||||
private ModelRenderer movingBox;
|
private ModelRenderer movingBox;
|
||||||
private ModelRenderer chamber;
|
private ModelRenderer chamber;
|
||||||
private String baseTexture;
|
private String baseTexture;
|
||||||
|
private static final float[] angleMap = new float[6];
|
||||||
|
|
||||||
|
static {
|
||||||
|
angleMap[EAST.ordinal()] = (float) -Math.PI / 2;
|
||||||
|
angleMap[WEST.ordinal()] = (float) Math.PI / 2;
|
||||||
|
angleMap[UP.ordinal()] = 0;
|
||||||
|
angleMap[DOWN.ordinal()] = (float) Math.PI;
|
||||||
|
angleMap[SOUTH.ordinal()] = (float) Math.PI / 2;
|
||||||
|
angleMap[NORTH.ordinal()] = (float) -Math.PI / 2;
|
||||||
|
}
|
||||||
|
|
||||||
public RenderEngine() {
|
public RenderEngine() {
|
||||||
|
|
||||||
|
@ -88,11 +96,16 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor
|
||||||
|
|
||||||
private void render(EnergyStage energy, float progress, ForgeDirection orientation, String baseTexture, double x, double y, double z) {
|
private void render(EnergyStage energy, float progress, ForgeDirection orientation, String baseTexture, double x, double y, double z) {
|
||||||
|
|
||||||
if (BuildCraftCore.render == RenderMode.NoDynamic)
|
if (BuildCraftCore.render == RenderMode.NoDynamic) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glDisable(2896 /* GL_LIGHTING */);
|
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||||
|
GL11.glColor3f(1, 1, 1);
|
||||||
|
|
||||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||||
|
|
||||||
|
@ -104,35 +117,21 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor
|
||||||
step = progress * 2F * 7.99F;
|
step = progress * 2F * 7.99F;
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] angle = { 0, 0, 0 };
|
|
||||||
float[] translate = { 0, 0, 0 };
|
|
||||||
float translatefact = step / 16;
|
float translatefact = step / 16;
|
||||||
|
|
||||||
|
float[] angle = {0, 0, 0};
|
||||||
|
float[] translate = {orientation.offsetX, orientation.offsetY, orientation.offsetZ};
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case EAST:
|
case EAST:
|
||||||
angle[2] = (float) -Math.PI / 2;
|
case WEST:
|
||||||
translate[0] = 1;
|
case DOWN:
|
||||||
break;
|
angle[2] = angleMap[orientation.ordinal()];
|
||||||
case WEST:
|
break;
|
||||||
angle[2] = (float) Math.PI / 2;
|
case SOUTH:
|
||||||
translate[0] = -1;
|
case NORTH:
|
||||||
break;
|
angle[0] = angleMap[orientation.ordinal()];
|
||||||
case UP:
|
break;
|
||||||
translate[1] = 1;
|
|
||||||
break;
|
|
||||||
case DOWN:
|
|
||||||
angle[2] = (float) Math.PI;
|
|
||||||
translate[1] = -1;
|
|
||||||
break;
|
|
||||||
case SOUTH:
|
|
||||||
angle[0] = (float) Math.PI / 2;
|
|
||||||
translate[2] = 1;
|
|
||||||
break;
|
|
||||||
case NORTH:
|
|
||||||
angle[0] = (float) -Math.PI / 2;
|
|
||||||
translate[2] = -1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
box.rotateAngleX = angle[0];
|
box.rotateAngleX = angle[0];
|
||||||
|
@ -177,25 +176,25 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor
|
||||||
String texture = "";
|
String texture = "";
|
||||||
|
|
||||||
switch (energy) {
|
switch (energy) {
|
||||||
case Blue:
|
case Blue:
|
||||||
texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_blue.png";
|
texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_blue.png";
|
||||||
break;
|
break;
|
||||||
case Green:
|
case Green:
|
||||||
texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_green.png";
|
texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_green.png";
|
||||||
break;
|
break;
|
||||||
case Yellow:
|
case Yellow:
|
||||||
texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_yellow.png";
|
texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_yellow.png";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_red.png";
|
texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_red.png";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bindTextureByName(texture);
|
bindTextureByName(texture);
|
||||||
|
|
||||||
trunk.render(factor);
|
trunk.render(factor);
|
||||||
|
|
||||||
GL11.glEnable(2896 /* GL_LIGHTING */);
|
GL11.glPopAttrib();
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue