From 702eda63669eb56934c3390ee8c0401ad725cb2f Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sun, 5 Jan 2014 13:26:34 +0800 Subject: [PATCH] Rendering new battery model --- .../resonantinduction/ResonantInduction.java | 7 +- .../core/render/BlockRenderingHandler.java | 37 +++----- .../machine/crusher/ItemDust.java | 2 +- .../transport/battery/RenderBattery.java | 87 +++--------------- .../resonantinduction/models/battery.tcn | Bin 1225 -> 0 bytes 5 files changed, 34 insertions(+), 99 deletions(-) delete mode 100644 src/main/resources/assets/resonantinduction/models/battery.tcn diff --git a/src/main/java/resonantinduction/ResonantInduction.java b/src/main/java/resonantinduction/ResonantInduction.java index f9ad43bf..4b17b371 100644 --- a/src/main/java/resonantinduction/ResonantInduction.java +++ b/src/main/java/resonantinduction/ResonantInduction.java @@ -100,8 +100,11 @@ public class ResonantInduction public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/"; public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/"; public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/"; - public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "models/"; - public static final String MODEL_DIRECTORY = DIRECTORY + "models/"; + + public static final String MODEL_PATH = "models/"; + + public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + MODEL_PATH; + public static final String MODEL_DIRECTORY = DIRECTORY + MODEL_PATH; public static final String LANGUAGE_DIRECTORY = DIRECTORY + "languages/"; public static final String[] LANGUAGES = new String[] { "en_US", "de_DE" }; diff --git a/src/main/java/resonantinduction/core/render/BlockRenderingHandler.java b/src/main/java/resonantinduction/core/render/BlockRenderingHandler.java index dae509c0..367ab74e 100644 --- a/src/main/java/resonantinduction/core/render/BlockRenderingHandler.java +++ b/src/main/java/resonantinduction/core/render/BlockRenderingHandler.java @@ -6,9 +6,6 @@ package resonantinduction.core.render; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; - -import org.lwjgl.opengl.GL11; - import resonantinduction.transport.battery.BlockBattery; import resonantinduction.transport.battery.RenderBattery; import resonantinduction.transport.levitator.BlockLevitator; @@ -20,6 +17,7 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import static org.lwjgl.opengl.GL11.*; /** * @author Calclavia @@ -36,42 +34,37 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { if (block instanceof BlockTesla) { - GL11.glPushMatrix(); - GL11.glTranslated(0.5, 1.5, 0.5); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + glPushMatrix(); + glTranslated(0.5, 1.5, 0.5); + glRotatef(180F, 0.0F, 0.0F, 1.0F); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderTesla.TEXTURE_BOTTOM); RenderTesla.MODEL_BOTTOM.render(0.0625f); - GL11.glPopMatrix(); + glPopMatrix(); } else if (block instanceof BlockLevitator) { - GL11.glPushMatrix(); - GL11.glTranslated(0.5, 1.5, 0.5); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + glPushMatrix(); + glTranslated(0.5, 1.5, 0.5); + glRotatef(180F, 0.0F, 0.0F, 1.0F); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderLevitator.TEXTURE); RenderLevitator.MODEL.render(0.0625f); - GL11.glPopMatrix(); + glPopMatrix(); } else if (block instanceof BlockBattery) { - GL11.glPushMatrix(); - GL11.glTranslated(0.5, 1.42, 0.5); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + glPushMatrix(); + glTranslatef(0.5f, 0.9f, 0.5f); + glScalef(0.5f, 0.5f, 0.5f); + glRotatef(180F, 0.0F, 0.0F, 1.0F); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderBattery.TEXTURE); - RenderBattery.MODEL.render(0.0625f); - GL11.glPopMatrix(); + RenderBattery.MODEL.renderAll(); + glPopMatrix(); } } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - if (block instanceof BlockBattery) - { - RenderBattery.render(); - return true; - } - return false; } diff --git a/src/main/java/resonantinduction/machine/crusher/ItemDust.java b/src/main/java/resonantinduction/machine/crusher/ItemDust.java index 51b00208..c6ec9474 100644 --- a/src/main/java/resonantinduction/machine/crusher/ItemDust.java +++ b/src/main/java/resonantinduction/machine/crusher/ItemDust.java @@ -115,7 +115,7 @@ public class ItemDust extends ItemBase } catch (ReflectiveOperationException e1) { - e1.printStackTrace(); + //e1.printStackTrace(); break; } diff --git a/src/main/java/resonantinduction/transport/battery/RenderBattery.java b/src/main/java/resonantinduction/transport/battery/RenderBattery.java index 2997a635..984f6eee 100644 --- a/src/main/java/resonantinduction/transport/battery/RenderBattery.java +++ b/src/main/java/resonantinduction/transport/battery/RenderBattery.java @@ -3,16 +3,17 @@ */ package resonantinduction.transport.battery; +import static org.lwjgl.opengl.GL11.glPopMatrix; +import static org.lwjgl.opengl.GL11.glPushMatrix; +import static org.lwjgl.opengl.GL11.glScalef; +import static org.lwjgl.opengl.GL11.glTranslatef; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; - -import org.lwjgl.opengl.GL11; - import resonantinduction.ResonantInduction; -import resonantinduction.transport.model.ModelBattery; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -23,79 +24,17 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderBattery extends TileEntitySpecialRenderer { - public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery.png"); - public static final ResourceLocation TEXTURE_MULTI = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery_multi.png"); - - public static final ModelBattery MODEL = new ModelBattery(); - - /* - * public static final Map MODELS; - * static - * { - * MODELS = CCModel.parseObjModels(new ResourceLocation("resonantinduction", "models/wire.obj"), - * 7, new InvertX()); - * for (CCModel c : MODELS.values()) - * { - * c.apply(new Translation(.5, 0, .5)); - * c.computeLighting(LightModel.standardLightModel); - * c.shrinkUVs(0.0005); - * } - * loadBuffer(location, 0, 0, 0, 1); - * loadBuffer(specular, 1, 1, 1, 1); - * loadBuffer(zero, 0, 0, 0, 0); - * loadBuffer(defaultAmbient, 0.4F, 0.4F, 0.4F, 1); - * GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, zero); - * GL11.glLight(GL11.GL_LIGHT3, GL11.GL_SPECULAR, specular); - * GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, specular); - * GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, zero); - * GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, zero); - * GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 128f); - * } - * public void renderStatic(TileBattery battery) - * { - * TextureUtils.bindAtlas(0); - * CCRenderState.reset(); - * CCRenderState.useModelColours(true); - * CCRenderState.setBrightness(battery.worldObj, battery.xCoord, battery.yCoord, - * battery.zCoord); - * renderPart(ForgeDirection.UNKNOWN, wire); - * byte renderSides = wire.getAllCurrentConnections(); - * for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - * { - * if (PartWire.connectionMapContainsSide(renderSides, side)) - * { - * renderSide(side, wire); - * } - * } - * } - * public void renderPart(Icon icon, CCModel cc, double x, double y, double z, Colour colour) - * { - * cc.render(0, cc.verts.length, Rotation.sideOrientation(0, Rotation.rotationTo(0, - * 2)).at(codechicken.lib.vec.Vector3.center).with(new Translation(x, y, z)), new - * IconTransformation(icon), new ColourMultiplier(colour)); - * } - */ - - static IModelCustom advancedmodel = AdvancedModelLoader.loadModel(ResonantInduction.MODEL_DIRECTORY + "battery.obj"); - - public static void render() - { - /* - * advancedmodel.renderAll(); - * FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderBattery.TEXTURE); - */ - } + public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_PATH + "battery.png"); + public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(ResonantInduction.MODEL_DIRECTORY + "battery.obj"); @Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - - this.bindTexture(TEXTURE); - - MODEL.render(0.0625f); - GL11.glPopMatrix(); + glPushMatrix(); + glTranslatef((float) x + 0.5F, (float) y + 0.1f, (float) z + 0.5F); + glScalef(0.46f, 0.46f, 0.46f); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); + MODEL.renderAll(); + glPopMatrix(); } } diff --git a/src/main/resources/assets/resonantinduction/models/battery.tcn b/src/main/resources/assets/resonantinduction/models/battery.tcn deleted file mode 100644 index 2e5f94f581555ada8fe76e5ece319806504aa91d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1225 zcmWIWW@Zs#U|`^2;B&a;q|9&2$;-mPa5{;Bfs;XnAvZrIHAk-^H;0Qs0jP+9fssLi zp(cy{x>eCRMs)h^-M87Z9V8e&yl?)?uQ-3}vCBtT)?8SoFLF)KB(bM<_Y2iRW2q}8 zXaD`0EB@Lf*POlGMuxw2+xJD5Pp5xAcU-*u;2+;JRq+wCT0Lv-si!Y_U;F36>z(4i zYbGzbXTI(KE2&f`k(i5fe1nhGv(L-E5_~*q+Rw}#r+>ccdKBd)a$lXX+vwwe?^V+` zKd+g;>GMBVi3>O4mzh|^9M_4JU-ny7+xvXk$6fJy$EWXEB01a5_9&G9D*je=D@*IbK)QNSfFDUf#~?>9L0Pns$#nE6q)`$_kXFM!O@gK2pwFCnrlF~B23!oyH$V2Y?K)?` z!*DFJaPPKV2aB5~GDuvK$z8JrXyk!{W7Q^G7bY4ou$j1jRaS3fPH+&mowdt+fdCIX z(7q3{r7X-$4huS?14Q;o$|f^SSg^9v{Fm>nBbIjOS?BHOT;j>NgMF7x+iTvgW=+3i z$}MY{?(E>*adCri!TcLsdmTTgX`jxW#`3VP`;3FZW%hLEvno*^!%t~$^PGKAdgHD` zWiy{tZqk+e+5RA*Ve`@4BSux*4CiZYd39q=9$Vh=KHjwlH@cZ5Wm!#3=v{p^s+I59 z-4;HvlJ6596w4p<5N;1N?4MG=qpI7#(9isDR3`8G4-JXFJTI2^UQdWRyxJxqqWb0a zB|X;{BpueaZAjQ0`tIgByJknLt^d(zJ_5KV~**9-X^1GItT@vd{6x ztk)~Pb}@Z7n^o-dG}U*H)66xe