Пытаюсь создать моба, но как только использую setChild, части моба встают криво. Про то что нужно правильно рассчитать rotationPoint и rotateAngle знаю, для этого использую функцию convertToChild. Помогите, кто разбирается.
Java:
public static class ModelMan extends ModelBase {
// fields
ModelRenderer Shape1;
ModelRenderer Shape2;
ModelRenderer Shape3;
public ModelMan() {
textureWidth = 64;
textureHeight = 32;
Shape1 = new ModelRenderer(this, 0, 0);
Shape1.addBox(-3F, -6F, -3F, 6, 6, 6);
Shape1.setRotationPoint(0F, 15F, 0F);
Shape1.setTextureSize(64, 32);
setRotation(Shape1, 0F, 0F, 0F);
Shape2 = new ModelRenderer(this, 0, 0);
Shape2.addBox(0F, 0F, 0F, 1, 4, 1);
Shape2.setRotationPoint(3F, 10F, 0F);
Shape2.setTextureSize(64, 32);
setRotation(Shape2, 27F, 0F, 0F);
Shape3 = new ModelRenderer(this, 0, 0);
Shape3.addBox(0F, 0F, 0F, 1, 5, 1);
Shape3.setRotationPoint(3F, 13F, 2.6F);
Shape3.setTextureSize(64, 32);
setRotation(Shape3, -80F, 0F, 0F);
convertToChild(Shape2, Shape3);
}
protected void convertToChild(ModelRenderer parParent, ModelRenderer parChild) {
// move child rotation point to be relative to parent
parChild.rotationPointX -= parParent.rotationPointX;
parChild.rotationPointY -= parParent.rotationPointY;
parChild.rotationPointZ -= parParent.rotationPointZ;
// make rotations relative to parent
parChild.rotateAngleX -= parParent.rotateAngleX;
parChild.rotateAngleY -= parParent.rotateAngleY;
parChild.rotateAngleZ -= parParent.rotateAngleZ;
// create relationship
parParent.addChild(parChild);
}
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);
Shape1.render(f5);
Shape2.render(f5);
}
protected float degToRad(float degrees) {
return degrees * (float) Math.PI / 180;
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = degToRad(x);
model.rotateAngleY = degToRad(y);
model.rotateAngleZ = degToRad(z);
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
}
}
}