Jump to content

Recommended Posts

Posted

I need those who have mastered or at least have an idea on how to work Model animations.

 

I made this mob which has "chicken" styled robot legs, and I implemented animation methods from ModelBiped. I have very small knowledge as to how to work on methods such as these:

 

this.LLegTop.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
  this.LLegMiddle.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
  this.LLegBottom.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 2F;

 

Here is the entire Model of the mob:

// Date: 7/20/2014 4:45:51 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX






package com.natin.borderlands2mod.entities.models;

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

public class ModelGUN_Loader extends ModelBase
{
  //fields
    ModelRenderer FrontHeadBump;
    ModelRenderer Head;
    ModelRenderer HeadSpike;
    ModelRenderer LArmMesh;
    ModelRenderer RArmMesh;
    ModelRenderer BodyInner;
    ModelRenderer BodyShield;
    ModelRenderer DaButt;
    ModelRenderer RLegTop;
    ModelRenderer LLegTop;
    ModelRenderer RLegMiddle;
    ModelRenderer LLegMiddle;
    ModelRenderer LLegBottom;
    ModelRenderer RLegBottom;
    ModelRenderer RFoot;
    ModelRenderer LFoot;
    ModelRenderer LeftArm1;
    ModelRenderer LeftArm2;
    ModelRenderer LeftArmThing;
    ModelRenderer RightArm1;
    ModelRenderer RightArm2;
  
