|
23 | 23 | using System.IO; |
24 | 24 | using UnityEditor.Animations; |
25 | 25 | using System.Reflection; |
| 26 | +using System.Linq; |
26 | 27 |
|
27 | 28 | namespace Reallusion.Import |
28 | 29 | { |
@@ -56,66 +57,97 @@ public class RL |
56 | 57 | { "RL_G6_Standard_Series", BaseGeneration.G1 }, |
57 | 58 | { "NonStdLookAtDataCopyFromCCBase", BaseGeneration.ActorCore }, |
58 | 59 | { "ActorBuild", BaseGeneration.ActorBuild }, |
59 | | - { "ActorScan", BaseGeneration.ActorCore } |
| 60 | + { "ActorScan", BaseGeneration.ActorCore }, |
| 61 | + { "AccuRig", BaseGeneration.ActorBuild } |
60 | 62 | }; |
61 | | - |
62 | | - public static BaseGeneration GetCharacterGeneration(GameObject fbx, string generationString) |
| 63 | + |
| 64 | + public static bool CharacterContainsBones(Transform[] bones, string[] boneNames) |
63 | 65 | { |
64 | | - if (!string.IsNullOrEmpty(generationString)) |
| 66 | + foreach (string n in boneNames) |
65 | 67 | { |
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; |
67 | 78 | } |
68 | | - else |
| 79 | + return true; |
| 80 | + } |
| 81 | + |
| 82 | + public static BaseGeneration GetCharacterGeneration(GameObject fbx, string generationString) |
| 83 | + { |
| 84 | + if (fbx) |
69 | 85 | { |
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); |
76 | 87 |
|
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; |
89 | 96 | } |
| 97 | + |
| 98 | + return gen; |
90 | 99 | } |
| 100 | + } |
| 101 | + |
| 102 | + // check game base |
| 103 | + if (CharacterContainsBones(children, new string[] { "head", "pelvis", "spine_02" })) |
| 104 | + return BaseGeneration.GameBase; |
91 | 105 |
|
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; |
95 | 109 |
|
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")) |
97 | 117 | { |
98 | | - return BaseGeneration.GameBase; |
| 118 | + Material acMat = GetActorCoreSingleMaterial(fbx); |
| 119 | + if (acMat) return BaseGeneration.ActorCore; |
| 120 | + else return BaseGeneration.G3; |
99 | 121 | } |
| 122 | + } |
| 123 | + } |
100 | 124 |
|
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) |
102 | 138 | { |
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; |
116 | 148 | } |
117 | 149 | } |
118 | | - } |
| 150 | + } |
119 | 151 | } |
120 | 152 | return BaseGeneration.Unknown; |
121 | 153 | } |
|
0 commit comments