More work on player arms animation. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2015-12-20 20:54:57 +11:00
parent 01e6f92b72
commit a094406585
2 changed files with 15 additions and 15 deletions

View file

@ -56,27 +56,25 @@ namespace ClassicalSharp {
CalcHumanAnim( idleXRot, idleZRot );
}
internal float leftXRot, leftYRot, leftZRot;
internal float rightXRot, rightYRot, rightZRot;
bool complexArms;
internal float leftXRot, leftZRot, rightXRot, rightZRot;
void CalcHumanAnim( float idleXRot, float idleZRot ) {
if( game.SimpleArmsAnim ) {
leftXRot = armXRot; leftYRot = 0; leftZRot = armZRot;
rightXRot = -armXRot; rightYRot = 0; rightZRot = -armZRot;
leftXRot = armXRot; leftZRot = armZRot;
rightXRot = -armXRot; rightZRot = -armZRot;
} else {
PerpendicularAnim( 0.23f, out leftXRot, out leftYRot, out leftZRot );
PerpendicularAnim( 0.28f, out rightXRot, out rightYRot, out rightZRot );
PerpendicularAnim( 0.23f, idleXRot, idleZRot, out leftXRot, out leftZRot );
PerpendicularAnim( 0.28f, idleXRot, idleZRot, out rightXRot, out rightZRot );
rightXRot = -rightXRot; rightZRot = -rightZRot;
}
}
const float maxAngle = 120 * Utils.Deg2Rad;
void PerpendicularAnim( float flapSpeed, out float xRot, out float yRot, out float zRot ) {
yRot = (float)(Math.Cos( walkTime ) * swing * armMax * 1.5f);
xRot = 0;
float angle = (float)(0.5 + 0.5 * Math.Sin( walkTime * flapSpeed ) );
zRot = -angle * swing * maxAngle;
void PerpendicularAnim( float flapSpeed, float idleXRot, float idleZRot,
out float xRot, out float zRot ) {
float verAngle = (float)(0.5 + 0.5 * Math.Sin( walkTime * flapSpeed ) );
zRot = -idleZRot - verAngle * swing * maxAngle;
float horAngle = (float)(Math.Cos( walkTime ) * swing * armMax * 1.5f);
xRot = idleXRot + horAngle;
}
}
}

View file

@ -73,8 +73,10 @@ namespace ClassicalSharp.Model {
DrawPart( model.Torso );
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, model.LeftLeg );
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, model.RightLeg );
DrawRotate( -6/16f, 22/16f, 0, p.leftXRot, p.leftYRot, p.leftZRot, model.LeftArm );
DrawRotate( 6/16f, 22/16f, 0, p.rightXRot, p.rightYRot, p.rightZRot, model.RightArm );
Rotate = RotateOrder.XZY;
DrawRotate( -6/16f, 22/16f, 0, p.leftXRot, 0, p.leftZRot, model.LeftArm );
DrawRotate( 6/16f, 22/16f, 0, p.rightXRot, 0, p.rightZRot, model.RightArm );
Rotate = RotateOrder.ZYX;
graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
graphics.AlphaTest = true;