diff --git a/ClassicalSharp/Entities/Components/AnimatedComponent.cs b/ClassicalSharp/Entities/Components/AnimatedComponent.cs index 021796f05..0fe2312b1 100644 --- a/ClassicalSharp/Entities/Components/AnimatedComponent.cs +++ b/ClassicalSharp/Entities/Components/AnimatedComponent.cs @@ -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; /// Calculates the next animation state based on old and new position. 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; diff --git a/ClassicalSharp/Entities/Model/ChickenModel.cs b/ClassicalSharp/Entities/Model/ChickenModel.cs index 4e2edb449..5bb8bd7d6 100644 --- a/ClassicalSharp/Entities/Model/ChickenModel.cs +++ b/ClassicalSharp/Entities/Model/ChickenModel.cs @@ -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(); } diff --git a/ClassicalSharp/Entities/Model/CreeperModel.cs b/ClassicalSharp/Entities/Model/CreeperModel.cs index e523a6a2e..f7d74358d 100644 --- a/ClassicalSharp/Entities/Model/CreeperModel.cs +++ b/ClassicalSharp/Entities/Model/CreeperModel.cs @@ -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(); } diff --git a/ClassicalSharp/Entities/Model/HumanModels.cs b/ClassicalSharp/Entities/Model/HumanModels.cs index 85e21f865..0f29a9e01 100644 --- a/ClassicalSharp/Entities/Model/HumanModels.cs +++ b/ClassicalSharp/Entities/Model/HumanModels.cs @@ -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); diff --git a/ClassicalSharp/Entities/Model/HumanoidModel.cs b/ClassicalSharp/Entities/Model/HumanoidModel.cs index faee14009..432bf5693 100644 --- a/ClassicalSharp/Entities/Model/HumanoidModel.cs +++ b/ClassicalSharp/Entities/Model/HumanoidModel.cs @@ -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); diff --git a/ClassicalSharp/Entities/Model/PigModel.cs b/ClassicalSharp/Entities/Model/PigModel.cs index 62cbabe85..21964cd8c 100644 --- a/ClassicalSharp/Entities/Model/PigModel.cs +++ b/ClassicalSharp/Entities/Model/PigModel.cs @@ -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(); } diff --git a/ClassicalSharp/Entities/Model/SheepModel.cs b/ClassicalSharp/Entities/Model/SheepModel.cs index 5545ed5bb..bb89ed0a9 100644 --- a/ClassicalSharp/Entities/Model/SheepModel.cs +++ b/ClassicalSharp/Entities/Model/SheepModel.cs @@ -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(); } diff --git a/ClassicalSharp/Entities/Model/SkeletonModel.cs b/ClassicalSharp/Entities/Model/SkeletonModel.cs index 193d965b8..bf0e11ba7 100644 --- a/ClassicalSharp/Entities/Model/SkeletonModel.cs +++ b/ClassicalSharp/Entities/Model/SkeletonModel.cs @@ -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(); } diff --git a/ClassicalSharp/Entities/Model/ZombieModel.cs b/ClassicalSharp/Entities/Model/ZombieModel.cs index 9e13a7739..3f2b36de9 100644 --- a/ClassicalSharp/Entities/Model/ZombieModel.cs +++ b/ClassicalSharp/Entities/Model/ZombieModel.cs @@ -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(); }