Added support for full armor masking

This commit is contained in:
MayNL
2026-02-18 20:32:41 -05:00
parent ef568ba63a
commit 354ffb8ace
6 changed files with 116 additions and 57 deletions

View File

@@ -73,7 +73,7 @@ namespace PckStudio.ModelSupport.Internal.Format
int uvX = mirrorAndUvX & 0x7f;
int uvY = hideWithArmorAndUvY & 0x7f;
bool mirror = (mirrorAndUvX & 0x80) != 0;
bool hideWithArmor = (hideWithArmorAndUvY & 0x80) != 0;
int hideWithArmor = (hideWithArmorAndUvY & 0x80);
float scale = reader.ReadSingle();
return new SkinBOX(type, new System.Numerics.Vector3(posX, posY, posZ), new System.Numerics.Vector3(sizeX, sizeY, sizeZ), new System.Numerics.Vector2(uvX, uvY), hideWithArmor, mirror, scale);
}

View File

@@ -60,8 +60,7 @@ namespace PckStudio.ModelSupport.Internal.Format
byte uvX = (byte)MathHelper.Clamp((int)part.UV.X, 0, 64);
byte uvY = (byte)MathHelper.Clamp((int)part.UV.Y, 0, 64);
byte mirrorAndUvX = (byte)(Convert.ToByte(part.Mirror) << 7 | uvX);
byte hideWithArmorAndUvY = (byte)(Convert.ToByte(part.HideWithArmor) << 7 | uvY);
byte hideWithArmorAndUvY = (byte)(Convert.ToByte(part.ArmorMaskFlags) << 7 | uvY);
writer.Write(mirrorAndUvX);
writer.Write(hideWithArmorAndUvY);
writer.Write(part.Scale);

View File

@@ -123,7 +123,7 @@ namespace PckStudio.ModelSupport
SkinBOX ApplyOffset(SkinBOX box)
{
SkinPartOffset offset = skinModel.PartOffsets.FirstOrDefault(offset => offset.Type == (box.IsOverlayPart() ? box.GetBaseType() : box.Type));
return string.IsNullOrEmpty(offset.Type) ? box : new SkinBOX(box.Type, box.Pos - (Vector3.UnitY * offset.Value), box.Size, box.UV, box.HideWithArmor, box.Mirror, box.Scale);
return string.IsNullOrEmpty(offset.Type) ? box : new SkinBOX(box.Type, box.Pos - (Vector3.UnitY * offset.Value), box.Size, box.UV, box.ArmorMaskFlags, box.Mirror, box.Scale);
}
IEnumerable<SkinBOX> convertedBoxes = boxes.Select(ApplyOffset);
@@ -310,10 +310,11 @@ namespace PckStudio.ModelSupport
foreach (Cube cube in bone.Cubes)
{
//TODO: add support for other armor flags
Vector3 pos = TranslateToInternalPosition(boxType, cube.Origin, cube.Size, Vector3.UnitY);
var skinBox = new SkinBOX(boxType, pos, cube.Size, cube.Uv, hideWithArmor: bone.Name == "helmet", mirror: cube.Mirror);
var skinBox = new SkinBOX(boxType, pos, cube.Size, cube.Uv, armorMaskFlags: Convert.ToInt32(bone.Name == "helmet"), mirror: cube.Mirror);
if (SkinBOX.IsBasePart(boxType) && ((boxType == "HEAD" && cube.Inflate == 0.5f) || (cube.Inflate >= 0.25f && cube.Inflate <= 0.5f)))
skinBox = new SkinBOX(SkinBOXExtensions.GetOverlayType(boxType), pos, cube.Size, cube.Uv, hideWithArmor: bone.Name == "helmet", mirror: cube.Mirror);
skinBox = new SkinBOX(SkinBOXExtensions.GetOverlayType(boxType), pos, cube.Size, cube.Uv, armorMaskFlags: Convert.ToInt32(bone.Name == "helmet"), mirror: cube.Mirror);
boxes.Add(skinBox);
}
}