mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-07 03:00:49 +00:00
Move static variables from 'ModelPartSpecifics' to 'GameConstants'
This commit is contained in:
@@ -2,14 +2,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PckStudio.Extensions;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Internal
|
||||
{
|
||||
internal static class GameConstants
|
||||
{
|
||||
|
||||
internal static readonly Vector3 SkinHeadTranslation = Vector3.Zero;
|
||||
internal static readonly Vector3 SkinHeadPivot = Vector3.Zero;
|
||||
|
||||
internal static readonly Vector3 SkinBodyTranslation = Vector3.Zero;
|
||||
internal static readonly Vector3 SkinBodyPivot = Vector3.Zero;
|
||||
|
||||
internal static readonly Vector3 SkinRightArmTranslation = new(-5f, 2f, 0f);
|
||||
internal static readonly Vector3 SkinRightArmPivot = new(-6f, 2f, 0f);
|
||||
|
||||
internal static readonly Vector3 SkinLeftArmTranslation = new(5f, 2f, 0f);
|
||||
internal static readonly Vector3 SkinLeftArmPivot = new(6f, 2f, 0f);
|
||||
|
||||
internal static readonly Vector3 SkinRightLegTranslation = new(-2f, 12f, 0f);
|
||||
internal static readonly Vector3 SkinRightLegPivot = new(-2f, 12f, 0f);
|
||||
|
||||
internal static readonly Vector3 SkinLeftLegTranslation = new(2f, 12f, 0f);
|
||||
internal static readonly Vector3 SkinLeftLegPivot = new(2f, 12f, 0f);
|
||||
|
||||
private static Dictionary<string, PositioningInfo> _posisioningInfos = new Dictionary<string, PositioningInfo>()
|
||||
{
|
||||
["HEAD"] = new PositioningInfo(SkinHeadTranslation, SkinHeadPivot),
|
||||
["BODY"] = new PositioningInfo(SkinBodyTranslation, SkinBodyPivot),
|
||||
["ARM0"] = new PositioningInfo(SkinRightArmTranslation, SkinRightArmPivot),
|
||||
["ARM1"] = new PositioningInfo(SkinLeftArmTranslation, SkinLeftArmPivot),
|
||||
["LEG0"] = new PositioningInfo(SkinRightLegTranslation, SkinRightLegPivot),
|
||||
["LEG1"] = new PositioningInfo(SkinLeftLegTranslation, SkinLeftLegPivot),
|
||||
};
|
||||
internal record struct PositioningInfo(Vector3 Translation, Vector3 Pivot);
|
||||
|
||||
internal static PositioningInfo GetPositioningInfo(string partName)
|
||||
{
|
||||
if (SkinBOX.IsOverlayPart(partName))
|
||||
partName = SkinBOXExtensions.GetBaseType(partName);
|
||||
return _posisioningInfos.ContainsKey(partName) ? _posisioningInfos[partName] : default;
|
||||
}
|
||||
|
||||
internal static Vector3 GetSkinPartPivot(string partName) => GetPositioningInfo(partName).Pivot;
|
||||
|
||||
internal static Vector3 GetSkinPartTranslation(string partName) => GetPositioningInfo(partName).Translation;
|
||||
|
||||
public const int GameTickInMilliseconds = 50;
|
||||
|
||||
// See: https://minecraft.fandom.com/wiki/Dye#Color_values for more information.
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using PckStudio.Extensions;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Internal
|
||||
{
|
||||
internal static class ModelPartSpecifics
|
||||
{
|
||||
private static Dictionary<string, PositioningInfo> _posisioningInfos = new Dictionary<string, PositioningInfo>()
|
||||
{
|
||||
["HEAD"] = new PositioningInfo(),
|
||||
["BODY"] = new PositioningInfo(),
|
||||
["ARM0"] = new PositioningInfo(new(-5f, 2f, 0f), new(-6f, 2f, 0f)),
|
||||
["ARM1"] = new PositioningInfo(new( 5f, 2f, 0f), new( 6f, 2f, 0f)),
|
||||
["LEG0"] = new PositioningInfo(new(-2f, 12f, 0f), new(-2f, 12f, 0f)),
|
||||
["LEG1"] = new PositioningInfo(new( 2f, 12f, 0f), new( 2f, 12f, 0f)),
|
||||
};
|
||||
|
||||
internal record struct PositioningInfo(Vector3 Translation, Vector3 Pivot);
|
||||
|
||||
internal static PositioningInfo GetPositioningInfo(string partName)
|
||||
{
|
||||
if (SkinBOX.IsOverlayPart(partName))
|
||||
partName = SkinBOXExtensions.GetBaseType(partName);
|
||||
return _posisioningInfos.ContainsKey(partName) ? _posisioningInfos[partName] : default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,7 +465,7 @@ namespace PckStudio.Internal
|
||||
|
||||
private static Vector3 GetOffsetFromOrigin(string boxType, Vector3 origin)
|
||||
{
|
||||
Vector3 partTranslation = ModelPartSpecifics.GetPositioningInfo(boxType).Pivot;
|
||||
Vector3 partTranslation = GameConstants.GetSkinPartPivot(boxType);
|
||||
Vector3 offset = partTranslation - ((Vector3.UnitY * 24f) - origin);
|
||||
if (offset.X != 0f || offset.Z != 0f)
|
||||
Trace.TraceWarning($"[{nameof(SkinModelImporter)}:{nameof(GetOffsetFromOrigin)}] Warning: skin part({boxType}) offsets only support horizontal offsets.");
|
||||
@@ -474,7 +474,7 @@ namespace PckStudio.Internal
|
||||
|
||||
private static Vector3 GetSkinPartPivot(string partName, Vector3 translationUnit)
|
||||
{
|
||||
return TransformSpace(ModelPartSpecifics.GetPositioningInfo(partName).Pivot, Vector3.Zero, translationUnit) + (24f * Vector3.UnitY);
|
||||
return TransformSpace(GameConstants.GetSkinPartPivot(partName), Vector3.Zero, translationUnit) + (24f * Vector3.UnitY);
|
||||
}
|
||||
|
||||
private static Vector3 GetOffsetForPart(string offsetType, ref Dictionary<string, SkinPartOffset> offsetLookUp, IEnumerable<SkinPartOffset> partOffsets)
|
||||
@@ -542,7 +542,7 @@ namespace PckStudio.Internal
|
||||
pos.Y += 24f;
|
||||
|
||||
// This will cancel out the part specific translation.
|
||||
Vector3 translation = ModelPartSpecifics.GetPositioningInfo(boxType).Translation;
|
||||
Vector3 translation = GameConstants.GetSkinPartTranslation(boxType);
|
||||
pos -= translation;
|
||||
|
||||
return pos;
|
||||
|
||||
@@ -189,7 +189,6 @@
|
||||
<Compile Include="Internal\GameModelImporter.cs" />
|
||||
<Compile Include="Internal\ModelImporter.cs" />
|
||||
<Compile Include="Internal\SkinModelImporter.cs" />
|
||||
<Compile Include="Internal\ModelPartSpecifics.cs" />
|
||||
<Compile Include="Internal\Json\JsonModelMetaData.cs" />
|
||||
<Compile Include="Internal\NamedTexture.cs" />
|
||||
<Compile Include="Internal\Json\UpdateInformation.cs" />
|
||||
|
||||
@@ -297,36 +297,30 @@ namespace PckStudio.Rendering
|
||||
|
||||
private void InitializeSkinData()
|
||||
{
|
||||
ModelPartSpecifics.PositioningInfo headInfo = ModelPartSpecifics.GetPositioningInfo("HEAD");
|
||||
head ??= new CubeMeshCollection("Head", headInfo.Translation.ToOpenTKVector(), headInfo.Pivot.ToOpenTKVector())
|
||||
head ??= new CubeMeshCollection("Head", GameConstants.SkinHeadTranslation.ToOpenTKVector(), GameConstants.SkinHeadPivot.ToOpenTKVector())
|
||||
{
|
||||
FlipZMapping = true
|
||||
};
|
||||
head.AddNamed("DefaultHead", new(-4, -8, -4), new(8, 8, 8), new(0, 0));
|
||||
head.AddNamed("DefaultHeadOverlay", new(-4, -8, -4), new(8, 8, 8), new(32, 0), OverlayScale * 2);
|
||||
|
||||
ModelPartSpecifics.PositioningInfo bodyInfo = ModelPartSpecifics.GetPositioningInfo("BODY");
|
||||
body ??= new CubeMeshCollection("Body", bodyInfo.Translation.ToOpenTKVector(), bodyInfo.Pivot.ToOpenTKVector());
|
||||
body ??= new CubeMeshCollection("Body", GameConstants.SkinBodyTranslation.ToOpenTKVector(), GameConstants.SkinBodyPivot.ToOpenTKVector());
|
||||
body.AddNamed("DefaultBody",new(-4, 0, -2), new(8, 12, 4), new(16, 16));
|
||||
body.AddNamed("DefaultBodyOverlay", new(-4, 0, -2), new(8, 12, 4), new(16, 32), OverlayScale);
|
||||
|
||||
ModelPartSpecifics.PositioningInfo rightArmInfo = ModelPartSpecifics.GetPositioningInfo("ARM0");
|
||||
rightArm ??= new CubeMeshCollection("Right Arm", rightArmInfo.Translation.ToOpenTKVector(), rightArmInfo.Pivot.ToOpenTKVector());
|
||||
rightArm ??= new CubeMeshCollection("Right Arm", GameConstants.SkinRightArmTranslation.ToOpenTKVector(), GameConstants.SkinRightArmPivot.ToOpenTKVector());
|
||||
rightArm.AddNamed("DefaultRightArm",new(-3, -2, -2), new(4, 12, 4), new(40, 16));
|
||||
rightArm.AddNamed("DefaultRightArmOverlay", new(-3, -2, -2), new(4, 12, 4), new(40, 32), OverlayScale);
|
||||
|
||||
ModelPartSpecifics.PositioningInfo leftArmInfo = ModelPartSpecifics.GetPositioningInfo("ARM1");
|
||||
leftArm ??= new CubeMeshCollection("Left Arm", leftArmInfo.Translation.ToOpenTKVector(), leftArmInfo.Pivot.ToOpenTKVector());
|
||||
leftArm ??= new CubeMeshCollection("Left Arm", GameConstants.SkinLeftArmTranslation.ToOpenTKVector(), GameConstants.SkinLeftArmPivot.ToOpenTKVector());
|
||||
leftArm.AddNamed("DefaultLeftArm",new(-1, -2, -2), new(4, 12, 4), new(32, 48));
|
||||
leftArm.AddNamed("DefaultLeftArmOverlay", new(-1, -2, -2), new(4, 12, 4), new(48, 48), inflate: OverlayScale);
|
||||
|
||||
ModelPartSpecifics.PositioningInfo rightLegInfo = ModelPartSpecifics.GetPositioningInfo("LEG0");
|
||||
rightLeg ??= new CubeMeshCollection("Right Leg", rightLegInfo.Translation.ToOpenTKVector(), rightLegInfo.Pivot.ToOpenTKVector());
|
||||
rightLeg ??= new CubeMeshCollection("Right Leg", GameConstants.SkinRightLegTranslation.ToOpenTKVector(), GameConstants.SkinRightLegPivot.ToOpenTKVector());
|
||||
rightLeg.AddNamed("DefaultRightLeg",new(-2, 0, -2), new(4, 12, 4), new(0, 16));
|
||||
rightLeg.AddNamed("DefaultRightLegOverlay", new(-2, 0, -2), new(4, 12, 4), new(0, 32), OverlayScale);
|
||||
|
||||
ModelPartSpecifics.PositioningInfo leftLegInfo = ModelPartSpecifics.GetPositioningInfo("LEG1");
|
||||
leftLeg ??= new CubeMeshCollection("Left Leg", leftLegInfo.Translation.ToOpenTKVector(), leftLegInfo.Pivot.ToOpenTKVector());
|
||||
leftLeg ??= new CubeMeshCollection("Left Leg", GameConstants.SkinLeftLegTranslation.ToOpenTKVector(), GameConstants.SkinLeftLegPivot.ToOpenTKVector());
|
||||
leftLeg.AddNamed("DefaultLeftLeg",new(-2, 0, -2), new(4, 12, 4), new(16, 48));
|
||||
leftLeg.AddNamed("DefaultLeftLegOverlay", new(-2, 0, -2), new(4, 12, 4), new(0, 48), OverlayScale);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user