Jump to content

[1.7.10] entity.RotationPitch question


Frag

Recommended Posts

Hi guys,

 

I have created a fish that swim quite well under water, however, even if I was able to set the rotationyaw mostly correctly ... I am still looking for a rotation pitch formula. The pitch should be quite straightforward, since the fish is mobbing in a 3D environment under water, I woulk like its nose to point in the direction it is swimming.

 

Here is my rotationyaw code ...

 

float f = (float) (Math.atan2(aWaterMob.motionZ, aWaterMob.motionX) * 180.0D / Math.PI) - 90.0F;

float f1 = MathHelper.wrapAngleTo180_float(f - aWaterMob.rotationYaw);

aWaterMob.rotationYaw += f1;

 

What would be the rotation pitch code? I was not able to figure it out.

 

aWaterMob.rotationPitch +=????

 

 

Also ...if you have any hint so my mobs would not change the rotationyaw in one frame ... I would be very happy.

 

Thanks guy, this forum was really helpful to me in the last few days.

Link to comment
Share on other sites

Use -math.cos(Math.toRadians(mob.rotationpitch)) should work.

 

I noticed that even if I hardcode manually:

 

aWaterMob.rotationPitch=90F;

 

or

 

 

aWaterMob.rotationPitch=0F;

 

... the pitch of my mobs does not change. Would it be an issue with my model class? Is the rotationpitch is the correct value to set?! Does the pitch value is in synch between the server and the station like the rotationyaw?

 

Here is the model class.

 

