Fix some of current text in top left not having font changed, hopefully improve view bobbing somewhat.

This commit is contained in:
UnknownShadow200 2015-11-24 11:04:29 +11:00
parent 30c4384d66
commit 1c5ef409ed
6 changed files with 28 additions and 26 deletions

View File

@ -83,7 +83,6 @@ namespace ClassicalSharp {
}
void ChatFontChanged( object sender, EventArgs e ) {
if( !game.Drawer2D.UseBitmappedChat ) return;
Dispose();
Init();
}

View File

@ -51,7 +51,7 @@ namespace ClassicalSharp {
rightArmZRot = idleZRot;
leftArmZRot = -idleZRot;
bobYOffset = -(float)(Math.Abs( Math.Cos( walkTime ) ) * swing * (2/16f));
bobYOffset = (float)(Math.Abs( Math.Cos( walkTime ) ) * swing * (2/16f));
}
}
}

View File

@ -81,7 +81,7 @@ namespace ClassicalSharp {
UpdateAnimState( lastPos, nextPos, delta );
CheckSkin();
game.Camera.PlayerTick( delta, prevVel, Velocity, onGround );
game.Camera.PlayerTick( delta, prevVel, Velocity, curMovementSpeed, onGround );
}
public override void RenderModel( double deltaTime, float t ) {
@ -152,6 +152,7 @@ namespace ClassicalSharp {
normalDrag = new Vector3( 0.91f, 0.98f, 0.91f ),
airDrag = new Vector3( 0.6f, 1f, 0.6f );
const float liquidGrav = 0.02f, ropeGrav = 0.034f, normalGrav = 0.08f;
float curMovementSpeed;
void PhysicsTick( float xMoving, float zMoving ) {
float multiply = (flying || noClip) ?
@ -160,6 +161,7 @@ namespace ClassicalSharp {
float modifier = LowestSpeedModifier();
float horMul = multiply * modifier;
float yMul = Math.Max( 1f, multiply / 5 ) * modifier;
curMovementSpeed = horMul;
if( TouchesAnyWater() && !flying && !noClip ) {
Move( xMoving, zMoving, 0.02f * horMul, waterDrag, liquidGrav, 1 );

View File

@ -67,7 +67,7 @@ namespace ClassicalSharp.Model {
XQuad( extent, TileSide.Left, -extent, extent, true, FastColour.ShadeX );
ZQuad( -extent, TileSide.Front, -extent, extent, true, FastColour.ShadeZ );
ZQuad( extent, TileSide.Back, -extent, extent, true, FastColour.ShadeZ );
ZQuad( extent, TileSide.Back, -extent, extent, false, FastColour.ShadeZ );
YQuad( blockHeight, TileSide.Top, 1.0f );
XQuad( -extent, TileSide.Right, -extent, extent, true, FastColour.ShadeX );
}
@ -181,7 +181,7 @@ namespace ClassicalSharp.Model {
void TransformVertices() {
for( int i = 0; i < index; i++ ) {
VertexPos3fTex2fCol4b vertex = cache.vertices[i];
Vector3 newPos = Utils.RotateY( vertex.X, vertex.Y, vertex.Z, cosA, sinA ) + pos;
Vector3 newPos = new Vector3( vertex.X, vertex.Y, vertex.Z ) + pos;//Utils.RotateY( vertex.X, vertex.Y, vertex.Z, cosA, sinA ) + pos;
vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z;
cache.vertices[i] = vertex;
}

View File

@ -24,7 +24,7 @@ namespace ClassicalSharp.Model {
}
public override bool Bobbing {
get { return false; }
get { return true; }
}
public override float NameYOffset {

View File

@ -23,8 +23,8 @@ namespace ClassicalSharp {
public virtual void Tick( double elapsed ) {
}
public virtual void PlayerTick( double elapsed, Vector3 prevVel,
Vector3 nextVel, bool onGround ) {
public virtual void PlayerTick( double elapsed, Vector3 prevVel, Vector3 nextVel,
float moveSpeed, bool onGround ) {
}
public virtual bool MouseZoom( MouseWheelEventArgs e ) {
@ -41,11 +41,11 @@ namespace ClassicalSharp {
public abstract class PerspectiveCamera : Camera {
protected LocalPlayer player;
protected Matrix4 BobMatrix;
protected Matrix4 titleMatrix;
public PerspectiveCamera( Game game ) {
this.game = game;
player = game.LocalPlayer;
BobMatrix = Matrix4.Identity;
titleMatrix = Matrix4.Identity;
}
public override Matrix4 GetProjection() {
@ -104,8 +104,8 @@ namespace ClassicalSharp {
}
float speed = 0;
public override void PlayerTick( double elapsed, Vector3 prevVel,
Vector3 nextVel, bool onGround ) {
public override void PlayerTick( double elapsed, Vector3 prevVel, Vector3 nextVel,
float moveSpeed, bool onGround ) {
if( !onGround || !game.ViewBobbing ) {
speed = 0; return;
}
@ -115,10 +115,9 @@ namespace ClassicalSharp {
zero( prevVel.X ) && zero( prevVel.Z ) ) {
speed = 0;
} else {
float sqrDist = (float)Math.Sqrt( Math.Abs( dist ) * 120 );
speed += Math.Sign( dist ) * sqrDist;
speed = moveSpeed * 8;
}
Utils.Clamp( ref speed, 0, 15f );
Utils.Clamp( ref speed, 0, 50f );
}
bool zero( float value ) {
@ -133,15 +132,17 @@ namespace ClassicalSharp {
protected float bobYOffset = 0;
const float angle = 0.25f * Utils.Deg2Rad;
protected void CalcBobMatix( double delta ) {
protected void CalcViewBobbing( double delta ) {
bobAccumulator += delta * speed;
if( speed == 0 ) {
BobMatrix = Matrix4.Identity;
titleMatrix = Matrix4.Identity;
bobYOffset = 0;
} else {
float time = (float)Math.Sin( bobAccumulator );
BobMatrix = Matrix4.RotateZ( time * angle );
bobYOffset = (float)Math.Sin( bobAccumulator ) * 0.1f;
float tiltTime = (float)Math.Sin( bobAccumulator );
titleMatrix = Matrix4.RotateZ( tiltTime * angle );
float bobTime = (float)Math.Sin( bobAccumulator );
bobYOffset = bobTime * (1/16f);
}
}
}
@ -159,11 +160,11 @@ namespace ClassicalSharp {
}
public override Matrix4 GetView( double delta ) {
CalcBobMatix( delta );
CalcViewBobbing( delta );
Vector3 eyePos = player.EyePosition;
eyePos.Y += bobYOffset;
Vector3 cameraPos = eyePos - Utils.GetDirVector( player.YawRadians, player.PitchRadians ) * distance;
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * BobMatrix;
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * titleMatrix;
}
public override bool IsThirdPerson {
@ -188,11 +189,11 @@ namespace ClassicalSharp {
}
public override Matrix4 GetView( double delta ) {
CalcBobMatix( delta );
CalcViewBobbing( delta );
Vector3 eyePos = player.EyePosition;
eyePos.Y += bobYOffset;
Vector3 cameraPos = eyePos + Utils.GetDirVector( player.YawRadians, player.PitchRadians ) * distance;
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * BobMatrix;
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * titleMatrix;
}
public override bool IsThirdPerson {
@ -211,11 +212,11 @@ namespace ClassicalSharp {
public override Matrix4 GetView( double delta ) {
CalcBobMatix( delta );
CalcViewBobbing( delta );
Vector3 eyePos = player.EyePosition;
eyePos.Y += bobYOffset;
Vector3 cameraDir = Utils.GetDirVector( player.YawRadians, player.PitchRadians );
return Matrix4.LookAt( eyePos, eyePos + cameraDir, Vector3.UnitY ) * BobMatrix;
return Matrix4.LookAt( eyePos, eyePos + cameraDir, Vector3.UnitY ) * titleMatrix;
}
public override bool IsThirdPerson {