diff --git a/ClassicalSharp/Entities/Model/HumanoidModel.cs b/ClassicalSharp/Entities/Model/HumanoidModel.cs index a7ffe6d60..d09ac5f3e 100644 --- a/ClassicalSharp/Entities/Model/HumanoidModel.cs +++ b/ClassicalSharp/Entities/Model/HumanoidModel.cs @@ -92,7 +92,6 @@ namespace ClassicalSharp.Model { bool _64x64 = p.SkinType != SkinType.Type64x32; uScale = p.uScale / 64f; vScale = p.vScale / (_64x64 ? 64 : 32); - uScale /= 1000f; vScale /= 1000f; RenderParts(p); } diff --git a/ClassicalSharp/Entities/Model/IModel.cs b/ClassicalSharp/Entities/Model/IModel.cs index d3d911e1b..508e206fc 100644 --- a/ClassicalSharp/Entities/Model/IModel.cs +++ b/ClassicalSharp/Entities/Model/IModel.cs @@ -127,7 +127,6 @@ namespace ClassicalSharp.Model { index = 0; int col = p.Colour(); uScale = 1 / 64f; vScale = 1 / 32f; - uScale /= 1000f; vScale /= 1000f; cols[0] = col; if (!p.NoShade) { @@ -192,8 +191,12 @@ namespace ClassicalSharp.Model { for (int i = 0; i < part.Count; i++) { ModelVertex v = vertices[part.Offset + i]; vertex.X = v.X; vertex.Y = v.Y; vertex.Z = v.Z; - vertex.Colour = cols[i >> 2]; + vertex.Colour = cols[i >> 2]; + vertex.U = v.U * uScale; vertex.V = v.V * vScale; + int quadI = i & 3; + if (quadI == 0 || quadI == 3) vertex.V -= 0.01f * vScale; + if (quadI == 2 || quadI == 3) vertex.U -= 0.01f * uScale; finVertices[index++] = vertex; } } @@ -226,10 +229,13 @@ namespace ClassicalSharp.Model { if (head) { t = cosHead * v.X - sinHead * v.Z; v.Z = sinHead * v.X + cosHead * v.Z; v.X = t; // Inlined RotY } - vertex.X = v.X + x; vertex.Y = v.Y + y; vertex.Z = v.Z + z; - vertex.Colour = cols[i >> 2]; + vertex.Colour = cols[i >> 2]; + vertex.U = v.U * uScale; vertex.V = v.V * vScale; + int quadI = i & 3; + if (quadI == 0 || quadI == 3) vertex.V -= 0.01f * vScale; + if (quadI == 2 || quadI == 3) vertex.U -= 0.01f * uScale; finVertices[index++] = vertex; } } diff --git a/ClassicalSharp/Entities/Model/ModelBuilder.cs b/ClassicalSharp/Entities/Model/ModelBuilder.cs index fc7cb13aa..5d8b1bcd8 100644 --- a/ClassicalSharp/Entities/Model/ModelBuilder.cs +++ b/ClassicalSharp/Entities/Model/ModelBuilder.cs @@ -53,7 +53,6 @@ namespace ClassicalSharp.Model { /// Contains methods to create parts of 3D objects, typically boxes and quads. public static class ModelBuilder { - const int UVScale = 1000; public static BoxDesc MakeBoxBounds(int x1, int y1, int z1, int x2, int y2, int z2) { BoxDesc desc = default(BoxDesc).SetModelBounds(x1, y1, z1, x2, y2, z2); desc.SidesW = Math.Abs(z2 - z1); @@ -84,10 +83,10 @@ namespace ClassicalSharp.Model { /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈SW┈┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┃
/// ┗━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┛ public static ModelPart BuildBox(IModel m, BoxDesc desc) { - int sidesW = desc.SidesW * UVScale, bodyW = desc.BodyW * UVScale, bodyH = desc.BodyH * UVScale; + int sidesW = desc.SidesW, bodyW = desc.BodyW, bodyH = desc.BodyH; float x1 = desc.X1, y1 = desc.Y1, z1 = desc.Z1; float x2 = desc.X2, y2 = desc.Y2, z2 = desc.Z2; - int x = desc.TexX * UVScale, y = desc.TexY * UVScale; + int x = desc.TexX, y = desc.TexY; YQuad(m, x + sidesW, y, bodyW, sidesW, x2, x1, z2, z1, y2); // top YQuad(m, x + sidesW + bodyW, y, bodyW, sidesW, x2, x1, z2, z1, y1); // bottom @@ -112,10 +111,10 @@ namespace ClassicalSharp.Model { /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈SW┈┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┃
/// ┗━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┛ public static ModelPart BuildRotatedBox(IModel m, BoxDesc desc) { - int sidesW = desc.SidesW * UVScale, bodyW = desc.BodyW * UVScale, bodyH = desc.BodyH * UVScale; + int sidesW = desc.SidesW, bodyW = desc.BodyW, bodyH = desc.BodyH; float x1 = desc.X1, y1 = desc.Y1, z1 = desc.Z1; float x2 = desc.X2, y2 = desc.Y2, z2 = desc.Z2; - int x = desc.TexX * UVScale, y = desc.TexY * UVScale; + int x = desc.TexX, y = desc.TexY; YQuad(m, x + sidesW + bodyW + sidesW, y + sidesW, bodyW, bodyH, x1, x2, z1, z2, y2); // top YQuad(m, x + sidesW, y + sidesW, bodyW, bodyH, x2, x1, z1, z2, y1); // bottom @@ -135,26 +134,26 @@ namespace ClassicalSharp.Model { public static void XQuad(IModel m, int texX, int texY, int texWidth, int texHeight, float z1, float z2, float y1, float y2, float x) { - m.vertices[m.index++] = new ModelVertex(x, y1, z1, texX, texY + texHeight - 1); + m.vertices[m.index++] = new ModelVertex(x, y1, z1, texX, texY + texHeight); m.vertices[m.index++] = new ModelVertex(x, y2, z1, texX, texY); - m.vertices[m.index++] = new ModelVertex(x, y2, z2, texX + texWidth - 1, texY); - m.vertices[m.index++] = new ModelVertex(x, y1, z2, texX + texWidth - 1, texY + texHeight - 1); + m.vertices[m.index++] = new ModelVertex(x, y2, z2, texX + texWidth, texY); + m.vertices[m.index++] = new ModelVertex(x, y1, z2, texX + texWidth, texY + texHeight); } public static void YQuad(IModel m, int texX, int texY, int texWidth, int texHeight, float x1, float x2, float z1, float z2, float y) { - m.vertices[m.index++] = new ModelVertex(x1, y, z2, texX, texY + texHeight - 1); + m.vertices[m.index++] = new ModelVertex(x1, y, z2, texX, texY + texHeight); m.vertices[m.index++] = new ModelVertex(x1, y, z1, texX, texY); - m.vertices[m.index++] = new ModelVertex(x2, y, z1, texX + texWidth - 1, texY); - m.vertices[m.index++] = new ModelVertex(x2, y, z2, texX + texWidth - 1, texY + texHeight - 1); + m.vertices[m.index++] = new ModelVertex(x2, y, z1, texX + texWidth, texY); + m.vertices[m.index++] = new ModelVertex(x2, y, z2, texX + texWidth, texY + texHeight); } public static void ZQuad(IModel m, int texX, int texY, int texWidth, int texHeight, float x1, float x2, float y1, float y2, float z) { - m.vertices[m.index++] = new ModelVertex(x1, y1, z, texX, texY + texHeight - 1); + m.vertices[m.index++] = new ModelVertex(x1, y1, z, texX, texY + texHeight); m.vertices[m.index++] = new ModelVertex(x1, y2, z, texX, texY); - m.vertices[m.index++] = new ModelVertex(x2, y2, z, texX + texWidth - 1, texY); - m.vertices[m.index++] = new ModelVertex(x2, y1, z, texX + texWidth - 1, texY + texHeight - 1); + m.vertices[m.index++] = new ModelVertex(x2, y2, z, texX + texWidth, texY); + m.vertices[m.index++] = new ModelVertex(x2, y1, z, texX + texWidth, texY + texHeight); } } } \ No newline at end of file diff --git a/src/Client/IModel.c b/src/Client/IModel.c index 10eead959..67a72d6db 100644 --- a/src/Client/IModel.c +++ b/src/Client/IModel.c @@ -89,7 +89,12 @@ void IModel_DrawPart(ModelPart part) { ModelVertex v = model->vertices[part.Offset + i]; dst->X = v.X; dst->Y = v.Y; dst->Z = v.Z; dst->Colour = IModel_Cols[i >> 2]; + dst->U = v.U * IModel_uScale; dst->V = v.V * IModel_vScale; + Int32 quadI = i & 3; + if (quadI == 0 || quadI == 3) dst->V -= 0.01f * IModel_vScale; + if (quadI == 2 || quadI == 3) dst->U -= 0.01f * IModel_uScale; + dst++; model->index++; } } @@ -123,10 +128,14 @@ void IModel_DrawRotate(Real32 angleX, Real32 angleY, Real32 angleZ, ModelPart pa if (head) { t = IModel_cosHead * v.X - IModel_sinHead * v.Z; v.Z = IModel_sinHead * v.X + IModel_cosHead * v.Z; v.X = t; /* Inlined RotY */ } - dst->X = v.X + x; dst->Y = v.Y + y; dst->Z = v.Z + z; dst->Colour = IModel_Cols[i >> 2]; + dst->U = v.U * IModel_uScale; dst->V = v.V * IModel_vScale; + Int32 quadI = i & 3; + if (quadI == 0 || quadI == 3) dst->V -= 0.01f * IModel_vScale; + if (quadI == 2 || quadI == 3) dst->U -= 0.01f * IModel_uScale; + dst++; model->index++; } } diff --git a/src/Client/ModelBuilder.c b/src/Client/ModelBuilder.c index c41221b31..738918041 100644 --- a/src/Client/ModelBuilder.c +++ b/src/Client/ModelBuilder.c @@ -1,7 +1,6 @@ #if 0 #include "ModelBuilder.h" #include "ExtMath.h" -#define UV_Scale 1000 void BoxDesc_TexOrigin(BoxDesc* desc, Int32 x, Int32 y) { desc->TexX = x; desc->TexY = y; @@ -59,10 +58,10 @@ void BoxDesc_RotatedBox(BoxDesc* desc, Int32 x1, Int32 y1, Int32 z1, Int32 x2, I ModelPart BoxDesc_BuildBox(IModel* m, BoxDesc* desc) { - Int32 sidesW = desc->SidesW * UV_Scale, bodyW = desc->BodyW * UV_Scale, bodyH = desc->BodyH * UV_Scale; + Int32 sidesW = desc->SidesW, bodyW = desc->BodyW, bodyH = desc->BodyH; Real32 x1 = desc->X1, y1 = desc->Y1, z1 = desc->Z1; Real32 x2 = desc->X2, y2 = desc->Y2, z2 = desc->Z2; - Int32 x = desc->TexX * UV_Scale, y = desc->TexY * UV_Scale; + Int32 x = desc->TexX, y = desc->TexY; BoxDesc_YQuad(m, x + sidesW, y, bodyW, sidesW, x2, x1, z2, z1, y2); /* top */ BoxDesc_YQuad(m, x + sidesW + bodyW, y, bodyW, sidesW, x2, x1, z2, z1, y1); /* bottom */ @@ -78,10 +77,10 @@ ModelPart BoxDesc_BuildBox(IModel* m, BoxDesc* desc) { } ModelPart BoxDesc_BuildRotatedBox(IModel* m, BoxDesc* desc) { - Int32 sidesW = desc->SidesW * UV_Scale, bodyW = desc->BodyW * UV_Scale, bodyH = desc->BodyH * UV_Scale; + Int32 sidesW = desc->SidesW, bodyW = desc->BodyW, bodyH = desc->BodyH; Real32 x1 = desc->X1, y1 = desc->Y1, z1 = desc->Z1; Real32 x2 = desc->X2, y2 = desc->Y2, z2 = desc->Z2; - Int32 x = desc->TexX * UV_Scale, y = desc->TexY * UV_Scale; + Int32 x = desc->TexX, y = desc->TexY; BoxDesc_YQuad(m, x + sidesW + bodyW + sidesW, y + sidesW, bodyW, bodyH, x1, x2, z1, z2, y2); /* top */ BoxDesc_YQuad(m, x + sidesW, y + sidesW, bodyW, bodyH, x2, x1, z1, z2, y1); /* bottom */ @@ -107,25 +106,25 @@ ModelPart BoxDesc_BuildRotatedBox(IModel* m, BoxDesc* desc) { void BoxDesc_XQuad(IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texHeight, Real32 z1, Real32 z2, Real32 y1, Real32 y2, Real32 x) { - ModelVertex_Init(&m->vertices[m->index], x, y1, z1, texX, texY + texHeight - 1); m->index++; + ModelVertex_Init(&m->vertices[m->index], x, y1, z1, texX, texY + texHeight); m->index++; ModelVertex_Init(&m->vertices[m->index], x, y2, z1, texX, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x, y2, z2, texX + texWidth - 1, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x, y1, z2, texX + texWidth - 1, texY + texHeight - 1); m->index++; + ModelVertex_Init(&m->vertices[m->index], x, y2, z2, texX + texWidth, texY); m->index++; + ModelVertex_Init(&m->vertices[m->index], x, y1, z2, texX + texWidth, texY + texHeight); m->index++; } void BoxDesc_YQuad(IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texHeight, Real32 x1, Real32 x2, Real32 z1, Real32 z2, Real32 y) { - ModelVertex_Init(&m->vertices[m->index], x1, y, z2, texX, texY + texHeight - 1); m->index++; + ModelVertex_Init(&m->vertices[m->index], x1, y, z2, texX, texY + texHeight); m->index++; ModelVertex_Init(&m->vertices[m->index], x1, y, z1, texX, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x2, y, z1, texX + texWidth - 1, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x2, y, z2, texX + texWidth - 1, texY + texHeight - 1); m->index++; + ModelVertex_Init(&m->vertices[m->index], x2, y, z1, texX + texWidth, texY); m->index++; + ModelVertex_Init(&m->vertices[m->index], x2, y, z2, texX + texWidth, texY + texHeight); m->index++; } void BoxDesc_ZQuad(IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texHeight, Real32 x1, Real32 x2, Real32 y1, Real32 y2, Real32 z) { - ModelVertex_Init(&m->vertices[m->index], x1, y1, z, texX, texY + texHeight - 1); m->index++; + ModelVertex_Init(&m->vertices[m->index], x1, y1, z, texX, texY + texHeight); m->index++; ModelVertex_Init(&m->vertices[m->index], x1, y2, z, texX, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x2, y2, z, texX + texWidth - 1, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x2, y1, z, texX + texWidth - 1, texY + texHeight - 1); m->index++; + ModelVertex_Init(&m->vertices[m->index], x2, y2, z, texX + texWidth, texY); m->index++; + ModelVertex_Init(&m->vertices[m->index], x2, y1, z, texX + texWidth, texY + texHeight); m->index++; } #endif \ No newline at end of file