From 04ade22693560c870c1fc28ffc98f61d5585359d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 29 Feb 2016 08:46:02 +1100 Subject: [PATCH] Make Chibi's model more consistent with the other models, also make set its name height to be just above the head. --- ClassicalSharp/Model/ChibiModel.cs | 71 ++++++++----------- ClassicalSharp/Model/IModel.cs | 7 ++ ClassicalSharp/Model/PlayerModel.cs | 3 +- ClassicalSharp/Model/SheepModel.cs | 7 +- .../Network/NetworkProcessor.Original.cs | 30 ++++---- 5 files changed, 56 insertions(+), 62 deletions(-) diff --git a/ClassicalSharp/Model/ChibiModel.cs b/ClassicalSharp/Model/ChibiModel.cs index 769fd2f66..2ff7a75a7 100644 --- a/ClassicalSharp/Model/ChibiModel.cs +++ b/ClassicalSharp/Model/ChibiModel.cs @@ -6,29 +6,33 @@ namespace ClassicalSharp.Model { public class ChibiModel : IModel { - ModelSet Set, SetSlim; public ChibiModel( Game window ) : base( window ) { vertices = new ModelVertex[boxVertices * (7 + 2)]; - Set = new ModelSet(); - Set.Head = EasyBox(8, 8, 8, 8f, 8f, 8f, 0, 0, 0, 16, 0); - Set.Hat = EasyBox(8, 8, 8, 8.5f, 8.5f, 8.5f, 32, 0, 0, 16, 0); - - Set.Torso = EasyBox(8, 12, 4, 4f, 6f, 2f, 16, 16, 0, 9, 0); - - Set.LeftLeg = EasyBox(4, 12, 4, -2f, 6f, 2f, 0, 16, -1, 3, 0); - - Set.RightLeg = EasyBox(4, 12, 4, 2f, 6f, 2f, 0, 16, 1, 3, 0); - - - Set.LeftArm = EasyBox(4, 12, 4, -2f, 6f, 2f, 40, 16, -3, 9, 0); - - Set.RightArm = EasyBox(4, 12, 4, 2f, 6f, 2f, 40, 16, 3, 9, 0); + Head = BuildBox( MakeBoxBounds( -4, 12, -4, 4, 20, 4 ) + .SetTexOrigin( 0, 0 ) ); + Hat = BuildBox( MakeBoxBounds( -4, 12, -4, 4, 20, 4 ) + .SetTexOrigin( 32, 0 ).ExpandBounds( 0.25f ) ); + Torso = BuildBox( MakeBoxBounds( -4, -6, -2, 4, 6, 2 ) + .SetTexOrigin( 16, 16 ) + .SetModelBounds( -2, 6, -1, 2, 12, 1 ) ); + LeftLeg = BuildBox( MakeBoxBounds( -2, -6, -2, 2, 6, 2 ) + .SetTexOrigin( 0, 16 ) + .SetModelBounds( -0, 0, -1, -2, 6, 1 ) ); + RightLeg = BuildBox( MakeBoxBounds( -2, -6, -2, 2, 6, 2 ) + .SetTexOrigin( 0, 16 ) + .SetModelBounds( 0, 0, -1, 2, 6, 1 ) ); + LeftArm = BuildBox( MakeBoxBounds( -2, -6, -2, 2, 6, 2 ) + .SetTexOrigin( 40, 16 ) + .SetModelBounds( -2, 6, -1, -4, 12, 1 ) ); + RightArm = BuildBox( MakeBoxBounds( -2, -6, -2, 2, 6, 2 ) + .SetTexOrigin( 40, 16 ) + .SetModelBounds( 2, 6, -1, 4, 12, 1 ) ); } public override bool Bobbing { get { return true; } } - public override float NameYOffset { get { return 2.1375f; } } + public override float NameYOffset { get { return 1.3875f; } } public override float GetEyeY( Entity entity ) { return 14/16f; } @@ -47,38 +51,23 @@ namespace ClassicalSharp.Model { SkinType skinType = p.SkinType; _64x64 = skinType != SkinType.Type64x32; - DrawHeadRotate( 0, 13/16f, 0, -p.PitchRadians, 0, 0, Set.Head ); - - DrawPart( Set.Torso ); - DrawRotate( 0, 6/16f, 0, p.anim.legXRot, 0, 0, Set.LeftLeg ); - DrawRotate( 0, 6/16f, 0, -p.anim.legXRot, 0, 0, Set.RightLeg ); - Rotate = RotateOrder.XZY; - - DrawRotate( -3/16f, 11/16f, 0, p.anim.leftXRot, 0, p.anim.leftZRot, Set.LeftArm ); - DrawRotate( 3/16f, 11/16f, 0, p.anim.rightXRot, 0, p.anim.rightZRot, Set.RightArm ); - Rotate = RotateOrder.ZYX; + DrawHeadRotate( 0, 13/16f, 0, -p.PitchRadians, 0, 0, Head ); + DrawPart( Torso ); + DrawRotate( 0, 6/16f, 0, p.anim.legXRot, 0, 0, LeftLeg ); + DrawRotate( 0, 6/16f, 0, -p.anim.legXRot, 0, 0, RightLeg ); + Rotate = RotateOrder.XZY; + DrawRotate( -3/16f, 11/16f, 0, p.anim.leftXRot, 0, p.anim.leftZRot, LeftArm ); + DrawRotate( 3/16f, 11/16f, 0, p.anim.rightXRot, 0, p.anim.rightZRot, RightArm ); + Rotate = RotateOrder.ZYX; graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 ); graphics.AlphaTest = true; index = 0; - DrawHeadRotate( 0, 13f/16f, 0, -p.PitchRadians, 0, 0, Set.Hat ); + DrawHeadRotate( 0, 13f/16f, 0, -p.PitchRadians, 0, 0, Hat ); graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 ); } - protected ModelPart EasyBox( int xSize, int ySize, int zSize, float xResize, float yResize, float zResize, - int u, int v, int xOff = 0, int yOff = 0, int zOff = 0 ) { - return BuildBox( - MakeBoxBounds( (int)(-xSize * 0.5f + xOff), (int)(-ySize * 0.5f + yOff), (int)(-zSize * 0.5f + zOff), - (int)(xSize * 0.5f + xOff), (int)(ySize * 0.5f + yOff), (int)(zSize * 0.5f + zOff) ) - .SetTexOrigin( u, v ) - .SetModelBounds( -xResize * 0.5f + xOff, -yResize * 0.5f + yOff, -zResize * 0.5f + zOff, - xResize * 0.5f + xOff, yResize * 0.5f + yOff, zResize * 0.5f + zOff ) - ); - } - - class ModelSet { - public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm, Hat; - } + ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm, Hat; } } diff --git a/ClassicalSharp/Model/IModel.cs b/ClassicalSharp/Model/IModel.cs index fa40504b6..7e182c097 100644 --- a/ClassicalSharp/Model/IModel.cs +++ b/ClassicalSharp/Model/IModel.cs @@ -86,6 +86,13 @@ namespace ClassicalSharp.Model { Z1 = z1 / 16f; Z2 = z2 / 16f; return this; } + + public BoxDescription ExpandBounds( float amount ) { + X1 -= amount / 16f; X2 += amount / 16f; + Y1 -= amount / 16f; Y2 += amount / 16f; + Z1 -= amount / 16f; Z2 += amount / 16f; + return this; + } } protected BoxDescription MakeBoxBounds( int x1, int y1, int z1, int x2, int y2, int z2 ) { diff --git a/ClassicalSharp/Model/PlayerModel.cs b/ClassicalSharp/Model/PlayerModel.cs index f86757f2d..16ef2aed6 100644 --- a/ClassicalSharp/Model/PlayerModel.cs +++ b/ClassicalSharp/Model/PlayerModel.cs @@ -21,8 +21,7 @@ namespace ClassicalSharp.Model { Set.RightLeg = BuildBox( MakeBoxBounds( 0, 0, -2, 4, 12, 2 ). SetTexOrigin( 0, 16 ) ); Set.Hat = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 ) - .SetTexOrigin( 32, 0 ) - .SetModelBounds( -4.5f, 23.5f, -4.5f, 4.5f, 32.5f, 4.5f ) ); + .SetTexOrigin( 32, 0 ).ExpandBounds( 0.5f ) ); Set.LeftArm = BuildBox( MakeBoxBounds( -4, 12, -2, -8, 24, 2 ) .SetTexOrigin( 40, 16 ) ); Set.RightArm = BuildBox( MakeBoxBounds( 4, 12, -2, 8, 24, 2 ) diff --git a/ClassicalSharp/Model/SheepModel.cs b/ClassicalSharp/Model/SheepModel.cs index 3e1e5ca83..721475797 100644 --- a/ClassicalSharp/Model/SheepModel.cs +++ b/ClassicalSharp/Model/SheepModel.cs @@ -23,8 +23,7 @@ namespace ClassicalSharp.Model { .SetTexOrigin( 0, 16 ) ); RightLegBack = BuildBox( MakeBoxBounds( 1, 0, 5, 5, 12, 9 ) .SetTexOrigin( 0, 16 ) ); - if( Fur ) - MakeFurModel(); + if( Fur ) MakeFurModel(); } @@ -35,9 +34,9 @@ namespace ClassicalSharp.Model { FurTorso = BuildRotatedBox( MakeRotatedBoxBounds( -4, 12, -8, 4, 18, 8 ) .SetTexOrigin( 28, 8 ) .SetModelBounds( -6f, 10.5f, -10f, 6f, 19.5f, 10f ) ); - BoxDescription legDesc = MakeBoxBounds( -2, -3, -2, 2, 3, 2 ) - .SetTexOrigin( 0, 16 ); + BoxDescription legDesc = MakeBoxBounds( -2, -3, -2, 2, 3, 2 ) + .SetTexOrigin( 0, 16 ); FurLeftLegFront = BuildBox( legDesc.SetModelBounds( -5.5f, 5.5f, -7.5f, -0.5f, 12.5f, -2.5f ) ); FurRightLegFront = BuildBox( legDesc.SetModelBounds( 0.5f, 5.5f, -7.5f, 5.5f, 12.5f, -2.5f ) ); FurLeftLegBack = BuildBox( legDesc.SetModelBounds( -5.5f, 5.5f, 4.5f, -0.5f, 12.5f, 9.5f ) ); diff --git a/ClassicalSharp/Network/NetworkProcessor.Original.cs b/ClassicalSharp/Network/NetworkProcessor.Original.cs index 23a6db54d..31881b381 100644 --- a/ClassicalSharp/Network/NetworkProcessor.Original.cs +++ b/ClassicalSharp/Network/NetworkProcessor.Original.cs @@ -73,7 +73,7 @@ namespace ClassicalSharp { void HandleHandshake() { byte protocolVer = reader.ReadUInt8(); ServerName = reader.ReadCp437String(); - ServerMotd = reader.ReadCp437String(); + ServerMotd = reader.ReadCp437String(); receivedFirstPosition = false; game.LocalPlayer.Hacks.SetUserType( reader.ReadUInt8() ); @@ -81,7 +81,7 @@ namespace ClassicalSharp { game.LocalPlayer.CheckHacksConsistency(); game.Events.RaiseHackPermissionsChanged(); } - + void HandlePing() { } void HandleLevelInit() { @@ -147,7 +147,7 @@ namespace ClassicalSharp { void HandleLevelFinalise() { game.SetNewScreen( null ); - game.activeScreen = prevScreen; + game.activeScreen = prevScreen; if( prevScreen != null && prevCursorVisible != game.CursorVisible ) game.CursorVisible = prevCursorVisible; prevScreen = null; @@ -272,21 +272,21 @@ namespace ClassicalSharp { oldPlayer.Despawn(); } game.Players[entityId] = new NetPlayer( displayName, skinName, game, entityId ); - string identifier = game.Players[entityId].SkinIdentifier; game.EntityEvents.RaiseEntityAdded( entityId ); - game.AsyncDownloader.DownloadSkin( identifier, skinName ); } else { - game.LocalPlayer.SkinName = skinName; - game.AsyncDownloader.DownloadSkin( "skin_255", skinName ); + game.LocalPlayer.SkinName = skinName; } - if( readPosition ) { - ReadAbsoluteLocation( entityId, false ); - if( entityId == 0xFF ) { - LocalPlayer p = game.LocalPlayer; - p.SpawnPoint = p.Position; - p.SpawnYaw = p.HeadYawDegrees; - p.SpawnPitch = p.PitchDegrees; - } + + string identifier = game.Players[entityId].SkinIdentifier; + game.AsyncDownloader.DownloadSkin( identifier, skinName ); + if( !readPosition ) return; + + ReadAbsoluteLocation( entityId, false ); + if( entityId == 0xFF ) { + LocalPlayer p = game.LocalPlayer; + p.SpawnPoint = p.Position; + p.SpawnYaw = p.HeadYawDegrees; + p.SpawnPitch = p.PitchDegrees; } }