Rendering new battery model

This commit is contained in:
Calclavia 2014-01-05 13:26:34 +08:00
parent 47f6f07d69
commit 702eda6366
5 changed files with 34 additions and 99 deletions

View file

@ -100,8 +100,11 @@ public class ResonantInduction
public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/"; public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/";
public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/"; public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/";
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/"; 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 LANGUAGE_DIRECTORY = DIRECTORY + "languages/";
public static final String[] LANGUAGES = new String[] { "en_US", "de_DE" }; public static final String[] LANGUAGES = new String[] { "en_US", "de_DE" };

View file

@ -6,9 +6,6 @@ package resonantinduction.core.render;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import resonantinduction.transport.battery.BlockBattery; import resonantinduction.transport.battery.BlockBattery;
import resonantinduction.transport.battery.RenderBattery; import resonantinduction.transport.battery.RenderBattery;
import resonantinduction.transport.levitator.BlockLevitator; 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.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import static org.lwjgl.opengl.GL11.*;
/** /**
* @author Calclavia * @author Calclavia
@ -36,42 +34,37 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
{ {
if (block instanceof BlockTesla) if (block instanceof BlockTesla)
{ {
GL11.glPushMatrix(); glPushMatrix();
GL11.glTranslated(0.5, 1.5, 0.5); glTranslated(0.5, 1.5, 0.5);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); glRotatef(180F, 0.0F, 0.0F, 1.0F);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderTesla.TEXTURE_BOTTOM); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderTesla.TEXTURE_BOTTOM);
RenderTesla.MODEL_BOTTOM.render(0.0625f); RenderTesla.MODEL_BOTTOM.render(0.0625f);
GL11.glPopMatrix(); glPopMatrix();
} }
else if (block instanceof BlockLevitator) else if (block instanceof BlockLevitator)
{ {
GL11.glPushMatrix(); glPushMatrix();
GL11.glTranslated(0.5, 1.5, 0.5); glTranslated(0.5, 1.5, 0.5);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); glRotatef(180F, 0.0F, 0.0F, 1.0F);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderLevitator.TEXTURE); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderLevitator.TEXTURE);
RenderLevitator.MODEL.render(0.0625f); RenderLevitator.MODEL.render(0.0625f);
GL11.glPopMatrix(); glPopMatrix();
} }
else if (block instanceof BlockBattery) else if (block instanceof BlockBattery)
{ {
GL11.glPushMatrix(); glPushMatrix();
GL11.glTranslated(0.5, 1.42, 0.5); glTranslatef(0.5f, 0.9f, 0.5f);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); glScalef(0.5f, 0.5f, 0.5f);
glRotatef(180F, 0.0F, 0.0F, 1.0F);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderBattery.TEXTURE); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderBattery.TEXTURE);
RenderBattery.MODEL.render(0.0625f); RenderBattery.MODEL.renderAll();
GL11.glPopMatrix(); glPopMatrix();
} }
} }
@Override @Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) 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; return false;
} }

View file

@ -115,7 +115,7 @@ public class ItemDust extends ItemBase
} }
catch (ReflectiveOperationException e1) catch (ReflectiveOperationException e1)
{ {
e1.printStackTrace(); //e1.printStackTrace();
break; break;
} }

View file

@ -3,16 +3,17 @@
*/ */
package resonantinduction.transport.battery; 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.client.renderer.tileentity.TileEntitySpecialRenderer;
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.IModelCustom;
import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; 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.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -23,79 +24,17 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderBattery extends TileEntitySpecialRenderer 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 = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_PATH + "battery.png");
public static final ResourceLocation TEXTURE_MULTI = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery_multi.png"); public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(ResonantInduction.MODEL_DIRECTORY + "battery.obj");
public static final ModelBattery MODEL = new ModelBattery();
/*
* public static final Map<String, CCModel> 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);
*/
}
@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)
{ {
GL11.glPushMatrix(); glPushMatrix();
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); glTranslatef((float) x + 0.5F, (float) y + 0.1f, (float) z + 0.5F);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); glScalef(0.46f, 0.46f, 0.46f);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
this.bindTexture(TEXTURE); MODEL.renderAll();
glPopMatrix();
MODEL.render(0.0625f);
GL11.glPopMatrix();
} }
} }