mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-25 14:14:46 -04:00
better model animation, fix sitting model
This commit is contained in:
parent
04cef2f247
commit
27c8512100
@ -14,13 +14,13 @@ namespace ClassicalSharp.Entities {
|
||||
this.game = game;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public float legXRot, armXRot, armZRot;
|
||||
|
||||
public float bobbingHor, bobbingVer, bobbingModel, tiltX, tiltY;
|
||||
public float walkTime, swing, bobStrength = 1, velTiltStrength = 1;
|
||||
|
||||
public float walkTime, swing, bobStrength = 1, velTiltStrength = 1;
|
||||
internal float walkTimeO, walkTimeN, swingO, swingN;
|
||||
public float leftXRot, leftZRot, rightXRot, rightZRot;
|
||||
|
||||
public float leftLegX, leftLegZ, rightLegX, rightLegZ;
|
||||
public float leftArmX, leftArmZ, rightArmX, rightArmZ;
|
||||
|
||||
/// <summary> Calculates the next animation state based on old and new position. </summary>
|
||||
public void UpdateAnimState(Vector3 oldPos, Vector3 newPos, double delta) {
|
||||
@ -54,9 +54,13 @@ namespace ClassicalSharp.Entities {
|
||||
float idleXRot = (float)(Math.Sin(idleTime * idleXPeriod) * idleMax);
|
||||
float idleZRot = (float)(idleMax + Math.Cos(idleTime * idleZPeriod) * idleMax);
|
||||
|
||||
armXRot = (float)(Math.Cos(walkTime) * swing * armMax) - idleXRot;
|
||||
legXRot = -(float)(Math.Cos(walkTime) * swing * legMax);
|
||||
armZRot = -idleZRot;
|
||||
leftArmX = (float)(Math.Cos(walkTime) * swing * armMax) - idleXRot;
|
||||
leftArmZ = -idleZRot;
|
||||
leftLegX = -(float)(Math.Cos(walkTime) * swing * legMax);
|
||||
leftLegZ = 0;
|
||||
|
||||
rightLegX = -leftLegX; rightLegZ = -leftLegZ;
|
||||
rightArmX = -leftArmX; rightArmZ = -leftArmZ;
|
||||
|
||||
bobbingHor = (float)(Math.Cos(walkTime) * swing * (2.5f/16f));
|
||||
bobbingVer = (float)(Math.Abs(Math.Sin(walkTime)) * swing * (2.5f/16f));
|
||||
@ -71,7 +75,7 @@ namespace ClassicalSharp.Entities {
|
||||
tiltY = (float)Math.Sin(walkTime) * swing * (0.15f * Utils.Deg2Rad);
|
||||
}
|
||||
|
||||
if (entity.Model.CalcHumanAnims)
|
||||
if (entity.Model.CalcHumanAnims && !game.SimpleArmsAnim)
|
||||
CalcHumanAnim(idleXRot, idleZRot);
|
||||
}
|
||||
|
||||
@ -82,14 +86,9 @@ namespace ClassicalSharp.Entities {
|
||||
}
|
||||
|
||||
void CalcHumanAnim(float idleXRot, float idleZRot) {
|
||||
if (game.SimpleArmsAnim) {
|
||||
leftXRot = armXRot; leftZRot = armZRot;
|
||||
rightXRot = -armXRot; rightZRot = -armZRot;
|
||||
} else {
|
||||
PerpendicularAnim(0.23f, idleXRot, idleZRot, out leftXRot, out leftZRot);
|
||||
PerpendicularAnim(0.28f, idleXRot, idleZRot, out rightXRot, out rightZRot);
|
||||
rightXRot = -rightXRot; rightZRot = -rightZRot;
|
||||
}
|
||||
PerpendicularAnim(0.23f, idleXRot, idleZRot, out leftArmX, out leftArmZ);
|
||||
PerpendicularAnim(0.28f, idleXRot, idleZRot, out rightArmX, out rightArmZ);
|
||||
rightArmX = -rightArmX; rightArmZ = -rightArmZ;
|
||||
}
|
||||
|
||||
const float maxAngle = 110 * Utils.Deg2Rad;
|
||||
|
@ -62,15 +62,15 @@ namespace ClassicalSharp.Model {
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Head3, true);
|
||||
|
||||
DrawPart(Torso);
|
||||
DrawRotate(0, 0, -Math.Abs(p.anim.armXRot), LeftWing, false);
|
||||
DrawRotate(0, 0, Math.Abs(p.anim.armXRot), RightWing, false);
|
||||
DrawRotate(0, 0, -Math.Abs(p.anim.leftArmX), LeftWing, false);
|
||||
DrawRotate(0, 0, Math.Abs(p.anim.leftArmX), RightWing, false);
|
||||
|
||||
int col = cols[0];
|
||||
for (int i = 0; i < cols.Length; i++) {
|
||||
cols[i] = FastColour.ScalePacked(col, 0.7f);
|
||||
}
|
||||
DrawRotate(p.anim.legXRot, 0, 0, LeftLeg, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, RightLeg, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, LeftLeg, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, RightLeg, false);
|
||||
UpdateVB();
|
||||
}
|
||||
|
||||
|
@ -55,10 +55,10 @@ namespace ClassicalSharp.Model {
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
|
||||
|
||||
DrawPart(Torso);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, LeftLegFront, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, RightLegFront, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, LeftLegBack, false);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, RightLegBack, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, LeftLegFront, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, RightLegFront, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, LeftLegBack, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, RightLegBack, false);
|
||||
UpdateVB();
|
||||
}
|
||||
|
||||
|
@ -62,15 +62,16 @@ namespace ClassicalSharp.Model {
|
||||
public override AABB PickingBounds {
|
||||
get { return new AABB(-8/16f, 0, -4/16f, 8/16f, (32 - sitOffset)/16f, 4/16f); }
|
||||
}
|
||||
|
||||
|
||||
protected override Matrix4 TransformMatrix(Entity p, Vector3 pos) {
|
||||
pos.Y -= sitOffset / 16f;
|
||||
return Matrix4.RotateY((float)game.accumulator) * p.TransformMatrix(p.ModelScale, pos);
|
||||
return p.TransformMatrix(p.ModelScale, pos);
|
||||
}
|
||||
|
||||
public override void DrawModel(Entity p) {
|
||||
p.anim.legXRot = 1.5f;
|
||||
p.anim.leftLegX = 1.5f; p.anim.rightLegX = 1.5f;
|
||||
p.anim.leftLegZ = -0.1f; p.anim.rightLegZ = 0.1f;
|
||||
|
||||
IModel model = game.ModelCache.Models[0].Instance;
|
||||
model.SetupState(p);
|
||||
model.DrawModel(p);
|
||||
|
@ -102,11 +102,11 @@ namespace ClassicalSharp.Model {
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, model.Head, true);
|
||||
DrawPart(model.Torso);
|
||||
|
||||
DrawRotate(p.anim.legXRot, 0, 0, model.LeftLeg, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, model.RightLeg, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, p.anim.leftLegZ, model.LeftLeg, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, p.anim.rightLegZ, model.RightLeg, false);
|
||||
Rotate = RotateOrder.XZY;
|
||||
DrawRotate(p.anim.leftXRot, 0, p.anim.leftZRot, model.LeftArm, false);
|
||||
DrawRotate(p.anim.rightXRot, 0, p.anim.rightZRot, model.RightArm, false);
|
||||
DrawRotate(p.anim.leftArmX, 0, p.anim.leftArmZ, model.LeftArm, false);
|
||||
DrawRotate(p.anim.rightArmX, 0, p.anim.rightArmZ, model.RightArm, false);
|
||||
Rotate = RotateOrder.ZYX;
|
||||
UpdateVB();
|
||||
|
||||
@ -114,11 +114,11 @@ namespace ClassicalSharp.Model {
|
||||
index = 0;
|
||||
if (skinType != SkinType.Type64x32) {
|
||||
DrawPart(model.TorsoLayer);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, model.LeftLegLayer, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, model.RightLegLayer, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, model.LeftLegLayer, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, model.RightLegLayer, false);
|
||||
Rotate = RotateOrder.XZY;
|
||||
DrawRotate(p.anim.leftXRot, 0, p.anim.leftZRot, model.LeftArmLayer, false);
|
||||
DrawRotate(p.anim.rightXRot, 0, p.anim.rightZRot, model.RightArmLayer, false);
|
||||
DrawRotate(p.anim.leftArmX, 0, p.anim.leftArmZ, model.LeftArmLayer, false);
|
||||
DrawRotate(p.anim.rightArmX, 0, p.anim.rightArmZ, model.RightArmLayer, false);
|
||||
Rotate = RotateOrder.ZYX;
|
||||
}
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, model.Hat, true);
|
||||
|
@ -54,10 +54,10 @@ namespace ClassicalSharp.Model {
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
|
||||
|
||||
DrawPart(Torso);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, LeftLegFront, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, RightLegFront, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, LeftLegBack, false);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, RightLegBack, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, LeftLegFront, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, RightLegFront, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, LeftLegBack, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, RightLegBack, false);
|
||||
UpdateVB();
|
||||
}
|
||||
|
||||
|
@ -88,10 +88,10 @@ namespace ClassicalSharp.Model {
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
|
||||
|
||||
DrawPart(Torso);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, LeftLegFront, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, RightLegFront, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, LeftLegBack, false);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, RightLegBack, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, LeftLegFront, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, RightLegFront, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, LeftLegBack, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, RightLegBack, false);
|
||||
UpdateVB();
|
||||
|
||||
if (Utils.CaselessEquals(p.ModelName, "sheep_nofur")) return;
|
||||
@ -100,10 +100,10 @@ namespace ClassicalSharp.Model {
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, FurHead, true);
|
||||
|
||||
DrawPart(FurTorso);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, FurLeftLegFront, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, FurRightLegFront, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, FurLeftLegBack, false);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, FurRightLegBack, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, FurLeftLegFront, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, FurRightLegFront, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, FurLeftLegBack, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, FurRightLegBack, false);
|
||||
UpdateVB();
|
||||
}
|
||||
|
||||
|
@ -49,10 +49,10 @@ namespace ClassicalSharp.Model {
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
|
||||
|
||||
DrawPart(Torso);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, LeftLeg, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, RightLeg, false);
|
||||
DrawRotate(90 * Utils.Deg2Rad, 0, p.anim.armZRot, LeftArm, false);
|
||||
DrawRotate(90 * Utils.Deg2Rad, 0, -p.anim.armZRot, RightArm, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, LeftLeg, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, RightLeg, false);
|
||||
DrawRotate(90 * Utils.Deg2Rad, 0, p.anim.leftArmZ, LeftArm, false);
|
||||
DrawRotate(90 * Utils.Deg2Rad, 0, p.anim.rightArmZ, RightArm, false);
|
||||
UpdateVB();
|
||||
}
|
||||
|
||||
|
@ -52,10 +52,10 @@ namespace ClassicalSharp.Model {
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
|
||||
|
||||
DrawPart(Torso);
|
||||
DrawRotate(p.anim.legXRot, 0, 0, LeftLeg, false);
|
||||
DrawRotate(-p.anim.legXRot, 0, 0, RightLeg, false);
|
||||
DrawRotate(90 * Utils.Deg2Rad, 0, p.anim.armZRot, LeftArm, false);
|
||||
DrawRotate(90 * Utils.Deg2Rad, 0, -p.anim.armZRot, RightArm, false);
|
||||
DrawRotate(p.anim.leftLegX, 0, 0, LeftLeg, false);
|
||||
DrawRotate(p.anim.rightLegX, 0, 0, RightLeg, false);
|
||||
DrawRotate(90 * Utils.Deg2Rad, 0, p.anim.leftArmZ, LeftArm, false);
|
||||
DrawRotate(90 * Utils.Deg2Rad, 0, p.anim.rightArmZ, RightArm, false);
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Hat, true);
|
||||
UpdateVB();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user