Jump to content

Recommended Posts

Posted

Hello everyone !

 

I'm currently trying to get some part of my model to be smaller than it should be.

Here are the classes:

 

Model:

 

 

public class ModelMasqueGhast extends ModelBiped
{
    public ModelRenderer Mask;
    ModelRenderer Ficelle;
    ModelRenderer TentacleA;
    ModelRenderer TentacleB;

    public ModelMasqueGhast()
    {
        this( 0.0f );
    }

    public ModelMasqueGhast( float par1 )
    {
    	
    	super(0f,0.0f,0,0);
    	
        Mask = new ModelRenderer( this, 12, 44 );
        Mask.setTextureSize( 128, 64 );
        Mask.addBox( -8F, -8F, -2F, 16, 16, 4);
        Mask.setRotationPoint( 0F, -18F, -3F );
        setRotation(Mask, 0F, 0F, 0F);
        
        Ficelle = new ModelRenderer( this, 69, 7 );
        Ficelle.setTextureSize( 128, 64 );
        Ficelle.addBox( -4.5F, -0.5F, -4.5F, 9, 1, 9);
        Ficelle.setRotationPoint( 0F, -18F, 0F );
        setRotation(Ficelle, 0F, 0F, 0F);

        
        TentacleA = new ModelRenderer( this, 0, 32 );
        TentacleA.setTextureSize( 128, 64 );
        TentacleA.addBox( -1F, -7F, -1F, 2, 14, 2);
        TentacleA.setRotationPoint( -2F, -14F, -2F );
        setRotation(TentacleA, 0F, 0F, 0F);

       
        TentacleB = new ModelRenderer( this, 0, 32 );
        TentacleB.setTextureSize( 128, 64 );
        TentacleB.addBox( -1F, -7F, -1F, 2, 14, 2);
        TentacleB.setRotationPoint( 2F, -14F, -2F );
        setRotation(TentacleB, 0F, 0F, 0F);

    
        this.bipedHeadwear.addChild(Mask);
        this.bipedHeadwear.addChild(Ficelle);
        this.bipedHeadwear.addChild(TentacleA);
        this.bipedHeadwear.addChild(TentacleB);

    }

    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);

    }
    
    private void setRotation(ModelRenderer model, float x, float y, float z)
    {
      model.rotateAngleX = x;
      model.rotateAngleY = y;
      model.rotateAngleZ = z;
    }
    
    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);
    }
}

 

 

 

Item:

 

 

public class ItemMaskGhast extends ItemMask {

public ItemMaskGhast() {
	super("ghast");
	this.setType(genre.NETHER);
}

 @Override
  @SideOnly(Side.CLIENT)
  public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
  {
    ModelMasqueGhast armorModel = null;
    if (itemStack != null) {
      if (itemStack.getItem() == Masks.mask_ghast) {
        armorModel = (ModelMasqueGhast) Masks.proxy.getArmorModel(2);
      }
    }
    if(armorModel != null){
    	
    	

    	armorModel.bipedHead.showModel = armorSlot == 0;
    	armorModel.bipedHeadwear.showModel = armorSlot == 0;
    	armorModel.bipedBody.showModel = armorSlot == 1 || armorSlot == 2;
    	armorModel.bipedRightArm.showModel = armorSlot == 1;
    	armorModel.bipedLeftArm.showModel = armorSlot == 1;
    	armorModel.bipedRightLeg.showModel = armorSlot == 2 || armorSlot == 3;
    	armorModel.bipedLeftLeg.showModel = armorSlot == 2 || armorSlot == 3;
    	armorModel.isSneak = entityLiving.isSneaking();
    	armorModel.isRiding = entityLiving.isRiding();
    	armorModel.isChild = entityLiving.isChild();
    	armorModel.heldItemRight = entityLiving.getCurrentArmor(0) != null ? 1 :0;
    	
    	if(entityLiving instanceof EntityPlayer){
    		armorModel.aimedBow =((EntityPlayer)entityLiving).getItemInUseDuration() > 2;
    		} 
    	
    	return armorModel;
    		}
    return null;
  }

}

 

 

 

I messed up a little bit with it, trying to do this:

armorModel.bipedHead.showModel = armorSlot == 0;
    	GL11.glScalef(0.5f, 0.5f, 0.5f);
    	armorModel.bipedHeadwear.showModel = armorSlot == 0;
    	GL11.glScalef(2.0f, 2.0f, 2.0f);
    	armorModel.bipedBody.showModel = armorSlot == 1 || armorSlot == 2;
    	armorModel.bipedRightArm.showModel = armorSlot == 1;
    	...

 

But it's not working. Plus, I want only one part of the model (the one called "Mask") to look smaller.

 

What I would like to know is where I have to make the scale edit, and how (if I'm not doing it the right way) ?

 

Thank you for helping me.

 

Posted

The growable animal mobs scale the body and head differently. If you look at ModelWolf, it has this code:

 

        if (this.isChild)

        {

            float f = 2.0F;

            GlStateManager.pushMatrix();

            GlStateManager.translate(0.0F, 5.0F * scale, 2.0F * scale);

            this.wolfHeadMain.renderWithRotation(scale);

            GlStateManager.popMatrix();

            GlStateManager.pushMatrix();

            GlStateManager.scale(1.0F / f, 1.0F / f, 1.0F / f);

            GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);

            this.wolfBody.render(scale);

            this.wolfLeg1.render(scale);

            this.wolfLeg2.render(scale);

            this.wolfLeg3.render(scale);

            this.wolfLeg4.render(scale);

            this.wolfTail.renderWithRotation(scale);

            this.wolfMane.render(scale);

            GlStateManager.popMatrix();

        }

        else

        {

            this.wolfHeadMain.renderWithRotation(scale);

            this.wolfBody.render(scale);

            this.wolfLeg1.render(scale);

            this.wolfLeg2.render(scale);

            this.wolfLeg3.render(scale);

            this.wolfLeg4.render(scale);

            this.wolfTail.renderWithRotation(scale);

            this.wolfMane.render(scale);

        }

    }

 

Notice one of the key points is that there is a push and pop of a matrix. In GL11 there is a "stack" of transformations and if you just want to operate on one part you will want to create a new matrix to perform that transformation. In other words, you push the matrix and scale and render the part then pop the matrix and render the parts you don't want to scale.

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

Posted

Or more specifically, you need to wrap the GL11 calls around the render function for the part.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You cannot scale a child part. Children inherent the scale of the parent as they are all placed into an array and rendered at the same time.

 

Right. That is actually the good thing about child parts.

 

But in this case the point is to do the model the same way that growable entities do. And yes, like you pointed out, the head must be a separate part and not made as child.

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

Posted

Sorry for not replying for a long time, and thank you for your answers!

 

So, I decided to ad the part I want to rescale to BipedHead and the other parts to BipedHeadWear, so I can avoid this problem.

But I have to problems:

-first it renders weirdly (it doesn't rotates smoothly with the face, and sometimes stays locked in a position even tough the head is moving)

-it's not a real solution (won't work for a model with 3 different scaled parts)

 

I took a look at the default model class, but it didn't really help me.

So if you have any clue to help me solve this (kinda new) problem, I'm all hear !

Posted

If something doesn't render smoothly, use the copyModelAngles (or whatever it's called) that is in I think RenderLivingEntity or deeper, at least if you want to keep it in sync with another part.

 

If you want something to scale, sadly you have to make it a separate part and animate it as such, or invent a custom ModelRenderer class that stores it's own scale for future reference, and use that in your model

I do pony stuff :3

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.