Esempio n. 1
0
        /// <summary>
        /// 指定ストリームからTSOFileを読み込みます。
        /// </summary>
        /// <param name="source_stream">ストリーム</param>
        public void LoadTSOFile(Stream source_stream)
        {
            List <TSOFile> tso_list = new List <TSOFile>();

            try
            {
                TSOFile tso = new TSOFile();
                tso.Load(source_stream);
                Debug.WriteLine("tso sum vertices count: " + tso.SumVerticesCount().ToString());
                tso_list.Add(tso);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex);
            }
            Figure fig = GetSelectedOrCreateFigure();

            foreach (TSOFile tso in tso_list)
            {
                tso.Open(device, effect);
                fig.AddTSO(tso);
            }
            fig.UpdateNodeMapAndBoneMatrices();
            if (FigureEvent != null)
            {
                FigureEvent(this, EventArgs.Empty);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 指定ディレクトリからフィギュアを作成して追加します。
        /// </summary>
        /// <param name="source_file">TSOFileを含むディレクトリ</param>
        public void AddFigureFromTSODirectory(string source_file)
        {
            List <TSOFile> tso_list = new List <TSOFile>();

            try
            {
                string[] files = Directory.GetFiles(source_file, "*.TSO");
                foreach (string file in files)
                {
                    TSOFile tso = new TSOFile();
                    Debug.WriteLine("loading " + file);
                    tso.Load(file);
                    Debug.WriteLine("tso sum vertices count: " + tso.SumVerticesCount().ToString());
                    tso_list.Add(tso);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex);
            }
            Figure fig = new Figure();

            foreach (TSOFile tso in tso_list)
            {
                tso.Open(device, effect);
                fig.AddTSO(tso);
            }
            fig.UpdateNodeMapAndBoneMatrices();
            int idx = FigureList.Count;

            FigureList.Add(fig);
            SetFigureIndex(idx);
            if (FigureEvent != null)
            {
                FigureEvent(this, EventArgs.Empty);
            }
        }
Esempio n. 3
0
        public List <Figure> LoadPNGFile(Stream stream)
        {
            List <Figure> fig_list = new List <Figure>();

//      if (File.Exists(source_file))
            try
            {
                PNGFile png      = new PNGFile();
                Figure  fig      = null;
                TMOFile tmo      = null;
                string  png_type = null;

                png.Hsav += delegate(string type)
                {
                    fig = new Figure();
                    fig_list.Add(fig);
                    png_type = type;
                };
                png.Lgta += delegate(Stream dest, int extract_length)
                {
                    fig = new Figure();
                    fig_list.Add(fig);
                };
                png.Ftmo += delegate(Stream dest, int extract_length)
                {
                    tmo = new TMOFile();
                    tmo.Load(dest);
                    fig.Tmo = tmo;
                };
                png.Figu += delegate(Stream dest, int extract_length)
                {
                    byte[] buf = new byte[extract_length];
                    dest.Read(buf, 0, extract_length);

                    List <float> ratios = new List <float>();
                    for (int offset = 0; offset < extract_length; offset += sizeof(float))
                    {
                        float flo = BitConverter.ToSingle(buf, offset);
                        ratios.Add(flo);
                    }

                    /*
                     * ◆FIGU
                     * スライダの位置。値は float型で 0.0 .. 1.0
                     *  0: 姉妹
                     *  1: うで
                     *  2: あし
                     *  3: 胴まわり
                     *  4: おっぱい
                     *  5: つり目たれ目
                     *  6: やわらか
                     */
                    fig.slide_matrices.TallRatio  = ratios[0];
                    fig.slide_matrices.ArmRatio   = ratios[1];
                    fig.slide_matrices.LegRatio   = ratios[2];
                    fig.slide_matrices.WaistRatio = ratios[3];
                    fig.slide_matrices.BustRatio  = ratios[4];
                    fig.slide_matrices.EyeRatio   = ratios[5];

                    fig.TransformTpo();
                };
                png.Ftso += delegate(Stream dest, int extract_length, byte[] opt1)
                {
                    TSOFile tso = new TSOFile();
                    tso.Load(dest);
                    Debug.WriteLine("tso sum vertices count: " + tso.SumVerticesCount().ToString());
                    fig.TSOList.Add(tso);
                };
                //Debug.WriteLine("loading " + source_file);
                png.Load(stream);

                if (png_type == "HSAV")
                {
                    MemoryStream ms = new MemoryStream();
                    png.Save(ms);
                    ms.Seek(0, SeekOrigin.Begin);
                    BMPSaveData data = new BMPSaveData();
                    data.Read(ms);

                    fig.slide_matrices.TallRatio  = data.proportions[1];
                    fig.slide_matrices.ArmRatio   = data.proportions[2];
                    fig.slide_matrices.LegRatio   = data.proportions[3];
                    fig.slide_matrices.WaistRatio = data.proportions[4];
                    fig.slide_matrices.BustRatio  = data.proportions[0];
                    fig.slide_matrices.EyeRatio   = data.proportions[5];
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex);
            }
            return(fig_list);
        }