Skin layers added

This commit is contained in:
mschiller890
2026-03-13 16:56:27 +01:00
parent 450f0d9ec2
commit 85224c42b7
3 changed files with 54 additions and 11 deletions

View File

@@ -10,8 +10,8 @@ HumanoidModel::HumanoidModel( float g /*= 0*/, float yOffset /*= 0*/, int texW /
sneaking(false), sneaking(false),
bowAndArrow(false), bowAndArrow(false),
head(0, 0), head(0, 0),
hair(32, 0),
//ear (24, 0), //ear (24, 0),
//hair(32, 0),
body(16, 16), body(16, 16),
arm0(24 + 16, 16), arm0(24 + 16, 16),
arm1(24 + 16, 16), arm1(24 + 16, 16),
@@ -22,19 +22,28 @@ HumanoidModel::HumanoidModel( float g /*= 0*/, float yOffset /*= 0*/, int texW /
texHeight = texH; texHeight = texH;
head.setModel(this); head.setModel(this);
hair.setModel(this);
body.setModel(this); body.setModel(this);
arm0.setModel(this); arm0.setModel(this);
arm1.setModel(this); arm1.setModel(this);
leg0.setModel(this); leg0.setModel(this);
leg1.setModel(this); leg1.setModel(this);
// If the texture is 64x64, use the modern skin layout for arms/legs and add overlay layers.
bool modernSkin = (texWidth == 64 && texHeight == 64);
if (modernSkin) {
// Left arm and left leg are located in the bottom half of a 64x64 skin.
arm1.texOffs(32, 48);
leg1.texOffs(16, 48);
}
head.addBox(-4, -8, -4, 8, 8, 8, g); // Head head.addBox(-4, -8, -4, 8, 8, 8, g); // Head
head.setPos(0, 0 + yOffset, 0); head.setPos(0, 0 + yOffset, 0);
//ear.addBox(-3, -6, -1, 6, 6, 1, g); // Ear if (modernSkin) {
hair.addBox(-4, -8, -4, 8, 8, 8, g + 0.5f); // Outer head layer (hat)
//hair.addBox(-4, -8, -4, 8, 8, 8, g + 0.5f); // Head hair.setPos(0, 0 + yOffset, 0);
// hair.setPos(0, 0 + yOffset, 0); }
body.addBox(-4, 0, -2, 8, 12, 4, g); // Body body.addBox(-4, 0, -2, 8, 12, 4, g); // Body
body.setPos(0, 0 + yOffset, 0); body.setPos(0, 0 + yOffset, 0);
@@ -52,6 +61,24 @@ HumanoidModel::HumanoidModel( float g /*= 0*/, float yOffset /*= 0*/, int texW /
leg1.mirror = true; leg1.mirror = true;
leg1.addBox(-2, 0, -2, 4, 12, 4, g); // Leg1 leg1.addBox(-2, 0, -2, 4, 12, 4, g); // Leg1
leg1.setPos(2, 12 + yOffset, 0); leg1.setPos(2, 12 + yOffset, 0);
if (modernSkin) {
// Overlay layers for 64x64 skins (same geometry, different texture regions)
body.texOffs(16, 32);
body.addBox(-4, 0, -2, 8, 12, 4, g + 0.5f);
arm0.texOffs(40, 32);
arm0.addBox(-3, -2, -2, 4, 12, 4, g + 0.5f);
arm1.texOffs(48, 48);
arm1.addBox(-1, -2, -2, 4, 12, 4, g + 0.5f);
leg0.texOffs(0, 32);
leg0.addBox(-2, 0, -2, 4, 12, 4, g + 0.5f);
leg1.texOffs(0, 48);
leg1.addBox(-2, 0, -2, 4, 12, 4, g + 0.5f);
}
} }
void HumanoidModel::render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale ) void HumanoidModel::render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale )
@@ -71,14 +98,24 @@ void HumanoidModel::render(Entity* e, float time, float r, float bob, float yRot
setupAnim(time, r, bob, yRot, xRot, scale); setupAnim(time, r, bob, yRot, xRot, scale);
// Sync overlay with head rotation/position
if (texWidth == 64 && texHeight == 64) {
hair.xRot = head.xRot;
hair.yRot = head.yRot;
hair.zRot = head.zRot;
hair.y = head.y;
}
head.render(scale); head.render(scale);
if (texWidth == 64 && texHeight == 64) {
hair.render(scale);
}
body.render(scale); body.render(scale);
arm0.render(scale); arm0.render(scale);
arm1.render(scale); arm1.render(scale);
leg0.render(scale); leg0.render(scale);
leg1.render(scale); leg1.render(scale);
bowAndArrow = false; bowAndArrow = false;
//hair.render(scale);
} }
void HumanoidModel::render( HumanoidModel* model, float scale ) void HumanoidModel::render( HumanoidModel* model, float scale )
@@ -86,8 +123,12 @@ void HumanoidModel::render( HumanoidModel* model, float scale )
head.yRot = model->head.yRot; head.yRot = model->head.yRot;
head.y = model->head.y; head.y = model->head.y;
head.xRot = model->head.xRot; head.xRot = model->head.xRot;
//hair.yRot = head.yRot; if (texWidth == 64 && texHeight == 64) {
//hair.xRot = head.xRot; hair.yRot = head.yRot;
hair.xRot = head.xRot;
hair.zRot = head.zRot;
hair.y = head.y;
}
arm0.xRot = model->arm0.xRot; arm0.xRot = model->arm0.xRot;
arm0.zRot = model->arm0.zRot; arm0.zRot = model->arm0.zRot;
@@ -99,12 +140,14 @@ void HumanoidModel::render( HumanoidModel* model, float scale )
leg1.xRot = model->leg1.xRot; leg1.xRot = model->leg1.xRot;
head.render(scale); head.render(scale);
if (texWidth == 64 && texHeight == 64) {
hair.render(scale);
}
body.render(scale); body.render(scale);
arm0.render(scale); arm0.render(scale);
arm1.render(scale); arm1.render(scale);
leg0.render(scale); leg0.render(scale);
leg1.render(scale); leg1.render(scale);
//hair.render(scale);
} }
void HumanoidModel::renderHorrible( float time, float r, float bob, float yRot, float xRot, float scale ) void HumanoidModel::renderHorrible( float time, float r, float bob, float yRot, float xRot, float scale )