[/


package fantastic.renders.models;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import fantastic.FantasticDebug;
import fantastic.entities.EntityBasicFish;
import fantastic.entities.EntityFantasticFish;
import fantastic.entities.EntityFeeder;
import fantastic.entities.EntityMossy;
import fantastic.entities.EntitySalmon;
import fantastic.entities.EntityTuna;

public class ModelBasicFish extends ModelBase
{
  //fields
    ModelRenderer headtop;
    ModelRenderer Lwisker;
    ModelRenderer Rwisker;
    ModelRenderer unihorn;
    ModelRenderer headfin;
    ModelRenderer hornL;
    ModelRenderer hornR;
    ModelRenderer suckermouth;
    ModelRenderer mouth;
    ModelRenderer bodysection1;
    ModelRenderer frontfinL;
    ModelRenderer frontfinR;
    ModelRenderer bodysection2;
    ModelRenderer sidefinL;
    ModelRenderer sidefinR;
    ModelRenderer bodysection3;
    ModelRenderer bodysection4;
    ModelRenderer bodysection5;
    ModelRenderer backfinL;
    ModelRenderer backfinR;
    ModelRenderer bodysection6;
    ModelRenderer tail;
    ModelRenderer altsidefinL;
    ModelRenderer altsidefinR;
    ModelRenderer topfin;
    ModelRenderer bottemfin;
   
  public ModelBasicFish()
  {
    textureWidth = 128;
    textureHeight = 64;
     
      headtop = new ModelRenderer(this, 0, 0);
      headtop.addBox(-3F, 0F, 0F, 6, 8, 7);
      headtop.setRotationPoint(0F, 1F, -14F);
      headtop.setTextureSize(128, 64);
      headtop.mirror = true;
      setRotation(headtop, 0.7853982F, 0F, 0F);
      Lwisker = new ModelRenderer(this, 0, 15);
      Lwisker.addBox(2F, -1F, -1F, 0, 7, 9);
      Lwisker.setRotationPoint(0F, 1F, -14F);
      Lwisker.setTextureSize(128, 64);
      Lwisker.mirror = true;
      setRotation(Lwisker, 0F, 0.2617994F, -0.2617994F);
      Rwisker = new ModelRenderer(this, 0, 15);
      Rwisker.addBox(-2F, -1F, -1F, 0, 7, 9);
      Rwisker.setRotationPoint(0F, 1F, -14F);
      Rwisker.setTextureSize(128, 64);
      Rwisker.mirror = true;
      setRotation(Rwisker, 0F, -0.2617994F, 0.2617994F);
      unihorn = new ModelRenderer(this, 19, 0);
      unihorn.addBox(-3F, -3F, 2F, 8, 1, 1);
      unihorn.setRotationPoint(0F, 1F, -14F);
      unihorn.setTextureSize(128, 64);
      unihorn.mirror = true;
      setRotation(unihorn, 0.7853982F, 1.570796F, -0.2617994F);
      headfin = new ModelRenderer(this, 40, 42);
      headfin.addBox(0F, -5F, 1F, 0, 9, 13);
      headfin.setRotationPoint(0F, 1F, -14F);
      headfin.setTextureSize(128, 64);
      headfin.mirror = true;
      setRotation(headfin, 0.8552113F, 0F, 0F);
      hornL = new ModelRenderer(this, 70, 45);
      hornL.addBox(0F, 1F, 5F, 1, 1, 10);
      hornL.setRotationPoint(0F, 1F, -14F);
      hornL.setTextureSize(128, 64);
      hornL.mirror = true;
      setRotation(hornL, 0.9250245F, 0.2617994F, 0.2617994F);
      hornR = new ModelRenderer(this, 70, 45);
      hornR.addBox(-1F, 1F, 5F, 1, 1, 10);
      hornR.setRotationPoint(0F, 1F, -14F);
      hornR.setTextureSize(128, 64);
      hornR.mirror = true;
      setRotation(hornR, 0.9250245F, -0.2617994F, -0.2617994F);
      suckermouth = new ModelRenderer(this, 106, 34);
      suckermouth.addBox(-2.5F, 0F, 0F, 5, 5, 5);
      suckermouth.setRotationPoint(0F, 1F, -14F);
      suckermouth.setTextureSize(128, 64);
      suckermouth.mirror = true;
      setRotation(suckermouth, 0F, 0F, 0F);
      mouth = new ModelRenderer(this, 0, 15);
      mouth.addBox(-2.5F, -4F, -2F, 5, 6, 3);
      mouth.setRotationPoint(0F, 4F, -9F);
      mouth.setTextureSize(128, 64);
      mouth.mirror = true;
      setRotation(mouth, 0.8726646F, 0F, 0F);
      bodysection1 = new ModelRenderer(this, 26, 4);
      bodysection1.addBox(-4F, -5F, 0F, 8, 10, 5);
      bodysection1.setRotationPoint(0F, 1F, -9F);
      bodysection1.setTextureSize(128, 64);
      bodysection1.mirror = true;
      setRotation(bodysection1, 0F, 0F, 0F);
      frontfinL = new ModelRenderer(this, 82, 36);
      frontfinL.addBox(2F, 5F, -1F, 0, 10, 9);
      frontfinL.setRotationPoint(0F, 0F, -4F);
      frontfinL.setTextureSize(128, 64);
      frontfinL.mirror = true;
      setRotation(frontfinL, 0.3316126F, 0.1396263F, -0.2617994F);
      frontfinR = new ModelRenderer(this, 82, 36);
      frontfinR.addBox(-2F, 5F, -1F, 0, 10, 9);
      frontfinR.setRotationPoint(0F, 0F, -4F);
      frontfinR.setTextureSize(128, 64);
      frontfinR.mirror = true;
      setRotation(frontfinR, 0.3316126F, -0.1396263F, 0.2617994F);
      bodysection2 = new ModelRenderer(this, 52, 0);
      bodysection2.addBox(-4.466667F, -5.466667F, 0F, 9, 11, ;
      bodysection2.setRotationPoint(0F, 0F, 4F);
      bodysection2.setTextureSize(128, 64);
      bodysection2.mirror = true;
      setRotation(bodysection2, 0F, 0F, 0F);
      sidefinL = new ModelRenderer(this, 0, 16);
      sidefinL.addBox(0F, -6F, 0F, 0, 12, 15);
      sidefinL.setRotationPoint(4F, 0F, 1F);
      sidefinL.setTextureSize(128, 64);
      sidefinL.mirror = true;
      setRotation(sidefinL, 0F, 0.7853982F, 0F);
      sidefinR = new ModelRenderer(this, 0, 16);
      sidefinR.addBox(0F, -6F, 0F, 0, 12, 15);
      sidefinR.setRotationPoint(-4F, 0F, 1F);
      sidefinR.setTextureSize(128, 64);
      sidefinR.mirror = true;
      setRotation(sidefinR, 0F, -0.7853982F, 0F);
      bodysection3 = new ModelRenderer(this, 86, 2);
      bodysection3.addBox(-4F, -4F, 0F, 8, 9, ;
      bodysection3.setRotationPoint(0F, -1F, 7F);
      bodysection3.setTextureSize(128, 64);
      bodysection3.mirror = true;
      setRotation(bodysection3, 0F, 0F, 0F);
      bodysection4 = new ModelRenderer(this, 29, 19);
      bodysection4.addBox(-3.5F, -3F, 0F, 7, 7, 5);
      bodysection4.setRotationPoint(0F, 0F, 7F);
      bodysection4.setTextureSize(128, 64);
      bodysection4.mirror = true;
      setRotation(bodysection4, 0F, 0F, 0F);
      bodysection5 = new ModelRenderer(this, 53, 21);
      bodysection5.addBox(-2.5F, -2F, 0F, 5, 5, 5);
      bodysection5.setRotationPoint(0F, 0F, 4F);
      bodysection5.setTextureSize(128, 64);
      bodysection5.mirror = true;
      setRotation(bodysection5, 0F, 0F, 0F);
      backfinL = new ModelRenderer(this, 80, 21);
      backfinL.addBox(1F, 3F, 2F, 0, 11, 13);
      backfinL.setRotationPoint(0F, 0F, 4F);
      backfinL.setTextureSize(128, 64);
      backfinL.mirror = true;
      setRotation(backfinL, 0F, 0F, -0.2617994F);
      backfinR = new ModelRenderer(this, 80, 21);
      backfinR.addBox(-1F, 3F, 2F, 0, 11, 13);
      backfinR.setRotationPoint(0F, 0F, 4F);
      backfinR.setTextureSize(128, 64);
      backfinR.mirror = true;
      setRotation(backfinR, 0F, 0F, 0.2617994F);
      bodysection6 = new ModelRenderer(this, 73, 24);
      bodysection6.addBox(-1F, -1F, 0F, 2, 3, 4);
      bodysection6.setRotationPoint(0F, 0F, 4F);
      bodysection6.setTextureSize(128, 64);
      bodysection6.mirror = true;
      setRotation(bodysection6, 0F, 0F, 0F);
      tail = new ModelRenderer(this, 0, 23);
      tail.addBox(0F, -2F, -2F, 0, 20, 20);
      tail.setRotationPoint(0F, 0F, 4F);
      tail.setTextureSize(128, 64);
      tail.mirror = true;
      setRotation(tail, 0.7853982F, 0F, 0F);
      altsidefinL = new ModelRenderer(this, 72, 19);
      altsidefinL.addBox(-2F, 0F, 0F, 19, 0, 15);
      altsidefinL.setRotationPoint(4F, 1F, -6F);
      altsidefinL.setTextureSize(128, 64);
      altsidefinL.mirror = true;
      setRotation(altsidefinL, 0F, 0F, 0.2617994F);
      altsidefinR = new ModelRenderer(this, 72, 19);
      altsidefinR.addBox(-2F, 0F, 0F, 19, 0, 15);
      altsidefinR.setRotationPoint(-4F, 1F, -6F);
      altsidefinR.setTextureSize(128, 64);
      altsidefinR.mirror = true;
      setRotation(altsidefinR, 0F, 0F, 2.879793F);
      topfin = new ModelRenderer(this, 40, 11);
      topfin.addBox(0F, -10F, -6F, 0, 12, 20);
      topfin.setRotationPoint(0F, -5F, 6F);
      topfin.setTextureSize(128, 64);
      topfin.mirror = true;
      setRotation(topfin, -0.2268928F, 0F, 0F);
      bottemfin = new ModelRenderer(this, 40, 23);
      bottemfin.addBox(0F, -1F, -6F, 0, 12, 20);
      bottemfin.setRotationPoint(0F, 4F, 5F);
      bottemfin.setTextureSize(128, 64);
      bottemfin.mirror = true;
      setRotation(bottemfin, 0.2443461F, 0F, 0F);
      
      
      bodysection1.addChild(bodysection2);
      bodysection2.addChild(bodysection3);
      bodysection2.addChild(sidefinL);
      bodysection2.addChild(sidefinR);
      bodysection2.addChild(frontfinL);
      bodysection2.addChild(frontfinR);
      bodysection2.addChild(bottemfin);
      bodysection3.addChild(altsidefinL);
      bodysection3.addChild(altsidefinR);
      bodysection3.addChild(bodysection4);
      bodysection4.addChild(bodysection5);
      bodysection4.addChild(backfinL);
      bodysection4.addChild(backfinR);
      bodysection5.addChild(bodysection6);
      bodysection6.addChild(tail);
      bodysection2.addChild(topfin);
      
  }
   
  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);
    headtop.render(f5);
    Lwisker.render(f5);
    Rwisker.render(f5);
    unihorn.render(f5);
    headfin.render(f5);
    hornL.render(f5);
    hornR.render(f5);
    suckermouth.render(f5);
    mouth.render(f5);
    bodysection1.render(f5);

  }
   
  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);
    EntityFantasticFish _fish = (EntityFantasticFish)entity;
    this.mouth.rotateAngleX = 0.17F*(MathHelper.cos(f2 * 0.06662F) ) + 0.8726646F;
    this.bodysection1.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F) );
    this.bodysection2.rotateAngleY = 0.2F *(MathHelper.cos(f2 *_fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/6)) );
    this.bodysection3.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/3)) );
    this.bodysection4.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/2)) );
    this.bodysection5.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(2*Math.PI/3)) );
    this.bodysection6.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(5*Math.PI/6)) );

   
  }
}
code]

