mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 13:57:59 +01:00
Fix lots of model animation errors.
This commit is contained in:
parent
53eaa3c40e
commit
9b437ca587
10 changed files with 50 additions and 160 deletions
|
@ -55,7 +55,7 @@ public abstract class AbstractPonyModel extends ModelPlayer {
|
|||
this.initTextures();
|
||||
this.initPositions(yOffset, stretch);
|
||||
for (IPonyPart part : modelParts) {
|
||||
part.init(this, yOffset, stretch);
|
||||
part.init(yOffset, stretch);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package com.brohoof.minelittlepony.model.part;
|
||||
|
||||
import com.brohoof.minelittlepony.PonyData;
|
||||
import com.brohoof.minelittlepony.model.BodyPart;
|
||||
import com.brohoof.minelittlepony.model.AbstractPonyModel;
|
||||
import com.brohoof.minelittlepony.model.BodyPart;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
public abstract class AbstractHeadPart implements IPonyPart {
|
||||
|
||||
private AbstractPonyModel pony;
|
||||
protected final AbstractPonyModel pony;
|
||||
|
||||
@Override
|
||||
public void init(AbstractPonyModel pony, float yOffset, float stretch) {
|
||||
public AbstractHeadPart(AbstractPonyModel pony) {
|
||||
this.pony = pony;
|
||||
}
|
||||
|
||||
|
@ -19,40 +18,11 @@ public abstract class AbstractHeadPart implements IPonyPart {
|
|||
public void render(PonyData data, float scale) {
|
||||
pony.transform(BodyPart.HEAD);
|
||||
GlStateManager.translate(pony.bipedHead.offsetX, pony.bipedHead.offsetY, pony.bipedHead.offsetZ);
|
||||
pony.bipedHead.postRender(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void animate(PonyData data, float move, float swing, float tick, float horz, float vert) {
|
||||
rotateHead(horz, vert);
|
||||
if (pony.isSneak && !pony.isFlying) {
|
||||
position(0, 6, -2);
|
||||
} else {
|
||||
position(0, 0, 0);
|
||||
}
|
||||
public void animate(PonyData metadata, float move, float swing, float tick, float horz, float vert) {
|
||||
|
||||
}
|
||||
|
||||
private void rotateHead(float horz, float vert) {
|
||||
float y;
|
||||
float x;
|
||||
if (pony.isSleeping) {
|
||||
y = 1.4F;
|
||||
x = 0.1F;
|
||||
} else {
|
||||
y = horz / (float) (180 / Math.PI);
|
||||
x = vert / (float) (180 / Math.PI);
|
||||
}
|
||||
x = Math.min(x, 0.5F);
|
||||
x = Math.max(x, -1.25F);
|
||||
|
||||
rotate(x, y);
|
||||
}
|
||||
|
||||
protected AbstractPonyModel getPony() {
|
||||
return pony;
|
||||
}
|
||||
|
||||
protected abstract void position(float posX, float posY, float posZ);
|
||||
|
||||
protected abstract void rotate(float rotX, float rotY);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package com.brohoof.minelittlepony.model.part;
|
||||
|
||||
import com.brohoof.minelittlepony.PonyData;
|
||||
import com.brohoof.minelittlepony.model.AbstractPonyModel;
|
||||
|
||||
public interface IPonyPart {
|
||||
|
||||
void init(AbstractPonyModel pony, float yOffset, float stretch);
|
||||
|
||||
void animate(PonyData metadata, float move, float moveswing, float loop, float right, float down);
|
||||
void init(float yOffset, float stretch);
|
||||
|
||||
void render(PonyData data, float scale);
|
||||
|
||||
void animate(PonyData metadata, float move, float swing, float tick, float horz, float vert);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.util.MathHelper;
|
|||
|
||||
public class PegasusWings implements IPonyPart, PonyModelConstants {
|
||||
|
||||
private AbstractPonyModel pony;
|
||||
private final AbstractPonyModel pony;
|
||||
|
||||
public ModelRenderer[] leftWing;
|
||||
public ModelRenderer[] rightWing;
|
||||
|
@ -18,10 +18,12 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
|
|||
public ModelRenderer[] leftWingExt;
|
||||
public ModelRenderer[] rightWingExt;
|
||||
|
||||
@Override
|
||||
public void init(AbstractPonyModel pony, float yOffset, float stretch) {
|
||||
public PegasusWings(AbstractPonyModel pony) {
|
||||
this.pony = pony;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(float yOffset, float stretch) {
|
||||
this.leftWing = new ModelRenderer[3];
|
||||
this.rightWing = new ModelRenderer[3];
|
||||
this.leftWingExt = new ModelRenderer[6];
|
||||
|
@ -110,7 +112,7 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
|
|||
|
||||
}
|
||||
|
||||
float angle = pony.isRiding ? (float) (Math.PI * .3) : ROTATE_90;
|
||||
float angle = ROTATE_90;
|
||||
|
||||
for (int i = 0; i < this.leftWing.length; i++) {
|
||||
this.leftWing[i].rotateAngleX = angle;
|
||||
|
@ -133,6 +135,7 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
|
|||
@Override
|
||||
public void render(PonyData data, float scale) {
|
||||
pony.transform(BodyPart.BODY);
|
||||
pony.bipedBody.postRender(scale);
|
||||
if (data.getRace() != null && data.getRace().hasWings()) {
|
||||
if (!pony.isFlying && !pony.isSneak) {
|
||||
|
||||
|
@ -158,46 +161,28 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
|
|||
|
||||
private void sneak() {
|
||||
for (int i = 0; i < this.leftWingExt.length; ++i) {
|
||||
this.leftWingExt[i].rotationPointY = LEFT_WING_RP_Y_SNEAK;
|
||||
this.leftWingExt[i].rotationPointZ = LEFT_WING_RP_Z_SNEAK;
|
||||
this.leftWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
||||
this.leftWingExt[i].rotateAngleZ = LEFT_WING_ROTATE_ANGLE_Z_SNEAK;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.leftWingExt.length; ++i) {
|
||||
this.rightWingExt[i].rotationPointY = RIGHT_WING_RP_Y_SNEAK;
|
||||
this.rightWingExt[i].rotationPointZ = RIGHT_WING_RP_Z_SNEAK;
|
||||
this.rightWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
||||
this.rightWingExt[i].rotateAngleZ = RIGHT_WING_ROTATE_ANGLE_Z_SNEAK;
|
||||
}
|
||||
}
|
||||
|
||||
private void unsneak(float tick) {
|
||||
if (!pony.isFlying) {
|
||||
for (int i = 0; i < this.leftWing.length; ++i) {
|
||||
this.leftWing[i].rotationPointY = WING_FOLDED_RP_Y;
|
||||
this.leftWing[i].rotationPointZ = WING_FOLDED_RP_Z;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.rightWing.length; ++i) {
|
||||
this.rightWing[i].rotationPointY = WING_FOLDED_RP_Y;
|
||||
this.rightWing[i].rotationPointZ = WING_FOLDED_RP_Z;
|
||||
}
|
||||
} else {
|
||||
if (pony.isFlying) {
|
||||
float WingRotateAngleZ = MathHelper.sin(tick * 0.536F) * 1.0F;
|
||||
|
||||
for (int i = 0; i < this.leftWingExt.length; ++i) {
|
||||
this.leftWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
||||
this.leftWingExt[i].rotateAngleZ = -WingRotateAngleZ - ROTATE_270 - 0.4F;
|
||||
this.leftWingExt[i].rotationPointY = LEFT_WING_RP_Y_NOTSNEAK;
|
||||
this.leftWingExt[i].rotationPointZ = LEFT_WING_RP_Z_NOTSNEAK;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.rightWingExt.length; ++i) {
|
||||
this.rightWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
||||
this.rightWingExt[i].rotateAngleZ = WingRotateAngleZ + ROTATE_270 + 0.4F;
|
||||
this.rightWingExt[i].rotationPointY = RIGHT_WING_RP_Y_NOTSNEAK;
|
||||
this.rightWingExt[i].rotationPointZ = RIGHT_WING_RP_Z_NOTSNEAK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,12 @@ public class PonyEars extends AbstractHeadPart implements PonyModelConstants {
|
|||
private ModelRenderer left;
|
||||
private ModelRenderer right;
|
||||
|
||||
public PonyEars(AbstractPonyModel pony) {
|
||||
super(pony);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(AbstractPonyModel pony, float yOffset, float stretch) {
|
||||
super.init(pony, yOffset, stretch);
|
||||
public void init(float yOffset, float stretch) {
|
||||
this.left = new ModelRenderer(pony, 12, 16);
|
||||
this.right = new ModelRenderer(pony, 12, 16);
|
||||
this.right.mirror = true;
|
||||
|
@ -24,20 +27,6 @@ public class PonyEars extends AbstractHeadPart implements PonyModelConstants {
|
|||
this.right.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void position(float posX, float posY, float posZ) {
|
||||
AbstractPonyModel.setRotationPoint(left, posX, posY, posZ);
|
||||
AbstractPonyModel.setRotationPoint(right, posX, posY, posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotate(float rotX, float rotY) {
|
||||
this.left.rotateAngleX = rotX;
|
||||
this.left.rotateAngleY = rotY;
|
||||
this.right.rotateAngleX = rotX;
|
||||
this.right.rotateAngleY = rotY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PonyData data, float scale) {
|
||||
super.render(data, scale);
|
||||
|
|
|
@ -17,9 +17,12 @@ public class PonySnout extends AbstractHeadPart implements PonyModelConstants {
|
|||
.put(PonyGender.STALLION, new PlaneRenderer[5])
|
||||
.build();
|
||||
|
||||
public PonySnout(AbstractPonyModel pony) {
|
||||
super(pony);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(AbstractPonyModel pony, float yOffset, float stretch) {
|
||||
super.init(pony, yOffset, stretch);
|
||||
public void init(float yOffset, float stretch) {
|
||||
|
||||
PlaneRenderer[] muzzle = MUZZLES.get(PonyGender.MARE);
|
||||
muzzle[0] = new PlaneRenderer(pony, 10, 14);
|
||||
|
@ -84,23 +87,4 @@ public class PonySnout extends AbstractHeadPart implements PonyModelConstants {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void position(float posX, float posY, float posZ) {
|
||||
for (PlaneRenderer[] pr : MUZZLES.values()) {
|
||||
for (PlaneRenderer p : pr) {
|
||||
AbstractPonyModel.setRotationPoint(p, posX, posY, posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotate(float rotX, float rotY) {
|
||||
for (PlaneRenderer[] pr : MUZZLES.values()) {
|
||||
for (PlaneRenderer p : pr) {
|
||||
p.rotateAngleX = rotX;
|
||||
p.rotateAngleY = rotY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,10 +16,12 @@ public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants
|
|||
private ModelRenderer horn;
|
||||
private HornGlowRenderer[] hornglow;
|
||||
|
||||
@Override
|
||||
public void init(AbstractPonyModel pony, float yOffset, float stretch) {
|
||||
super.init(pony, yOffset, stretch);
|
||||
public UnicornHorn(AbstractPonyModel pony) {
|
||||
super(pony);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(float yOffset, float stretch) {
|
||||
this.horn = new ModelRenderer(pony, 0, 3);
|
||||
this.hornglow = new HornGlowRenderer[2];
|
||||
for (int i = 0; i < hornglow.length; i++) {
|
||||
|
@ -28,11 +30,10 @@ public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants
|
|||
|
||||
this.horn.addBox(-0.5F + HEAD_CENTRE_X, -10.0F + HEAD_CENTRE_Y, -1.5F + HEAD_CENTRE_Z, 1, 4, 1, stretch);
|
||||
this.horn.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
||||
this.horn.rotateAngleX = 0.5F;
|
||||
|
||||
this.hornglow[0].addBox(-0.5F + HEAD_CENTRE_X, -10.0F + HEAD_CENTRE_Y, -1.5F + HEAD_CENTRE_Z, 1, 4, 1, stretch + 0.5F);
|
||||
this.hornglow[0].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
||||
this.hornglow[1].addBox(-0.5F + HEAD_CENTRE_X, -10.0F + HEAD_CENTRE_Y, -1.5F + HEAD_CENTRE_Z, 1, 3, 1, stretch + 0.8F);
|
||||
this.hornglow[1].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +41,7 @@ public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants
|
|||
super.render(data, scale);
|
||||
if (data.getRace() != null && data.getRace().hasHorn()) {
|
||||
this.horn.render(scale);
|
||||
if (getPony().heldItemRight != 0 && data.getGlowColor() != 0) {
|
||||
if (pony.heldItemRight != 0 && data.getGlowColor() != 0) {
|
||||
GL11.glPushAttrib(24577);
|
||||
disableTexture2D();
|
||||
disableLighting();
|
||||
|
@ -51,6 +52,8 @@ public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants
|
|||
float blue = (data.getGlowColor() & 255) / 255.0F;
|
||||
blendFunc(GL11.GL_SRC_ALPHA, 1);
|
||||
|
||||
this.horn.postRender(scale);
|
||||
|
||||
color(var4, green, blue, 0.4F);
|
||||
this.hornglow[0].render(scale);
|
||||
color(var4, green, blue, 0.2F);
|
||||
|
@ -64,24 +67,4 @@ public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void position(float posX, float posY, float posZ) {
|
||||
AbstractPonyModel.setRotationPoint(this.horn, posX, posY, posZ);
|
||||
for (int i = 0; i < this.hornglow.length; i++) {
|
||||
AbstractPonyModel.setRotationPoint(this.hornglow[i], posX, posY, posZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotate(float rotX, float rotY) {
|
||||
|
||||
this.horn.rotateAngleX = rotX + 0.5F;
|
||||
this.horn.rotateAngleY = rotY;
|
||||
|
||||
for (int i = 0; i < this.hornglow.length; i++) {
|
||||
this.hornglow[i].rotateAngleX = rotX + 0.5F;
|
||||
this.hornglow[i].rotateAngleY = rotY;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.brohoof.minelittlepony.model.part.UnicornHorn;
|
|||
import com.brohoof.minelittlepony.renderer.PlaneRenderer;
|
||||
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConstants {
|
||||
|
@ -34,10 +35,10 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
|
|||
}
|
||||
|
||||
protected void addParts() {
|
||||
modelParts.add(new PonyEars());
|
||||
modelParts.add(new PonySnout());
|
||||
modelParts.add(new UnicornHorn());
|
||||
modelParts.add(new PegasusWings());
|
||||
modelParts.add(new PonyEars(this));
|
||||
modelParts.add(new PonySnout(this));
|
||||
modelParts.add(new UnicornHorn(this));
|
||||
modelParts.add(new PegasusWings(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,6 +150,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
|
|||
|
||||
animateWears();
|
||||
|
||||
this.bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0;
|
||||
}
|
||||
|
||||
private void animateWears() {
|
||||
|
@ -471,7 +473,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
|
|||
protected void aimBowUnicorn(float tick) {
|
||||
this.unicornarm.rotateAngleZ = 0.0F;
|
||||
this.unicornarm.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY;
|
||||
this.unicornarm.rotateAngleX = ROTATE_270+ this.bipedHead.rotateAngleX;
|
||||
this.unicornarm.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX;
|
||||
this.unicornarm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.unicornarm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F;
|
||||
}
|
||||
|
@ -517,10 +519,10 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
|
|||
}
|
||||
|
||||
protected void renderNeck() {
|
||||
GlStateManager.scale(0.9, 0.9, 0.9);
|
||||
for (PlaneRenderer element : this.BodypieceNeck) {
|
||||
element.render(this.scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void renderBody() {
|
||||
|
@ -665,9 +667,9 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
|
|||
protected void initHeadPositions(float yOffset, float stretch) {
|
||||
this.bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch);
|
||||
this.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -4 + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch);
|
||||
this.bipedHead.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
||||
this.bipedHead.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2);
|
||||
this.bipedHeadwear.addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch + 0.5F);
|
||||
this.bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
||||
this.bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2);
|
||||
}
|
||||
|
||||
protected void initBodyPositions(float yOffset, float stretch) {
|
||||
|
|
|
@ -35,28 +35,11 @@ public class ModelVillagerPony extends ModelPlayerPony {
|
|||
this.VillagerTrinket.rotateAngleY = bodySwingRotation * 0.2F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
|
||||
super.adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
|
||||
|
||||
for (int i = 0; i < this.VillagerBagPiece.length; ++i) {
|
||||
this.VillagerBagPiece[i].rotateAngleX = rotateAngleX;
|
||||
this.VillagerBagPiece[i].rotationPointY = rotationPointY;
|
||||
this.VillagerBagPiece[i].rotationPointZ = rotationPointZ;
|
||||
}
|
||||
|
||||
this.VillagerApron.rotateAngleX = rotateAngleX;
|
||||
this.VillagerApron.rotationPointY = rotationPointY;
|
||||
this.VillagerApron.rotationPointZ = rotationPointZ;
|
||||
this.VillagerTrinket.rotateAngleX = rotateAngleX;
|
||||
this.VillagerTrinket.rotationPointY = rotationPointY;
|
||||
this.VillagerTrinket.rotationPointZ = rotationPointZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBody() {
|
||||
super.renderBody();
|
||||
|
||||
this.bipedBody.postRender(scale);
|
||||
if (profession < 2) {
|
||||
for (int i = 0; i < this.VillagerBagPiece.length; ++i) {
|
||||
this.VillagerBagPiece[i].render(this.scale);
|
||||
|
|
|
@ -40,9 +40,7 @@ public class LayerPonyCape implements LayerRenderer<AbstractClientPlayer> {
|
|||
pushMatrix();
|
||||
model.getModel().transform(BodyPart.BODY);
|
||||
translate(0.0F, 0.24F, 0.0F);
|
||||
if (clientPlayer.isRiding()) {
|
||||
rotate(-36, 1, 0, 0);
|
||||
}
|
||||
model.getModel().bipedBody.postRender(scale);
|
||||
|
||||
double d = clientPlayer.prevChasingPosX + (clientPlayer.chasingPosX - clientPlayer.prevChasingPosX) * scale
|
||||
- (clientPlayer.prevPosX + (clientPlayer.posX - clientPlayer.prevPosX) * scale);
|
||||
|
@ -73,9 +71,6 @@ public class LayerPonyCape implements LayerRenderer<AbstractClientPlayer> {
|
|||
f12 += MathHelper.sin((clientPlayer.prevDistanceWalkedModified
|
||||
+ (clientPlayer.distanceWalkedModified - clientPlayer.prevDistanceWalkedModified) * scale) * 6.0F)
|
||||
* 32.0F * f15;
|
||||
if (clientPlayer.isSneaking()) {
|
||||
f12 += 25.0F;
|
||||
}
|
||||
|
||||
rotate(2.0F + f13 / 12.0F + f12, 1.0F, 0.0F, 0.0F);
|
||||
rotate(f14 / 2.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
|
Loading…
Reference in a new issue