View File

@@ -18,7 +18,7 @@ HumanoidModel(float g = 0, float yOffset = 0, int texW = 64, int texH = 32);
void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale); void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale);
void onGraphicsReset(); void onGraphicsReset();
ModelPart head, /*hair,*/ body, arm0, arm1, leg0, leg1;//, ear; ModelPart head, hair, body, arm0, arm1, leg0, leg1;//, ear;
bool holdingLeftHand; bool holdingLeftHand;
bool holdingRightHand; bool holdingRightHand;
bool sneaking; bool sneaking;

View File

@@ -354,7 +354,7 @@ void ItemInHandRenderer::render( float a )
glRotatef2(-swing3 * 20, 0, 0, 1); glRotatef2(-swing3 * 20, 0, 0, 1);
// glRotatef2(-swing2 * 80, 1, 0, 0); // glRotatef2(-swing2 * 80, 1, 0, 0);
mc->textures->loadAndBindTexture("mob/char.png"); mc->textures->loadAndBindTexture(player->getTexture());
glTranslatef2(-1.0f, +3.6f, +3.5f); glTranslatef2(-1.0f, +3.6f, +3.5f);
glRotatef2(120, 0, 0, 1); glRotatef2(120, 0, 0, 1);
glRotatef2(180 + 20, 1, 0, 0); glRotatef2(180 + 20, 1, 0, 0);