Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: loading characters with custom colors via projects #136

Merged
merged 11 commits into from
Feb 20, 2025
28 changes: 28 additions & 0 deletions Brio/Core/BrioUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Brio.Game.Actor.Appearance;
using Brio.Game.Actor.Interop;

namespace Brio.Core;


public static class BrioUtilities
{
// Imports Custom Colors from Chara files into Brio Shaders
public static void ImportShadersFromFile(ref ModelShaderOverride modelShaderOverride, BrioHuman.ShaderParams shaderParams)
{
modelShaderOverride.SkinColor = shaderParams.SkinColor;
modelShaderOverride.SkinGloss = shaderParams.SkinGloss;
modelShaderOverride.MuscleTone = shaderParams.MuscleTone;
modelShaderOverride.MouthColor = shaderParams.MouthColor;
modelShaderOverride.HairColor = shaderParams.HairColor;
modelShaderOverride.HairGloss = shaderParams.HairGloss;
modelShaderOverride.HairHighlight = shaderParams.HairHighlight;
modelShaderOverride.LeftEyeColor = shaderParams.LeftEyeColor;
modelShaderOverride.RightEyeColor = shaderParams.RightEyeColor;
modelShaderOverride.FeatureColor = shaderParams.FeatureColor;
}
}
5 changes: 4 additions & 1 deletion Brio/Game/Scene/SceneService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Brio.Capabilities.Posing;
using Brio.Capabilities.World;
using Brio.Config;
using Brio.Core;
using Brio.Entities;
using Brio.Entities.Actor;
using Brio.Entities.Core;
Expand All @@ -10,6 +11,7 @@
using Brio.Game.Actor;
using Brio.Game.Actor.Appearance;
using Brio.Game.Actor.Extensions;
using Brio.Game.Actor.Interop;
using Brio.Game.Camera;
using Brio.Game.Core;
using Brio.Game.Posing;
Expand All @@ -18,7 +20,7 @@

namespace Brio.Game.Scene;

public class SceneService(EntityManager _entityManager, VirtualCameraManager _virtualCameraManager, PosingService _posingService, ActorSpawnService _actorSpawnService, IClientState _clientState, IFramework _framework)

Check warning on line 23 in Brio/Game/Scene/SceneService.cs

View workflow job for this annotation

GitHub Actions / build

Parameter '_posingService' is unread.

Check warning on line 23 in Brio/Game/Scene/SceneService.cs

View workflow job for this annotation

GitHub Actions / build

Parameter '_actorSpawnService' is unread.

Check warning on line 23 in Brio/Game/Scene/SceneService.cs

View workflow job for this annotation

GitHub Actions / build

Parameter '_clientState' is unread.

Check warning on line 23 in Brio/Game/Scene/SceneService.cs

View workflow job for this annotation

GitHub Actions / build

Parameter '_posingService' is unread.

Check warning on line 23 in Brio/Game/Scene/SceneService.cs

View workflow job for this annotation

GitHub Actions / build

Parameter '_actorSpawnService' is unread.

Check warning on line 23 in Brio/Game/Scene/SceneService.cs

View workflow job for this annotation

GitHub Actions / build

Parameter '_clientState' is unread.
{
public bool IsLoading { get; private set; }

Expand Down Expand Up @@ -93,7 +95,7 @@
);
}
else
{
{
var (actorId, actor) = actorCapability.CreateCharacter(actorFile.HasChild, false, forceSpawnActorWithoutCompanion: !actorFile.HasChild);

_framework.RunUntilSatisfied(
Expand Down Expand Up @@ -169,6 +171,7 @@

await _framework.RunOnTick(async () =>
{
BrioUtilities.ImportShadersFromFile(ref appearanceCapability._modelShaderOverride, actorFile.AnamnesisCharaFile);
await appearanceCapability.SetAppearance(actorFile.AnamnesisCharaFile, AppearanceImportOptions.All);

await _framework.RunOnTick(async () =>
Expand Down
18 changes: 2 additions & 16 deletions Brio/UI/Controls/Stateless/FileUIHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,6 @@ public static void ShowExportPoseModal(PosingCapability capability)
}, ConfigurationService.Instance.Configuration.LastExportPath, true);
}

public static void ImportShadersFromFile(ref ModelShaderOverride modelShaderOverride, BrioHuman.ShaderParams shaderParams)
{
modelShaderOverride.SkinColor = shaderParams.SkinColor;
modelShaderOverride.SkinGloss = shaderParams.SkinGloss;
modelShaderOverride.MuscleTone = shaderParams.MuscleTone;
modelShaderOverride.MouthColor = shaderParams.MouthColor;
modelShaderOverride.HairColor = shaderParams.HairColor;
modelShaderOverride.HairGloss = shaderParams.HairGloss;
modelShaderOverride.HairHighlight = shaderParams.HairHighlight;
modelShaderOverride.LeftEyeColor = shaderParams.LeftEyeColor;
modelShaderOverride.RightEyeColor = shaderParams.RightEyeColor;
modelShaderOverride.FeatureColor = shaderParams.FeatureColor;
}

public static void ShowImportCharacterModal(ActorAppearanceCapability capability, AppearanceImportOptions options)
{
List<Type> types = [typeof(ActorAppearanceUnion), typeof(AnamnesisCharaFile)];
Expand All @@ -310,7 +296,7 @@ public static void ShowImportCharacterModal(ActorAppearanceCapability capability
if (options.HasFlag(AppearanceImportOptions.Shaders))
{
BrioHuman.ShaderParams shaderParams = appearanceFile;
ImportShadersFromFile(ref capability._modelShaderOverride, shaderParams);
BrioUtilities.ImportShadersFromFile(ref capability._modelShaderOverride, shaderParams);
}
_ = capability.SetAppearance(appearanceFile, options);
}
Expand All @@ -334,7 +320,7 @@ public static void ShowImportCharacterModal(ActorAppearanceCapability capability
if(options.HasFlag(AppearanceImportOptions.Shaders))
{
BrioHuman.ShaderParams shaderParams = appearanceFile;
ImportShadersFromFile(ref capability._modelShaderOverride, shaderParams);
BrioUtilities.ImportShadersFromFile(ref capability._modelShaderOverride, shaderParams);
}
_ = capability.SetAppearance(appearanceFile, options);
}
Expand Down
Loading