Finished multimeter model render
This commit is contained in:
parent
b7e391ce89
commit
8dbef429f5
3 changed files with 98 additions and 108 deletions
|
@ -183,11 +183,11 @@ public class ResonantInduction
|
||||||
metadata.modId = ID;
|
metadata.modId = ID;
|
||||||
metadata.name = NAME;
|
metadata.name = NAME;
|
||||||
metadata.description = "Resonant Induction is a Minecraft mod focusing on the manipulation of electricity and wireless technology. Ever wanted blazing electrical shocks flying off your evil lairs? You've came to the right place!";
|
metadata.description = "Resonant Induction is a Minecraft mod focusing on the manipulation of electricity and wireless technology. Ever wanted blazing electrical shocks flying off your evil lairs? You've came to the right place!";
|
||||||
metadata.url = "http://universalelectricity.com";
|
metadata.url = "http://universalelectricity.com/resonant-induction";
|
||||||
metadata.version = VERSION + BUILD_VERSION;
|
metadata.version = VERSION + BUILD_VERSION;
|
||||||
metadata.authorList = Arrays.asList(new String[] { "Calclavia", "Aidancbrady" });
|
metadata.authorList = Arrays.asList(new String[] { "Calclavia", "Aidancbrady" });
|
||||||
metadata.logoFile = "/";
|
metadata.logoFile = "/";
|
||||||
metadata.credits = "Thanks to Archadia for the assets.";
|
metadata.credits = "Thanks to Archadia for the awesome assets!";
|
||||||
metadata.autogenerated = true;
|
metadata.autogenerated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
|
||||||
*/
|
*/
|
||||||
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int side, float hitX, float hitY, float hitZ, int metadata)
|
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||||
{
|
{
|
||||||
return ForgeDirection.getOrientation(side).ordinal();
|
return ForgeDirection.getOrientation(side).getOpposite().ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,27 +34,24 @@ public class RenderMultimeter extends TileEntitySpecialRenderer
|
||||||
ForgeDirection direction = ForgeDirection.getOrientation(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
ForgeDirection direction = ForgeDirection.getOrientation(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
/ GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
GL11.glRotatef(90, 0, 0, 1);
|
||||||
//GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
GL11.glTranslated(0, -1, 0);
|
||||||
GL11.glRotatef(90F, 0, 0, 1);
|
|
||||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
|
||||||
/*
|
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
|
case UP:
|
||||||
|
GL11.glRotatef(90, 0, 1, 0);
|
||||||
|
break;
|
||||||
case DOWN:
|
case DOWN:
|
||||||
|
GL11.glRotatef(-90, 0, 1, 0);
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
GL11.glRotatef(180, 0, 1, 0);
|
||||||
GL11.glRotatef(180, 0, 0, 1);
|
GL11.glRotatef(180, 0, 0, 1);
|
||||||
GL11.glTranslatef(0, -2, 0);
|
GL11.glTranslatef(0, -2, 0);
|
||||||
break;
|
break;
|
||||||
case UP:
|
|
||||||
break;
|
|
||||||
case NORTH:
|
|
||||||
GL11.glTranslatef(1, 1, 0);
|
|
||||||
GL11.glRotatef(90, 0, 0, 1);
|
|
||||||
break;
|
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
GL11.glTranslatef(-1, 1, 0);
|
|
||||||
GL11.glRotatef(-90, 0, 0, 1);
|
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
GL11.glTranslatef(0, 1, 1);
|
GL11.glTranslatef(0, 1, 1);
|
||||||
|
@ -65,103 +62,96 @@ public class RenderMultimeter extends TileEntitySpecialRenderer
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
this.func_110628_a(TEXTURE);
|
this.func_110628_a(TEXTURE);
|
||||||
MODEL.render(0.0625f);
|
MODEL.render(0.0625f);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
/**
|
GL11.glPushMatrix();
|
||||||
* Render from side 2 to 6. This means render all sides excluding top and bottom.
|
GL11.glPolygonOffset(-10, -10);
|
||||||
*/
|
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||||
for (int side = 0; side < 6; side++)
|
|
||||||
|
float dx = 1F / 16;
|
||||||
|
float dz = 1F / 16;
|
||||||
|
float displayWidth = 1 - 2F / 16;
|
||||||
|
float displayHeight = 1 - 2F / 16;
|
||||||
|
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
{
|
{
|
||||||
if (direction.ordinal() != side)
|
case UP:
|
||||||
{
|
GL11.glTranslatef(1, 1, 0);
|
||||||
GL11.glPushMatrix();
|
GL11.glRotatef(180, 1, 0, 0);
|
||||||
GL11.glPolygonOffset(-10, -10);
|
GL11.glRotatef(180, 0, 1, 0);
|
||||||
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
GL11.glTranslatef(0, -0.9f, -0.1f);
|
||||||
|
break;
|
||||||
float dx = 1F / 16;
|
case DOWN:
|
||||||
float dz = 1F / 16;
|
GL11.glRotatef(180, 0, 1, 0);
|
||||||
float displayWidth = 1 - 2F / 16;
|
GL11.glTranslatef(-1, -0.9f, -1.1f);
|
||||||
float displayHeight = 1 - 2F / 16;
|
break;
|
||||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
case SOUTH:
|
||||||
|
GL11.glTranslatef(1, 1, 1);
|
||||||
switch (side)
|
GL11.glRotatef(180, 0, 1, 0);
|
||||||
{
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
case 1:
|
GL11.glTranslatef(0, -0.9f, -0.1f);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case NORTH:
|
||||||
GL11.glTranslatef(1, 1, 0);
|
GL11.glTranslatef(0, 1, 0);
|
||||||
GL11.glRotatef(180, 1, 0, 0);
|
GL11.glRotatef(0, 0, 1, 0);
|
||||||
GL11.glRotatef(180, 0, 1, 0);
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
GL11.glTranslatef(0, -0.9f, -0.1f);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case EAST:
|
||||||
GL11.glTranslatef(0, 1, 0);
|
GL11.glTranslatef(1, 1, 0);
|
||||||
GL11.glRotatef(0, 0, 1, 0);
|
GL11.glRotatef(-90, 0, 1, 0);
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
GL11.glTranslatef(0, -0.9f, -0.1f);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case WEST:
|
||||||
GL11.glTranslatef(1, 1, 1);
|
GL11.glTranslatef(0, 1, 1);
|
||||||
GL11.glRotatef(180, 0, 1, 0);
|
GL11.glRotatef(90, 0, 1, 0);
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
GL11.glTranslatef(0, -0.9f, -0.1f);
|
||||||
break;
|
break;
|
||||||
case 5:
|
|
||||||
GL11.glTranslatef(0, 1, 1);
|
|
||||||
GL11.glRotatef(90, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
GL11.glTranslatef(1, 1, 0);
|
|
||||||
GL11.glRotatef(-90, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2);
|
|
||||||
GL11.glRotatef(-90, 1, 0, 0);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
FontRenderer fontRenderer = this.getFontRenderer();
|
|
||||||
|
|
||||||
String joules = Math.round(tileEntity.getDetectedEnergy()) + " J";
|
|
||||||
|
|
||||||
int stringWidth = Math.max(fontRenderer.getStringWidth(joules), 0);
|
|
||||||
// maxWidth += 8;
|
|
||||||
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
|
|
||||||
int requiredHeight = lineHeight * 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an average scale.
|
|
||||||
*/
|
|
||||||
float scaleX = displayWidth / stringWidth;
|
|
||||||
float scaleY = displayHeight / requiredHeight;
|
|
||||||
float scale = (float) (Math.min(scaleX, scaleY) * 0.8);
|
|
||||||
GL11.glScalef(scale, -scale, scale);
|
|
||||||
GL11.glDepthMask(false);
|
|
||||||
|
|
||||||
int realHeight = (int) Math.floor(displayHeight / scale);
|
|
||||||
int realWidth = (int) Math.floor(displayWidth / scale);
|
|
||||||
|
|
||||||
int offsetY = (realHeight - requiredHeight) / 2;
|
|
||||||
int offsetX = (realWidth - stringWidth) / 2;
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
fontRenderer.drawString(joules, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1);
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glDepthMask(true);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2);
|
||||||
|
GL11.glRotatef(-90, 1, 0, 0);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
|
FontRenderer fontRenderer = this.getFontRenderer();
|
||||||
|
|
||||||
|
String joules = Math.round(tileEntity.getDetectedEnergy()) + " J";
|
||||||
|
|
||||||
|
int stringWidth = Math.max(fontRenderer.getStringWidth(joules), 0);
|
||||||
|
// maxWidth += 8;
|
||||||
|
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
|
||||||
|
int requiredHeight = lineHeight * 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an average scale.
|
||||||
|
*/
|
||||||
|
float scaleX = displayWidth / stringWidth;
|
||||||
|
float scaleY = displayHeight / requiredHeight;
|
||||||
|
float scale = (float) (Math.min(scaleX, scaleY) * 0.8);
|
||||||
|
GL11.glScalef(scale, -scale, scale);
|
||||||
|
GL11.glDepthMask(false);
|
||||||
|
|
||||||
|
int realHeight = (int) Math.floor(displayHeight / scale);
|
||||||
|
int realWidth = (int) Math.floor(displayWidth / scale);
|
||||||
|
|
||||||
|
int offsetY = (realHeight - requiredHeight) / 2;
|
||||||
|
int offsetX = (realWidth - stringWidth) / 2;
|
||||||
|
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
fontRenderer.drawString(joules, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1);
|
||||||
|
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
GL11.glDepthMask(true);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||||
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue