Skip to content

Commit 3103174

Browse files
committed
1.6.3
GameBase override detection. WrinkleManager head material detection.
1 parent 04513b5 commit 3103174

File tree

2 files changed

+80
-45
lines changed

2 files changed

+80
-45
lines changed

Editor/RL.cs

Lines changed: 76 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.IO;
2424
using UnityEditor.Animations;
2525
using System.Reflection;
26+
using System.Linq;
2627

2728
namespace Reallusion.Import
2829
{
@@ -56,66 +57,97 @@ public class RL
5657
{ "RL_G6_Standard_Series", BaseGeneration.G1 },
5758
{ "NonStdLookAtDataCopyFromCCBase", BaseGeneration.ActorCore },
5859
{ "ActorBuild", BaseGeneration.ActorBuild },
59-
{ "ActorScan", BaseGeneration.ActorCore }
60+
{ "ActorScan", BaseGeneration.ActorCore },
61+
{ "AccuRig", BaseGeneration.ActorBuild }
6062
};
61-
62-
public static BaseGeneration GetCharacterGeneration(GameObject fbx, string generationString)
63+
64+
public static bool CharacterContainsBones(Transform[] bones, string[] boneNames)
6365
{
64-
if (!string.IsNullOrEmpty(generationString))
66+
foreach (string n in boneNames)
6567
{
66-
if (GENERATION_MAP.TryGetValue(generationString, out BaseGeneration gen)) return gen;
68+
bool found = false;
69+
foreach (Transform b in bones)
70+
{
71+
if (b.name == n)
72+
{
73+
found = true;
74+
break;
75+
}
76+
}
77+
if (!found) return false;
6778
}
68-
else
79+
return true;
80+
}
81+
82+
public static BaseGeneration GetCharacterGeneration(GameObject fbx, string generationString)
83+
{
84+
if (fbx)
6985
{
70-
if (fbx)
71-
{
72-
Transform[] children = fbx.transform.GetComponentsInChildren<Transform>(true);
73-
foreach (Transform child in children)
74-
{
75-
string objectName = child.gameObject.name;
86+
Transform[] children = fbx.transform.GetComponentsInChildren<Transform>(true);
7687

77-
if (objectName.iContains("RootNode_0_")) return BaseGeneration.ActorCore;
78-
if (objectName.iContains("CC_Base_L_Pinky3")) return BaseGeneration.G3;
79-
if (objectName.iContains("pinky_03_l")) return BaseGeneration.GameBase;
80-
if (objectName.iContains("CC_Base_L_Finger42")) return BaseGeneration.G1;
81-
if (objectName.iContains("RL_BoneRoot"))
82-
{
83-
if (child.Find("CC_Base_Hip"))
84-
{
85-
Material acMat = GetActorCoreSingleMaterial(fbx);
86-
if (acMat) return BaseGeneration.ActorCore;
87-
else return BaseGeneration.G3;
88-
}
88+
if (!string.IsNullOrEmpty(generationString))
89+
{
90+
if (GENERATION_MAP.TryGetValue(generationString, out BaseGeneration gen))
91+
{
92+
// some ActorScan characters are really GameBase
93+
if (CharacterContainsBones(children, new string[] { "head", "pelvis", "spine_02" }))
94+
{
95+
gen = BaseGeneration.GameBase;
8996
}
97+
98+
return gen;
9099
}
100+
}
101+
102+
// check game base
103+
if (CharacterContainsBones(children, new string[] { "head", "pelvis", "spine_02" }))
104+
return BaseGeneration.GameBase;
91105

92-
foreach (Transform child in children)
93-
{
94-
string objectName = child.gameObject.name;
106+
foreach (Transform child in children)
107+
{
108+
string objectName = child.gameObject.name;
95109

96-
if (objectName.iContains("CC_Game_Body") || objectName.iContains("CC_Game_Tongue"))
110+
if (objectName.iContains("RootNode_0_")) return BaseGeneration.ActorCore;
111+
if (objectName.iContains("CC_Base_L_Pinky3")) return BaseGeneration.G3;
112+
if (objectName.iContains("pinky_03_l")) return BaseGeneration.GameBase;
113+
if (objectName.iContains("CC_Base_L_Finger42")) return BaseGeneration.G1;
114+
if (objectName.iContains("RL_BoneRoot"))
115+
{
116+
if (child.Find("CC_Base_Hip"))
97117
{
98-
return BaseGeneration.GameBase;
118+
Material acMat = GetActorCoreSingleMaterial(fbx);
119+
if (acMat) return BaseGeneration.ActorCore;
120+
else return BaseGeneration.G3;
99121
}
122+
}
123+
}
100124

101-
if (objectName == "CC_Base_Body")
125+
foreach (Transform child in children)
126+
{
127+
string objectName = child.gameObject.name;
128+
129+
if (objectName.iContains("CC_Game_Body") || objectName.iContains("CC_Game_Tongue"))
130+
{
131+
return BaseGeneration.GameBase;
132+
}
133+
134+
if (objectName == "CC_Base_Body")
135+
{
136+
Renderer renderer = child.GetComponent<Renderer>();
137+
foreach (Material mat in renderer.sharedMaterials)
102138
{
103-
Renderer renderer = child.GetComponent<Renderer>();
104-
foreach (Material mat in renderer.sharedMaterials)
105-
{
106-
if (!mat) continue;
107-
108-
string materialName = mat.name;
109-
if (materialName.iContains("Skin_Body"))
110-
return BaseGeneration.G1;
111-
else if (materialName.iContains("Std_Skin_Body"))
112-
return BaseGeneration.G3;
113-
else if (materialName.iContains("ga_skin_body"))
114-
return BaseGeneration.GameBase;
115-
}
139+
if (!mat) continue;
140+
141+
string materialName = mat.name;
142+
if (materialName.iContains("Skin_Body"))
143+
return BaseGeneration.G1;
144+
else if (materialName.iContains("Std_Skin_Body"))
145+
return BaseGeneration.G3;
146+
else if (materialName.iContains("ga_skin_body"))
147+
return BaseGeneration.GameBase;
116148
}
117149
}
118-
}
150+
}
119151
}
120152
return BaseGeneration.Unknown;
121153
}

Runtime/WrinkleManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,10 @@ void Start()
652652
{
653653
foreach (Material mat in smr.materials)
654654
{
655-
if (mat.IsKeywordEnabled("BOOLEAN_IS_HEAD_ON"))
655+
// catch a few more possibilities for wrinkle shaders
656+
if (mat.IsKeywordEnabled("BOOLEAN_IS_HEAD_ON") ||
657+
mat.IsKeywordEnabled("BOOLEAN_USE_WRINKLE_ON") ||
658+
mat.shader.name.Contains("_HeadShaderWrinkle_"))
656659
{
657660
headMaterial = mat;
658661
break;

0 commit comments

Comments
 (0)