mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Make animations closer to classic. (Thanks goodlyay)
This commit is contained in:
parent
b56edd2dad
commit
01e6f92b72
@ -29,7 +29,6 @@ namespace ClassicalSharp {
|
|||||||
swingN -= (float)delta * 3;
|
swingN -= (float)delta * 3;
|
||||||
}
|
}
|
||||||
Utils.Clamp( ref swingN, 0, 1 );
|
Utils.Clamp( ref swingN, 0, 1 );
|
||||||
UpdateHumanState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const float armMax = 60 * Utils.Deg2Rad;
|
const float armMax = 60 * Utils.Deg2Rad;
|
||||||
@ -59,65 +58,25 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
internal float leftXRot, leftYRot, leftZRot;
|
internal float leftXRot, leftYRot, leftZRot;
|
||||||
internal float rightXRot, rightYRot, rightZRot;
|
internal float rightXRot, rightYRot, rightZRot;
|
||||||
ArmsAnim animMode = ArmsAnim.NoPerpendicular;
|
bool complexArms;
|
||||||
int statesDone;
|
|
||||||
static Random rnd = new Random();
|
|
||||||
|
|
||||||
void UpdateHumanState() {
|
|
||||||
if( game.SimpleArmsAnim ) {
|
|
||||||
animMode = ArmsAnim.NoPerpendicular;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// crosses over body, finished an arm swing
|
|
||||||
int oldState = Math.Sign( Math.Cos( walkTimeO ) );
|
|
||||||
int newState = Math.Sign( Math.Cos( walkTimeN ) );
|
|
||||||
if( oldState != newState )
|
|
||||||
statesDone++;
|
|
||||||
|
|
||||||
// should we switch animations?
|
|
||||||
if( statesDone == 5 ) {
|
|
||||||
statesDone = 0;
|
|
||||||
animMode = (ArmsAnim)rnd.Next( 0, 4 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalcHumanAnim( float idleXRot, float idleZRot ) {
|
void CalcHumanAnim( float idleXRot, float idleZRot ) {
|
||||||
switch( animMode ) {
|
if( game.SimpleArmsAnim ) {
|
||||||
case ArmsAnim.NoPerpendicular:
|
leftXRot = armXRot; leftYRot = 0; leftZRot = armZRot;
|
||||||
leftXRot = armXRot; leftYRot = 0; leftZRot = armZRot;
|
rightXRot = -armXRot; rightYRot = 0; rightZRot = -armZRot;
|
||||||
rightXRot = -armXRot; rightYRot = 0; rightZRot = -armZRot;
|
} else {
|
||||||
return;
|
PerpendicularAnim( 0.23f, out leftXRot, out leftYRot, out leftZRot );
|
||||||
case ArmsAnim.LeftPerpendicular:
|
PerpendicularAnim( 0.28f, out rightXRot, out rightYRot, out rightZRot );
|
||||||
PerpendicularAnim( out leftXRot, out leftYRot, out leftZRot );
|
rightXRot = -rightXRot; rightZRot = -rightZRot;
|
||||||
rightXRot = -armXRot; rightYRot = 0; rightZRot = -armZRot;
|
|
||||||
return;
|
|
||||||
case ArmsAnim.RightPerpendicular:
|
|
||||||
leftXRot = armXRot; leftYRot = 0; leftZRot = armZRot;
|
|
||||||
PerpendicularAnim( out rightXRot, out rightYRot, out rightZRot );
|
|
||||||
rightXRot = -rightXRot; rightZRot = -rightZRot;
|
|
||||||
return;
|
|
||||||
case ArmsAnim.BothPerpendicular:
|
|
||||||
PerpendicularAnim( out leftXRot, out leftYRot, out leftZRot );
|
|
||||||
PerpendicularAnim( out rightXRot, out rightYRot, out rightZRot );
|
|
||||||
rightXRot = -rightXRot; rightZRot = -rightZRot;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const float maxAngle = 90 * Utils.Deg2Rad;
|
const float maxAngle = 120 * Utils.Deg2Rad;
|
||||||
void PerpendicularAnim( out float xRot, out float yRot, out float zRot ) {
|
void PerpendicularAnim( float flapSpeed, out float xRot, out float yRot, out float zRot ) {
|
||||||
xRot = 0;
|
|
||||||
yRot = 0;
|
|
||||||
yRot = (float)(Math.Cos( walkTime ) * swing * armMax * 1.5f);
|
yRot = (float)(Math.Cos( walkTime ) * swing * armMax * 1.5f);
|
||||||
float angle = (float)(1 + 0.3 * Math.Sin( walkTime ) );
|
xRot = 0;
|
||||||
|
float angle = (float)(0.5 + 0.5 * Math.Sin( walkTime * flapSpeed ) );
|
||||||
zRot = -angle * swing * maxAngle;
|
zRot = -angle * swing * maxAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ArmsAnim {
|
|
||||||
NoPerpendicular, // i.e. both parallel
|
|
||||||
LeftPerpendicular,
|
|
||||||
RightPerpendicular,
|
|
||||||
BothPerpendicular,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -73,10 +73,8 @@ namespace ClassicalSharp.Model {
|
|||||||
DrawPart( model.Torso );
|
DrawPart( model.Torso );
|
||||||
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, model.LeftLeg );
|
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, model.LeftLeg );
|
||||||
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, model.RightLeg );
|
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, model.RightLeg );
|
||||||
Rotate = RotateOrder.XZY;
|
|
||||||
DrawRotate( -6/16f, 22/16f, 0, p.leftXRot, p.leftYRot, p.leftZRot, model.LeftArm );
|
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 );
|
DrawRotate( 6/16f, 22/16f, 0, p.rightXRot, p.rightYRot, p.rightZRot, model.RightArm );
|
||||||
Rotate = RotateOrder.ZYX;
|
|
||||||
graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
|
graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
|
||||||
|
|
||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user