123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package com.zjinja.mcmod.decor.element_templates.renderer;
- import com.zjinja.mcmod.decor.ZJinJaDecoration;
- import com.zjinja.mcmod.decor.element_base.EBaseTileBlock;
- import com.zjinja.mcmod.decor.element_base.EBaseTileRenderer;
- import net.minecraft.block.Block;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.renderer.RenderHelper;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.client.model.obj.WavefrontObject;
- import org.lwjgl.opengl.GL11;
- public class WaveFrontRenderer extends EBaseTileRenderer {
- protected WavefrontObject WaveFrontModel;
- protected ResourceLocation TextureRes;
- public WaveFrontRenderer(){
- }
- public void LoadResources(String ObjLocation, String TextureLocation){
- String modelloc = "models/blocks/" + ObjLocation + ".obj";
- String textureloc = "textures/blocks/" + TextureLocation + ".png";
- if(ZJinJaDecoration.DebugMode) {
- ZJinJaDecoration.logger.warn("[Model Location] " + modelloc);
- ZJinJaDecoration.logger.warn("[Texture Location] " + textureloc);
- }
- WaveFrontModel = new WavefrontObject(new ResourceLocation(ZJinJaDecoration.MODID, modelloc));
- TextureRes = new ResourceLocation(ZJinJaDecoration.MODID, textureloc);
- }
- protected void preRender(double x, double y, double z){
- GL11.glPushMatrix();
- GL11.glTranslatef((float)x + 0.5F, (float)y + 0.5F, (float)z + 0.5F);
- RenderHelper.disableStandardItemLighting();
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_CULL_FACE);
- if(Minecraft.isAmbientOcclusionEnabled()){
- GL11.glShadeModel(GL11.GL_SMOOTH);
- }else {
- GL11.glShadeModel(GL11.GL_FLAT);
- }
- Tessellator.instance.setColorOpaque_F(1.0F, 1.0F, 1.0F);
- }
- protected void render(WavefrontObject model,EBaseTileBlock tileBlock, int meta){
- GL11.glPushMatrix();
- GL11.glScalef(0.0625F, 0.0625F, 0.0625F);
- tileBlock.DirUtil.GLTransformByMeta(meta);
- model.renderAll();
- GL11.glPopMatrix();
- GL11.glPopMatrix();
- GL11.glPopMatrix();
- GL11.glPopMatrix();
- }
- protected void postRender(){
- RenderHelper.enableStandardItemLighting();
- GL11.glPopMatrix();
- }
- @Override
- public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale){
- preRender(x, y, z);
- Block block = te.getWorldObj().getBlock(te.xCoord, te.yCoord, te.zCoord);
- int meta = te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord, te.zCoord);
- if(block instanceof EBaseTileBlock){
- EBaseTileBlock tileBlock = (EBaseTileBlock)block;
- Minecraft.getMinecraft().getTextureManager().bindTexture(TextureRes);
- render(WaveFrontModel, tileBlock, meta);
- }
- postRender();
- }
- }
|