Esempio n. 1
0
        public static void Picture2Model()
        {
            XEditorUtil.SetupEnv();
            string name = "";

            float[] args  = new float[CNT];
            float[] args2 = new float[CNT2];
            if (ParseFromPicture(ref args, ref args2, ref name))
            {
                string str   = "";
                int    shape = int.Parse(name[name.Length - 1].ToString());
                for (int i = 0; i < CNT; i++)
                {
                    str += i + "-" + args[i].ToString("f3") + " ";
                }
                Debug.Log(str);
                NeuralData data = new NeuralData
                {
                    callback  = Capture,
                    boneArgs  = args,
                    paintArgs = args2,
                    shape     = (RoleShape)shape,
                    name      = name
                };
                NeuralInput(data, true, true);
            }
        }
Esempio n. 2
0
        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;
                }
            }
        }
Esempio n. 3
0
        private static void RandomExportModels()
        {
            XEditorUtil.SetupEnv();
            float[]      args = new float[CNT];
            int          expc = 1000;
            FileStream   fs   = new FileStream(EXPORT + "db_description", FileMode.OpenOrCreate, FileAccess.Write);
            BinaryWriter bw   = new BinaryWriter(fs);

            for (int j = 0; j < expc; j++)
            {
                int    shape = UnityEngine.Random.Range(3, 5);
                string name  = string.Format("db_{0:000}_{1}", j, shape);
                bw.Write(name);
                for (int i = 0; i < CNT; i++)
                {
                    args[i] = UnityEngine.Random.Range(0.0f, 1.0f);
                    bw.Write(args[i]);
                }
                NeuralData data = new NeuralData
                {
                    callback = Capture,
                    boneArgs = args,
                    shape    = (RoleShape)shape,
                    name     = name
                };
                UnityEditor.EditorUtility.DisplayProgressBar("database", string.Format("is generating {0}/{1}", j, expc), (float)j / expc);
                NeuralInput(data);
            }
            UnityEditor.EditorUtility.DisplayProgressBar("database", "post processing, wait for a moment", 1);
            bw.Close();
            fs.Close();
            MoveDestDir("db_*", "database/");
            UnityEditor.EditorUtility.ClearProgressBar();
        }
Esempio n. 4
0
        public static void Model2Image()
        {
            XEditorUtil.SetupEnv();
            string   file = EditorUtility.OpenFilePanel("Select model file", MODEL, "bytes");
            FileInfo info = new FileInfo(file);

            ProcessFile(info);
            HelperEditor.Open(EXPORT);
        }
Esempio n. 5
0
        public static void Model2Image()
        {
            XEditorUtil.SetupEnv();
            string   file = UnityEditor.EditorUtility.OpenFilePanel("Select model file", MODEL, "bytes");
            FileInfo info = new FileInfo(file);

            ProcessFile(info);
            MoveDestDir("model_*", "regular/");
            EditorUtility.Open(EXPORT + "regular/");
        }
Esempio n. 6
0
        public static void BatchModels()
        {
            XEditorUtil.SetupEnv();
            DirectoryInfo dir   = new DirectoryInfo(MODEL);
            var           files = dir.GetFiles("*.bytes");

            for (int i = 0; i < files.Length; i++)
            {
                ProcessFile(files[i]);
            }
            MoveDestDir("model_*", "regular/");
        }
Esempio n. 7
0
 static void AnimExportTool()
 {
     if (XEditorUtil.MakeNewScene())
     {
         if (preview != null)
         {
             ScriptableObject.DestroyImmediate(preview);
         }
         var window = EditorWindow.GetWindowWithRect(typeof(FashionPreview), new Rect(0, 0, 440, 640), true, "Preview");
         preview = window as FashionPreview;
         preview.Show();
     }
 }
Esempio n. 8
0
        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();
        }