Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So I am trying to make a deer mob. The AI works, the deer is being initialized correctly and the model looks almost right. I only have a problem with rendering cubes with custom rotation. The problem is some what weird because rotateAngel y and z does work, but I can't get rotate Angel x to work. Boxes like head (which is slightly rotated with x value) appear in-game with no rotation.

Can someone please tell me what I am doing wrong here ;D

 

the code:

public class ModelHirvi extends ModelBase{

public ModelRenderer body = new ModelRenderer(this, 0, 0);
public ModelRenderer kaula;
public ModelRenderer hanta;
public ModelRenderer head;

public ModelRenderer horno;
public ModelRenderer hornv;

    public ModelRenderer lankieo;
    public ModelRenderer lankiev;
    public ModelRenderer lankito;
    public ModelRenderer lankitv;

public ModelRenderer leg3eo;
public ModelRenderer leg4ev;
public ModelRenderer leg1to;
public ModelRenderer leg2tv;

public ModelHirvi()
{
	textureWidth = 64;
	textureHeight = 64;


	this.horno = new ModelRenderer(this, 14, 0);
	this.horno.addBox(-2F, 1F, 1.5F, 1, 3, 4);
	this.horno.setRotationPoint(0F, -7F, -9F);
	this.setRotation(horno, 0.1308997F, -1.151917F, -0.4014257F);


	this.hornv = new ModelRenderer(this, 14, 0);
	this.hornv.addBox(1F, 1F, 2F, 1, 3, 4);
	this.hornv.setRotationPoint(0F, -7F, -9F);
	this.setRotation(hornv, 0.1308997F, 1.151917F, 0.4014257F);

                //rotation not rendering correctly:
	this.head = new ModelRenderer(this, 40, 0);
	this.head.addBox(-3F, 0F, -6F, 6, 9, 6);
	this.head.setRotationPoint(0F, -1F, -6F);
	this.head.setTextureOffset(0, 41).addBox(-2.5F, 9F, -5.5F, 5, 4, 5);
                this.setRotation(head, 0.2235988F, 0F, 0F);



	this.leg1to = new ModelRenderer(this, 0, 0);
	this.leg1to.addBox(-3F, 0F, -2F, 3, 12, 3);
        this.leg1to.setRotationPoint(-3F, 12F, 11F);
    
		this.leg2tv = new ModelRenderer(this, 0, 0);
	this.leg2tv.addBox(0F, 0F, 0F, 3, 12, 3);
        this.leg2tv.setRotationPoint(3F, 12F, 9F);
    
        this.leg3eo = new ModelRenderer(this, 0, 0);
	this.leg3eo.addBox(-3F, 0F, -3F, 3, 12, 3);
        this.leg3eo.setRotationPoint(-3F, 12F, -5F);
    
	this.leg4ev = new ModelRenderer(this, 0, 0);
	this.leg4ev.addBox(-1F, 0F, -3F, 3, 12, 3);
        this.leg4ev.setRotationPoint(4F, 12F, -5F);
    
	this.body = new ModelRenderer(this, 22, 32);
	this.body.addBox(-5F, -10F, -11F, 10, 21, 11);
	this.body.setRotationPoint(0F, 3F, 2F);

	this.lankieo = new ModelRenderer(this, 11, 16);
        this.lankieo.addBox(-6F, 5F, -10.5F, 1, 6, 4);
        this.lankieo.setRotationPoint(0F, 3F, 2F);
        this.setRotation(lankieo, 0F, 0F, 0F);
    
        this.lankiev = new ModelRenderer(this, 11, 16);
        this.lankiev.addBox(5F, 5F, -10.5F, 1, 6, 4);
        this.lankiev.setRotationPoint(0F, 3F, 2F);
        this.setRotation(lankiev, 0F, 0F, 0F);

        this.lankito = new ModelRenderer(this, 0, 16);
        this.lankito.addBox(-6F, 1F, 6.5F, 1, 10, 4);
        this.lankito.setRotationPoint(0F, 3F, 2F);
        this.setRotation(lankito, 0F, 0F, 0F);
     
        this.lankitv = new ModelRenderer(this, 0, 16);
        this.lankitv.addBox(5F, 1F, 6.5F, 1, 10, 4);
        this.lankitv.setRotationPoint(0F, 3F, 2F);
        this.setRotation(lankitv, 0F, 0F, 0F);

                //rotation not rendering correctly:
        this.kaula = new ModelRenderer(this, 0, 51);
	this.kaula.addBox(-3F, -8F, 0F, 6, 8, 5);
        this.kaula.setRotationPoint(0F, 7F, -8F);
         this.setRotation(kaula, 0.4461433F, 0F, 0F);

                //rotation not rendering correctly:
	this.hanta = new ModelRenderer(this, 26, 0);
	this.hanta.addBox(-1.5F, -3F, 0F, 3, 5, 3);
        this.hanta.setRotationPoint(0F, 4F, 13F);
        this.setRotation(hanta, 2.240011F, 0F, 0F);

    
}


	public void render(Entity entity, float time, float limbSwingDistance, float p_78087_3_, float headYRot, float headXRot, float Ytrans)
	{
		this.setRotationAngles(time, limbSwingDistance, p_78087_3_, headYRot, headXRot, Ytrans, entity);

		if(this.isChild)
		{
			float div = 2.0F;
			GlStateManager.pushMatrix();
			GlStateManager.scale(1.0F/div, 1.0F/div, 1.0F/div);
			GlStateManager.translate(0.0F, 24.0F * Ytrans, 0.0F);

			this.head.render(Ytrans);
			this.kaula.render(Ytrans);
			this.hanta.render(Ytrans);
			this.horno.render(Ytrans);
			this.hornv.render(Ytrans);
			this.body.render(Ytrans);
			this.leg1to.render(Ytrans);
			this.leg2tv.render(Ytrans);
			this.leg3eo.render(Ytrans);
			this.leg4ev.render(Ytrans);
			this.lankieo.render(Ytrans);
			this.lankiev.render(Ytrans);
			this.lankito.render(Ytrans);
			this.lankitv.render(Ytrans);
			GlStateManager.popMatrix();
		}
		else
		{
			this.head.render(Ytrans);
			this.kaula.render(Ytrans);
			this.hanta.render(Ytrans);
			this.horno.render(Ytrans);
			this.hornv.render(Ytrans);
			this.body.render(Ytrans);
			this.leg1to.render(Ytrans);
			this.leg2tv.render(Ytrans);
			this.leg3eo.render(Ytrans);
			this.leg4ev.render(Ytrans);
			this.lankieo.render(Ytrans);
			this.lankiev.render(Ytrans);
			this.lankito.render(Ytrans);
			this.lankitv.render(Ytrans);
		}
	}


	 private void setRotation(ModelRenderer model, float x, float y, float z)
	    {
	        model.rotateAngleX = x;
	        model.rotateAngleY = y;
	        model.rotateAngleZ = z;
	    }

	public void setRotationAngles(float time, float limbSwingDistance, float p_78087_3_, float headYRot, float headXRot, float p_78087_6_, Entity entity) 
	{
		this.head.rotateAngleX = headXRot / (300F / (float)Math.PI);
		this.head.rotateAngleX = headYRot / (300F / (float)Math.PI);

		this.horno.rotateAngleX = headXRot / (180F / (float)Math.PI);
		this.horno.rotateAngleX = headYRot / (180F / (float)Math.PI);

		this.hornv.rotateAngleX = headXRot / (180F / (float)Math.PI);
		this.hornv.rotateAngleX = headYRot / (180F / (float)Math.PI);

		this.body.rotateAngleX = ((float)Math.PI / 2F);
		this.kaula.rotateAngleX = ((float)Math.PI / 2F);
		this.hanta.rotateAngleX = ((float)Math.PI / 2F);
		this.lankieo.rotateAngleX = ((float)Math.PI / 2F);
		this.lankiev.rotateAngleX = ((float)Math.PI / 2F);
		this.lankito.rotateAngleX = ((float)Math.PI / 2F);
		this.lankitv.rotateAngleX = ((float)Math.PI / 2F);

		this.leg1to.rotateAngleX = MathHelper.cos(time * 0.6662F) * 1.4F * limbSwingDistance;
		this.leg2tv.rotateAngleX = MathHelper.cos(time * 0.6662F + (float)Math.PI) * 1.4F * limbSwingDistance;
		this.leg3eo.rotateAngleX = MathHelper.cos(time * 0.6662F + (float)Math.PI) * 1.4F * limbSwingDistance;
		this.leg4ev.rotateAngleX = MathHelper.cos(time * 0.6662F) * 1.4F * limbSwingDistance;

	}



}


 

You want to see my code so far? Here it is: System.out.println("Hello, World");

  • Author

Why can't you just render everything without rotation then rotate the parts in set RotationAngles?

 

Thanks mate. How dumb from me to first tell the x value and then override it in set RotationAngels. I just deleted the this.setrotation and add all the rotation values to set RotationAngels

You want to see my code so far? Here it is: System.out.println("Hello, World");

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.