  public ModelGUN_Loader()
  {
    textureWidth = 128;
    textureHeight = 128;
    
      FrontHeadBump = new ModelRenderer(this, 1, 21);
      FrontHeadBump.addBox(-2F, -6F, -3F, 4, 6, 2);
      FrontHeadBump.setRotationPoint(0F, 0F, 0F);
      FrontHeadBump.setTextureSize(128, 128);
      FrontHeadBump.mirror = true;
      setRotation(FrontHeadBump, 0F, 0.0174533F, 0F);
      Head = new ModelRenderer(this, 0, 31);
      Head.addBox(-8F, -6F, -2F, 16, 6, 4);
      Head.setRotationPoint(0F, 0F, 0F);
      Head.setTextureSize(128, 128);
      Head.mirror = true;
      setRotation(Head, 0F, 0F, 0F);
      HeadSpike = new ModelRenderer(this, 1, 11);
      HeadSpike.addBox(-2F, -7F, -5F, 4, 4, 2);
      HeadSpike.setRotationPoint(0F, 0F, 0F);
      HeadSpike.setTextureSize(128, 128);
      HeadSpike.mirror = true;
      setRotation(HeadSpike, -0.6981317F, 0F, 0F);
      LArmMesh = new ModelRenderer(this, 64, 1);
      LArmMesh.addBox(-10F, -5F, -1F, 2, 4, 2);
      LArmMesh.setRotationPoint(0F, 0F, 0F);
      LArmMesh.setTextureSize(128, 128);
      LArmMesh.mirror = true;
      setRotation(LArmMesh, 0F, 0F, 0F);
      RArmMesh = new ModelRenderer(this, 73, 1);
      RArmMesh.addBox(8F, -5F, -1F, 2, 4, 2);
      RArmMesh.setRotationPoint(0F, 0F, 0F);
      RArmMesh.setTextureSize(128, 128);
      RArmMesh.mirror = true;
      setRotation(RArmMesh, 0F, 0F, 0F);
      BodyInner = new ModelRenderer(this, 10, 43);
      BodyInner.addBox(-1.5F, -8F, -2F, 3, 9, 3);
      BodyInner.setRotationPoint(0F, 7F, 0F);
      BodyInner.setTextureSize(128, 128);
      BodyInner.mirror = true;
      setRotation(BodyInner, -0.1745329F, 0F, 0F);
      BodyShield = new ModelRenderer(this, 1, 43);
      BodyShield.addBox(-1.5F, -6F, -3F, 3, 7, 1);
      BodyShield.setRotationPoint(0F, 7F, 0F);
      BodyShield.setTextureSize(128, 128);
      BodyShield.mirror = true;
      setRotation(BodyShield, -0.0698132F, 0F, 0F);
      DaButt = new ModelRenderer(this, 1, 56);
      DaButt.addBox(-2F, 0F, -4F, 4, 3, ;
      DaButt.setRotationPoint(0F, 7F, 0F);
      DaButt.setTextureSize(128, 128);
      DaButt.mirror = true;
      setRotation(DaButt, 0F, 0F, 0F);
      RLegTop = new ModelRenderer(this, 12, 81);
      RLegTop.addBox(0F, -1F, -1F, 2, 7, 2);
      RLegTop.setRotationPoint(2F, 9F, -2F);
      RLegTop.setTextureSize(128, 128);
      RLegTop.mirror = true;
      setRotation(RLegTop, -0.1745329F, 0F, 0F);
      LLegTop = new ModelRenderer(this, 0, 81);
      LLegTop.addBox(-2F, -1F, -1F, 2, 7, 2);
      LLegTop.setRotationPoint(-2F, 9F, -2F);
      LLegTop.setTextureSize(128, 128);
      LLegTop.mirror = true;
      setRotation(LLegTop, -0.1745329F, 0F, 0F);
      RLegMiddle = new ModelRenderer(this, 12, 92);
      RLegMiddle.addBox(0F, -1F, -7F, 2, 7, 2);
      RLegMiddle.setRotationPoint(2F, 9F, -2F);
      RLegMiddle.setTextureSize(128, 128);
      RLegMiddle.mirror = true;
      setRotation(RLegMiddle, 1.396263F, 0F, 0F);
      LLegMiddle = new ModelRenderer(this, 0, 92);
      LLegMiddle.addBox(-2F, -1F, -7F, 2, 7, 2);
      LLegMiddle.setRotationPoint(-2F, 9F, -2F);
      LLegMiddle.setTextureSize(128, 128);
      LLegMiddle.mirror = true;
      setRotation(LLegMiddle, 2.396263F, 0F, 0F);
      LLegBottom = new ModelRenderer(this, 0, 103);
      LLegBottom.addBox(-2F, 5F, 4F, 2, 9, 4);
      LLegBottom.setRotationPoint(-2F, 9F, -2F);
      LLegBottom.setTextureSize(128, 128);
      LLegBottom.mirror = true;
      setRotation(LLegBottom, 0F, 0F, 0F);
      RLegBottom = new ModelRenderer(this, 12, 103);
      RLegBottom.addBox(0F, 5F, 4F, 2, 9, 4);
      RLegBottom.setRotationPoint(2F, 9F, -2F);
      RLegBottom.setTextureSize(128, 128);
      RLegBottom.mirror = true;
      setRotation(RLegBottom, -0.2443461F, 0F, 0F);
      RFoot = new ModelRenderer(this, 0, 0);
      RFoot.addBox(-0.5F, 12F, -3F, 3, 2, ;
      RFoot.setRotationPoint(2F, 10F, -2F);
      RFoot.setTextureSize(128, 128);
      RFoot.mirror = true;
      setRotation(RFoot, 0F, 0F, 0F);
      LFoot = new ModelRenderer(this, 0, 0);
      LFoot.addBox(-6.5F, 12F, -3F, 3, 2, ;
      LFoot.setRotationPoint(2F, 10F, -2F);
      LFoot.setTextureSize(128, 128);
      LFoot.mirror = true;
      setRotation(LFoot, 0F, 0F, 0F);
      LeftArm1 = new ModelRenderer(this, 62, 19);
      LeftArm1.addBox(-1F, -1F, -1F, 1, 10, 2);
      LeftArm1.setRotationPoint(-10F, -3F, 0F);
      LeftArm1.setTextureSize(128, 128);
      LeftArm1.mirror = true;
      setRotation(LeftArm1, 0F, 0F, 0F);
      LeftArm2 = new ModelRenderer(this, 62, 19);
      LeftArm2.addBox(-0.5333334F, -1F, -1F, 1, 10, 2);
      LeftArm2.setRotationPoint(-10.5F, 5F, 0F);
      LeftArm2.setTextureSize(128, 128);
      LeftArm2.mirror = true;
      setRotation(LeftArm2, 0F, 0F, 0F);
      LeftArmThing = new ModelRenderer(this, 22, 2);
      LeftArmThing.addBox(-2F, -5F, -1F, 2, 6, 2);
      LeftArmThing.setRotationPoint(-10F, -3F, 0F);
      LeftArmThing.setTextureSize(128, 128);
      LeftArmThing.mirror = true;
      setRotation(LeftArmThing, 0F, 0F, 0.1396263F);
      RightArm1 = new ModelRenderer(this, 62, 19);
      RightArm1.addBox(0F, -1F, -1F, 1, 10, 2);
      RightArm1.setRotationPoint(10F, -3F, 0F);
      RightArm1.setTextureSize(128, 128);
      RightArm1.mirror = true;
      setRotation(RightArm1, 0F, 0F, 0F);
      RightArm2 = new ModelRenderer(this, 62, 19);
      RightArm2.addBox(-0.5F, 0F, -1F, 1, 10, 2);
      RightArm2.setRotationPoint(10.5F, 4F, 0F);
      RightArm2.setTextureSize(128, 128);
      RightArm2.mirror = true;
      setRotation(RightArm2, 0F, 0F, 0F);
  }
  
  public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
  {
      this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
     
    setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
    FrontHeadBump.render(par7);
    Head.render(par7);
    HeadSpike.render(par7);
    LArmMesh.render(par7);
    RArmMesh.render(par7);
    BodyInner.render(par7);
    BodyShield.render(par7);
    DaButt.render(par7);
    RLegTop.render(par7);
    LLegTop.render(par7);
    RLegMiddle.render(par7);
    LLegMiddle.render(par7);
    LLegBottom.render(par7);
    RLegBottom.render(par7);
    RFoot.render(par7);
    LFoot.render(par7);
    LeftArm1.render(par7);
    LeftArm2.render(par7);
    LeftArmThing.render(par7);
    RightArm1.render(par7);
    RightArm2.render(par7);
  }
  
  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 par7Entity)
  {
    super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity);
  
  

  
  this.LeftArm1.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 2.0F * par2 * 0.5F;
  this.LeftArm2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 2.0F * par2 * 0.5F;

  this.RightArm1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
  this.RightArm2.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
  
  this.RLegTop.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 2.0F * par2 * 0.5F;
  this.RLegMiddle.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 2.0F * par2 * 0.5F;
  this.RLegBottom.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 2.0F * par2 * 0.5F;

  												
  this.LLegTop.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
  this.LLegMiddle.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
  this.LLegBottom.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 2F;
  												
  }
}

 

 

The legs are the problem right now.

Here's how it's supposed to look in-game:

4o7qV5W.png

 

And here's how it turned out: 

ZawjqVQ.png

 

 

Posted

The problem is that you haven't used a "child" relationship between parts, so they won't stay connected (unless you do a lot of math to re-position them).  The vanilla Minecraft biped model has only one part for each arm and each leg so it doesn't have to worry about this.  As soon as you make it multiple parts you can't just copy the way Minecraft does it -- instead you have to organize your model into child parts.

 

The ModelRenderer had a method for this called addChild().  You can add children to children as well.  The way you should organize it is that the top of the leg should be the child of the body, then the middle of the leg a child to the top of the leg, the bottom of the leg a child to the middle of the let, etc.  Then if you rotate the top of the leg, all the other parts will rotate properly with it.

 

I have a tutorial on this: http://jabelarminecraft.blogspot.com/p/complex-entity-models-including.html

 

The difficult part is that the children have a position that is relative to the parent, rather than to the overall model origin.  So after you add the child you will need to adjust the rotation point by subtracting the parent's rotation point.

 

Once you have the model properly set up with child parts, animation becomes much easier.  You can do things like wave the hand while also raising the arm and it will all work together.

 

Hope that helps.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.