Link to comment
Share on other sites

Where did you hardcode the rotationPitch value?

 

In my movement class which is executed server side only. All my mobs motion are set server side. I noticed that the motion and yaw are kept in synch with the client.

 

I noticed that I can play with the pitch by using the client side GL11.glRotated method in the render class (which run client side). But I am curious to know why the pitch needs to be handled by GL11.glRotated...

 

So my question is back ... why rotationyaw is rendered correctly ...but not rotationpitch. I am probably missing something.

Link to comment
Share on other sites

Where did you hardcode the rotationPitch value?

 

In my movement class which is executed server side only. All my mobs motion are set server side. I noticed that the motion and yaw are kept in synch with the client.

 

I noticed that I can play with the pitch by using the client side GL11.glRotated method in the render class (which run client side). But I am curious to know why the pitch needs to be handled by GL11.glRotated...

 

So my question is back ... why rotationyaw is rendered correctly ...but not rotationpitch. I am probably missing something.

Please post the image of the fish. I think you should apply rotation yourself.

Also please post code of your Render class.

    this.mouth.rotateAngleX = 0.17F*(MathHelper.cos(f2 * 0.06662F) ) + 0.8726646F;
    this.bodysection1.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F) );
    this.bodysection2.rotateAngleY = 0.2F *(MathHelper.cos(f2 *_fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/6)) );
    this.bodysection3.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/3)) );
    this.bodysection4.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/2)) );
    this.bodysection5.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(2*Math.PI/3)) );
    this.bodysection6.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(5*Math.PI/6)) );

This might make your model like it is applying yaw.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Where did you hardcode the rotationPitch value?

 

In my movement class which is executed server side only. All my mobs motion are set server side. I noticed that the motion and yaw are kept in synch with the client.

 

I noticed that I can play with the pitch by using the client side GL11.glRotated method in the render class (which run client side). But I am curious to know why the pitch needs to be handled by GL11.glRotated...

 

So my question is back ... why rotationyaw is rendered correctly ...but not rotationpitch. I am probably missing something.

Please post the image of the fish. I think you should apply rotation yourself.

Also please post code of your Render class.

    this.mouth.rotateAngleX = 0.17F*(MathHelper.cos(f2 * 0.06662F) ) + 0.8726646F;
    this.bodysection1.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F) );
    this.bodysection2.rotateAngleY = 0.2F *(MathHelper.cos(f2 *_fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/6)) );
    this.bodysection3.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/3)) );
    this.bodysection4.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/2)) );
    this.bodysection5.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(2*Math.PI/3)) );
    this.bodysection6.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(5*Math.PI/6)) );

This might make your model like it is applying yaw.

 

Thanks Abastro, you were really helpful to me those days...

 

Just to make sure we are on the same page. The yaw is fine ... I have issue with the pitch. My fish will never point their nose up or down to swim thru their destination.

 

Here is the render

 

package fantastic.renders.entity;



import org.lwjgl.opengl.GL11;

import fantastic.FantasticDebug;
import fantastic.FantasticInfo;
import fantastic.entities.EntityBasicFish;
import fantastic.entities.EntityBasicFish;
import fantastic.renders.models.ModelBasicFish;
import net.minecraft.block.material.Material;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;

public class RenderBasicFish extends RenderLiving
{

protected ModelBasicFish model;

public RenderBasicFish(ModelBase par1ModelBase, float par2)
{
	super(par1ModelBase, par2);
	model = ((ModelBasicFish) mainModel);
}

public void renderBasicFish(EntityBasicFish par1, double par2, double par3, double par4, float par5, float par6)
{
	super.doRender(par1, par2, par3, par4, par5, par6);

}

public void doRenderLiving(EntityLiving par1, double par2, double par3, double par4, float par5, float par6)
{
	this.renderBasicFish((EntityBasicFish) par1, par2, par3, par4, par5, par6);

}

@Override
public void doRender(Entity par1, double par2, double par3, double par4, float par5, float par6)
{
	this.renderBasicFish((EntityBasicFish) par1, par2, par3, par4, par5, par6);

}

protected ResourceLocation getEntityTexture(Entity entity)
{
	return ((EntityBasicFish)entity).GetTexture();

}


/**
     * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
     * entityLiving, partialTickTime
     */
@Override
    protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2)
    {
        this.scaleFish((EntityBasicFish)par1EntityLivingBase, par2);
    }
    
    protected void scaleFish(EntityBasicFish par1, float par2)
    {
    	float scale = (float)par1.GetRenderValueFromSize();
        GL11.glScalef(scale, scale, scale);
    }




protected void func_82430_a(EntityBasicFish par1, float par2, float par3, float par4)
    {		
	GL11.glTranslatef(0.0F, (float)(-par1.GetRenderValueFromSize()), 0.0F);
	super.rotateCorpse((EntityLivingBase)par1, par2, par3, 0);

}

protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4)
    {
        this.func_82430_a((EntityBasicFish)par1EntityLivingBase, par2, par3, par4);
        
    }
}

Link to comment
Share on other sites

Post your movement code I think you might have an issue somewhere in there with the pitch. They should be handled the same so theres probably an issue in the movement class. Show the classes in order of movement is set here-> movement is passed here -> fish is rendered here-> etc etc. will help in figuring this out.

Link to comment
Share on other sites

Post your movement code I think you might have an issue somewhere in there with the pitch. They should be handled the same so theres probably an issue in the movement class. Show the classes in order of movement is set here-> movement is passed here -> fish is rendered here-> etc etc. will help in figuring this out.

 

Hi Thornack, thanks fir the help.

 

So my fish movement is called server side in this method.

 

//Math converted to use more accurate and readable Vec3's
public static void SwimTo(EntityFantasticFish aWaterMob, double xCoor, double yCoor, double zCoor, double speed) 
{
FantasticDebug.Output("Swim to new target");
if ((aWaterMob!=null) && (aWaterMob.isEntityAlive()))
{
	if (!aWaterMob.worldObj.isRemote)
	{
		double speedAdjustment = 0.1D;


			//Create vector
			Vec3 vec3 = Vec3.createVectorHelper(xCoor - aWaterMob.posX, yCoor - aWaterMob.posY, zCoor - aWaterMob.posZ).normalize();

			//Set motion and angles
			aWaterMob.motionX = (vec3.xCoord * speed)*speedAdjustment;
			aWaterMob.motionY = (vec3.yCoord * speed)*speedAdjustment;
			aWaterMob.motionZ = (vec3.zCoord * speed)*speedAdjustment;

			//*** OPTION 1
			float f = (float) (Math.atan2(aWaterMob.motionZ, aWaterMob.motionX) * 180.0D / Math.PI) - 90.0F;
			float f1 = MathHelper.wrapAngleTo180_float(f - aWaterMob.rotationYaw);
			aWaterMob.rotationYaw += f1;



			aWaterMob.rotationPitch = 0.5F; //I can set anything here, the pitch will never change	
		//}



	}
}
}

 

Notice the line aWaterMob.rotationPitch ... I can set any values in there ... pitch NEVER change. Do you know where that pitch should be passed as a parameter in SetRotationAngle?

 

This is my RenderClass

 

package fantastic.renders.entity;



import org.lwjgl.opengl.GL11;

import fantastic.FantasticDebug;
import fantastic.FantasticInfo;
import fantastic.entities.EntityBasicFish;
import fantastic.entities.EntityBasicFish;
import fantastic.renders.models.ModelBasicFish;
import net.minecraft.block.material.Material;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;

public class RenderBasicFish extends RenderLiving
{

protected ModelBasicFish model;

public RenderBasicFish(ModelBase par1ModelBase, float par2)
{
	super(par1ModelBase, par2);
	model = ((ModelBasicFish) mainModel);
}

public void renderBasicFish(EntityBasicFish par1, double par2, double par3, double par4, float par5, float par6)
{
	super.doRender(par1, par2, par3, par4, par5, par6);

}

public void doRenderLiving(EntityLiving par1, double par2, double par3, double par4, float par5, float par6)
{
	this.renderBasicFish((EntityBasicFish) par1, par2, par3, par4, par5, par6);

}

@Override
public void doRender(Entity par1, double par2, double par3, double par4, float par5, float par6)
{
	this.renderBasicFish((EntityBasicFish) par1, par2, par3, par4, par5, par6);

}

protected ResourceLocation getEntityTexture(Entity entity)
{
	return ((EntityBasicFish)entity).GetTexture();

}


/**
     * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
     * entityLiving, partialTickTime
     */
@Override
    protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2)
    {
        this.scaleFish((EntityBasicFish)par1EntityLivingBase, par2);
    }
    
    protected void scaleFish(EntityBasicFish par1, float par2)
    {
    	float scale = (float)par1.GetRenderValueFromSize();
        GL11.glScalef(scale, scale, scale);
    }




protected void func_82430_a(EntityBasicFish par1, float par2, float par3, float par4)
    {		
	GL11.glTranslatef(0.0F, (float)(-par1.GetRenderValueFromSize()), 0.0F);
	super.rotateCorpse((EntityLivingBase)par1, par2, par3, 0);

}

protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4)
    {
        this.func_82430_a((EntityBasicFish)par1EntityLivingBase, par2, par3, par4);
        
    }
}

 

This is my model class

 



package fantastic.renders.models;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import fantastic.FantasticDebug;
import fantastic.entities.EntityBasicFish;
import fantastic.entities.EntityFantasticFish;
import fantastic.entities.EntityFeeder;
import fantastic.entities.EntityMossy;
import fantastic.entities.EntitySalmon;
import fantastic.entities.EntityTuna;

public class ModelBasicFish extends ModelBase
{
  //fields
    ModelRenderer headtop;
    ModelRenderer Lwisker;
    ModelRenderer Rwisker;
    ModelRenderer unihorn;
    ModelRenderer headfin;
    ModelRenderer hornL;
    ModelRenderer hornR;
    ModelRenderer suckermouth;
    ModelRenderer mouth;
    ModelRenderer bodysection1;
    ModelRenderer frontfinL;
    ModelRenderer frontfinR;
    ModelRenderer bodysection2;
    ModelRenderer sidefinL;
    ModelRenderer sidefinR;
    ModelRenderer bodysection3;
    ModelRenderer bodysection4;
    ModelRenderer bodysection5;
    ModelRenderer backfinL;
    ModelRenderer backfinR;
    ModelRenderer bodysection6;
    ModelRenderer tail;
    ModelRenderer altsidefinL;
    ModelRenderer altsidefinR;
    ModelRenderer topfin;
    ModelRenderer bottemfin;
   
  public ModelBasicFish()
  {
    textureWidth = 128;
    textureHeight = 64;
     
      headtop = new ModelRenderer(this, 0, 0);
      headtop.addBox(-3F, 0F, 0F, 6, 8, 7);
      headtop.setRotationPoint(0F, 1F, -14F);
      headtop.setTextureSize(128, 64);
      headtop.mirror = true;
      setRotation(headtop, 0.7853982F, 0F, 0F);
      Lwisker = new ModelRenderer(this, 0, 15);
      Lwisker.addBox(2F, -1F, -1F, 0, 7, 9);
      Lwisker.setRotationPoint(0F, 1F, -14F);
      Lwisker.setTextureSize(128, 64);
      Lwisker.mirror = true;
      setRotation(Lwisker, 0F, 0.2617994F, -0.2617994F);
      Rwisker = new ModelRenderer(this, 0, 15);
      Rwisker.addBox(-2F, -1F, -1F, 0, 7, 9);
      Rwisker.setRotationPoint(0F, 1F, -14F);
      Rwisker.setTextureSize(128, 64);
      Rwisker.mirror = true;
      setRotation(Rwisker, 0F, -0.2617994F, 0.2617994F);
      unihorn = new ModelRenderer(this, 19, 0);
      unihorn.addBox(-3F, -3F, 2F, 8, 1, 1);
      unihorn.setRotationPoint(0F, 1F, -14F);
      unihorn.setTextureSize(128, 64);
      unihorn.mirror = true;
      setRotation(unihorn, 0.7853982F, 1.570796F, -0.2617994F);
      headfin = new ModelRenderer(this, 40, 42);
      headfin.addBox(0F, -5F, 1F, 0, 9, 13);
      headfin.setRotationPoint(0F, 1F, -14F);
      headfin.setTextureSize(128, 64);
      headfin.mirror = true;
      setRotation(headfin, 0.8552113F, 0F, 0F);
      hornL = new ModelRenderer(this, 70, 45);
      hornL.addBox(0F, 1F, 5F, 1, 1, 10);
      hornL.setRotationPoint(0F, 1F, -14F);
      hornL.setTextureSize(128, 64);
      hornL.mirror = true;
      setRotation(hornL, 0.9250245F, 0.2617994F, 0.2617994F);
      hornR = new ModelRenderer(this, 70, 45);
      hornR.addBox(-1F, 1F, 5F, 1, 1, 10);
      hornR.setRotationPoint(0F, 1F, -14F);
      hornR.setTextureSize(128, 64);
      hornR.mirror = true;
      setRotation(hornR, 0.9250245F, -0.2617994F, -0.2617994F);
      suckermouth = new ModelRenderer(this, 106, 34);
      suckermouth.addBox(-2.5F, 0F, 0F, 5, 5, 5);
      suckermouth.setRotationPoint(0F, 1F, -14F);
      suckermouth.setTextureSize(128, 64);
      suckermouth.mirror = true;
      setRotation(suckermouth, 0F, 0F, 0F);
      mouth = new ModelRenderer(this, 0, 15);
      mouth.addBox(-2.5F, -4F, -2F, 5, 6, 3);
      mouth.setRotationPoint(0F, 4F, -9F);
      mouth.setTextureSize(128, 64);
      mouth.mirror = true;
      setRotation(mouth, 0.8726646F, 0F, 0F);
      bodysection1 = new ModelRenderer(this, 26, 4);
      bodysection1.addBox(-4F, -5F, 0F, 8, 10, 5);
      bodysection1.setRotationPoint(0F, 1F, -9F);
      bodysection1.setTextureSize(128, 64);
      bodysection1.mirror = true;
      setRotation(bodysection1, 0F, 0F, 0F);
      frontfinL = new ModelRenderer(this, 82, 36);
      frontfinL.addBox(2F, 5F, -1F, 0, 10, 9);
      frontfinL.setRotationPoint(0F, 0F, -4F);
      frontfinL.setTextureSize(128, 64);
      frontfinL.mirror = true;
      setRotation(frontfinL, 0.3316126F, 0.1396263F, -0.2617994F);
      frontfinR = new ModelRenderer(this, 82, 36);
      frontfinR.addBox(-2F, 5F, -1F, 0, 10, 9);
      frontfinR.setRotationPoint(0F, 0F, -4F);
      frontfinR.setTextureSize(128, 64);
      frontfinR.mirror = true;
      setRotation(frontfinR, 0.3316126F, -0.1396263F, 0.2617994F);
      bodysection2 = new ModelRenderer(this, 52, 0);
      bodysection2.addBox(-4.466667F, -5.466667F, 0F, 9, 11, ;
      bodysection2.setRotationPoint(0F, 0F, 4F);
      bodysection2.setTextureSize(128, 64);
      bodysection2.mirror = true;
      setRotation(bodysection2, 0F, 0F, 0F);
      sidefinL = new ModelRenderer(this, 0, 16);
      sidefinL.addBox(0F, -6F, 0F, 0, 12, 15);
      sidefinL.setRotationPoint(4F, 0F, 1F);
      sidefinL.setTextureSize(128, 64);
      sidefinL.mirror = true;
      setRotation(sidefinL, 0F, 0.7853982F, 0F);
      sidefinR = new ModelRenderer(this, 0, 16);
      sidefinR.addBox(0F, -6F, 0F, 0, 12, 15);
      sidefinR.setRotationPoint(-4F, 0F, 1F);
      sidefinR.setTextureSize(128, 64);
      sidefinR.mirror = true;
      setRotation(sidefinR, 0F, -0.7853982F, 0F);
      bodysection3 = new ModelRenderer(this, 86, 2);
      bodysection3.addBox(-4F, -4F, 0F, 8, 9, ;
      bodysection3.setRotationPoint(0F, -1F, 7F);
      bodysection3.setTextureSize(128, 64);
      bodysection3.mirror = true;
      setRotation(bodysection3, 0F, 0F, 0F);
      bodysection4 = new ModelRenderer(this, 29, 19);
      bodysection4.addBox(-3.5F, -3F, 0F, 7, 7, 5);
      bodysection4.setRotationPoint(0F, 0F, 7F);
      bodysection4.setTextureSize(128, 64);
      bodysection4.mirror = true;
      setRotation(bodysection4, 0F, 0F, 0F);
      bodysection5 = new ModelRenderer(this, 53, 21);
      bodysection5.addBox(-2.5F, -2F, 0F, 5, 5, 5);
      bodysection5.setRotationPoint(0F, 0F, 4F);
      bodysection5.setTextureSize(128, 64);
      bodysection5.mirror = true;
      setRotation(bodysection5, 0F, 0F, 0F);
      backfinL = new ModelRenderer(this, 80, 21);
      backfinL.addBox(1F, 3F, 2F, 0, 11, 13);
      backfinL.setRotationPoint(0F, 0F, 4F);
      backfinL.setTextureSize(128, 64);
      backfinL.mirror = true;
      setRotation(backfinL, 0F, 0F, -0.2617994F);
      backfinR = new ModelRenderer(this, 80, 21);
      backfinR.addBox(-1F, 3F, 2F, 0, 11, 13);
      backfinR.setRotationPoint(0F, 0F, 4F);
      backfinR.setTextureSize(128, 64);
      backfinR.mirror = true;
      setRotation(backfinR, 0F, 0F, 0.2617994F);
      bodysection6 = new ModelRenderer(this, 73, 24);
      bodysection6.addBox(-1F, -1F, 0F, 2, 3, 4);
      bodysection6.setRotationPoint(0F, 0F, 4F);
      bodysection6.setTextureSize(128, 64);
      bodysection6.mirror = true;
      setRotation(bodysection6, 0F, 0F, 0F);
      tail = new ModelRenderer(this, 0, 23);
      tail.addBox(0F, -2F, -2F, 0, 20, 20);
      tail.setRotationPoint(0F, 0F, 4F);
      tail.setTextureSize(128, 64);
      tail.mirror = true;
      setRotation(tail, 0.7853982F, 0F, 0F);
      altsidefinL = new ModelRenderer(this, 72, 19);
      altsidefinL.addBox(-2F, 0F, 0F, 19, 0, 15);
      altsidefinL.setRotationPoint(4F, 1F, -6F);
      altsidefinL.setTextureSize(128, 64);
      altsidefinL.mirror = true;
      setRotation(altsidefinL, 0F, 0F, 0.2617994F);
      altsidefinR = new ModelRenderer(this, 72, 19);
      altsidefinR.addBox(-2F, 0F, 0F, 19, 0, 15);
      altsidefinR.setRotationPoint(-4F, 1F, -6F);
      altsidefinR.setTextureSize(128, 64);
      altsidefinR.mirror = true;
      setRotation(altsidefinR, 0F, 0F, 2.879793F);
      topfin = new ModelRenderer(this, 40, 11);
      topfin.addBox(0F, -10F, -6F, 0, 12, 20);
      topfin.setRotationPoint(0F, -5F, 6F);
      topfin.setTextureSize(128, 64);
      topfin.mirror = true;
      setRotation(topfin, -0.2268928F, 0F, 0F);
      bottemfin = new ModelRenderer(this, 40, 23);
      bottemfin.addBox(0F, -1F, -6F, 0, 12, 20);
      bottemfin.setRotationPoint(0F, 4F, 5F);
      bottemfin.setTextureSize(128, 64);
      bottemfin.mirror = true;
      setRotation(bottemfin, 0.2443461F, 0F, 0F);
      
      
      bodysection1.addChild(bodysection2);
      bodysection2.addChild(bodysection3);
      bodysection2.addChild(sidefinL);
      bodysection2.addChild(sidefinR);
      bodysection2.addChild(frontfinL);
      bodysection2.addChild(frontfinR);
      bodysection2.addChild(bottemfin);
      bodysection3.addChild(altsidefinL);
      bodysection3.addChild(altsidefinR);
      bodysection3.addChild(bodysection4);
      bodysection4.addChild(bodysection5);
      bodysection4.addChild(backfinL);
      bodysection4.addChild(backfinR);
      bodysection5.addChild(bodysection6);
      bodysection6.addChild(tail);
      bodysection2.addChild(topfin);
      
  }
   
  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);
    headtop.render(f5);
    Lwisker.render(f5);
    Rwisker.render(f5);
    unihorn.render(f5);
    headfin.render(f5);
    hornL.render(f5);
    hornR.render(f5);
    suckermouth.render(f5);
    mouth.render(f5);
    bodysection1.render(f5);

  }
   
  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)
  {
      EntityFantasticFish _fish = (EntityFantasticFish)entity;
      //FantasticDebug.Output(Float.toString(_fish.GetTailFlapSpeed()),true);
  if (_fish.GetTailFlapSpeed()>0)
  {
	super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
	this.mouth.rotateAngleX = 0.17F*(MathHelper.cos(f2 * 0.06662F) ) + 0.8726646F;
	this.bodysection1.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F) );
	this.bodysection2.rotateAngleY = 0.2F *(MathHelper.cos(f2 *_fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/6)) );
	this.bodysection3.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/3)) );
	this.bodysection4.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/2)) );
	this.bodysection5.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(2*Math.PI/3)) );
	this.bodysection6.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(5*Math.PI/6)) );
    }

   
  }
}

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys,

 

I am still hunting that pitch issue. Actually, reading a tutorial from Jabelar led me to this one.

 

http://greyminecraftcoder.blogspot.ca/2015/07/entity-rotations-and-animation.html?showComment=1444584624236#c7188593033068666922

 

In this tutorial, the author specifically talk about the DoRender and DoRenderEntity ... which seems that they do not get the pitch by parameters.

 

HEre are the signature of both methods ...so where is the pitch value client side!!??

 

RenderManager::

 

doRenderEntity(Entity entity,

 

              double x, double y, double z,

 

              float rotationYaw, float partialTicks,

 

              boolean showOutline);

 

 

 

 

 

this then calls the Entity Renderer:

 

RendererLivingEntity::

 

 

doRender(Entity entity,

 

 

        double x, double y, double z,

 

        float rotationYaw, float partialTicks);

Link to comment
Share on other sites

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.