2018-04-25 12:59:18 +02:00
|
|
|
package com.minelittlepony.model.components;
|
|
|
|
|
2018-04-24 16:46:53 +02:00
|
|
|
import net.minecraft.client.model.ModelRenderer;
|
|
|
|
|
2018-04-25 12:59:18 +02:00
|
|
|
import static com.minelittlepony.model.PonyModelConstants.*;
|
|
|
|
|
2018-04-25 16:40:47 +02:00
|
|
|
import com.minelittlepony.model.AbstractPonyModel;
|
|
|
|
|
2018-04-24 16:46:53 +02:00
|
|
|
// TODO: Combine each wing into one ModelRenderer with multiple boxes, not multiple ModelRenderers each with one box.
|
2018-04-25 12:59:18 +02:00
|
|
|
public class ModelWing {
|
2018-04-24 16:46:53 +02:00
|
|
|
public ModelRenderer[] folded = new ModelRenderer[3],
|
|
|
|
extended = new ModelRenderer[6];
|
|
|
|
|
|
|
|
public ModelWing(AbstractPonyModel pony, boolean mirror, float xOffset, float yOffset, float stretch, int texY) {
|
|
|
|
|
|
|
|
// TODO: Don't add the model to the pony if you're just going to remove it again.
|
|
|
|
for (int i = 0; i < folded.length; i++) {
|
|
|
|
folded[i] = new ModelRenderer(pony, 56, texY);
|
|
|
|
pony.boxList.remove(folded[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < extended.length; i++) {
|
|
|
|
extended[i] = new ModelRenderer(pony, 56, texY + 3);
|
|
|
|
pony.boxList.remove(extended[i]);
|
|
|
|
// this seems to hide the wings being a different size when folded
|
|
|
|
extended[i].mirror = mirror;
|
|
|
|
}
|
|
|
|
|
2018-04-24 21:24:29 +02:00
|
|
|
init(xOffset, yOffset, stretch);
|
2018-04-24 16:46:53 +02:00
|
|
|
addFeathers(mirror ? -1 : 1, yOffset, stretch);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addFeathers(float r, float y, float scale) {
|
|
|
|
addFeather(0, r, y, 6.0F, 0.0F, 8, scale + 0.1F);
|
|
|
|
addFeather(1, r, y, -1.2F, -0.2F, 8, scale + 0.2F);
|
|
|
|
addFeather(2, r, y, 1.8F, 1.3F, 8, scale - 0.1F);
|
|
|
|
addFeather(3, r, y, 5.0F, 2.0F, 8, scale);
|
|
|
|
addFeather(4, r, y, 0.0F, -0.2F, 6, scale + 0.3F);
|
|
|
|
addFeather(5, r, y, 0.0F, 0.2F, 3, scale + 0.19F);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addFeather(int i, float r, float Y, float y, float z, int h, float scale) {
|
|
|
|
extended[i].addBox(-0.5f, y, z, 1, h, 2, scale);
|
|
|
|
extended[i].setRotationPoint(r * LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + Y, LEFT_WING_EXT_RP_Z);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void init(float x, float y, float scale) {
|
2018-04-24 17:12:23 +02:00
|
|
|
initFeather(folded[0], y, x, 2F, 6, scale);
|
|
|
|
initFeather(folded[1], y, x, 4F, 8, scale);
|
|
|
|
initFeather(folded[2], y, x, 6F, 6, scale);
|
2018-04-24 16:46:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void initFeather(ModelRenderer wing, float y, float x, float z, int h, float scale) {
|
|
|
|
wing.addBox(x, 5f, z, 2, h, 2, scale);
|
|
|
|
wing.setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + y, WING_FOLDED_RP_Z);
|
|
|
|
wing.rotateAngleX = ROTATE_90;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateModelRotation(float swing) {
|
|
|
|
for (ModelRenderer feather : folded) {
|
|
|
|
feather.rotateAngleY = swing * 0.2F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void rotate(float angle) {
|
|
|
|
for (ModelRenderer feather : folded) {
|
|
|
|
feather.rotateAngleX = angle;
|
|
|
|
}
|
|
|
|
// Special
|
|
|
|
extended[1].rotateAngleX -= 0.85F;
|
|
|
|
extended[2].rotateAngleX -= 0.75F;
|
|
|
|
extended[3].rotateAngleX -= 0.5F;
|
|
|
|
extended[5].rotateAngleX -= 0.85F;
|
|
|
|
}
|
|
|
|
|
2018-04-24 17:12:23 +02:00
|
|
|
public void render(boolean standing, float scale) {
|
|
|
|
for (ModelRenderer feather : (standing ? folded : extended)) {
|
2018-04-24 16:46:53 +02:00
|
|
|
feather.render(scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void rotateSneaked(float rotZ) {
|
|
|
|
for (ModelRenderer feather : extended) {
|
|
|
|
feather.rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
|
|
|
feather.rotateAngleZ = rotZ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void rotateUnsneaked(float angle) {
|
|
|
|
for (ModelRenderer aLeftWingExt : extended) {
|
|
|
|
aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
|
|
|
aLeftWingExt.rotateAngleZ = -angle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|