feat(eyes): per-race eye position sliders in Configuration Manager
One 'Eyes Position - <race>' section each for the Alfar, Aswid, Dvergar and Sverm, with a female and a male set: forward, height, separation and size, plus rotation X/Y/Z for the Alfar and Aswid. All are deltas on the computed placement (0 and size 1 change nothing), read live, and left local by ConfigSync because they only change how this client draws faces.
This commit is contained in:
parent
a7e9996441
commit
8b2b5180ed
7 changed files with 155 additions and 11 deletions
|
|
@ -186,7 +186,23 @@ namespace RacesOfValheim
|
|||
float size = AlfarConfig.EyeSizeMultiplier.Value;
|
||||
PlayerFace.AdjustEyes(player, ref height, ref separation, ref size);
|
||||
|
||||
Vector3 baseOffset = frame.LocalForward * AlfarConfig.EyeForward + frame.LocalUp * height;
|
||||
float forward = AlfarConfig.EyeForward;
|
||||
float wrap = AlfarConfig.EyeWrap;
|
||||
float slant = AlfarConfig.EyeSlant;
|
||||
float tilt = 0f;
|
||||
EyePositionConfig.Tuning tuning = EyePositionConfig.For(AlfarConfig.RaceId, player);
|
||||
if (tuning != null)
|
||||
{
|
||||
forward += tuning.Forward.Value;
|
||||
height += tuning.Height.Value;
|
||||
separation += tuning.Separation.Value;
|
||||
size *= tuning.Size.Value;
|
||||
tilt = tuning.RotX;
|
||||
wrap += tuning.RotY;
|
||||
slant += tuning.RotZ;
|
||||
}
|
||||
|
||||
Vector3 baseOffset = frame.LocalForward * forward + frame.LocalUp * height;
|
||||
Vector3 extent = AlfarConfig.EyeExtent * (size * toLocal);
|
||||
Quaternion facing = Quaternion.LookRotation(frame.LocalForward, frame.LocalUp);
|
||||
|
||||
|
|
@ -200,7 +216,7 @@ namespace RacesOfValheim
|
|||
Vector3 offset = baseOffset + frame.LocalRight * (side * separation);
|
||||
|
||||
eye.localPosition = offset * toLocal;
|
||||
eye.localRotation = facing * Quaternion.Euler(0f, AlfarConfig.EyeWrap * side, AlfarConfig.EyeSlant * side);
|
||||
eye.localRotation = facing * Quaternion.Euler(tilt, wrap * side, slant * side);
|
||||
eye.localScale = extent;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,8 +320,15 @@ namespace RacesOfValheim
|
|||
|
||||
float scale = GetPlayerScale(player) * toLocal;
|
||||
|
||||
Vector3 shift = frame.LocalForward * (AswidConfig.EyeForwardOffset.Value * scale)
|
||||
+ frame.LocalUp * (AswidConfig.EyeHeightOffset.Value * scale);
|
||||
// The per-body sliders of "Eyes Position - Aswid", on top of the race's own offsets.
|
||||
EyePositionConfig.Tuning tuning = EyePositionConfig.For("Aswid", player);
|
||||
float forward = AswidConfig.EyeForwardOffset.Value + (tuning != null ? tuning.Forward.Value : 0f);
|
||||
float height = AswidConfig.EyeHeightOffset.Value + (tuning != null ? tuning.Height.Value : 0f);
|
||||
float separation = AswidConfig.EyeSeparationOffset.Value + (tuning != null ? tuning.Separation.Value : 0f);
|
||||
float size = AswidConfig.EyeSizeMultiplier.Value * (tuning != null ? tuning.Size.Value : 1f);
|
||||
|
||||
Vector3 shift = frame.LocalForward * (forward * scale)
|
||||
+ frame.LocalUp * (height * scale);
|
||||
|
||||
for (int i = 0; i < holder.childCount; i++)
|
||||
{
|
||||
|
|
@ -344,14 +351,14 @@ namespace RacesOfValheim
|
|||
// Pitch and roll are shared deliberately: both eyes looking up is a face looking
|
||||
// up, and mirroring either of those would cross them instead of aiming them.
|
||||
Quaternion twist = Quaternion.Euler(
|
||||
AswidConfig.EyeRotationX.Value,
|
||||
AswidConfig.EyeRotationY.Value * side,
|
||||
AswidConfig.EyeRotationZ.Value);
|
||||
AswidConfig.EyeRotationX.Value + (tuning != null ? tuning.RotX : 0f),
|
||||
(AswidConfig.EyeRotationY.Value + (tuning != null ? tuning.RotY : 0f)) * side,
|
||||
AswidConfig.EyeRotationZ.Value + (tuning != null ? tuning.RotZ * side : 0f));
|
||||
|
||||
eye.localPosition = authored.Position + shift +
|
||||
frame.LocalRight * (side * AswidConfig.EyeSeparationOffset.Value * scale);
|
||||
frame.LocalRight * (side * separation * scale);
|
||||
eye.localRotation = twist * authored.Rotation;
|
||||
eye.localScale = authored.Scale * AswidConfig.EyeSizeMultiplier.Value;
|
||||
eye.localScale = authored.Scale * size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ namespace RacesOfValheim
|
|||
|
||||
if (section.EndsWith("Keybinds", StringComparison.OrdinalIgnoreCase)) return false;
|
||||
if (LocalSections.Contains(section, StringComparer.OrdinalIgnoreCase)) return false;
|
||||
if (section.StartsWith(EyePositionConfig.SectionPrefix, StringComparison.OrdinalIgnoreCase)) return false;
|
||||
if (LocalKeyParts.Any(key.Contains)) return false;
|
||||
|
||||
// Model pose nudges (rotation/offset/yaw) are cosmetic, but "Attack Reach Offset" is a
|
||||
|
|
|
|||
|
|
@ -283,7 +283,17 @@ namespace RacesOfValheim
|
|||
float eyeSize = DvergarConfig.EyeSize;
|
||||
PlayerFace.AdjustEyes(player, ref height, ref separation, ref eyeSize);
|
||||
|
||||
Vector3 baseLocal = localForward * (DvergarConfig.EyeForward * raceScale * toLocal)
|
||||
float forward = DvergarConfig.EyeForward;
|
||||
EyePositionConfig.Tuning tuning = EyePositionConfig.For(DvergarConfig.RaceId, player);
|
||||
if (tuning != null)
|
||||
{
|
||||
forward += tuning.Forward.Value;
|
||||
height += tuning.Height.Value;
|
||||
separation += tuning.Separation.Value;
|
||||
eyeSize *= tuning.Size.Value;
|
||||
}
|
||||
|
||||
Vector3 baseLocal = localForward * (forward * raceScale * toLocal)
|
||||
+ localUp * (height * raceScale * toLocal);
|
||||
|
||||
float eyeLocalSize = eyeSize * raceScale * toLocal;
|
||||
|
|
|
|||
98
JotunnModStub/EyePositionConfig.cs
Normal file
98
JotunnModStub/EyePositionConfig.cs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// Hand placement for every race that hangs eyes on the face: one "Eyes Position - race"
|
||||
/// section each, with a female and a male set, because the two bodies put their painted eyes
|
||||
/// in different places (PlayerFace). Every value is a delta on the placement the race's own
|
||||
/// code computes, so all zeros (and size 1) is the shipped look.
|
||||
///
|
||||
/// Local, never synced (ConfigSync): it only changes how this client draws faces.
|
||||
/// </summary>
|
||||
public static class EyePositionConfig
|
||||
{
|
||||
public const string SectionPrefix = "Eyes Position - ";
|
||||
|
||||
/// <summary>One body's sliders for one race.</summary>
|
||||
public sealed class Tuning
|
||||
{
|
||||
public ConfigEntry<float> Forward;
|
||||
public ConfigEntry<float> Height;
|
||||
public ConfigEntry<float> Separation;
|
||||
public ConfigEntry<float> Size;
|
||||
|
||||
// Only bound for races whose eyes are not spheres; null elsewhere.
|
||||
public ConfigEntry<float> RotationX;
|
||||
public ConfigEntry<float> RotationY;
|
||||
public ConfigEntry<float> RotationZ;
|
||||
|
||||
public float RotX => RotationX != null ? RotationX.Value : 0f;
|
||||
public float RotY => RotationY != null ? RotationY.Value : 0f;
|
||||
public float RotZ => RotationZ != null ? RotationZ.Value : 0f;
|
||||
}
|
||||
|
||||
// [race] -> { male, female }
|
||||
private static readonly Dictionary<string, Tuning[]> tunings = new Dictionary<string, Tuning[]>();
|
||||
|
||||
public static void Bind(ConfigFile config)
|
||||
{
|
||||
BindRace(config, AlfarConfig.RaceId, true);
|
||||
BindRace(config, "Aswid", true);
|
||||
BindRace(config, DvergarConfig.RaceId, false);
|
||||
BindRace(config, SvermConfig.RaceId, false);
|
||||
}
|
||||
|
||||
/// <summary>The sliders for the body this player is wearing right now.</summary>
|
||||
public static Tuning For(string race, Player player)
|
||||
{
|
||||
if (!tunings.TryGetValue(race, out Tuning[] pair)) return null;
|
||||
return pair[PlayerFace.IsFemale(player) ? 1 : 0];
|
||||
}
|
||||
|
||||
private static void BindRace(ConfigFile config, string race, bool rotation)
|
||||
{
|
||||
string section = SectionPrefix + race;
|
||||
tunings[race] = new[]
|
||||
{
|
||||
BindBody(config, section, "Male", rotation, 100),
|
||||
BindBody(config, section, "Female", rotation, 200),
|
||||
};
|
||||
}
|
||||
|
||||
private static Tuning BindBody(ConfigFile config, string section, string body, bool rotation, int order)
|
||||
{
|
||||
// Female first in the list: Order sorts high to low.
|
||||
Tuning t = new Tuning();
|
||||
|
||||
t.Forward = config.Bind(section, body + " Forward", 0f,
|
||||
new ConfigDescription($"{body} characters: moves both eyes out of (+) or into (-) the face, in metres.",
|
||||
new AcceptableValueRange<float>(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 9 }));
|
||||
t.Height = config.Bind(section, body + " Height", 0f,
|
||||
new ConfigDescription($"{body} characters: moves both eyes up (+) or down (-), in metres.",
|
||||
new AcceptableValueRange<float>(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 8 }));
|
||||
t.Separation = config.Bind(section, body + " Separation", 0f,
|
||||
new ConfigDescription($"{body} characters: pushes the eyes apart (+) or together (-), in metres. Each eye moves by this much.",
|
||||
new AcceptableValueRange<float>(-0.03f, 0.03f), new ConfigurationManagerAttributes { Order = order + 7 }));
|
||||
t.Size = config.Bind(section, body + " Size", 1f,
|
||||
new ConfigDescription($"{body} characters: scales both eyes. 1 is the default size.",
|
||||
new AcceptableValueRange<float>(0.2f, 3f), new ConfigurationManagerAttributes { Order = order + 6 }));
|
||||
|
||||
if (rotation)
|
||||
{
|
||||
t.RotationX = config.Bind(section, body + " Rotation X", 0f,
|
||||
new ConfigDescription($"{body} characters: tilts both eyes up or down, in degrees.",
|
||||
new AcceptableValueRange<float>(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 5 }));
|
||||
t.RotationY = config.Bind(section, body + " Rotation Y", 0f,
|
||||
new ConfigDescription($"{body} characters: turns the eyes toward the temples (+) or the nose (-), in degrees. Mirrored between the two eyes.",
|
||||
new AcceptableValueRange<float>(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 4 }));
|
||||
t.RotationZ = config.Bind(section, body + " Rotation Z", 0f,
|
||||
new ConfigDescription($"{body} characters: raises (+) or lowers (-) the outer corners, in degrees. Mirrored between the two eyes.",
|
||||
new AcceptableValueRange<float>(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 3 }));
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +56,8 @@ namespace RacesOfValheim
|
|||
// Not a race either: the faction truce and the faction merchants, which cut across
|
||||
// every race at once, so they bind last rather than inside the alphabetical run above.
|
||||
FactionsConfig.Bind(Config);
|
||||
// Not a race either: the hand placement of every race's eyes, one section per race.
|
||||
EyePositionConfig.Bind(Config);
|
||||
// After every Bind above: tags the gameplay entries for Jotunn's server-to-client sync.
|
||||
ConfigSync.Apply(Config);
|
||||
harmony.PatchAll();
|
||||
|
|
|
|||
|
|
@ -256,7 +256,17 @@ namespace RacesOfValheim
|
|||
float eyeSize = EyeSize;
|
||||
PlayerFace.AdjustEyes(player, ref height, ref separation, ref eyeSize);
|
||||
|
||||
Vector3 baseLocal = frame.LocalForward * (EyeForward * scale * toLocal)
|
||||
float forward = EyeForward;
|
||||
EyePositionConfig.Tuning tuning = EyePositionConfig.For(SvermConfig.RaceId, player);
|
||||
if (tuning != null)
|
||||
{
|
||||
forward += tuning.Forward.Value;
|
||||
height += tuning.Height.Value;
|
||||
separation += tuning.Separation.Value;
|
||||
eyeSize *= tuning.Size.Value;
|
||||
}
|
||||
|
||||
Vector3 baseLocal = frame.LocalForward * (forward * scale * toLocal)
|
||||
+ frame.LocalUp * (height * scale * toLocal);
|
||||
|
||||
float eyeLocalSize = eyeSize * scale * toLocal;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue