    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import org.lwjgl.opengl.GL11;
    006
    007    @SideOnly(Side.CLIENT)
    008    public class ModelQuadruped extends ModelBase
    009    {
    010        public ModelRenderer head = new ModelRenderer(this, 0, 0);
    011        public ModelRenderer body;
    012        public ModelRenderer leg1;
    013        public ModelRenderer leg2;
    014        public ModelRenderer leg3;
    015        public ModelRenderer leg4;
    016        protected float field_78145_g = 8.0F;
    017        protected float field_78151_h = 4.0F;
    018
    019        public ModelQuadruped(int par1, float par2)
    020        {
    021            this.head.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, par2);
    022            this.head.setRotationPoint(0.0F, (float)(18 - par1), -6.0F);
    023            this.body = new ModelRenderer(this, 28, 8);
    024            this.body.addBox(-5.0F, -10.0F, -7.0F, 10, 16, 8, par2);
    025            this.body.setRotationPoint(0.0F, (float)(17 - par1), 2.0F);
    026            this.leg1 = new ModelRenderer(this, 0, 16);
    027            this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2);
    028            this.leg1.setRotationPoint(-3.0F, (float)(24 - par1), 7.0F);
    029            this.leg2 = new ModelRenderer(this, 0, 16);
    030            this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2);
    031            this.leg2.setRotationPoint(3.0F, (float)(24 - par1), 7.0F);
    032            this.leg3 = new ModelRenderer(this, 0, 16);
    033            this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2);
    034            this.leg3.setRotationPoint(-3.0F, (float)(24 - par1), -5.0F);
    035            this.leg4 = new ModelRenderer(this, 0, 16);
    036            this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2);
    037            this.leg4.setRotationPoint(3.0F, (float)(24 - par1), -5.0F);
    038        }
    039
    040        /**
    041         * Sets the models various rotation angles then renders the model.
    042         */
    043        public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
    044        {
    045            this.setRotationAngles(par2, par3, par4, par5, par6, par7);
    046
    047            if (this.isChild)
    048            {
    049                float var8 = 2.0F;
    050                GL11.glPushMatrix();
    051                GL11.glTranslatef(0.0F, this.field_78145_g * par7, this.field_78151_h * par7);
    052                this.head.render(par7);
    053                GL11.glPopMatrix();
    054                GL11.glPushMatrix();
    055                GL11.glScalef(1.0F / var8, 1.0F / var8, 1.0F / var8);
    056                GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F);
    057                this.body.render(par7);
    058                this.leg1.render(par7);
    059                this.leg2.render(par7);
    060                this.leg3.render(par7);
    061                this.leg4.render(par7);
    062                GL11.glPopMatrix();
    063            }
    064            else
    065            {
    066                this.head.render(par7);
    067                this.body.render(par7);
    068                this.leg1.render(par7);
    069                this.leg2.render(par7);
    070                this.leg3.render(par7);
    071                this.leg4.render(par7);
    072            }
    073        }
    074
    075        /**
    076         * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
    077         * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
    078         * "far" arms and legs can swing at most.
    079         */
    080        public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6)
    081        {
    082            this.head.rotateAngleX = par5 / (180F / (float)Math.PI);
    083            this.head.rotateAngleY = par4 / (180F / (float)Math.PI);
    084            this.body.rotateAngleX = ((float)Math.PI / 2F);
    085            this.leg1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
    086            this.leg2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2;
    087            this.leg3.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2;
    088            this.leg4.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
    089        }
    090    }