Added new awesome battery model thanks to CyanideX!

This commit is contained in:
Calclavia 2014-02-23 14:26:05 +08:00
parent d6d028df70
commit 55458ff82a
25 changed files with 38 additions and 412 deletions

View file

@ -8,14 +8,19 @@ import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef; import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glScalef; import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef; import static org.lwjgl.opengl.GL11.glTranslatef;
import javax.naming.directory.DirContext;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.client.model.obj.WavefrontObject; import net.minecraftforge.client.model.obj.WavefrontObject;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import org.apache.commons.lang3.ArrayUtils;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
@ -34,135 +39,56 @@ import cpw.mods.fml.relauncher.SideOnly;
public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleItemRenderer public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleItemRenderer
{ {
public static RenderBattery INSTANCE = new RenderBattery(); public static RenderBattery INSTANCE = new RenderBattery();
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "battery/battery.tcn");
public static final ResourceLocation TEXTURE_CAP = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "battery/bat_base_cap_tex.png"); //Renders only if another battery on this side exists
public static final ResourceLocation TEXTURE_CASE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "battery/bat_case_tex.png"); public static String[][] renderForSideOnly = new String[][] { new String[] { }, new String[] { }, new String[] { "frame1", "frame2" }, new String[] { "frame2", "frame3" }, new String[] { "frame3", "frame4" }, new String[] { "frame4", "frame5" } };
public static final WavefrontObject MODEL = (WavefrontObject) AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "battery/battery.obj");
//Renders only if another battery on this side does NOT exist
public static String[][] renderNotForSide = new String[][] { new String[] {"bottom", "coil1"}, new String[] { "top", "frame1con", "frame2con", "frame3con", "frame4con" }, new String[] { }, new String[] { }, new String[] { }, new String[] { } };
@Override @Override
public void renderInventoryItem(ItemStack itemStack) public void renderInventoryItem(ItemStack itemStack)
{ {
glPushMatrix(); glPushMatrix();
GL11.glTranslated(0, -0.5f, 0); GL11.glTranslated(0, 0, 0);
int energyLevel = (int) (((double) ((ItemBlockBattery) itemStack.getItem()).getEnergy(itemStack) / (double) ((ItemBlockBattery) itemStack.getItem()).getEnergyCapacity(itemStack)) * 8);
for (int i = 2; i < 6; i++) RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery_" + energyLevel + ".png");
{ MODEL.renderAllExcept("frame1con", "frame2con", "frame3con", "frame4con");
glPushMatrix();
glScalef(0.5f, 0.5f, 0.5f);
ForgeDirection dir = ForgeDirection.getOrientation(i);
switch (dir)
{
case NORTH:
glRotatef(0, 0, 1, 0);
break;
case SOUTH:
glRotatef(180, 0, 1, 0);
break;
case WEST:
glRotatef(90, 0, 1, 0);
break;
case EAST:
glRotatef(-90, 0, 1, 0);
break;
}
int energyLevel = (int) (((double) ((ItemBlockBattery) itemStack.getItem()).getEnergy(itemStack) / (double) ((ItemBlockBattery) itemStack.getItem()).getEnergyCapacity(itemStack)) * 10);
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/bat_level_" + energyLevel + ".png");
MODEL.renderPart("Battery");
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_CAP);
MODEL.renderOnly("CapCorner", "BaseCorner", "CapEdge", "BaseEdge", "CapInterior", "BaseInterior");
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_CASE);
MODEL.renderOnly("BatteryCase");
glPopMatrix();
}
glPopMatrix(); glPopMatrix();
} }
@Override @Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
{ {
glPushMatrix();
glTranslatef((float) x + 0.5F, (float) y, (float) z + 0.5F);
for (int i = 2; i < 6; i++) renderForSideOnly = new String[][] { new String[] { "frame1con", "frame2con", "frame3con", "frame4con" }, new String[] { }, new String[] { }, new String[] { }, new String[] { }, new String[] { } };
{ renderNotForSide = new String[][] { new String[] {"bottom", "coil1"}, new String[] { "top" }, new String[] { "frame1" }, new String[] { "frame3" }, new String[] { "frame2" }, new String[] { "frame4" } };
glPushMatrix();
ForgeDirection dir = ForgeDirection.getOrientation(i);
switch (dir)
{
case NORTH:
glRotatef(0, 0, 1, 0);
break;
case SOUTH:
glRotatef(180, 0, 1, 0);
break;
case WEST:
glRotatef(90, 0, 1, 0);
break;
case EAST:
glRotatef(-90, 0, 1, 0);
break;
}
glScalef(0.5f, 0.5f, 0.5f); String[][] partToDisable = new String[][] { new String[] {"bottom", "coil1"}, new String[] { "top","frame1con" ,"frame2con" ,"frame3con" ,"frame4con" }, new String[] { }, new String[] { }, new String[] { }, new String[] { } };
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
/**
* If we're rendering in the world:
*/
TileBattery tile = (TileBattery) t; TileBattery tile = (TileBattery) t;
int energyLevel = (int) (((double) tile.energy.getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 10); int energyLevel = (int) (((double) tile.energy.getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/bat_level_" + energyLevel + ".png"); RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery_" + energyLevel + ".png");
MODEL.renderPart("Battery");
// Render top and bottom String[] disabledParts = new String[0];
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_CAP);
if (!(new Vector3(t).translate(ForgeDirection.UP).getTileEntity(t.worldObj) instanceof TileBattery))
MODEL.renderPart("CapCorner");
if (!(new Vector3(t).translate(ForgeDirection.DOWN).getTileEntity(t.worldObj) instanceof TileBattery))
MODEL.renderPart("BaseCorner");
// If quadrant with one external neighbor for (ForgeDirection check : ForgeDirection.VALID_DIRECTIONS)
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_CAP);
if (!(new Vector3(t).translate(ForgeDirection.UP).getTileEntity(t.worldObj) instanceof TileBattery))
MODEL.renderPart("CapEdge");
if (!(new Vector3(t).translate(ForgeDirection.DOWN).getTileEntity(t.worldObj) instanceof TileBattery))
MODEL.renderPart("BaseEdge");
/*
* If quadrant with three external neighbors //can't have quadrant with 2 external
* neighbors in rectangular prism
*/
if (!(new Vector3(t).translate(ForgeDirection.UP).getTileEntity(t.worldObj) instanceof TileBattery))
MODEL.renderPart("CapInterior");
if (!(new Vector3(t).translate(ForgeDirection.DOWN).getTileEntity(t.worldObj) instanceof TileBattery))
MODEL.renderPart("BaseInterior");
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_CASE);
if (tile.getInputDirections().contains(dir))
{ {
GL11.glColor3f(0, 0.294f, 0.498f); if (new Vector3(t).translate(check).getTileEntity(t.worldObj) instanceof TileBattery)
}
else if (tile.getOutputDirections().contains(dir))
{ {
GL11.glColor3f(1, 0.478f, 0.01f); disabledParts = ArrayUtils.addAll(disabledParts, partToDisable[check.ordinal()]);
}
} }
MODEL.renderPart("BatteryCase");
GL11.glColor3f(1, 1, 1); GL11.glColor3f(1, 1, 1);
MODEL.renderAllExcept(disabledParts);
if (new Vector3(t).translate(ForgeDirection.UP).getTileEntity(t.worldObj) instanceof TileBattery) GL11.glPopMatrix();
MODEL.renderPart("VertConnector");
glPopMatrix();
}
glPopMatrix();
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 633 B

View file

@ -1,300 +0,0 @@
# Blender v2.69 (sub 0) OBJ File: 'battery.blend'
# www.blender.org
mtllib battery.mtl
g Battery
v 0.333532 0.200000 -0.884667
v 0.333532 1.600000 -0.884667
v 0.566469 0.200000 -0.884667
v 0.566469 1.600000 -0.884667
v 0.768198 0.200000 -0.768198
v 0.768198 1.600000 -0.768198
v 0.884667 0.200000 -0.566469
v 0.884667 1.600000 -0.566469
v 0.884667 0.200000 -0.333531
v 0.884667 1.600000 -0.333531
v 0.768198 0.200000 -0.131802
v 0.768198 1.600000 -0.131802
v 0.566469 0.200000 0.000000
v 0.566469 1.600000 0.000000
v 0.000000 0.200000 -0.566468
v 0.000000 1.600000 -0.566468
v 0.131802 0.200000 -0.768198
v 0.131802 1.600000 -0.768198
vt 0.062500 0.000000
vt 0.062500 0.625000
vt 0.000000 -0.000000
vt 0.000000 0.625000
usemtl (null)
s off
f 1/1 2/2 3/3
f 3/1 4/2 5/3
f 5/1 6/2 7/3
f 7/1 8/2 9/3
f 9/1 10/2 11/3
f 11/1 12/2 13/3
f 15/1 16/2 17/3
f 17/1 18/2 1/3
f 2/2 4/4 3/3
f 4/2 6/4 5/3
f 6/2 8/4 7/3
f 8/2 10/4 9/3
f 10/2 12/4 11/3
f 12/2 14/4 13/3
f 16/2 18/4 17/3
f 18/2 2/4 1/3
g CapInterior
v 0.000000 1.800000 -0.000000
v 0.000000 1.800000 -1.000000
v 1.000000 1.800000 0.000000
v 1.000000 1.800000 -1.000000
v 0.000000 1.600000 -0.000000
v 0.000000 1.600000 -1.000000
v 1.000000 1.600000 0.000000
v 1.000000 1.600000 -1.000000
vt 0.500000 0.500000
vt 0.000000 0.500000
vt 0.500000 0.000000
vt 0.000000 0.000000
usemtl Material
s off
f 19/5 21/6 20/7
f 23/5 25/6 24/7
f 21/6 22/8 20/7
f 25/6 26/8 24/7
g CapCorner
v 0.900000 1.600000 0.000000
v 0.900000 1.600000 -0.900000
v 0.000000 1.600000 -0.900000
v 0.000000 1.800000 -0.000000
v 0.000000 1.800000 -0.750000
v 0.750000 1.800000 0.000000
v 0.750000 1.800000 -0.750000
v 0.000000 1.600000 -0.000000
vt 0.249993 0.917969
vt 0.250007 0.500000
vt 0.390625 1.000000
vt 0.390625 0.500000
vt 0.250000 0.500000
vt 0.390625 0.000000
vt 0.417969 0.500000
vt 0.000000 0.500000
vt 0.417969 0.082031
vt 0.500000 0.500000
vt 0.500000 0.000000
vt 0.250000 0.082031
vt 0.000000 0.082031
vt 0.000000 0.000000
usemtl Material
s off
f 33/9 32/10 28/11
f 29/12 31/13 28/14
f 30/15 32/16 31/17
f 28/18 27/16 29/19
f 32/10 27/12 28/11
f 31/13 33/20 28/14
f 32/16 33/21 31/17
f 27/16 34/22 29/19
g BaseEdge
v 1.000000 0.200000 0.000000
v 1.000000 0.200000 -0.900000
v 0.000000 0.200000 -0.900000
v 0.000000 -0.000000 -0.000000
v 0.000000 -0.000000 -1.000000
v 1.000000 -0.000000 0.000000
v 1.000000 -0.000000 -1.000000
v 0.000000 0.200000 -0.000000
vt 0.500000 0.000048
vt 0.500000 0.449976
vt 0.000095 0.000095
vt 0.000000 0.500000
vt -0.000000 -0.000000
vt 0.500000 0.500000
vt 0.140625 1.000000
vt 0.000000 1.000000
vt 0.140625 0.500000
vt 0.000095 0.450024
vt 0.500000 0.000000
usemtl Material
s off
f 35/23 36/24 42/25
f 41/26 40/27 39/28
f 36/29 41/30 37/31
f 36/24 37/32 42/25
f 40/27 38/33 39/28
f 41/30 39/26 37/31
g BaseInterior
v 1.000000 0.200000 -1.000000
v 0.000000 -0.000000 -0.000000
v 0.000000 -0.000000 -1.000000
v 1.000000 -0.000000 0.000000
v 1.000000 -0.000000 -1.000000
v 1.000000 0.200000 0.000000
v 0.000000 0.200000 -1.000000
v 0.000000 0.200000 -0.000000
vt 0.496979 0.496979
vt -0.000000 0.496979
vt 0.496979 0.000000
vt 0.000000 -0.000000
usemtl Material
s off
f 47/34 46/35 45/36
f 43/34 48/35 49/36
f 46/35 44/37 45/36
f 48/35 50/37 49/36
g BaseCorner
v 0.900000 0.200000 0.000000
v 0.900000 0.200000 -0.900000
v 0.000000 0.200000 -0.900000
v 0.000000 -0.000000 -0.000000
v 0.000000 -0.000000 -1.000000
v 1.000000 -0.000000 0.000000
v 1.000000 -0.000000 -1.000000
v 0.000000 0.200000 -0.000000
vt 0.000000 0.500000
vt 0.140625 0.500000
vt 0.140625 1.000000
vt 0.140625 0.000000
vt 0.000000 0.000000
vt 0.500000 -0.000000
vt 0.000000 0.917969
vt 0.000000 0.082031
vt 0.500000 0.500000
usemtl Material
s off
f 51/38 56/39 57/40
f 57/41 55/39 53/38
f 57/42 56/43 55/38
f 52/44 53/38 51/42
f 52/44 51/38 57/40
f 52/45 57/41 53/38
f 56/43 54/46 55/38
f 53/38 58/42 51/42
g VertConnector
v 0.900000 1.600000 -0.900000
v 0.750000 1.800000 -0.750000
v 0.900000 2.200000 -0.900000
v 0.750000 2.000000 -0.750000
v -0.900000 1.600000 -0.900000
v -0.750000 1.800000 -0.750000
v -0.900000 2.200000 -0.900000
v -0.750000 2.000000 -0.750000
vt 0.000000 0.000000
vt 0.140625 0.082031
vt 0.000000 1.000000
vt 0.390625 0.000000
vt 0.390814 0.999458
vt 0.250000 0.082031
vt 0.140625 0.917969
vt 0.250000 0.917969
usemtl Material
s off
f 61/47 62/48 65/49
f 59/50 63/51 60/52
f 66/53 62/48 64/54
f 62/48 66/53 65/49
f 63/51 64/54 60/52
f 62/48 60/52 64/54
g CapEdge
v 0.000000 1.600000 -0.000000
v 0.000000 1.600000 -0.900000
v 0.000000 1.800000 -0.000000
v 0.000000 1.800000 -0.750000
v 1.000000 1.800000 0.000000
v 1.000000 1.800000 -0.750000
v 1.000000 1.600000 -0.900000
v 1.000000 1.600000 0.000000
vt 0.500000 0.450000
vt 0.000000 0.450000
vt 0.500000 0.050000
vt 0.195312 -0.000000
vt 0.195312 0.500000
vt 0.125000 0.000000
vt 0.000000 0.000000
vt 0.450000 0.000000
vt 0.000000 0.500000
vt 0.000000 0.050000
vt 0.125000 0.500000
vt 0.450000 0.500000
usemtl Material
s off
f 69/55 71/56 70/57
f 73/58 68/59 72/60
f 67/61 68/62 74/63
f 71/56 72/64 70/57
f 68/59 70/65 72/60
f 68/62 73/66 74/63
g BatteryCase
v 0.900000 1.600000 -0.900000
v 0.050000 1.600000 -0.900000
v 0.750000 1.600000 -0.900000
v 0.050000 1.600000 -0.850000
v 0.750000 1.600000 -0.850000
v 0.900000 0.200000 -0.900000
v 0.050000 0.200000 -0.900000
v 0.750000 0.200000 -0.900000
v 0.050000 0.200000 -0.850000
v 0.750000 0.200000 -0.850000
v -0.900000 1.600000 -0.900000
v -0.000000 1.600000 -0.900000
v -0.050000 1.600000 -0.900000
v -0.750000 1.600000 -0.900000
v -0.050000 1.600000 -0.850000
v -0.750000 1.600000 -0.850000
v -0.900000 0.200000 -0.900000
v -0.000000 0.200000 -0.900000
v -0.050000 0.200000 -0.900000
v -0.750000 0.200000 -0.900000
v -0.050000 0.200000 -0.850000
v -0.750000 0.200000 -0.850000
v 0.800000 0.200000 -0.800000
v -0.800000 0.200000 -0.800000
v 0.800000 1.600000 -0.800000
v -0.800000 1.600000 -0.800000
vt 0.193694 0.800002
vt 0.193694 0.100000
vt 0.300810 0.800002
vt 0.300810 0.100000
vt 0.336515 0.100000
vt 0.387262 0.799997
vt 0.387262 0.100000
vt 0.422968 0.799997
vt 0.422967 0.100000
vt 0.458674 0.799997
vt 0.193442 0.800002
vt 0.086326 0.800002
vt 0.193442 0.100000
vt 0.086326 0.100000
vt 0.050620 0.100000
vt 0.530084 0.799997
vt 0.494379 0.799997
vt 0.530084 0.100000
vt 0.494378 0.100000
vt 0.050621 0.800002
vt 0.000126 0.800002
vt 0.336516 0.800002
vt 0.387010 0.800002
vt 0.458672 0.100000
vt 0.000126 0.100000
vt 0.387010 0.100000
usemtl Material.002
s off
f 75/67 80/68 77/69
f 82/70 84/71 77/69
f 78/72 83/73 76/74
f 76/74 81/75 86/76
f 85/77 88/78 91/79
f 94/80 88/78 96/81
f 89/82 87/83 95/84
f 87/83 86/76 93/85
f 90/86 100/87 96/81
f 79/88 84/71 99/89
f 80/68 82/70 77/69
f 84/71 79/88 77/69
f 83/73 81/75 76/74
f 81/75 92/90 86/76
f 88/78 94/80 91/79
f 88/78 90/86 96/81
f 87/83 93/85 95/84
f 86/76 92/90 93/85
f 100/87 98/91 96/81
f 84/71 97/92 99/89

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB