Naitenne

Render .obj 1.7.10

Mar 6th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.11 KB | None | 0 0
  1. package net.row.renderer.entity;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import net.minecraft.client.model.ModelBase;
  6. import net.minecraft.client.renderer.entity.Render;
  7. import net.minecraft.entity.Entity;
  8. import net.minecraft.util.ResourceLocation;
  9. import net.row.entity.GunHowitzerLight;
  10. import net.row.models.howitzer.*;
  11. import org.lwjgl.opengl.GL11;
  12.  
  13. @SideOnly(Side.CLIENT)
  14. public class RenderGunLightHowitzer extends Render{
  15.     protected final ModelBase base = new ModelPedestal();
  16.     protected final ModelBase mount = new ModelMount();
  17.     protected final ModelBase cradle = new ModelCradle();
  18.     protected final ModelBase bolt = new ModelBolt();
  19.     protected final ModelBase handleAzimuth = new ModelHandleAzimuth();
  20.     protected final ModelBase handleZenith = new ModelHandleZenith();
  21.     protected final ModelBase axle = new ModelAxle();
  22.     protected final ResourceLocation texture = new ResourceLocation("row:textures/cannon/howitzer/cannon_light_1.png");
  23.  
  24. //For .obj models
  25. //private final WavefrontObject modelObj = (WavefrontObject) AdvancedModelLoader.loadModel(new //ResourceLocation("modid:path/name.obj"));
  26.  
  27.     public RenderGunLightHowitzer(){
  28.         this.shadowSize = 1.0F;
  29.     }
  30.  
  31.     public void renderHowitzer(GunHowitzerLight par1, double par2, double par4, double par6, float par8, float par9){
  32.         GL11.glPushMatrix();
  33.         GL11.glTranslated(par2, par4, par6);
  34.         bindTexture(texture);
  35.         base.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  36.         GL11.glRotatef(-par1.rotationYaw, 0F, 1F, 0F);
  37.         mount.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  38. //For .obj models
  39. //this.modelObj.renderAll();
  40.  
  41.         GL11.glPushMatrix();
  42.         GL11.glTranslatef(0.0F, 15F/16.0F, -0F/16.0F);
  43.         GL11.glRotatef(-par1.rotationPitch*9.0F + 45F, 1F, 0F, 0F);
  44.         axle.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  45.         GL11.glPopMatrix();
  46.  
  47.         GL11.glPushMatrix();
  48.         GL11.glTranslatef(0.0F, 12/16.0F, 0.0F);
  49.         GL11.glRotatef(-110F, 0F, 1F, 0F);
  50.         GL11.glTranslatef(-7/16.0F, 0.0F, -2/16.0F);
  51.         GL11.glRotatef(par1.rotationYaw*20.0F, 1F, 0F, 0F);
  52.         handleAzimuth.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  53.         GL11.glPopMatrix();
  54.  
  55.         GL11.glPushMatrix();
  56.         GL11.glTranslatef(0.0F, 17/16.0F, 0.0F);
  57.         GL11.glRotatef(-90F, 0F, 1F, 0F);
  58.         GL11.glTranslatef(-6/16.0F, 0.0F, -4.5F/16.0F);
  59.         GL11.glRotatef(par1.rotationPitch*20.0F, 1F, 0F, 0F);
  60.         handleZenith.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  61.         GL11.glPopMatrix();
  62.  
  63.         GL11.glTranslatef(0.0F, 22/16.0F, -2/16.0F);
  64.         GL11.glRotatef(-par1.rotationPitch, 1F, 0F, 0F);
  65.         cradle.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  66.         GL11.glTranslatef(0.0F, 0.0F, -par1.shootingStage/60F*6F/16F);
  67.         bolt.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  68.         GL11.glPopMatrix();
  69.     }
  70.  
  71.     @Override
  72.     public void doRender(Entity par1, double par2, double par4, double par6, float par8, float par9){
  73.         this.renderHowitzer((GunHowitzerLight) par1, par2, par4, par6, par8, par9);
  74.     }
  75.  
  76.     @Override
  77.     protected ResourceLocation getEntityTexture(Entity entity){
  78.         return null;
  79.     }
  80. }
Add Comment
Please, Sign In to add comment