public void Initial(GameObject go, RoleShape shape) { if (mat == null) { mat = AssetDatabase.LoadAssetAtPath <Material>("Assets/Resource/RawData/FaceMakeup.mat"); } string child = "Player_" + shape.ToString().ToLower() + "_face"; Transform face = go.transform.Find(child); var skr = face.gameObject.GetComponent <SkinnedMeshRenderer>(); child = "Player_" + shape.ToString().ToLower() + "_helmet"; helmet = go.transform.Find(child).gameObject; outputMat = skr.sharedMaterial; roleShape = shape; if (camera == null) { camera = GameObject.FindObjectOfType <Camera>(); } if (mainTex == null) { FecthMainTex(); } if (mainRt == null) { CreateRT(); } Update(); EditorSceneManager.sceneClosed -= OnSceneClose; EditorSceneManager.sceneClosed += OnSceneClose; }
private void CreateAvatar() { XEditorUtil.ClearCreatures(); List <int> list = new List <int>(); var table = XFashionLibrary._profession.Table; presentid = table.Where(x => x.Shape == (int)shape).Select(x => x.PresentID).First(); string path = "Assets/BundleRes/Prefabs/Player_" + shape.ToString().ToLower() + ".prefab"; var prefab = AssetDatabase.LoadAssetAtPath <GameObject>(path); if (prefab != null) { GameObject root = GameObject.Find("Player"); if (root == null) { root = new GameObject("Player"); root.transform.position = new Vector3(0f, 0f, -8f); } go = Instantiate(prefab); go.transform.SetParent(root.transform); go.name = shape.ToString(); go.transform.localScale = Vector3.one; go.transform.rotation = Quaternion.Euler(0, 180, 0); go.transform.localPosition = Vector3.zero; Selection.activeGameObject = go; fashionInfo = XFashionLibrary.GetFashionsInfo(shape); fashionDesInfo = new string[fashionInfo.Length]; for (int i = 0; i < fashionInfo.Length; i++) { fashionDesInfo[i] = fashionInfo[i].name; } } }
void OnGUI() { GUILayout.BeginVertical(); GUILayout.Space(4); shape = (RoleShape)EditorGUILayout.EnumPopup("Gender", shape); clip = (AnimationClip)EditorGUILayout.ObjectField("Clip ", clip, typeof(AnimationClip), true); if (go == null || (go != null && go.name != shape.ToString()) || shape.ToString() != go.name) { CreateAvatar(); } if (fashionInfo != null) { suit_select = EditorGUILayout.Popup("Suit ", suit_select, fashionDesInfo); if (suit_pre != suit_select || shape != shape_pre) { DrawSuit(true, true); suit_pre = suit_select; shape_pre = shape; } } GUILayout.EndVertical(); GUILayout.Space(12); GUILayout.BeginHorizontal(); if (GUILayout.Button("Sync-Picture", GUILayout.Width(120))) { string name = ""; float[] args = new float[NeuralInterface.CNT]; float[] args2 = new float[NeuralInterface.CNT2]; if (NeuralInterface.ParseFromPicture(ref args, ref args2, ref name)) { bone.NeuralProcess(args); paint.NeuralProcess(args2); } } if (GUILayout.Button("Sync-Model", GUILayout.Width(120))) { string file = UnityEditor.EditorUtility.OpenFilePanel("Select model file", NeuralInterface.MODEL, "bytes"); if (!string.IsNullOrEmpty(file)) { FileInfo info = new FileInfo(file); float[] args, args2; NeuralInterface.ProcessFile(info, out args, out args2); bone.NeuralProcess(args); paint.NeuralProcess(args2); } } GUILayout.EndHorizontal(); paint.OnGui(); bone.OnGui(); }
void OnGUI() { GUILayout.BeginVertical(); GUILayout.Label(XEditorUtil.Config.suit_pre, XEditorUtil.titleLableStyle); GUILayout.Space(8); GUILayout.BeginHorizontal(); GUILayout.Label("Role Shape"); shape = (RoleShape)EditorGUILayout.EnumPopup(shape); GUILayout.EndHorizontal(); GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.Label("Select Clip"); clip = (AnimationClip)EditorGUILayout.ObjectField(clip, typeof(AnimationClip), true); GUILayout.EndHorizontal(); GUILayout.Space(4); if (go == null || (go != null && go.name != shape.ToString()) || shape.ToString() != go.name) { CreateAvatar(); } if (fashionInfo != null) { GUILayout.BeginHorizontal(); GUILayout.Label("Select Suit"); suit_select = EditorGUILayout.Popup(suit_select, fashionDesInfo); if (suit_pre != suit_select || shape != shape_pre) { DrawSuit(); suit_pre = suit_select; shape_pre = shape; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); paint.OnGui(); bone.OnGui(); }
public void Initial(GameObject go, RoleShape shape) { RoleParts = go.GetComponent <XRoleParts>(); string path = "Assets/BundleRes/Config/" + shape.ToString().ToLower(); TextAsset ta = AssetDatabase.LoadAssetAtPath <TextAsset>(path + ".bytes"); if (ta != null) { MemoryStream ms = new MemoryStream(ta.bytes); fbData = new FaceBoneDatas(ms); CleanData(); MakeControlGroups(); ms.Close(); } }
private static void RandomExportModels(int expc, RoleShape shape, string prefix, bool noise, bool complete) { XEditorUtil.SetupEnv(); float[] args = new float[CNT]; FileStream fs = new FileStream(EXPORT + "db_description", FileMode.OpenOrCreate, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(expc); for (int j = 0; j < expc; j++) { string name = string.Format("db_{0:00000}_{1}", j, (int)shape); bw.Write(name); for (int i = 0; i < CNT; i++) { args[i] = UnityEngine.Random.Range(0.0f, 1.0f); bw.Write(noise ? AddNoise(args[i], i) : args[i]); } float[] args2 = new float[CNT2]; int r = UnityEngine.Random.Range(0, 3); args2[r] = 1; r = UnityEngine.Random.Range(3, 6); args2[r] = 1; args2[6] = UnityEngine.Random.Range(0.2f, 0.8f); args2[7] = UnityEngine.Random.Range(0.2f, 0.8f); for (int i = 0; i < CNT2; i++) { bw.Write(args2[i]); } NeuralData data = new NeuralData { callback = Capture, boneArgs = args, paintArgs = args2, shape = shape, name = name }; UnityEditor.EditorUtility.DisplayProgressBar(prefix, string.Format("is generating {0}/{1}", j, expc), (float)j / expc); NeuralInput(data, complete, true); } UnityEditor.EditorUtility.DisplayProgressBar(prefix, "post processing, wait for a moment", 1); bw.Close(); fs.Close(); MoveDestDir("db_*", prefix + "_" + shape.ToString().ToLower() + "/"); UnityEditor.EditorUtility.ClearProgressBar(); }
public static void DrawFace(GameObject go, RoleShape shape, string suffix, Transform[] bones, uint presentid) { string sshape = shape.ToString().ToLower(); Transform transf = go.transform.Find("Player_" + sshape + "_" + TCConst.FACE); string shape_dir = "Player_" + sshape; var row = XFashionLibrary.FindRole(presentid); if (row != null) { string cname = "Player_" + sshape + "_common_" + TCConst.FACE + "_" + row.ID; string asset = "Assets/BundleRes/FBXRawData/" + shape_dir + "/Common/" + cname; DrawPart(transf, asset, bones, null, null); } else { Debug.LogError("not find present id in profession table, " + presentid); } }
public static void DrawPart(GameObject go, string part, RoleShape shape, string dir, string suffix, Transform[] bones, string[] dbones, FashionList.RowData row) { string sshape = shape.ToString().ToLower(); Transform transf = go.transform.Find("Player_" + sshape + "_" + suffix); string asset = string.Empty; string shape_dir = "Player_" + sshape; if (string.IsNullOrEmpty(part)) { string cname = "Player_" + sshape + "_" + dir + "_" + suffix; asset = "Assets/BundleRes/FBXRawData/" + shape_dir + "/" + shape_dir + "_" + dir + "/" + cname; DrawPart(transf, asset, bones, dbones, row); } else if (!part.Equals("E")) { string cname = "Player_" + sshape + "_common_" + suffix + "_" + part; asset = "Assets/BundleRes/FBXRawData/" + shape_dir + "/Common/" + cname; DrawPart(transf, asset, bones, dbones, row); } }
public static void DrawWeapon(GameObject go, RoleShape shape, string dir, XRolePart part, uint presentid, int weapon_index, FashionList.RowData row) { string sshape = shape.ToString().ToLower(); Transform transf = go.transform.Find("Player_" + sshape + "_" + TCConst.WEAPON); string shape_dir = "Player_" + sshape; string cname = "Player_" + sshape + "_" + dir + "_" + TCConst.WEAPON + "_" + presentid + "_" + weapon_index; string asset = "Assets/BundleRes/FBXRawData/" + shape_dir + "/" + shape_dir + "_" + dir + "/" + cname; for (int i = 0; i < part.weapon.Length; i++) { if (part.weapon[i].presentid == presentid) { if (weapon_index == 1) { FashionUtility.DrawPart(transf, asset, part.weapon[i].weapon1, part.weapon[i].sweapon1, row); } else { DrawPart(transf, asset, part.weapon[i].weapon2, part.weapon[i].sweapon2, row); } break; } } }
private Texture2D GetPaintTex(string name, RoleShape shape) { string path = "Assets/BundleRes/Knead/" + name + "_" + shape.ToString().ToLower() + ".tga"; return(AssetDatabase.LoadAssetAtPath <Texture2D>(path)); }