The female body maps the painted eyes about 6 mm lower and a quarter closer together than the male one (read from bodymale/bodyfem and the skin UVs), so every race's male-tuned eyes sat on the female brow. PlayerFace moves them for the Dvergar, Aswid, Sverm and Alfar. Dvergar eyes shrink to an 18 mm radius. The Aswid's borrowed sockets are halved before the config multiplier and the smoke is off by default. Alfar eyes become slanted, wrapped black almonds with a wet sheen. They are placed in fixed head-local units: the live lossyScale under the non-uniform Alfar body drifted as the head turned, and the 0.5 s cosmetic pass made the eyes trail the face.
49 lines
2.4 KiB
C#
49 lines
2.4 KiB
C#
using UnityEngine;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
/// <summary>
|
|
/// Where a player's painted eyes are, for the races that hang something over them (Alfar,
|
|
/// Aswid, Dvergar, Sverm).
|
|
///
|
|
/// Every eye constant in this mod (0.081 forward, 0.181 up, 0.032 apart) was tuned on the MALE
|
|
/// body. The female body is a different mesh on the same rig and the same skin texture, and it
|
|
/// maps the painted eyes elsewhere: read offline from VisEquipment.m_models (bodymale vs
|
|
/// bodyfem, Valheim 1.0.20), by finding the dark socket pixels of PlayerCharacter_01 and
|
|
/// following the UVs back onto each mesh in head-bone space, the female eyes sit about 6mm
|
|
/// lower and a quarter closer together. Both are weighted 100% to Head, so once placed they
|
|
/// follow the head exactly; a sphere on the male spot simply sits on the brow, off the face.
|
|
///
|
|
/// HEAD-LOCAL UNITS. The player armature is authored at 100x, so one metre at human scale is
|
|
/// 0.01 in the head bone's own space. That is a constant of the rig, not of this frame:
|
|
/// reading headBone.lossyScale live instead breaks under a non-uniform body scale (the Alfar),
|
|
/// where the value drifts as the head turns.
|
|
/// </summary>
|
|
public static class PlayerFace
|
|
{
|
|
public const float MetresToHeadLocal = 0.01f;
|
|
|
|
// Female against male, measured as described above.
|
|
private const float FemaleHeightShift = -0.006f;
|
|
private const float FemaleSeparationScale = 0.75f;
|
|
private const float FemaleSizeScale = 0.9f;
|
|
|
|
/// <summary>True while the body wears the female mesh (VisEquipment model index 1).</summary>
|
|
public static bool IsFemale(Player player)
|
|
{
|
|
VisEquipment vis = player != null ? player.GetComponent<VisEquipment>() : null;
|
|
if (vis == null || vis.m_bodyModel == null || vis.m_models == null || vis.m_models.Length < 2) return false;
|
|
return vis.m_bodyModel.sharedMesh == vis.m_models[1].m_mesh;
|
|
}
|
|
|
|
/// <summary>Moves male-tuned eye numbers (metres) onto the female face; leaves a male face alone.</summary>
|
|
public static void AdjustEyes(Player player, ref float height, ref float separation, ref float size)
|
|
{
|
|
if (!IsFemale(player)) return;
|
|
|
|
height += FemaleHeightShift;
|
|
separation *= FemaleSeparationScale;
|
|
size *= FemaleSizeScale;
|
|
}
|
|
}
|
|
}
|