Fix mirroring and thin arms on 64x64 skins. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2016-03-24 18:31:28 +11:00
parent 73ed96be7e
commit 1c219447e5
13 changed files with 46 additions and 21 deletions

View File

@ -14,8 +14,9 @@ namespace ClassicalSharp.Model {
bool bright; bool bright;
Vector3 minBB, maxBB; Vector3 minBB, maxBB;
public BlockModel( Game game ) : base( game ) { public BlockModel( Game game ) : base( game ) { }
}
internal override void CreateParts() { }
public override bool Bobbing { get { return false; } } public override bool Bobbing { get { return false; } }

View File

@ -6,7 +6,9 @@ namespace ClassicalSharp.Model {
public class ChibiModel : IModel { public class ChibiModel : IModel {
public ChibiModel( Game window ) : base( window ) { public ChibiModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * (7 + 2)]; vertices = new ModelVertex[boxVertices * (7 + 2)];
Head = BuildBox( MakeBoxBounds( -4, 12, -4, 4, 20, 4 ) Head = BuildBox( MakeBoxBounds( -4, 12, -4, 4, 20, 4 )

View File

@ -6,7 +6,9 @@ namespace ClassicalSharp.Model {
public class ChickenModel : IModel { public class ChickenModel : IModel {
public ChickenModel( Game window ) : base( window ) { public ChickenModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6 + quadVertices * 2 * 2]; vertices = new ModelVertex[boxVertices * 6 + quadVertices * 2 * 2];
Head = BuildBox( MakeBoxBounds( -2, 9, -6, 2, 15, -3 ) Head = BuildBox( MakeBoxBounds( -2, 9, -6, 2, 15, -3 )
.TexOrigin( 0, 0 ) .TexOrigin( 0, 0 )

View File

@ -6,7 +6,9 @@ namespace ClassicalSharp.Model {
public class CreeperModel : IModel { public class CreeperModel : IModel {
public CreeperModel( Game window ) : base( window ) { public CreeperModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6]; vertices = new ModelVertex[boxVertices * 6];
Head = BuildBox( MakeBoxBounds( -4, 18, -4, 4, 26, 4 ) Head = BuildBox( MakeBoxBounds( -4, 18, -4, 4, 26, 4 )
.TexOrigin( 0, 0 ) .TexOrigin( 0, 0 )

View File

@ -6,8 +6,9 @@ namespace ClassicalSharp.Model {
public class CustomModel : IModel { public class CustomModel : IModel {
public CustomModel( Game window ) : base( window ) { public CustomModel( Game window ) : base( window ) { }
}
internal override void CreateParts() { }
internal bool bobbing; internal bool bobbing;
public override bool Bobbing { get { return bobbing; } } public override bool Bobbing { get { return bobbing; } }

View File

@ -8,7 +8,9 @@ namespace ClassicalSharp.Model {
public class HumanoidModel : IModel { public class HumanoidModel : IModel {
ModelSet Set, SetSlim, Set64; ModelSet Set, SetSlim, Set64;
public HumanoidModel( Game window ) : base( window ) { public HumanoidModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * ( 7 + 11 )]; vertices = new ModelVertex[boxVertices * ( 7 + 11 )];
Set = new ModelSet(); Set = new ModelSet();
@ -21,19 +23,19 @@ namespace ClassicalSharp.Model {
Set.Head = BuildBox( head.TexOrigin( 0, 0 ) ); Set.Head = BuildBox( head.TexOrigin( 0, 0 ) );
Set.Torso = BuildBox( torso.TexOrigin( 16, 16 ) ); Set.Torso = BuildBox( torso.TexOrigin( 16, 16 ) );
Set.LeftLeg = BuildBox( lLeg.MirrorX().TexOrigin( 0, 16 ) ); Set.LeftLeg = BuildBox( lLeg.TexOrigin( 0, 16 ) );
Set.RightLeg = BuildBox( rLeg.TexOrigin( 0, 16 ) ); Set.RightLeg = BuildBox( rLeg.TexOrigin( 0, 16 ) );
Set.Hat = BuildBox( head.TexOrigin( 32, 0 ).Expand( 0.5f ) ); Set.Hat = BuildBox( head.TexOrigin( 32, 0 ).Expand( 0.5f ) );
Set.LeftArm = BuildBox( lArm.MirrorX().TexOrigin( 40, 16 ) ); Set.LeftArm = BuildBox( lArm.TexOrigin( 40, 16 ) );
Set.RightArm = BuildBox( rArm.TexOrigin( 40, 16 ) ); Set.RightArm = BuildBox( rArm.TexOrigin( 40, 16 ) );
Set64 = new ModelSet(); Set64 = new ModelSet();
Set64.Head = Set.Head; Set64.Head = Set.Head;
Set64.Torso = Set.Torso; Set64.Torso = Set.Torso;
Set64.LeftLeg = BuildBox( lLeg.TexOrigin( 16, 48 ) ); Set64.LeftLeg = BuildBox( lLeg.MirrorX().TexOrigin( 16, 48 ) );
Set64.RightLeg = Set.RightLeg; Set64.RightLeg = Set.RightLeg;
Set64.Hat = Set.Hat; Set64.Hat = Set.Hat;
Set64.LeftArm = BuildBox( lArm.TexOrigin( 32, 48 ) ); Set64.LeftArm = BuildBox( lArm.MirrorX().TexOrigin( 32, 48 ) );
Set64.RightArm = Set.RightArm; Set64.RightArm = Set.RightArm;
Set64.TorsoLayer = BuildBox( torso.TexOrigin( 16, 32 ).Expand( 0.5f ) ); Set64.TorsoLayer = BuildBox( torso.TexOrigin( 16, 32 ).Expand( 0.5f ) );
Set64.LeftLegLayer = BuildBox( lLeg.TexOrigin( 0, 48 ).Expand( 0.5f ) ); Set64.LeftLegLayer = BuildBox( lLeg.TexOrigin( 0, 48 ).Expand( 0.5f ) );
@ -47,7 +49,7 @@ namespace ClassicalSharp.Model {
SetSlim.LeftLeg = Set64.LeftLeg; SetSlim.LeftLeg = Set64.LeftLeg;
SetSlim.RightLeg = Set.RightLeg; SetSlim.RightLeg = Set.RightLeg;
SetSlim.Hat = Set.Hat; SetSlim.Hat = Set.Hat;
lArm.BodyW -= 1; lArm.X1 += 1/16f; lArm.BodyW -= 1; lArm.X2 += 1/16f;
SetSlim.LeftArm = BuildBox( lArm.TexOrigin( 32, 48 ) ); SetSlim.LeftArm = BuildBox( lArm.TexOrigin( 32, 48 ) );
rArm.BodyW -= 1; rArm.X2 -= 1/16f; rArm.BodyW -= 1; rArm.X2 -= 1/16f;
SetSlim.RightArm = BuildBox( rArm.TexOrigin( 40, 16 ) ); SetSlim.RightArm = BuildBox( rArm.TexOrigin( 40, 16 ) );
@ -55,7 +57,7 @@ namespace ClassicalSharp.Model {
SetSlim.LeftLegLayer = Set64.LeftLegLayer; SetSlim.LeftLegLayer = Set64.LeftLegLayer;
SetSlim.RightLegLayer = Set64.RightLegLayer; SetSlim.RightLegLayer = Set64.RightLegLayer;
SetSlim.LeftArmLayer = BuildBox( lArm.TexOrigin( 32, 48 ).Expand( 0.5f ) ); SetSlim.LeftArmLayer = BuildBox( lArm.TexOrigin( 32, 48 ).Expand( 0.5f ) );
SetSlim.RightArmLayer = BuildBox( rArm.TexOrigin( 40, 16 ).Expand( 0.5f ) ); SetSlim.RightArmLayer = BuildBox( rArm.TexOrigin( 40, 32 ).Expand( 0.5f ) );
} }
public override bool Bobbing { get { return true; } } public override bool Bobbing { get { return true; } }

View File

@ -23,6 +23,8 @@ namespace ClassicalSharp.Model {
cache = game.ModelCache; cache = game.ModelCache;
} }
internal abstract void CreateParts();
/// <summary> Whether the entity should be slightly bobbed up and down when rendering. </summary> /// <summary> Whether the entity should be slightly bobbed up and down when rendering. </summary>
/// <remarks> e.g. for players when their legs are at the peak of their swing, /// <remarks> e.g. for players when their legs are at the peak of their swing,
/// the whole model will be moved slightly down. </remarks> /// the whole model will be moved slightly down. </remarks>

View File

@ -17,7 +17,9 @@ namespace ClassicalSharp.Model {
public void InitCache() { public void InitCache() {
vertices = new VertexPos3fTex2fCol4b[24 * 12]; vertices = new VertexPos3fTex2fCol4b[24 * 12];
vb = api.CreateDynamicVb( VertexFormat.Pos3fTex2fCol4b, vertices.Length ); vb = api.CreateDynamicVb( VertexFormat.Pos3fTex2fCol4b, vertices.Length );
cache["humanoid"] = new HumanoidModel( game ); IModel model = new HumanoidModel( game );
model.CreateParts();
cache["humanoid"] = model;
cache["human"] = cache["humanoid"]; cache["human"] = cache["humanoid"];
} }
@ -36,7 +38,8 @@ namespace ClassicalSharp.Model {
if( !cache.TryGetValue( modelName, out model ) ) { if( !cache.TryGetValue( modelName, out model ) ) {
model = InitModel( modelName ); model = InitModel( modelName );
if( model == null ) model = cache["humanoid"]; // fallback to default if( model != null ) model.CreateParts();
else model = cache["humanoid"]; // fallback to default
cache[modelName] = model; cache[modelName] = model;
} }
return model; return model;

View File

@ -6,7 +6,9 @@ namespace ClassicalSharp.Model {
public class PigModel : IModel { public class PigModel : IModel {
public PigModel( Game window ) : base( window ) { public PigModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6]; vertices = new ModelVertex[boxVertices * 6];
Head = BuildBox( MakeBoxBounds( -4, 8, -14, 4, 16, -6 ) Head = BuildBox( MakeBoxBounds( -4, 8, -14, 4, 16, -6 )
.TexOrigin( 0, 0 ) .TexOrigin( 0, 0 )

View File

@ -9,7 +9,9 @@ namespace ClassicalSharp.Model {
public bool Fur = true; public bool Fur = true;
public SheepModel( Game window ) : base( window ) { public SheepModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6 * ( Fur ? 2 : 1 )]; vertices = new ModelVertex[boxVertices * 6 * ( Fur ? 2 : 1 )];
Head = BuildBox( MakeBoxBounds( -3, 16, -14, 3, 22, -6 ) Head = BuildBox( MakeBoxBounds( -3, 16, -14, 3, 22, -6 )
.TexOrigin( 0, 0 ) .TexOrigin( 0, 0 )

View File

@ -6,7 +6,9 @@ namespace ClassicalSharp.Model {
public class SkeletonModel : IModel { public class SkeletonModel : IModel {
public SkeletonModel( Game window ) : base( window ) { public SkeletonModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6]; vertices = new ModelVertex[boxVertices * 6];
Head = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 ) Head = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 )
.TexOrigin( 0, 0 ) .TexOrigin( 0, 0 )

View File

@ -6,7 +6,9 @@ namespace ClassicalSharp.Model {
public class SpiderModel : IModel { public class SpiderModel : IModel {
public SpiderModel( Game window ) : base( window ) { public SpiderModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * 5]; vertices = new ModelVertex[boxVertices * 5];
Head = BuildBox( MakeBoxBounds( -4, 4, -11, 4, 12, -3 ) Head = BuildBox( MakeBoxBounds( -4, 4, -11, 4, 12, -3 )
.TexOrigin( 32, 4 ) .TexOrigin( 32, 4 )

View File

@ -6,7 +6,9 @@ namespace ClassicalSharp.Model {
public class ZombieModel : IModel { public class ZombieModel : IModel {
public ZombieModel( Game window ) : base( window ) { public ZombieModel( Game window ) : base( window ) { }
internal override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6]; vertices = new ModelVertex[boxVertices * 6];
Head = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 ) Head = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 )
.TexOrigin( 0, 0 ) .TexOrigin( 0, 0 )