Jump to content

Custom Held Item Model Rotation Problem


Gurman8r

Recommended Posts

When I render one of the models i use for a held item the rotation is wrong while in 1st person. in 3rd person it's in the right place but in 1st person the model is sideways. Sorry if I'm not making sense, it's hard for me to explain. Also, just in case it's relevant, i'm using 1.5.2.

 

Screens

http://i.imgur.com/JMHEbp6.png

http://i.imgur.com/d2PVRNN.png

http://i.imgur.com/SyvgtVK.jpg

 

 

Here's the code form the render file.

package mods.StarTrek.textures.render;

import mods.StarTrek.models.ModelPhaser;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.FMLClientHandler;

public class RenderPhaser extends Render implements IItemRenderer
{
protected ModelPhaser launcherModel;

public RenderPhaser()
{
	launcherModel = new ModelPhaser();
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
	switch(type)
	{
	case EQUIPPED: return true;
	default: return false;
	}
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) 
{

	return false;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) 
{
	switch(type)
	{
	case EQUIPPED:
	{

		GL11.glPushMatrix();

		GL11.glRotatef(190F, 1.0F, 0.0F, 0.0F);
		GL11.glRotatef(167F, 0.0F, 1.0F, 0.0F);
		GL11.glRotatef(16F, 0.0F, 0.0F, 1.0F);

		GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture("/mods/startrek/textures/models/phaserGun.png"));

		GL11.glTranslatef(-0.5F, -0.225F, 0.45F);

		float scale = 1.0F;

		GL11.glScalef(scale, scale, scale);

		launcherModel.render((Entity)data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0635F);

		GL11.glPopMatrix();
	}
	default:
		break;
	}

}

@Override
public void doRender(Entity entity, double d0, double d1, double d2,
		float f, float f1) {
	// TODO Auto-generated method stub

}

}

 

Model File(Just incase)

package mods.StarTrek.models;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelPhaser extends ModelBase
{
  //fields
    ModelRenderer Shape1;
    ModelRenderer Shape2;
    ModelRenderer Shape3;
    ModelRenderer Shape4;
    ModelRenderer Shape5;
    ModelRenderer Shape6;
  
  public ModelPhaser()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Shape1 = new ModelRenderer(this, 0, 11);
      Shape1.addBox(0F, 0F, 0F, 1, 1, 2);
      Shape1.setRotationPoint(0F, 0F, -1F);
      Shape1.setTextureSize(64, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 15);
      Shape2.addBox(0F, 0F, 0F, 3, 3, 1);
      Shape2.setRotationPoint(-1F, -1F, -1F);
      Shape2.setTextureSize(64, 32);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
      Shape3 = new ModelRenderer(this, 0, 22);
      Shape3.addBox(0F, 0F, 0F, 3, 4, 5);
      Shape3.setRotationPoint(-1F, -2F, -6F);
      Shape3.setTextureSize(64, 32);
      Shape3.mirror = true;
      setRotation(Shape3, 0F, 0F, 0F);
      Shape4 = new ModelRenderer(this, 0, 0);
      Shape4.addBox(0F, 0F, 0F, 3, 2, ;
      Shape4.setRotationPoint(-1F, -2F, -12F);
      Shape4.setTextureSize(64, 32);
      Shape4.mirror = true;
      setRotation(Shape4, 0F, 0F, 0F);
      Shape5 = new ModelRenderer(this, 56, 0);
      Shape5.addBox(0F, 0F, 0F, 2, 8, 2);
      Shape5.setRotationPoint(-0.5F, -1F, -6F);
      Shape5.setTextureSize(64, 32);
      Shape5.mirror = true;
      setRotation(Shape5, -0.3839724F, 0F, 0F);
      Shape6 = new ModelRenderer(this, 27, 10);
      Shape6.addBox(0F, 0F, 0F, 2, 1, 4);
      Shape6.setRotationPoint(-0.5F, -2.5F, -6F);
      Shape6.setTextureSize(64, 32);
      Shape6.mirror = true;
      setRotation(Shape6, 0F, 0F, 0F);
  }
  
  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);
    Shape1.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
    Shape6.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 ent)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, ent);
  }

}

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.