Skip to content

Instantly share code, notes, and snippets.

@yakumo-proj
Last active December 18, 2021 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yakumo-proj/649f74ad188b32b7773bdb488110cdc2 to your computer and use it in GitHub Desktop.
Save yakumo-proj/649f74ad188b32b7773bdb488110cdc2 to your computer and use it in GitHub Desktop.
VRoid正式版の表情ブレンドシェイプをVRoidモバイル用に置換するコード in C#
using System;
using System.Collections.Generic;
using System.Json;
using System.Linq;
namespace VRMTextureUtil
{
public class VRoidLegacyFaceShapeKeyReplacer
{
static Dictionary<string, string> tables = new Dictionary<string, string>() {
["Fcl_ALL_Neutral"] = "Face.M_F00_000_00_Fcl_ALL_Neutral",
["Fcl_ALL_Angry"] = "Face.M_F00_000_00_Fcl_ALL_Angry",
["Fcl_ALL_Fun"] = "Face.M_F00_000_00_Fcl_ALL_Fun",
["Fcl_ALL_Joy"] = "Face.M_F00_000_00_Fcl_ALL_Joy",
["Fcl_ALL_Sorrow"] = "Face.M_F00_000_00_Fcl_ALL_Sorrow",
["Fcl_ALL_Surprised"] = "Face.M_F00_000_00_Fcl_ALL_Surprised",
["Fcl_BRW_Angry"] = "Face.M_F00_000_00_Fcl_BRW_Angry",
["Fcl_BRW_Fun"] = "Face.M_F00_000_00_Fcl_BRW_Fun",
["Fcl_BRW_Joy"] = "Face.M_F00_000_00_Fcl_BRW_Joy",
["Fcl_BRW_Sorrow"] = "Face.M_F00_000_00_Fcl_BRW_Sorrow",
["Fcl_BRW_Surprised"] = "Face.M_F00_000_00_Fcl_BRW_Surprised",
["Fcl_EYE_Natural"] = "Face.M_F00_000_00_Fcl_EYE_Natural",
["Fcl_EYE_Angry"] = "Face.M_F00_000_00_Fcl_EYE_Angry",
["Fcl_EYE_Close"] = "Face.M_F00_000_00_Fcl_EYE_Close",
["Fcl_EYE_Close_R"] = "Face.M_F00_000_00_Fcl_EYE_Close_R",
["Fcl_EYE_Close_L"] = "Face.M_F00_000_00_Fcl_EYE_Close_L",
["Fcl_EYE_Fun"] = "Face.M_F00_000_00_Fcl_Eye_Fun",
["Fcl_EYE_Joy"] = "Face.M_F00_000_00_Fcl_EYE_Joy",
["Fcl_EYE_Joy_R"] = "Face.M_F00_000_00_Fcl_EYE_Joy_R",
["Fcl_EYE_Joy_L"] = "Face.M_F00_000_00_Fcl_EYE_Joy_L",
["Fcl_EYE_Sorrow"] = "Face.M_F00_000_00_Fcl_EYE_Sorrow",
["Fcl_EYE_Surprised"] = "Face.M_F00_000_00_Fcl_EYE_Surprised",
["Fcl_EYE_Spread"] = "Face.M_F00_000_00_Fcl_EYE_Spread",
["Fcl_EYE_Iris_Hide"] = "Face.M_F00_000_00_Fcl_EYE_Iris_Hide",
["Fcl_EYE_Highlight_Hide"] = "Face.M_F00_000_00_Fcl_EYE_Highlight_Hide",
["Fcl_MTH_Up"] = "Face.M_F00_000_00_Fcl_MTH_Up",
["Fcl_MTH_Down"] = "Face.M_F00_000_00_Fcl_MTH_Down",
["Fcl_MTH_Angry"] = "Face.M_F00_000_00_Fcl_MTH_Angry",
["Fcl_MTH_Neutral"] = "Face.M_F00_000_00_Fcl_MTH_Neutral",
["Fcl_MTH_Fun"] = "Face.M_F00_000_00_Fcl_MTH_Fun",
["Fcl_MTH_Joy"] = "Face.M_F00_000_00_Fcl_MTH_Joy",
["Fcl_MTH_Sorrow"] = "Face.M_F00_000_00_Fcl_MTH_Sorrow",
["Fcl_MTH_Surprised"] = "Face.M_F00_000_00_Fcl_MTH_Surprised",
["Fcl_MTH_SkinFung"] = "Face.M_F00_000_00_Fcl_MTH_SkinFung",
["Fcl_MTH_SkinFung_R"] = "Face.M_F00_000_00_Fcl_MTH_SkinFung_R",
["Fcl_MTH_SkinFung_L"] = "Face.M_F00_000_00_Fcl_MTH_SkinFung_L",
["Fcl_MTH_A"] = "Face.M_F00_000_00_Fcl_MTH_A",
["Fcl_MTH_I"] = "Face.M_F00_000_00_Fcl_MTH_I",
["Fcl_MTH_U"] = "Face.M_F00_000_00_Fcl_MTH_U",
["Fcl_MTH_E"] = "Face.M_F00_000_00_Fcl_MTH_E",
["Fcl_MTH_O"] = "Face.M_F00_000_00_Fcl_MTH_O",
["Fcl_HA_Hide"] = "Face.M_F00_000_00_Fcl_HA_Hide",
["Fcl_HA_Fung1"] = "Face.M_F00_000_00_Fcl_HA_Fung1",
["Fcl_HA_Fung1_Low"] = "Face.M_F00_000_00_Fcl_HA_Fung1_Low",
["Fcl_HA_Fung1_Up"] = "Face.M_F00_000_00_Fcl_HA_Fung1_Up",
["Fcl_HA_Fung2"] = "Face.M_F00_000_00_Fcl_HA_Fung2",
["Fcl_HA_Fung2_Low"] = "Face.M_F00_000_00_Fcl_HA_Fung2_Low",
["Fcl_HA_Fung2_Up"] = "Face.M_F00_000_00_Fcl_HA_Fung2_Up",
["Fcl_HA_Fung3"] = "Face.M_F00_000_00_Fcl_HA_Fung3",
["Fcl_HA_Fung3_Up"] = "Face.M_F00_000_00_Fcl_HA_Fung3_Up",
["Fcl_HA_Fung3_Low"] = "Face.M_F00_000_00_Fcl_HA_Fung3_Low",
["Fcl_HA_Short"] = "Face.M_F00_000_00_Fcl_HA_Short",
["Fcl_HA_Short_Up"] = "Face.M_F00_000_00_Fcl_HA_Short_Up",
["Fcl_HA_Short_Low"] = "Face.M_F00_000_00_Fcl_HA_Short_Low",
};
public static void Replace(ref JsonValue gltf)
{
var result = gltf["meshes"][0]["primitives"].OfType<JsonValue>().Select(node => {
if (node["extras"] == null || node["extras"]["targetNames"] == null) {
return node;
}
var names = node["extras"]["targetNames"].OfType<JsonValue>().Select(str => {
string outVal;
return new JsonPrimitive(tables.TryGetValue(str, out outVal) ? outVal : str);
}).ToArray();
node["extras"]["targetNames"] = new JsonArray(names);
return node;
});
gltf["meshes"][0]["primitives"] = new JsonArray(result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment