Jump to content

Recommended Posts

Posted

I don't really feel like this needs much of an explanation...

 

Model as it appears in Techne (sorry, dropbox images broke, have to post links):

 

https://www.dropbox.com/s/xcpuvz0stihu4s2/meh.PNG

 

Model as it appears in-game:

 

https://www.dropbox.com/s/rxk5klq65lvtvtd/javaw%202014-06-13%2000-35-48-151.png

 

And my code:

 

Model

public class ModelGoblinModel extends ModelBase
{
  //fields
    ModelRenderer Head;
    ModelRenderer RightEar;
    ModelRenderer LeftEar;
    ModelRenderer Nose;
    ModelRenderer NosePart2;
    
    ModelRenderer UpperArm2;
    ModelRenderer UpperArm1;
    ModelRenderer LowerArm2;
    ModelRenderer LowerArm1;
    
    ModelRenderer UpperBody;
    ModelRenderer LowerBody;
    
    ModelRenderer Leg2;
    ModelRenderer Leg1;
    ModelRenderer Foot2;
    ModelRenderer Foot1;
    ModelRenderer UpperLeg1;
    ModelRenderer UpperLeg2;
    
    ModelRenderer hilt;
    ModelRenderer CrossGuard;
    ModelRenderer CrossGuardLeft;
    ModelRenderer CrossGuardRight;
    ModelRenderer Blade;
    ModelRenderer BladePart3;
    ModelRenderer BladePart2;
  
  public ModelGoblinModel()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Head = new ModelRenderer(this, 42, 0);
      Head.addBox(-3F, -5F, -2.5F, 6, 5, 5);
      Head.setRotationPoint(0F, 5F, 0F);
      Head.setTextureSize(64, 32);
      setRotation(Head, 0F, 0F, 0F);
      
      Nose = new ModelRenderer(this, 50, 26);
      Nose.addBox(-0.5F, -0.5F, -1F, 1, 1, 1);
      Nose.setRotationPoint(0F, 3F, -2F);
      Nose.setTextureSize(64, 32);
      setRotation(Nose, 0.1745329F, 0F, 0F);
      Head.addChild(Nose);
      
      NosePart2 = new ModelRenderer(this, 50, 29);
      NosePart2.addBox(-0.5F, -0.5F, -1F, 1, 2, 1);
      NosePart2.setRotationPoint(0F, 3.7F, -2.5F);
      NosePart2.setTextureSize(64, 32);
      setRotation(NosePart2, -0.5948578F, 0F, 0F);
      Nose.addChild(NosePart2);
      
      RightEar = new ModelRenderer(this, 54, 29);
      RightEar.addBox(-4F, -1F, -0.5F, 4, 2, 1);
      RightEar.setRotationPoint(-2.5F, 2F, 0F);
      RightEar.setTextureSize(64, 32);
      setRotation(RightEar, 0.3490659F, 0.7853982F, 0.3490659F);
      Head.addChild(RightEar);
      
      LeftEar = new ModelRenderer(this, 54, 26);
      LeftEar.addBox(0F, -1F, -0.5F, 4, 2, 1);
      LeftEar.setRotationPoint(2.5F, 2F, 0F);
      LeftEar.setTextureSize(64, 32);
      setRotation(LeftEar, 0.3490659F, -0.7853982F, -0.3490659F);
      Head.addChild(LeftEar);
      
      UpperArm2 = new ModelRenderer(this, 28, 24);
      UpperArm2.addBox(-1F, 0F, -1.5F, 2, 5, 3);
      UpperArm2.setRotationPoint(3F, 5F, 0.5F);
      UpperArm2.setTextureSize(64, 32);
      setRotation(UpperArm2, 0.4014257F, 0.1483529F, -0.3665191F);
      
      UpperArm1 = new ModelRenderer(this, 38, 24);
      UpperArm1.addBox(-1F, 0F, -1.5F, 2, 5, 3);
      UpperArm1.setRotationPoint(-3F, 5F, 0.5F);
      UpperArm1.setTextureSize(64, 32);
      setRotation(UpperArm1, 0.4014257F, -0.1483529F, 03665191F);
      
      LowerArm2 = new ModelRenderer(this, 26, 6);
      LowerArm2.addBox(-1F, 0F, -1F, 2, 6, 2);
      LowerArm2.setRotationPoint(3F, 10F, 0.5F);
      LowerArm2.setTextureSize(64, 32);
      setRotation(LowerArm2, -0.7853981F, 0F, 0F);
      UpperArm2.addChild(LowerArm2);
      
      LowerArm1 = new ModelRenderer(this, 34, 6);
      LowerArm1.addBox(-1F, 0F, -1F, 2, 6, 2);
      LowerArm1.setRotationPoint(-3F, 10F, 0.5F);
      LowerArm1.setTextureSize(64, 32);
      setRotation(LowerArm1, -0.7853981F, 0F, 0F);
      UpperArm1.addChild(LowerArm1);
      
      UpperLeg1 = new ModelRenderer(this, 26, 0);
      UpperLeg1.addBox(-1F, 0F, -1F, 2, 4, 2);
      UpperLeg1.setRotationPoint(-2F, 15F, 0.5F);
      UpperLeg1.setTextureSize(64, 32);
      setRotation(UpperLeg1, -0.5235988F, 0F, 0F);
      
      Leg1 = new ModelRenderer(this, 30, 14);
      Leg1.addBox(-1F, 0F, -1F, 2, 6, 2);
      Leg1.setRotationPoint(-2F, 18F, -1.5F);
      Leg1.setTextureSize(64, 32);
      setRotation(Leg1, 0.4014257F, 0F, 0F);
      UpperLeg1.addChild(Leg1);
      
      Foot1 = new ModelRenderer(this, 20, 29);
      Foot1.addBox(-1F, 0F, -1F, 2, 1, 2);
      Foot1.setRotationPoint(-2F, 23F, -0.5F);
      Foot1.setTextureSize(64, 32);
      setRotation(Foot1, 0F, 0F, 0F);
      
      UpperLeg2 = new ModelRenderer(this, 34, 0);
      UpperLeg2.addBox(-1F, 0F, -1F, 2, 4, 2);
      UpperLeg2.setRotationPoint(2F, 15F, 0.5F);
      UpperLeg2.setTextureSize(64, 32);
      setRotation(UpperLeg2, -0.5235988F, 0F, 0F);
      
      Leg2 = new ModelRenderer(this, 38, 14);
      Leg2.addBox(-1F, 0F, -1F, 2, 6, 2);
      Leg2.setRotationPoint(2F, 18F, -1.5F);
      Leg2.setTextureSize(64, 32);
      setRotation(Leg2, 0.4014257F, 0F, 0F);
      UpperLeg2.addChild(Leg2);
      
      Foot2 = new ModelRenderer(this, 20, 26);
      Foot2.addBox(-1F, 0F, -1F, 2, 1, 2);
      Foot2.setRotationPoint(2F, 23F, -0.5F);
      Foot2.setTextureSize(64, 32);
      setRotation(Foot2, 0F, 0F, 0F);
      Leg2.addChild(Foot2);
      
      UpperBody = new ModelRenderer(this, 46, 10);
      UpperBody.addBox(-3F, -5F, -1F, 6, 5, 3);
      UpperBody.setRotationPoint(0F, 10F, 0F);
      UpperBody.setTextureSize(64, 32);
      setRotation(UpperBody, 0F, 0F, 0F);
      
      LowerBody = new ModelRenderer(this, 48, 18);
      LowerBody.addBox(-2.5F, -2F, -1F, 5, 5, 3);
      LowerBody.setRotationPoint(0F, 12F, 0F);
      LowerBody.setTextureSize(64, 32);
      setRotation(LowerBody, 0F, 0F, 0F);
      
      hilt = new ModelRenderer(this, 0, 28);
      hilt.addBox(0F, 0F, 0F, 1, 1, 3);
      hilt.setRotationPoint(-4F, 14F, -1F);
      hilt.setTextureSize(64, 32);
      setRotation(hilt, 0F, 0F, 0F);
      LowerArm1.addChild(hilt);
      
