diff --git a/src/client/java/com/minelittlepony/client/model/components/BatWings.java b/src/client/java/com/minelittlepony/client/model/components/BatWings.java index 12e18481..424f85fa 100644 --- a/src/client/java/com/minelittlepony/client/model/components/BatWings.java +++ b/src/client/java/com/minelittlepony/client/model/components/BatWings.java @@ -3,6 +3,7 @@ package com.minelittlepony.client.model.components; import net.minecraft.client.renderer.GlStateManager; import com.minelittlepony.client.model.AbstractPonyModel; +import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.model.IPegasus; import java.util.UUID; @@ -15,13 +16,9 @@ public class BatWings extends PegasusWin @Override public void init(float yOffset, float stretch) { - leftWing = new ModelBatWing<>(pegasus, false, false, yOffset, stretch, 16); - rightWing = new ModelBatWing<>(pegasus, true, false, yOffset, stretch, 16); - } - - @Override - public ModelWing getRight() { - return rightWing; + leftWing = new Wing(pegasus, false, false, yOffset, stretch, 16); + rightWing = new Wing(pegasus, true, false, yOffset, stretch, 16); + legacyWing = rightWing; } @Override @@ -34,4 +31,61 @@ public class BatWings extends PegasusWin GlStateManager.popMatrix(); } + + public class Wing extends PegasusWings.Wing { + + public Wing(T pegasus, boolean right, boolean legacy, float y, float scale, int texY) { + super(pegasus, right, legacy, y, scale, texY); + } + + @Override + protected void addClosedWing(boolean right, float y, float scale) { + float x = right ? -4 : 3; + + folded.around(HEAD_RP_X, WING_FOLDED_RP_Y + y - 1, WING_FOLDED_RP_Z - 2) + .mirror(right) + .tex(56, 16).box(x * 0.9F, 5, 4, 1, 4, 1, scale) + .tex(56, 16).box(x, 5, 6, 1, 7, 1, scale) + .box(x, 5, 5, 1, 6, 1, scale) + .tex(56, 16).box(x * 0.9F, 5, 7, 1, 7, 1, scale) + .rotateAngleX = ROTATE_90; + } + + @Override + protected void addFeathers(boolean right, boolean l, float rotationPointY, float scale) { + float r = right ? -1 : 1; + + extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY - 1, EXT_WING_RP_Z - 3) + .mirror(right) + .rotateAngleY = r * 3; + + extended.child().tex(60, 16) + .mirror(right) // children are unaware of their parents being mirrored, sadly + .rotate(0.1F, 0, 0) + .box(-0.5F, -1, 0, 1, 8, 1, scale + 0.001F) // this was enough to fix z-fighting + .child().tex(60, 16) + .mirror(right) + .rotate(-0.5F, 0, 0) + .around(0, -1, -2) + .box(-0.5F, 0, 2, 1, 7, 1, scale); + extended.child(0) + .child().tex(60, 16) + .mirror(right) + .rotate(-0.5F, 0, 0) + .around(0, 4, -2.4F) + .box(-0.5F, 0, 3, 1, 7, 1, scale); + + PlaneRenderer skin = new PlaneRenderer(pegasus) + .tex(56, 32) + .mirror(right) + .west(0, 0, -7, 16, 8, scale); + + extended.child(0).child(skin); + } + + @Override + public void rotateWalking(float swing) { + folded.rotateAngleY = swing * 0.05F; + } + } } diff --git a/src/client/java/com/minelittlepony/client/model/components/BugWings.java b/src/client/java/com/minelittlepony/client/model/components/BugWings.java index 3076e8f8..6fcb364c 100644 --- a/src/client/java/com/minelittlepony/client/model/components/BugWings.java +++ b/src/client/java/com/minelittlepony/client/model/components/BugWings.java @@ -1,6 +1,7 @@ package com.minelittlepony.client.model.components; import com.minelittlepony.client.model.AbstractPonyModel; +import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.model.IPegasus; public class BugWings extends PegasusWings { @@ -11,12 +12,47 @@ public class BugWings extends PegasusWin @Override public void init(float yOffset, float stretch) { - leftWing = new ModelBugWing<>(pegasus, false, false, yOffset, stretch, 16); - rightWing = new ModelBugWing<>(pegasus, true, false, yOffset, stretch, 16); + leftWing = new Wing(pegasus, false, false, yOffset, stretch, 16); + rightWing = new Wing(pegasus, true, false, yOffset, stretch, 16); + legacyWing = rightWing; } - @Override - public ModelWing getRight() { - return rightWing; + public class Wing extends PegasusWings.Wing { + + public Wing(T pegasus, boolean right, boolean legacy, float y, float scale, int texY) { + super(pegasus, right, legacy, y, scale, texY); + } + + @Override + protected void addClosedWing(boolean right, float y, float scale) { + + } + + @Override + protected void addFeathers(boolean right, boolean l, float rotationPointY, float scale) { + float r = right ? -1 : 1; + + extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z - 2) + .mirror(right) + .rotateAngleY = r * 3; + + PlaneRenderer primary = new PlaneRenderer(pegasus) + .tex(56, 16) + .mirror(right) + .west(r * -0.5F, 0, -7, 16, 8, scale); + PlaneRenderer secondary = new PlaneRenderer(pegasus) + .tex(56, 32) + .rotate(-0.5F, r * 0.3F, r / 3) + .mirror(right) + .west(r, 0, -5, 16, 8, scale); + + extended.child(primary); + extended.child(secondary); + } + + @Override + public void render(float scale) { + extended.render(scale); + } } } diff --git a/src/client/java/com/minelittlepony/client/model/components/ModelBatWing.java b/src/client/java/com/minelittlepony/client/model/components/ModelBatWing.java deleted file mode 100644 index 912dae62..00000000 --- a/src/client/java/com/minelittlepony/client/model/components/ModelBatWing.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.minelittlepony.client.model.components; - -import com.minelittlepony.client.model.AbstractPonyModel; -import com.minelittlepony.client.util.render.plane.PlaneRenderer; -import com.minelittlepony.model.IPegasus; - -public class ModelBatWing extends ModelWing { - - public ModelBatWing(T pegasus, boolean right, boolean legacy, float y, float scale, int texY) { - super(pegasus, right, legacy, y, scale, texY); - } - - @Override - protected void addClosedWing(boolean right, float y, float scale) { - float x = right ? -4 : 3; - - folded.around(HEAD_RP_X, WING_FOLDED_RP_Y + y - 1, WING_FOLDED_RP_Z - 2) - .mirror(right) - .tex(56, 16).box(x * 0.9F, 5, 4, 1, 4, 1, scale) - .tex(56, 16).box(x, 5, 6, 1, 7, 1, scale) - .box(x, 5, 5, 1, 6, 1, scale) - .tex(56, 16).box(x * 0.9F, 5, 7, 1, 7, 1, scale) - .rotateAngleX = ROTATE_90; - } - - @Override - protected void addFeathers(boolean right, boolean l, float rotationPointY, float scale) { - float r = right ? -1 : 1; - - extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY - 1, EXT_WING_RP_Z - 3) - .mirror(right) - .rotateAngleY = r * 3; - - extended.child().tex(60, 16) - .mirror(right) // children are unaware of their parents being mirrored, sadly - .rotate(0.1F, 0, 0) - .box(-0.5F, -1, 0, 1, 8, 1, scale + 0.001F) // this was enough to fix z-fighting - .child().tex(60, 16) - .mirror(right) - .rotate(-0.5F, 0, 0) - .around(0, -1, -2) - .box(-0.5F, 0, 2, 1, 7, 1, scale); - extended.child(0) - .child().tex(60, 16) - .mirror(right) - .rotate(-0.5F, 0, 0) - .around(0, 4, -2.4F) - .box(-0.5F, 0, 3, 1, 7, 1, scale); - - PlaneRenderer skin = new PlaneRenderer(pegasus) - .tex(56, 32) - .mirror(right) - .west(0, 0, -7, 16, 8, scale); - - extended.child(0).child(skin); - } - - @Override - public void rotateWalking(float swing) { - folded.rotateAngleY = swing * 0.05F; - } -} diff --git a/src/client/java/com/minelittlepony/client/model/components/ModelBugWing.java b/src/client/java/com/minelittlepony/client/model/components/ModelBugWing.java deleted file mode 100644 index e4637010..00000000 --- a/src/client/java/com/minelittlepony/client/model/components/ModelBugWing.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.minelittlepony.client.model.components; - -import com.minelittlepony.client.model.AbstractPonyModel; -import com.minelittlepony.client.util.render.plane.PlaneRenderer; -import com.minelittlepony.model.IPegasus; - -public class ModelBugWing extends ModelWing { - - public ModelBugWing(T pegasus, boolean right, boolean legacy, float y, float scale, int texY) { - super(pegasus, right, legacy, y, scale, texY); - } - - @Override - protected void addClosedWing(boolean right, float y, float scale) { - - } - - @Override - protected void addFeathers(boolean right, boolean l, float rotationPointY, float scale) { - float r = right ? -1 : 1; - - extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z - 2) - .mirror(right) - .rotateAngleY = r * 3; - - PlaneRenderer primary = new PlaneRenderer(pegasus) - .tex(56, 16) - .mirror(right) - .west(r * -0.5F, 0, -7, 16, 8, scale); - PlaneRenderer secondary = new PlaneRenderer(pegasus) - .tex(56, 32) - .rotate(-0.5F, r * 0.3F, r / 3) - .mirror(right) - .west(r, 0, -5, 16, 8, scale); - - extended.child(primary); - extended.child(secondary); - } - - @Override - public void render(float scale) { - extended.render(scale); - } -} diff --git a/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java b/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java index 4791b093..6ae72146 100644 --- a/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java +++ b/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java @@ -27,9 +27,10 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated implements PonyModelConstants { - - protected final T pegasus; - - protected final PonyRenderer extended; - protected final PonyRenderer folded; - - public ModelWing(T pegasus, boolean right, boolean legacy, float y, float scale, int texY) { - this.pegasus = pegasus; - - folded = new PonyRenderer(pegasus, 56, texY).mirror(legacy); - extended = new PonyRenderer(pegasus, 56 + ((!right || legacy) ? 1 : 0), texY + 3); - - addClosedWing(right, y, scale); - addFeathers(right, legacy, y, scale); - } - - protected void addClosedWing(boolean right, float y, float scale) { - float x = right ? -6 : 4; - - folded.around(HEAD_RP_X, WING_FOLDED_RP_Y + y, WING_FOLDED_RP_Z) - .box(x, 5, 2, 2, 6, 2, scale) - .box(x, 5, 4, 2, 8, 2, scale) - .box(x, 5, 6, 2, 6, 2, scale) - .rotateAngleX = ROTATE_90; - } - - protected void addFeathers(boolean right, boolean l, float rotationPointY, float scale) { - float r = right ? -1 : 1; - - extended.around(r * EXT_WING_RP_X, EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z) - .rotateAngleY = r * 3; - addFeather(0, l, 6, 0, 9, scale + 0.1F); - addFeather(1, l, -1, -0.3F, 8, scale + 0.1F) .rotateAngleX = -0.85F; - addFeather(2, l, 1.8F, 1.3F, 8, scale - 0.1F) .rotateAngleX = -0.75F; - addFeather(3, l, 5, 2, 8, scale) .rotateAngleX = -0.5F; - addFeather(4, l, 0, -0.2F, 6, scale + 0.3F); - addFeather(5, l, 0, 0, 3, scale + 0.19F).rotateAngleX = -0.85F; - } - - private PonyRenderer addFeather(int i, boolean l, float y, float z, int h, float scale) { - return extended.child(i).around(0, 0, 0).mirror(l).box(-0.5F, y, z, 1, h, 2, scale); - } - - public void rotateWalking(float swing) { - folded.rotateAngleY = swing * 0.15F; - } - - public void rotateFlying(float angle) { - extended.rotateAngleZ = angle; - } - - public void render(float scale) { - if (pegasus.wingsAreOpen()) { - extended.render(scale); - } else { - boolean bags = pegasus.isWearing(Wearable.SADDLE_BAGS); - if (bags) { - GlStateManager.pushMatrix(); - GlStateManager.translatef(0, 0, 0.198F); - } - folded.render(scale); - if (bags) { - GlStateManager.popMatrix(); - } - } - } -} diff --git a/src/client/java/com/minelittlepony/client/model/components/PegasusWings.java b/src/client/java/com/minelittlepony/client/model/components/PegasusWings.java index b7a40a25..0a6e0e90 100644 --- a/src/client/java/com/minelittlepony/client/model/components/PegasusWings.java +++ b/src/client/java/com/minelittlepony/client/model/components/PegasusWings.java @@ -1,24 +1,25 @@ package com.minelittlepony.client.model.components; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.model.AbstractPonyModel; +import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.model.IPart; import com.minelittlepony.model.IPegasus; +import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.pony.meta.Wearable; import java.util.UUID; -import static com.minelittlepony.model.PonyModelConstants.*; - -public class PegasusWings implements IPart { +public class PegasusWings implements IPart, PonyModelConstants { protected final T pegasus; - protected ModelWing leftWing; - protected ModelWing rightWing; + protected Wing leftWing; + protected Wing rightWing; - protected ModelWing legacyWing; + protected Wing legacyWing; public PegasusWings(T model, float yOffset, float stretch) { pegasus = model; @@ -28,17 +29,17 @@ public class PegasusWings implements IPa @Override public void init(float yOffset, float stretch) { - leftWing = new ModelWing<>(pegasus, false, false, yOffset, stretch, 32); - rightWing = new ModelWing<>(pegasus, true, false, yOffset, stretch, 16); + leftWing = new Wing(pegasus, false, false, yOffset, stretch, 32); + rightWing = new Wing(pegasus, true, false, yOffset, stretch, 16); - legacyWing = new ModelWing<>(pegasus, true, true, yOffset, stretch, 32); + legacyWing = new Wing(pegasus, true, true, yOffset, stretch, 32); } - public ModelWing getLeft() { + public Wing getLeft() { return leftWing; } - public ModelWing getRight() { + public Wing getRight() { return pegasus.isWearing(Wearable.SADDLE_BAGS) ? legacyWing : rightWing; } @@ -84,4 +85,73 @@ public class PegasusWings implements IPa getLeft().render(scale); getRight().render(scale); } + + public class Wing { + + protected final T pegasus; + + protected final PonyRenderer extended; + protected final PonyRenderer folded; + + public Wing(T pegasus, boolean right, boolean legacy, float y, float scale, int texY) { + this.pegasus = pegasus; + + folded = new PonyRenderer(pegasus, 56, texY).mirror(legacy); + extended = new PonyRenderer(pegasus, 56 + ((!right || legacy) ? 1 : 0), texY + 3); + + addClosedWing(right, y, scale); + addFeathers(right, legacy, y, scale); + } + + protected void addClosedWing(boolean right, float y, float scale) { + float x = right ? -6 : 4; + + folded.around(HEAD_RP_X, WING_FOLDED_RP_Y + y, WING_FOLDED_RP_Z) + .box(x, 5, 2, 2, 6, 2, scale) + .box(x, 5, 4, 2, 8, 2, scale) + .box(x, 5, 6, 2, 6, 2, scale) + .rotateAngleX = ROTATE_90; + } + + protected void addFeathers(boolean right, boolean l, float rotationPointY, float scale) { + float r = right ? -1 : 1; + + extended.around(r * EXT_WING_RP_X, EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z) + .rotateAngleY = r * 3; + addFeather(0, l, 6, 0, 9, scale + 0.1F); + addFeather(1, l, -1, -0.3F, 8, scale + 0.1F) .rotateAngleX = -0.85F; + addFeather(2, l, 1.8F, 1.3F, 8, scale - 0.1F) .rotateAngleX = -0.75F; + addFeather(3, l, 5, 2, 8, scale) .rotateAngleX = -0.5F; + addFeather(4, l, 0, -0.2F, 6, scale + 0.3F); + addFeather(5, l, 0, 0, 3, scale + 0.19F).rotateAngleX = -0.85F; + } + + private PonyRenderer addFeather(int i, boolean l, float y, float z, int h, float scale) { + return extended.child(i).around(0, 0, 0).mirror(l).box(-0.5F, y, z, 1, h, 2, scale); + } + + public void rotateWalking(float swing) { + folded.rotateAngleY = swing * 0.15F; + } + + public void rotateFlying(float angle) { + extended.rotateAngleZ = angle; + } + + public void render(float scale) { + if (pegasus.wingsAreOpen()) { + extended.render(scale); + } else { + boolean bags = pegasus.isWearing(Wearable.SADDLE_BAGS); + if (bags) { + GlStateManager.pushMatrix(); + GlStateManager.translatef(0, 0, 0.198F); + } + folded.render(scale); + if (bags) { + GlStateManager.popMatrix(); + } + } + } + } }