Skip to content

Commit

Permalink
1.6.3
Browse files Browse the repository at this point in the history
GameBase override detection.
WrinkleManager head material detection.
  • Loading branch information
soupday committed Jul 29, 2024
1 parent 5e63fa8 commit cae3fb3
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 45 deletions.
120 changes: 76 additions & 44 deletions Editor/RL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.IO;
using UnityEditor.Animations;
using System.Reflection;
using System.Linq;

namespace Reallusion.Import
{
Expand Down Expand Up @@ -56,66 +57,97 @@ public class RL
{ "RL_G6_Standard_Series", BaseGeneration.G1 },
{ "NonStdLookAtDataCopyFromCCBase", BaseGeneration.ActorCore },
{ "ActorBuild", BaseGeneration.ActorBuild },
{ "ActorScan", BaseGeneration.ActorCore }
{ "ActorScan", BaseGeneration.ActorCore },
{ "AccuRig", BaseGeneration.ActorBuild }
};
public static BaseGeneration GetCharacterGeneration(GameObject fbx, string generationString)

public static bool CharacterContainsBones(Transform[] bones, string[] boneNames)
{
if (!string.IsNullOrEmpty(generationString))
foreach (string n in boneNames)
{
if (GENERATION_MAP.TryGetValue(generationString, out BaseGeneration gen)) return gen;
bool found = false;
foreach (Transform b in bones)
{
if (b.name == n)
{
found = true;
break;
}
}
if (!found) return false;
}
else
return true;
}

public static BaseGeneration GetCharacterGeneration(GameObject fbx, string generationString)
{
if (fbx)
{
if (fbx)
{
Transform[] children = fbx.transform.GetComponentsInChildren<Transform>(true);
foreach (Transform child in children)
{
string objectName = child.gameObject.name;
Transform[] children = fbx.transform.GetComponentsInChildren<Transform>(true);

if (objectName.iContains("RootNode_0_")) return BaseGeneration.ActorCore;
if (objectName.iContains("CC_Base_L_Pinky3")) return BaseGeneration.G3;
if (objectName.iContains("pinky_03_l")) return BaseGeneration.GameBase;
if (objectName.iContains("CC_Base_L_Finger42")) return BaseGeneration.G1;
if (objectName.iContains("RL_BoneRoot"))
{
if (child.Find("CC_Base_Hip"))
{
Material acMat = GetActorCoreSingleMaterial(fbx);
if (acMat) return BaseGeneration.ActorCore;
else return BaseGeneration.G3;
}
if (!string.IsNullOrEmpty(generationString))
{
if (GENERATION_MAP.TryGetValue(generationString, out BaseGeneration gen))
{
// some ActorScan characters are really GameBase
if (CharacterContainsBones(children, new string[] { "head", "pelvis", "spine_02" }))
{
gen = BaseGeneration.GameBase;
}

return gen;
}
}

// check game base
if (CharacterContainsBones(children, new string[] { "head", "pelvis", "spine_02" }))
return BaseGeneration.GameBase;

foreach (Transform child in children)
{
string objectName = child.gameObject.name;
foreach (Transform child in children)
{
string objectName = child.gameObject.name;

if (objectName.iContains("CC_Game_Body") || objectName.iContains("CC_Game_Tongue"))
if (objectName.iContains("RootNode_0_")) return BaseGeneration.ActorCore;
if (objectName.iContains("CC_Base_L_Pinky3")) return BaseGeneration.G3;
if (objectName.iContains("pinky_03_l")) return BaseGeneration.GameBase;
if (objectName.iContains("CC_Base_L_Finger42")) return BaseGeneration.G1;
if (objectName.iContains("RL_BoneRoot"))
{
if (child.Find("CC_Base_Hip"))
{
return BaseGeneration.GameBase;
Material acMat = GetActorCoreSingleMaterial(fbx);
if (acMat) return BaseGeneration.ActorCore;
else return BaseGeneration.G3;
}
}
}

if (objectName == "CC_Base_Body")
foreach (Transform child in children)
{
string objectName = child.gameObject.name;

if (objectName.iContains("CC_Game_Body") || objectName.iContains("CC_Game_Tongue"))
{
return BaseGeneration.GameBase;
}

if (objectName == "CC_Base_Body")
{
Renderer renderer = child.GetComponent<Renderer>();
foreach (Material mat in renderer.sharedMaterials)
{
Renderer renderer = child.GetComponent<Renderer>();
foreach (Material mat in renderer.sharedMaterials)
{
if (!mat) continue;

string materialName = mat.name;
if (materialName.iContains("Skin_Body"))
return BaseGeneration.G1;
else if (materialName.iContains("Std_Skin_Body"))
return BaseGeneration.G3;
else if (materialName.iContains("ga_skin_body"))
return BaseGeneration.GameBase;
}
if (!mat) continue;

string materialName = mat.name;
if (materialName.iContains("Skin_Body"))
return BaseGeneration.G1;
else if (materialName.iContains("Std_Skin_Body"))
return BaseGeneration.G3;
else if (materialName.iContains("ga_skin_body"))
return BaseGeneration.GameBase;
}
}
}
}
}
return BaseGeneration.Unknown;
}
Expand Down
5 changes: 4 additions & 1 deletion Runtime/WrinkleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,10 @@ void Start()
{
foreach (Material mat in smr.materials)
{
if (mat.IsKeywordEnabled("BOOLEAN_IS_HEAD_ON"))
// catch a few more possibilities for wrinkle shaders
if (mat.IsKeywordEnabled("BOOLEAN_IS_HEAD_ON") ||
mat.IsKeywordEnabled("BOOLEAN_USE_WRINKLE_ON") ||
mat.shader.name.Contains("_HeadShaderWrinkle_"))
{
headMaterial = mat;
break;
Expand Down

0 comments on commit cae3fb3

Please sign in to comment.