Jump to content

[1.11.2]Changing scale on child box model


TheMattyBoy

Recommended Posts

So I have this model which only calls the

ModelRenderer#render

function once, because all other boxes are child models or child models of child models etc. of that

ModelRenderer

. Problem is, I want to scale one of these child models (called 'head') and all of it's child models based on conditions, but I'm not sure how I should go about doing that. I have made this method that successfully

for

's itself through all child models and their children to find the box I'm looking for:

@Nullable
private ModelRenderer scaleHead(ModelRenderer currentBox, EntityVelociraptor raptor) {
    for(int i = 0; i < currentBox.childModels.size(); i++) {
    	ModelRenderer box = currentBox.childModels.get(i);
    	if(box == head) {
    		return box;
    	}
    	else {
    		this.scaleHead(box, raptor);
    		return null;
    	}
    }
    return null;
}

But now I'm lost. I tried adding

GLStateManager#scale

inside the

if(box == head)

statement, but that scaled the whole model, not just the box. I tried pushing a glMatrix in that same statement and then tried, with variable values,

ModelRenderer#render

, which rendered the head seperately, and

ModelRenderer#postRender

, which turned the entire model on it's side. When I used

GL11#glScaled

and fixed values in

render

and

postRender

, I got the same results respectively. Besides, when I push a glMatrix inside the

if

statement, it stops updating the method in real time, which is essential for what I'm doing (I'm calling the method in

ModelRenderer#setRotationAndAngles

[i know, probably not the optimal method but it works], so it should update in real time).

 

I could give you the whole class but it's nearly 400 lines long and I think pretty much everyone here has seen a model renderer class generated in Techne before...

 

Thanks in advance :)

 

P.S. For some odd reason, Eclipse highlights the "i++" in the

for

loop with a warning and tells me that it's "Dead code". Any idea why this could be?

IGN: matte006

Played Minecraft since summer 2011.

Modding is my life now.

Please check out my mod :)

https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028

Link to comment
Share on other sites

If you want to scale a certain part of a model, you have to scale it, render it and then set the scale back to the original for the other parts not to be scaled.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

If you want to scale a certain part of a model, you have to scale it, render it and then set the scale back to the original for the other parts not to be scaled.

But can it be done without rendering it? As I said, it's a child model (a child of a child of a child to be exact), and child models shouldn't be rendered like normal. Instead, they are added to the parent through

ModelRenderer#addChild

in the constructor of the ModelRenderer class, and only the parent (in this case parent of the parent of the parent) is rendered like normal through

ModelRenderer#render

.

 

Here's my code for reference:

package themattyboy.mesozoicraft.entity.model;

import javax.annotation.Nullable;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.MathHelper;
import themattyboy.mesozoicraft.entity.prehistoric.carnivore.EntityVelociraptor;

public class ModelVelociraptor extends ModelBase {

    public ModelRenderer body;
    public ModelRenderer chest;
    public ModelRenderer neck;
    public ModelRenderer head;
    public ModelRenderer snout;
    public ModelRenderer jaw;
    public ModelRenderer tailOrigin;
    public ModelRenderer tailMiddle;
    public ModelRenderer tailTip;
    public ModelRenderer thighLeft;
    public ModelRenderer shinLeft;
    public ModelRenderer thighRight;
    public ModelRenderer shinRight;
    public ModelRenderer footLeft;
    public ModelRenderer footRight;
    public ModelRenderer toeLeft;
    public ModelRenderer toeRight;
    public ModelRenderer clawLowerLeft;
    public ModelRenderer clawLowerRight;
    public ModelRenderer clawUpperLeft;
    public ModelRenderer clawUpperRight;
    public ModelRenderer upperArmLeft;
    public ModelRenderer upperArmRight;
    public ModelRenderer lowerArmLeft;
    public ModelRenderer lowerArmRight;
    public ModelRenderer handLeft;
    public ModelRenderer handRight;
    public ModelRenderer armFeatherLeft;
    public ModelRenderer armFeatherRight;
    public ModelRenderer tailFeather;
    public ModelRenderer headFeatherLeft;
    public ModelRenderer headFeatherRight;
  
    public ModelVelociraptor() {
    	textureWidth = 64;
    	textureHeight = 64;
    	
    	body = new ModelRenderer(this, 0, 26);
    	body.addBox(-2F, 0F, -8F, 4, 3, ;
    	body.setRotationPoint(0F, 16F, 4F);
    	body.setTextureSize(64, 64);
    	body.mirror = false;
    	setRotation(body, -0.0523599F, 0F, 0F);
    	chest = new ModelRenderer(this, 0, 13);
    	chest.addBox(-1.533333F, 0F, -10F, 3, 3, 10);
    	chest.setRotationPoint(0F, 0F, 0F);
    	chest.setTextureSize(64, 64);
    	chest.mirror = false;
    	setRotation(chest, 0.0523599F, 0F, 0F);
    	neck = new ModelRenderer(this, 0, 6);
    	neck.addBox(-1F, 0F, -5F, 2, 2, 5);
    	neck.setRotationPoint(0F, 0F, -8F);
    	neck.setTextureSize(64, 64);
    	neck.mirror = false;
    	setRotation(neck, -0.6108652F, 0F, 0F);
    	head = new ModelRenderer(this, 0, 0);
    	head.addBox(-1.5F, 0F, -3F, 3, 3, 3);
    	head.setRotationPoint(0F, 0F, -5F);
    	head.setTextureSize(64, 64);
    	head.mirror = false;
    	setRotation(head, 0.0872665F + 0.6108652F, 0F, 0F);
    	snout = new ModelRenderer(this, 12, 0);
    	snout.addBox(-1F, 0F, -3F, 2, 2, 3);
    	snout.setRotationPoint(0F, 0F, -3F);
    	snout.setTextureSize(64, 64);
    	snout.mirror = false;
    	setRotation(snout, 0.0872665F, 0F, 0F);
    	jaw = new ModelRenderer(this, 22, 0);
    	jaw.addBox(-1F, 0F, -2F, 2, 1, 2);
    	jaw.setRotationPoint(0F, 2F, -3F);
    	jaw.setTextureSize(64, 64);
    	jaw.mirror = false;
    	setRotation(jaw, 0F, 0F, 0F);
    	tailOrigin = new ModelRenderer(this, 0, 37);
    	tailOrigin.addBox(-1.5F, 0F, 0F, 3, 3, 6);
    	tailOrigin.setRotationPoint(0F, 0F, -2F);
    	tailOrigin.setTextureSize(64, 64);
    	tailOrigin.mirror = false;
    	setRotation(tailOrigin, 0.2617994F, 0F, 0F);
    	tailMiddle = new ModelRenderer(this, 0, 46);
    	tailMiddle.addBox(-1F, 0F, 0F, 2, 2, 5);
    	tailMiddle.setRotationPoint(0F, 0F, 6F);
    	tailMiddle.setTextureSize(64, 64);
    	tailMiddle.mirror = false;
    	setRotation(tailMiddle, -0.2617994F, 0F, 0F);
    	tailTip = new ModelRenderer(this, 0, 53);
    	tailTip.addBox(-0.5F, 0F, 0F, 1, 1, 4);
    	tailTip.setRotationPoint(0F, 0F, 5F);
    	tailTip.setTextureSize(64, 64);
    	tailTip.mirror = false;
    	setRotation(tailTip, -0.1745329F, 0F, 0F);
    	thighLeft = new ModelRenderer(this, 56, 0);
    	thighLeft.addBox(0F, -1F, -1F, 2, 6, 2);
    	thighLeft.setRotationPoint(1F, 2F, -3F);
    	thighLeft.setTextureSize(64, 64);
    	thighLeft.mirror = false;
    	setRotation(thighLeft, -0.7853982F, 0F, 0F);
    	shinLeft = new ModelRenderer(this, 52, ;
    	shinLeft.addBox(-0.5F, -1F, 0F, 1, 1, 5);
    	shinLeft.setRotationPoint(1F, 5F, 0F);
    	shinLeft.setTextureSize(64, 64);
    	shinLeft.mirror = false;
    	setRotation(shinLeft, 0.7853982F, 0F, 0F);
    	thighRight = new ModelRenderer(this, 56, 0);
    	thighRight.addBox(-2F, -1F, -1F, 2, 6, 2);
    	thighRight.setRotationPoint(-1F, 2F, -3F);
    	thighRight.setTextureSize(64, 64);
    	thighRight.mirror = true;
    	setRotation(thighRight, -0.7853982F, 0F, 0F);
    	shinRight = new ModelRenderer(this, 52, ;
    	shinRight.addBox(-0.5F, -1F, 0F, 1, 1, 5);
    	shinRight.setRotationPoint(-1F, 5F, 0F);
    	shinRight.setTextureSize(64, 64);
    	shinRight.mirror = true;
    	setRotation(shinRight, 0.7853982F, 0F, 0F);
    	footLeft = new ModelRenderer(this, 58, 14);
    	footLeft.addBox(-1F, 0F, 0F, 2, 4, 1);
    	footLeft.setRotationPoint(0F, -1F, 5F);
    	footLeft.setTextureSize(64, 64);
    	footLeft.mirror = false;
    	setRotation(footLeft, -0.7853982F, 0F, 0F);
    	footRight = new ModelRenderer(this, 58, 14);
    	footRight.addBox(-1F, 0F, 0F, 2, 4, 1);
    	footRight.setRotationPoint(0F, -1F, 5F);
    	footRight.setTextureSize(64, 64);
    	footRight.mirror = true;
    	setRotation(footRight, -0.7853982F, 0F, 0F);
    	toeLeft = new ModelRenderer(this, 56, 19);
    	toeLeft.addBox(0F, -1F, -3F, 1, 1, 3);
    	toeLeft.setRotationPoint(0F, 4F, 1F);
    	toeLeft.setTextureSize(64, 64);
    	toeLeft.mirror = false;
    	setRotation(toeLeft, 0.7853982F, -0.1745329F, 0F);
    	toeRight = new ModelRenderer(this, 56, 19);
    	toeRight.addBox(-1F, -1F, -3F, 1, 1, 3);
    	toeRight.setRotationPoint(0F, 4F, 1F);
    	toeRight.setTextureSize(64, 64);
    	toeRight.mirror = true;
    	setRotation(toeRight, 0.7853982F, 0.1745329F, 0F);
    	clawLowerLeft = new ModelRenderer(this, 60, 23);
    	clawLowerLeft.addBox(-0.5F, -2F, -1F, 1, 2, 1);
    	clawLowerLeft.setRotationPoint(-0.55F, 4F, 1F);
    	clawLowerLeft.setTextureSize(64, 64);
    	clawLowerLeft.mirror = false;
    	setRotation(clawLowerLeft, 0.7853982F, 0F, 0F);
    	clawLowerRight = new ModelRenderer(this, 60, 23);
    	clawLowerRight.addBox(-0.5F, -2F, -1F, 1, 2, 1);
    	clawLowerRight.setRotationPoint(0.55F, 4F, 1F);
    	clawLowerRight.setTextureSize(64, 64);
    	clawLowerRight.mirror = true;
    	setRotation(clawLowerRight, 0.7853982F, 0F, 0F);
    	clawUpperLeft = new ModelRenderer(this, 60, 26);
    	clawUpperLeft.addBox(-0.5F, 0F, -1F, 1, 1, 1);
    	clawUpperLeft.setRotationPoint(0F, -2F, -1F);
    	clawUpperLeft.setTextureSize(64, 64);
    	clawUpperLeft.mirror = false;
    	setRotation(clawUpperLeft, 0F, 0F, 0F);
    	clawUpperRight = new ModelRenderer(this, 60, 26);
    	clawUpperRight.addBox(-0.5F, 0F, -1F, 1, 1, 1);
    	clawUpperRight.setRotationPoint(0F, -2F, -1F);
    	clawUpperRight.setTextureSize(64, 64);
    	clawUpperRight.mirror = true;
    	setRotation(clawUpperRight, 0F, 0F, 0F);
    	upperArmLeft = new ModelRenderer(this, 30, 0);
    	upperArmLeft.addBox(0F, 0F, 0F, 1, 3, 1);
    	upperArmLeft.setRotationPoint(1.5F, 1F, -9F);
    	upperArmLeft.setTextureSize(64, 64);
    	upperArmLeft.mirror = false;
    	setRotation(upperArmLeft, 0.1745329F, 0F, 0F);
    	upperArmRight = new ModelRenderer(this, 30, 0);
    	upperArmRight.addBox(-1F, 0F, 0F, 1, 3, 1);
    	upperArmRight.setRotationPoint(-1.5F, 1F, -9F);
    	upperArmRight.setTextureSize(64, 64);
    	upperArmRight.mirror = true;
    	setRotation(upperArmRight, 0.1745329F, 0F, 0F);
    	lowerArmLeft = new ModelRenderer(this, 30, 4);
    	lowerArmLeft.addBox(-1F, 0F, -1F, 1, 2, 1);
    	lowerArmLeft.setRotationPoint(0.9F, 3F, 1F);
    	lowerArmLeft.setTextureSize(64, 64);
    	lowerArmLeft.mirror = false;
    	setRotation(lowerArmLeft, -0.3926991F - 0.1745329F, 0F, 0F);
    	lowerArmRight = new ModelRenderer(this, 30, 4);
    	lowerArmRight.addBox(0F, 0F, -1F, 1, 2, 1);
    	lowerArmRight.setRotationPoint(-0.9F, 3F, 1F);
    	lowerArmRight.setTextureSize(64, 64);
    	lowerArmRight.mirror = true;
    	setRotation(lowerArmRight, -0.3926991F - 0.1745329F, 0F, 0F);
    	handLeft = new ModelRenderer(this, 30, 7);
    	handLeft.addBox(-0.5F, 0F, 0F, 1, 2, 1);
    	handLeft.setRotationPoint(-0.4F, 2F, -1F);
    	handLeft.setTextureSize(64, 64);
    	handLeft.mirror = false;
    	setRotation(handLeft, 0.1745329F + 0.3926991F, 0F, 0F);
    	handRight = new ModelRenderer(this, 30, 7);
    	handRight.addBox(-0.5F, 0F, 0F, 1, 2, 1);
    	handRight.setRotationPoint(0.4F, 2F, -1F);
    	handRight.setTextureSize(64, 64);
    	handRight.mirror = true;
    	setRotation(handRight, 0.1745329F + 0.3926991F, 0F, 0F);
        armFeatherLeft = new ModelRenderer(this, 62, 28);
        armFeatherLeft.addBox(0F, 0F, 0F, 0, 2, 1);
        armFeatherLeft.setRotationPoint(-0.5F, 0F, 0F);
        armFeatherLeft.setTextureSize(64, 64);
        armFeatherLeft.mirror = true;
        setRotation(armFeatherLeft, 0F, 0F, 0F);
        armFeatherRight = new ModelRenderer(this, 62, 28);
        armFeatherRight.addBox(0F, 0F, 0F, 0, 2, 1);
        armFeatherRight.setRotationPoint(0.5F, 0F, 0F);
        armFeatherRight.setTextureSize(64, 64);
        armFeatherRight.mirror = true;
        setRotation(armFeatherRight, 0F, 0F, 0F);
        armFeatherRight.mirror = false;
        tailFeather = new ModelRenderer(this, 0, 58);
        tailFeather.addBox(-2.5F, 0F, -6F, 5, 0, 6);
        tailFeather.setRotationPoint(0F, 0.5F, 4F);
        tailFeather.setTextureSize(64, 64);
        tailFeather.mirror = true;
        setRotation(tailFeather, 0F, 0F, 0F);
        headFeatherLeft = new ModelRenderer(this, 34, 0);
        headFeatherLeft.addBox(0F, -4F, 0F, 0, 4, 6);
        headFeatherLeft.setRotationPoint(0.5F, 1F, -6F);
        headFeatherLeft.setTextureSize(64, 64);
        headFeatherLeft.mirror = true;
        setRotation(headFeatherLeft, 0, 0F, 0F);
        headFeatherLeft.mirror = false;
        headFeatherRight = new ModelRenderer(this, 34, 0);
        headFeatherRight.addBox(0F, -4F, 0F, 0, 4, 6);
        headFeatherRight.setRotationPoint(-0.5F, 1F, -6F);
        headFeatherRight.setTextureSize(64, 64);
        headFeatherRight.mirror = true;
        setRotation(headFeatherRight, 0F, 0F, 0F);
      
    	body.addChild(chest);
    	chest.addChild(neck);
    	neck.addChild(head);
    	head.addChild(snout);
    	head.addChild(jaw);
    	chest.addChild(tailOrigin);
    	tailOrigin.addChild(tailMiddle);
    	tailMiddle.addChild(tailTip);
    	chest.addChild(thighLeft);
    	chest.addChild(thighRight);
    	thighLeft.addChild(shinLeft);
    	thighRight.addChild(shinRight);
    	shinLeft.addChild(footLeft);
    	shinRight.addChild(footRight);
    	footLeft.addChild(toeLeft);
    	footRight.addChild(toeRight);
    	footLeft.addChild(clawLowerLeft);
    	footRight.addChild(clawLowerRight);
    	clawLowerLeft.addChild(clawUpperLeft);
    	clawLowerRight.addChild(clawUpperRight);
    	chest.addChild(upperArmLeft);
    	chest.addChild(upperArmRight);
    	upperArmLeft.addChild(lowerArmLeft);
    	upperArmRight.addChild(lowerArmRight);
    	lowerArmLeft.addChild(handLeft);
    	lowerArmRight.addChild(handRight);
    	lowerArmLeft.addChild(armFeatherLeft);
    	lowerArmRight.addChild(armFeatherRight);
    	tailTip.addChild(tailFeather);
    	neck.addChild(headFeatherLeft);
    	neck.addChild(headFeatherRight);
    }
  
    public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    	super.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
    	setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
    	body.render(scale);
    }
  
    private void setRotation(ModelRenderer model, float x, float y, float z) {
    	model.rotateAngleX = x;
    	model.rotateAngleY = y;
    	model.rotateAngleZ = z;
    }
  
    public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float headYaw, float headPitch, float scale, Entity entity) {
    	super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, headYaw, headPitch, scale, entity);
    
    	EntityVelociraptor raptor = (EntityVelociraptor)entity;
    	
    	this.scaleHead(body, raptor);
    	
    	this.tailOrigin.rotateAngleY = MathHelper.cos(ageInTicks * 0.075F) * 0.8F * -0.2F + MathHelper.cos(limbSwing * 0.4F) * 0.4F * limbSwingAmount;
    	this.tailMiddle.rotateAngleY = MathHelper.cos(ageInTicks * 0.075F - (float)Math.PI / 3) * 0.6F * -0.2F + MathHelper.cos(limbSwing * 0.4F - (float)Math.PI / 3) * 0.2F * limbSwingAmount;
    	this.tailTip.rotateAngleY = MathHelper.cos(ageInTicks * 0.075F - (float)Math.PI / 2) * 0.4F * -0.2F + MathHelper.cos(limbSwing * 0.4F - (float)Math.PI / 2) * 0.1F * limbSwingAmount;
    
    	this.tailOrigin.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F) * 0.2F * -0.2F + 0.2617994F;
    	this.tailMiddle.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F - (float)Math.PI / 3) * 0.1F * -0.2F - 0.2617994F;
    	this.tailTip.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F - (float)Math.PI / 2) * 0.05F * -0.2F - 0.1745329F;
    
    	this.head.rotateAngleX = headPitch / (180F / (float)Math.PI) + 0.0872665F + 0.6108652F;
    	this.head.rotateAngleY = (headYaw / (180F / (float)Math.PI)) * 0.7F;
    	this.neck.rotateAngleY = (headYaw / (180F / (float)Math.PI)) * 0.3F;
    
    	this.neck.rotateAngleX = -MathHelper.cos(ageInTicks * 0.15F) * 0.4F * -0.2F + (headPitch / (180F / (float)Math.PI)) * 0.3F - 0.6108652F;
    	this.head.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F + (float)Math.PI / 5) * 0.4F * -0.2F + (headPitch / (180F / (float)Math.PI)) * 0.3F + 0.0872665F + 0.6108652F;
    	
    	this.body.rotateAngleX = -MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount - 0.0523599F;
    	this.body.offsetY = MathHelper.cos(ageInTicks * 0.15F) * 0.005F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount;
    	this.body.offsetZ = -MathHelper.cos(ageInTicks * 0.15F) * 0.01F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount;
    	
    	this.body.rotateAngleZ = MathHelper.cos(limbSwing * 0.4F) * 0.075F * limbSwingAmount;
    
    	this.thighLeft.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.1F * limbSwingAmount - 0.7853982F;
    	this.thighRight.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.4F) * 0.1F * limbSwingAmount - 0.7853982F;
    
    	this.shinLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI + (float)Math.PI / 4) * 0.2F * limbSwingAmount + 0.7853982F;
    	this.shinRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI / 4) * 0.2F * limbSwingAmount + 0.7853982F;
    
    	this.footLeft.rotateAngleX = MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.4F * limbSwingAmount + MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount - 0.7853982F;
    	this.footRight.rotateAngleX = MathHelper.cos(limbSwing * 0.4F) * 0.4F * limbSwingAmount + MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount - 0.7853982F;
    	
    	this.toeLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.7F * limbSwingAmount - MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount + 0.7853982F;
    	this.toeRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F) * 0.7F * limbSwingAmount - MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount + 0.7853982F;
    	
    	this.clawLowerLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.7F * limbSwingAmount - MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount + 0.7853982F;
    	this.clawLowerRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F) * 0.7F * limbSwingAmount - MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount + 0.7853982F;
    
    	this.upperArmLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.3F * limbSwingAmount + 0.1745329F;
    	this.upperArmRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F) * 0.3F * limbSwingAmount + 0.1745329F;
    
    	this.lowerArmLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI + (float)Math.PI / 4) * 0.7F * limbSwingAmount - 0.3926991F - 0.1745329F;
    	this.lowerArmRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI / 4) * 0.7F * limbSwingAmount - 0.3926991F - 0.1745329F;
    
    	this.handLeft.rotateAngleX = MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.7F * limbSwingAmount + 0.1745329F + 0.3926991F;
    	this.handRight.rotateAngleX = MathHelper.cos(limbSwing * 0.4F) * 0.7F * limbSwingAmount + 0.1745329F + 0.3926991F;
    	
    	if(raptor.isMouthOpen()) {
    		this.jaw.rotateAngleX = (float)Math.PI / 4;
    	}
    	else {
    		this.jaw.rotateAngleX = 0;
    	}
    	
    	if(limbSwing > 0) {
    		this.neck.rotateAngleX += 0.7F * limbSwingAmount;
    		this.head.rotateAngleX -= 0.7F * limbSwingAmount;
    		
    		this.tailOrigin.rotateAngleX -= 0.3F * limbSwingAmount;
    		this.tailMiddle.rotateAngleX += 0.3F * limbSwingAmount;
    		this.tailTip.rotateAngleX += 0.3F * limbSwingAmount;
    		
    		this.shinLeft.rotateAngleX += 0.4F * limbSwingAmount;
    		this.shinRight.rotateAngleX += 0.4F * limbSwingAmount;
    		
    		this.footLeft.rotateAngleX += 0.7F * limbSwingAmount;
    		this.footRight.rotateAngleX += 0.7F * limbSwingAmount;
    		
    		this.toeLeft.rotateAngleX -= 0.7F * limbSwingAmount;
    		this.toeRight.rotateAngleX -= 0.7F * limbSwingAmount;
    		
    		this.clawLowerLeft.rotateAngleX -= 0.7F * limbSwingAmount;
    		this.clawLowerRight.rotateAngleX -= 0.7F * limbSwingAmount;
    	}
    }
    
    @Nullable
    private ModelRenderer scaleHead(ModelRenderer currentBox, EntityVelociraptor raptor) {
    	for(int i = 0; i < currentBox.childModels.size(); i++) {
    		ModelRenderer box = currentBox.childModels.get(i);
    		if(box == head) {
    			//stuff to scale the head
    			return box;
    		}
    		else {
    			this.scaleHead(box, raptor);
    			return null;
    		}
    	}
	return null;
    }
}

