Jump to content

Recommended Posts

Posted

First of all, a huge thank you to Eternaldoom for helping out with the rendering. Unfortunately, my penguin doesn't quite walk properly, and I can't figure out why. I built the model in Techne, but for some reason I cannot find it and reopen it. http://minecraftforge.net/forum/Smileys/default/undecided.gif My penguin animates properly (aside from the head, I need to fix that), but it walks sideways... Can anyone help?

 

Here is the ModelPenguin file, if you need more I can help.

 

package ArctiCraftMob;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;

public class ModelPenguin extends ModelBase
{
  //fields
    ModelRenderer Leg1;
    ModelRenderer Leg2;
    ModelRenderer Body;
    ModelRenderer Arm1;
    ModelRenderer Arm2;
    ModelRenderer Head; 
    ModelRenderer Foot1;
    ModelRenderer Foot2;
  
  public ModelPenguin()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Leg1 = new ModelRenderer(this, 42, 12);
      Leg1.addBox(0F, 0F, 0F, 1, 7, 1);
      Leg1.setRotationPoint(0F, 17F, -2F);
      Leg1.setTextureSize(64, 32);
      Leg1.mirror = true;
      setRotation(Leg1, 0F, 0F, 0F);
      Leg2 = new ModelRenderer(this, 42, 12);
      Leg2.addBox(0F, 0F, 0F, 1, 7, 1);
      Leg2.setRotationPoint(0F, 17F, 1F);
      Leg2.setTextureSize(64, 32);
      Leg2.mirror = true;
      setRotation(Leg2, 0F, 0F, 0F);
      Body = new ModelRenderer(this, 46, 12);
      Body.addBox(0F, 0F, 0F, 3, 11, 6);
      Body.setRotationPoint(-1F, 6F, -3F);
      Body.setTextureSize(64, 32);
      Body.mirror = true;
      setRotation(Body, 0F, 0F, 0F);
      Arm1 = new ModelRenderer(this, 32, 0);
      Arm1.addBox(0F, 0F, 0F, 3, 11, 1);
      Arm1.setRotationPoint(2F, 6F, -3F);
      Arm1.setTextureSize(64, 32);
      Arm1.mirror = true;
      setRotation(Arm1, 0.2617994F, 3.141593F, 0F);
      Arm2 = new ModelRenderer(this, 32, 0);
      Arm2.addBox(0F, 0F, 0F, 3, 11, 1);
      Arm2.setRotationPoint(-1F, 6F, 3F);
      Arm2.setTextureSize(64, 32);
      Arm2.mirror = true;
      setRotation(Arm2, 0.2617994F, 0F, 0F);
      Head = new ModelRenderer(this, 42, 0);
      Head.addBox(0F, -2F, -3F, 5, 6, 6);
      Head.setTextureOffset(24, 0); //beak
      Head.setRotationPoint(-2F, 2F, 0F);
      Head.setTextureSize(64, 32);
      Head.mirror = true;
      setRotation(Head, 0F, 0F, 0F);
      Foot1 = new ModelRenderer(this, 36, 26);
      Foot1.addBox(0F, 0F, -3F, 2, 0, 3);
      Foot1.setRotationPoint(0F, 24F, 0F);
      Foot1.setTextureSize(64, 32);
      Foot1.mirror = true;
      setRotation(Foot1, 0F, 0F, 0F);
      Foot2 = new ModelRenderer(this, 36, 26);
      Foot2.addBox(0F, 0F, 0F, 2, 0, 3);
      Foot2.setRotationPoint(0F, 24F, 0F);
      Foot2.setTextureSize(64, 32);
      Foot2.mirror = true;
      setRotation(Foot2, 0F, 0F, 0F);
      
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    
    if (this.isChild) {
    	float f6 = 2.0F;
    	GL11.glPushMatrix();
    	GL11.glTranslatef(0.0F, 5.0F * f5, 2.0F * f5);
    	this.Head.renderWithRotation(f5);
    	GL11.glPopMatrix();
    	GL11.glPushMatrix();
    	GL11.glScalef(1.0F / f6,  1.0F / f6, 1.0F / f6);
    	GL11.glTranslatef(0.0F, 24.0F * f5, 0.0F);
    	this.Body.render(f5);
    	this.Leg1.render(f5);
    	this.Leg2.render(f5);
    	this.Arm1.render(f5);
    	this.Arm2.render(f5);
    	this.Foot1.render(f5);
    	this.Foot2.render(f5);
    	GL11.glPopMatrix();
    } else {
    	this.Leg1.render(f5);
        this.Leg2.render(f5);
        this.Body.render(f5);
        this.Arm1.render(f5);
        this.Arm2.render(f5);
        this.Head.renderWithRotation(f5);
        this.Foot1.render(f5);
        this.Foot2.render(f5);
    }
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7)
  {
float f6 = (180F / (float)Math.PI);
this.Head.rotateAngleX = par5 / (180F / (float)Math.PI);
this.Head.rotateAngleY = par4 / (180F / (float)Math.PI);
this.Body.rotateAngleY = par5 / (180F / (float)Math.PI);
this.Leg1.rotateAngleZ = MathHelper.cos(par1 * 0.3331F) * 1.4F * par2;
this.Leg2.rotateAngleZ = MathHelper.cos(par1 * 0.3331F + (float)Math.PI) * 1.4F * par2;
this.Arm1.rotateAngleZ = MathHelper.cos(par1 * 0.3331F) * 1.4F * par2;
this.Arm2.rotateAngleZ = MathHelper.cos(par1 * 0.3331F + (float)Math.PI) * 1.4F * par2;
  }

}

 