      CrossGuard = new ModelRenderer(this, 0, 0);
      CrossGuard.addBox(0F, 0F, 0F, 1, 3, 1);
      CrossGuard.setRotationPoint(-4F, 13F, -2F);
      CrossGuard.setTextureSize(64, 32);
      setRotation(CrossGuard, 0F, 0F, 0F);
      hilt.addChild(CrossGuard);
      
      CrossGuardLeft = new ModelRenderer(this, 8, 26);
      CrossGuardLeft.addBox(0F, 0F, 0F, 1, 2, 1);
      CrossGuardLeft.setRotationPoint(-4F, 15.4F, -1.7F);
      CrossGuardLeft.setTextureSize(64, 32);
      setRotation(CrossGuardLeft, -0.5948578F, 0F, 0F);
      CrossGuard.addChild(CrossGuardLeft);
      
      Blade = new ModelRenderer(this, 0, 11);
      Blade.addBox(0F, 0F, 0F, 1, 3, 12);
      Blade.setRotationPoint(-4F, 13F, -14F);
      Blade.setTextureSize(64, 32);
      setRotation(Blade, 0F, 0F, 0F);
      CrossGuard.addChild(Blade);
      
      CrossGuardRight = new ModelRenderer(this, 8, 29);
      CrossGuardRight.addBox(0F, 0F, 0F, 1, 2, 1);
      CrossGuardRight.setRotationPoint(-4F, 13.1F, -0.9F);
      CrossGuardRight.setTextureSize(64, 32);
      setRotation(CrossGuardRight, 3.735005F, 0F, 0F);
      CrossGuard.addChild(CrossGuardRight);
      
      BladePart3 = new ModelRenderer(this, 15, 4);
      BladePart3.addBox(0F, 0F, 0F, 1, 1, 1);
      BladePart3.setRotationPoint(-4F, 12F, -13F);
      BladePart3.setTextureSize(64, 32);
      setRotation(BladePart3, 0F, 0F, 0F);
      Blade.addChild(BladePart3);
      
      BladePart2 = new ModelRenderer(this, 4, 0);
      BladePart2.addBox(0F, 0F, 0F, 1, 2, 1);
      BladePart2.setRotationPoint(-4F, 11F, -14F);
      BladePart2.setTextureSize(64, 32);
      setRotation(BladePart2, 0F, 0F, 0F);
      Blade.addChild(BladePart2);
  }
  
  @Override
  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);
    Head.render(f5);
    Nose.render(f5);
    UpperArm2.render(f5);
    UpperArm1.render(f5);
    LowerArm2.render(f5);
    LowerArm1.render(f5);
    Leg2.render(f5);
    Leg1.render(f5);
    LowerBody.render(f5);
    Foot2.render(f5);
    UpperLeg1.render(f5);
    UpperLeg2.render(f5);
    UpperBody.render(f5);
    hilt.render(f5);
    CrossGuard.render(f5);
    CrossGuardLeft.render(f5);
    RightEar.render(f5);
    LeftEar.render(f5);
    Blade.render(f5);
    CrossGuardRight.render(f5);
    NosePart2.render(f5);
    Foot1.render(f5);
    BladePart3.render(f5);
    BladePart2.render(f5);
  }
  
  protected void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  @Override
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    
    this.Head.rotateAngleY = f3 / (180F / (float)Math.PI);
    this.Head.rotateAngleX = f3 / (180F / (float)Math.PI);

    this.UpperArm1.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 2.0F * f1 * 0.5F;
    this.UpperArm2.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F;
    this.UpperArm1.rotateAngleZ = 0.0F;
    this.UpperArm2.rotateAngleZ = 0.0F;
    
    this.UpperLeg1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    this.UpperLeg2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
    this.UpperLeg1.rotateAngleY = 0.0F;
    this.UpperLeg2.rotateAngleY = 0.0F;

    float f6;
    float f7;
  }

}

 

Renderer:

public class GoblinRenderer extends RenderLiving {

private static final ResourceLocation texLoc = new ResourceLocation(Reference.MODID + ":" + "textures/models/goblin.png");

public GoblinRenderer(ModelGoblinModel model, float shadowSize)
{
	super(model, shadowSize);
}

@Override
protected ResourceLocation getEntityTexture(Entity entity)
{
	return texLoc;
}

}

 

 

Posted

eugh what a mess :)

 

It looks to me like the body parts aren't grouping together correctly, so whenever you rotate bits of the model, they don't stay stuck together.  Or something to do with the choice of rotation points perhaps.

 

I've never used Techne so I can't be of much help.  Trial and error on a simpler model might help, i.e. start from a very simple base that works, then add one bit at a time - for example just the nose - and tweak either your Techne model or the generated code until the nose moves properly with the head rotation. 

 

-TGG

Posted

@TheGreyGhost I already have another custom model working fine, but it does seem to be the addChild part which is breaking things. What you can't see in the image is that it's actually cloned some parts of the model 2-3 times under the ground.

 

@jabelar I already took a look at that, not entirely sure which part you're referring to.

Posted

I had a similar problem, but I solved it by removing some animations. Under setRotationAngles try removing different lines of code and see if it fixes the problem.

Developer of the WIP Rubies mod.

Posted

@TheGreyGhost I already have another custom model working fine, but it does seem to be the addChild part which is breaking things. What you can't see in the image is that it's actually cloned some parts of the model 2-3 times under the ground.

 

@jabelar I already took a look at that, not entirely sure which part you're referring to.

 

Well, for example the part where I mention that if you use addChild() you should only render the parent.  In your case, you are rendering the children like the ears and such.  That will cause a double rendering effect (or triple if they are children of children) and each render will be offset by the relative rotation point).

 

So my first suggestion is that you should only be rendering the parent parts -- the children get rendered automatically.

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

Posted

Depending on how you are moving things around, it also matter what order you make things children.

 

I found the angles and the way it works shift around if you do tail1, tail2, tail3 vs tail3, tail2, tail1.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

Alright, I'm putting this on a back burner for now and focusing on other things - I just tried a very simple model, just adding one cube to the head of a biped and adding it as a child, but every time I add a child it messes it up in-game

 

Posted

it may be tedious but this might help

rightleg.setRotationPoint(-2F, 12F, 0F);

the first float determins the left and right positions of the model, the second determins the height, and the third determines depth, you could try use these to position the parts where you want, you may be better not rendering the parts all at once but one at a time and positioning them until everyone is loaded and in place.

Posted

Alright, I'm putting this on a back burner for now and focusing on other things - I just tried a very simple model, just adding one cube to the head of a biped and adding it as a child, but every time I add a child it messes it up in-game

 

There are only two things that can really mess up.  Once you get the idea it will be easy.

 

First, you should not render the child if you render the parent.  Rendering both will cause duplicate in different positions.

 

The second thing is that the rotation point of the child has to be *relative* to the parent's rotation point.  So if you made a Techne model that had the parent rotation point at (0, 12, 0) then in Java you have to subtract that amount from the rotation point of the child's rotation point (if you got the values from Techne).

 

The other tip I will give you is to ensure that the rotation points in Techne are correct (i.e. at the joint or connection point that you want) because a lot of people erroneously use offsets to make it look right but then it will go really wrong when you rotate.

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

Posted

the rotation point of the child has to be *relative* to the parent's rotation point.

 

Now this I did not know. Thanks so much for that, just adjusted the rotation points of the arms and it's fixed it.

 

LAST UPDATE: Yup. Fixed now, thanks to Jabelar. Just a thought, you might want to put that thing about offsetting the rotation point relative to that of the parents in your tutorial if it's not already on there (not sure, was 3am when I read it). Anyway, the final, less possessed/deformed product:

 

J3iJHKt.jpg

Posted

Good.

 

Yeah, I think the concept of what a child is needs more explaining.  I'm actually going to do more to add the convertToChild() method that I came up with while helping delpi on a similar issue.

 

I really wish Techne just handled child parts better...  Techne is so close to being fully useful, but their Java export has a few nagging issues.

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.