IGN: matte006

Played Minecraft since summer 2011.

Modding is my life now.

Please check out my mod :)

https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028

Link to comment
Share on other sites

I'm sorry, but it's been two days since my last post and I would really appreciate some help...

Quick question. Why are you using recursion? If you already know where the head is just get it that way. Hint they should be in the order that you add them under. And they should still be in the same hierarchy that you added them. And unless the addChild creates a new field then you should just be able to call scale your variable called head.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Quick question. Why are you using recursion? If you already know where the head is just get it that way. Hint they should be in the order that you add them under. And they should still be in the same hierarchy that you added them.

I know I could, but I'm thinking that I might make a super class for this model and a few others that share similar properties, and by doing this I can easily move the method to that class and insert another parameter to let you find and scale any box you like in the model, if I decide to make the super class that is. Always good to keep the possibility open.

And unless the addChild creates a new field then you should just be able to call scale your variable called head.

That's the thing: I don't know how. What you would normally do to scale a part of a model is push a glMatrix around where you render it and scale it with GL11, but since I'm not rendering the box since the parent box does the rendering for it, this isn't really an option. And ModelRenderers don't have a native method for scaling them, besides setting the size of the box in pixels (not what I want), so I can't just simply "scale [my] variable called head".

IGN: matte006

Played Minecraft since summer 2011.

Modding is my life now.

Please check out my mod :)

https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028

Link to comment
Share on other sites

That's the thing: I don't know how. What you would normally do to scale a part of a model is push a glMatrix around where you render it and scale it with GL11, but since I'm not rendering the box since the parent box does the rendering for it, this isn't really an option. And ModelRenderers don't have a native method for scaling them, besides setting the size of the box in pixels (not what I want), so I can't just simply "scale [my] variable called head".

Scaling is just multiplying, so you need to write a method that changes the dimensions of the cubes that are in the model. And probably keep the cube centered on where it is.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.