Thanks in advance.

Developer of small, unreleased, basic, and incomplete mods since 2014!

Posted

You pointed your model the wrong way when modeling it. You can rotate the whole thing in your render class by using glRotatef in the preRenderCallback method.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Posted

Hm... I added a new preRenderCallback method, with the glRotatef, but it doesn't seem to be working.

 

protected void preRenderCallback() {
  GL11.glRotatef(90, 0, 1, 0);
  }

 

Should this be before the ModelPenguin() method? It's currently between ModelPenguin() and render().

 

EDIT: Tried and does not work

Developer of small, unreleased, basic, and incomplete mods since 2014!

Posted

My preRenderCallback method is now as follows:

 

    protected void preRenderCallback(EntityLivingBase par1, float par2) {
  	  GL11.glRotatef(90, 0, 1, 0);
    }

 

Should I be calling for the method anywhere?

 

Here is my full ModelPenguin:


package ArctiCraftMob;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.MathHelper;

public class ModelPenguin extends ModelBase
{
  //fields
    ModelRenderer Leg1;
    ModelRenderer Leg2;
    ModelRenderer Body;
    ModelRenderer Arm1;
    ModelRenderer Arm2;
    ModelRenderer Head; 
    ModelRenderer Foot1;
    ModelRenderer Foot2;
  
    protected void preRenderCallback(EntityLivingBase par1, float par2) {
  	  GL11.glRotatef(90, 0, 1, 0);
    }
    
  public ModelPenguin()
  {
    textureWidth = 64;
    textureHeight = 32;
    	
    
      Leg1 = new ModelRenderer(this, 42, 12);
      Leg1.addBox(0F, 0F, 0F, 1, 7, 1);
      Leg1.setRotationPoint(0F, 17F, -2F);
      Leg1.setTextureSize(64, 32);
      Leg1.mirror = true;
      setRotation(Leg1, 0F, 0F, 0F);
      Leg2 = new ModelRenderer(this, 42, 12);
      Leg2.addBox(0F, 0F, 0F, 1, 7, 1);
      Leg2.setRotationPoint(0F, 17F, 1F);
      Leg2.setTextureSize(64, 32);
      Leg2.mirror = true;
      setRotation(Leg2, 0F, 0F, 0F);
      Body = new ModelRenderer(this, 46, 12);
      Body.addBox(0F, 0F, 0F, 3, 11, 6);
      Body.setRotationPoint(-1F, 6F, -3F);
      Body.setTextureSize(64, 32);
      Body.mirror = true;
      setRotation(Body, 0F, 0F, 0F);
      Arm1 = new ModelRenderer(this, 32, 0);
      Arm1.addBox(0F, 0F, 0F, 3, 11, 1);
      Arm1.setRotationPoint(2F, 6F, -3F);
      Arm1.setTextureSize(64, 32);
      Arm1.mirror = true;
      setRotation(Arm1, 0.2617994F, 3.141593F, 0F);
      Arm2 = new ModelRenderer(this, 32, 0);
      Arm2.addBox(0F, 0F, 0F, 3, 11, 1);
      Arm2.setRotationPoint(-1F, 6F, 3F);
      Arm2.setTextureSize(64, 32);
      Arm2.mirror = true;
      setRotation(Arm2, 0.2617994F, 0F, 0F);
      Head = new ModelRenderer(this, 42, 0);
      Head.addBox(0F, -2F, -3F, 5, 6, 6);
      Head.setTextureOffset(24, 0); //beak
      Head.setRotationPoint(-2F, 2F, 0F);
      Head.setTextureSize(64, 32);
      Head.mirror = true;
      setRotation(Head, 0F, 0F, 0F);
      Foot1 = new ModelRenderer(this, 36, 26);
      Foot1.addBox(0F, 0F, -3F, 2, 0, 3);
      Foot1.setRotationPoint(0F, 24F, 0F);
      Foot1.setTextureSize(64, 32);
      Foot1.mirror = true;
      setRotation(Foot1, 0F, 0F, 0F);
      Foot2 = new ModelRenderer(this, 36, 26);
      Foot2.addBox(0F, 0F, 0F, 2, 0, 3);
      Foot2.setRotationPoint(0F, 24F, 0F);
      Foot2.setTextureSize(64, 32);
      Foot2.mirror = true;
      setRotation(Foot2, 0F, 0F, 0F);
      
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    
    if (this.isChild) {
    	float f6 = 2.0F;
    	GL11.glPushMatrix();
    	GL11.glTranslatef(0.0F, 5.0F * f5, 2.0F * f5);
    	this.Head.renderWithRotation(f5);
    	GL11.glPopMatrix();
    	GL11.glPushMatrix();
    	GL11.glScalef(1.0F / f6,  1.0F / f6, 1.0F / f6);
    	GL11.glTranslatef(0.0F, 24.0F * f5, 0.0F);
    	this.Body.render(f5);
    	this.Leg1.render(f5);
    	this.Leg2.render(f5);
    	this.Arm1.render(f5);
    	this.Arm2.render(f5);
    	this.Foot1.render(f5);
    	this.Foot2.render(f5);
    	GL11.glPopMatrix();
    } else {
    	this.Leg1.render(f5);
        this.Leg2.render(f5);
        this.Body.render(f5);
        this.Arm1.render(f5);
        this.Arm2.render(f5);
        this.Head.renderWithRotation(f5);
        this.Foot1.render(f5);
        this.Foot2.render(f5);
    }
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7)
  {
float f6 = (180F / (float)Math.PI);
this.Head.rotateAngleX = par5 / (180F / (float)Math.PI);
this.Head.rotateAngleY = par4 / (180F / (float)Math.PI);
this.Body.rotateAngleY = par5 / (180F / (float)Math.PI);
this.Leg1.rotateAngleZ = MathHelper.cos(par1 * 0.3331F) * 1.4F * par2;
this.Leg2.rotateAngleZ = MathHelper.cos(par1 * 0.3331F + (float)Math.PI) * 1.4F * par2;
this.Arm1.rotateAngleZ = MathHelper.cos(par1 * 0.3331F) * 1.4F * par2;
this.Arm2.rotateAngleZ = MathHelper.cos(par1 * 0.3331F + (float)Math.PI) * 1.4F * par2;
  }

}

 

Developer of small, unreleased, basic, and incomplete mods since 2014!

Posted

I see. I mistook "render" for the render within ModelPenguin...

 

And I fixed the angle to 270 as well. Thanks again, sorry to be a hassle!

Developer of small, unreleased, basic, and incomplete mods since 2014!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.