From 1c5ef409ed773ff9cd5e082d504f89c70abb6750 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 24 Nov 2015 11:04:29 +1100 Subject: [PATCH] Fix some of current text in top left not having font changed, hopefully improve view bobbing somewhat. --- ClassicalSharp/2D/Screens/FpsScreen.cs | 1 - ClassicalSharp/Entities/AnimatedEntity.cs | 2 +- ClassicalSharp/Entities/LocalPlayer.cs | 4 ++- ClassicalSharp/Model/BlockModel.cs | 4 +-- ClassicalSharp/Model/CreeperModel.cs | 2 +- ClassicalSharp/Utils/Camera.cs | 41 ++++++++++++----------- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/ClassicalSharp/2D/Screens/FpsScreen.cs b/ClassicalSharp/2D/Screens/FpsScreen.cs index 2b62cfb8f..b179cd4a8 100644 --- a/ClassicalSharp/2D/Screens/FpsScreen.cs +++ b/ClassicalSharp/2D/Screens/FpsScreen.cs @@ -83,7 +83,6 @@ namespace ClassicalSharp { } void ChatFontChanged( object sender, EventArgs e ) { - if( !game.Drawer2D.UseBitmappedChat ) return; Dispose(); Init(); } diff --git a/ClassicalSharp/Entities/AnimatedEntity.cs b/ClassicalSharp/Entities/AnimatedEntity.cs index ee8195d6b..8a536be1b 100644 --- a/ClassicalSharp/Entities/AnimatedEntity.cs +++ b/ClassicalSharp/Entities/AnimatedEntity.cs @@ -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)); } } } \ No newline at end of file diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs index a57d16fb5..5b3cb90d8 100644 --- a/ClassicalSharp/Entities/LocalPlayer.cs +++ b/ClassicalSharp/Entities/LocalPlayer.cs @@ -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 ); diff --git a/ClassicalSharp/Model/BlockModel.cs b/ClassicalSharp/Model/BlockModel.cs index db5a29cb8..6532aa143 100644 --- a/ClassicalSharp/Model/BlockModel.cs +++ b/ClassicalSharp/Model/BlockModel.cs @@ -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; } diff --git a/ClassicalSharp/Model/CreeperModel.cs b/ClassicalSharp/Model/CreeperModel.cs index 5c7bc5e6d..66f15aff1 100644 --- a/ClassicalSharp/Model/CreeperModel.cs +++ b/ClassicalSharp/Model/CreeperModel.cs @@ -24,7 +24,7 @@ namespace ClassicalSharp.Model { } public override bool Bobbing { - get { return false; } + get { return true; } } public override float NameYOffset { diff --git a/ClassicalSharp/Utils/Camera.cs b/ClassicalSharp/Utils/Camera.cs index 5019fb852..2d976de00 100644 --- a/ClassicalSharp/Utils/Camera.cs +++ b/ClassicalSharp/Utils/Camera.cs @@ -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 {