Ejemplo n.º 1
0
        public void Load(string ssbx_name)
        {
            //ssbxの読み込み
            ssbx_animedata = SSBX.GetSsbx_animedata(ssbx_name);

            //すでにテクスチャを読み込んでいる場合は解放
            int idx = 0;

            for (idx = 0; idx < 32; idx++)
            {
                if (tex[idx] != null)
                {
                    tex[idx].Dispose();
                    tex[idx] = null;
                }
            }

            //モーションデータからテクスチャ情報を取得して画像読み込み
            for (idx = 0; idx < ssbx_animedata.texturedata.Count; idx++)
            {
                string str;
                str = string.Format("texture{0:D3}", idx);
                SSBX_TEXTUREDATA ssbx_texturedata = ssbx_animedata.texturedata[str];
                int    id   = ssbx_texturedata.id;
                string name = "/Application/resources/" + ssbx_texturedata.name;

                //画像読み込み
                tex[idx] = new Texture2D(name, false, PixelFormat.Rgba);
            }

            //スプライトシートのフレーム番号
            frame_count = 0;
            anime_stop  = true;
        }
Ejemplo n.º 2
0
        public Player(GraphicsContext app_graphics)
        {
            graphics       = app_graphics;
            ssbx_animedata = null;

            int idx = 0;

            for (idx = 0; idx < 32; idx++)
            {
                tex[idx] = null;
            }
            shaderProgram = new ShaderProgram("/Application/shaders/Sprite.cgx");
            shaderProgram.SetUniformBinding(0, "u_ScreenMatrix");

            indices    = new ushort[indexSize];
            indices[0] = 0;
            indices[1] = 1;
            indices[2] = 2;
            indices[3] = 3;

            ImageRect rectScreen = graphics.Screen.Rectangle;

            screenMatrix = new Matrix4(
                2.0f / rectScreen.Width, 0.0f, 0.0f, 0.0f,
                0.0f, -2.0f / rectScreen.Height, 0.0f, 0.0f,
                0.0f, 0.0f, 1.0f, 0.0f,
                -1.0f, 1.0f, 0.0f, 1.0f
                );
            //												vertex pos,               texture,       color
            vertexBuffer = new VertexBuffer(4, indexSize, VertexFormat.Float3, VertexFormat.Float2, VertexFormat.Float4);
        }
Ejemplo n.º 3
0
        static public SSBX_ANIMEDATA GetSsbx_animedata(string xmlFilename)
        {
            SSBX_ANIMEDATA animedata = null;
            string         str;

            try
            {
                XDocument doc = XDocument.Load(xmlFilename);

                //------------------------------------------
                //ssbxはアニメの設定などの情報、使用するテクスチャの情報、表示するパーツのフレーム情報から構成されています。
                //------------------------------------------

                //ssbpdataエレメントの取得
                XElement ssbx     = doc.Element("ssbx");
                string   sspbname = ssbx.Element("name").Value;                 //ssbp名

                XElement ssbpdata = ssbx.Element("ssbpdata");
                //テクスチャーデータの取得
                Dictionary <string, SSBX_TEXTUREDATA> dic_texturedata = new Dictionary <string, SSBX_TEXTUREDATA>();
                {
                    XElement textures = ssbx.Element("textures");

                    int idx = 0;
                    foreach (var texture in textures.Descendants("texture"))
                    {
                        int    id   = int.Parse(texture.Attribute("id").Value);
                        string name = texture.Attribute("name").Value;

                        str = string.Format("texture{0:D3}", idx);
                        dic_texturedata.Add(str, new SSBX_TEXTUREDATA(id, name));
                        idx++;
                    }
                }

                Dictionary <string, SSBX_MOTIONDATA> dic_motiondata = new Dictionary <string, SSBX_MOTIONDATA>();
                foreach (var motion in ssbx.Descendants("motion"))
                {
                    //アニメ設定の取得
                    string motionname = motion.Element("name").Value;
                    int    fps        = int.Parse(motion.Element("fps").Value);
                    int    maxframe   = int.Parse(motion.Element("maxframe").Value);


                    //フレームデータの取得
                    Dictionary <string, SSBX_FRAMEDATA> dic_ssbx_framedata = new Dictionary <string, SSBX_FRAMEDATA>();
                    {
                        XElement framedata = motion.Element("framedata");
                        foreach (var frame in framedata.Descendants("frame"))
                        {
                            //各フレームに含まれるパーツ情報を格納していく、
                            //フレームデータ連想配列 に パーツデータ連想配列を追加していく。
                            int time = int.Parse(frame.Attribute("time").Value);
                            //						Console.WriteLine("time" + time);
                            Dictionary <string, SSBX_PARTDATA> dic_ssbx_partdata = new Dictionary <string, SSBX_PARTDATA>();

                            int idx = 0;
                            foreach (var partdata in frame.Descendants("partdata"))
                            {
                                PART_STATE part;
                                part.name           = partdata.Attribute("NAME").Value;
                                part.x              = float.Parse(partdata.Attribute("X").Value);
                                part.y              = float.Parse(partdata.Attribute("Y").Value);
                                part.rotz           = float.Parse(partdata.Attribute("ROTZ").Value);
                                part.scale_x        = float.Parse(partdata.Attribute("SCLX").Value);
                                part.scale_y        = float.Parse(partdata.Attribute("SCLY").Value);
                                part.alpha          = float.Parse(partdata.Attribute("ALPH").Value) / 255.0f;
                                part.size_x         = float.Parse(partdata.Attribute("SIZX").Value);
                                part.size_y         = float.Parse(partdata.Attribute("SIZY").Value);
                                part.boundingRadius = float.Parse(partdata.Attribute("BORA").Value);
                                part.flip_x         = int.Parse(partdata.Attribute("FLPX").Value);
                                part.flip_y         = int.Parse(partdata.Attribute("FLPY").Value);
                                part.tex_id         = int.Parse(partdata.Attribute("TXID").Value);
                                part.rect_x         = int.Parse(partdata.Attribute("RECX").Value);
                                part.rect_y         = int.Parse(partdata.Attribute("RECY").Value);
                                part.rect_w         = int.Parse(partdata.Attribute("RECW").Value);
                                part.rect_h         = int.Parse(partdata.Attribute("RECH").Value);
                                part.blend_func     = int.Parse(partdata.Attribute("BLED").Value);
                                //						Console.WriteLine("partdata x" + x + " y" + y + " ROTZ" + rotz + " SCLX" + scale_x + " SCLY" + scale_y + " ALPH" + alpha + " SIZX" + size_x + " SIZY" + size_y );

                                //パーツデータ配列のアクセス名を設定
                                str = string.Format("part{0:D3}", idx);
                                dic_ssbx_partdata.Add(str, new SSBX_PARTDATA(part));
                                idx++;
                            }
                            //フレームデータ配列のアクセス名を設定
                            str = string.Format("frame{0:D3}", time);
                            dic_ssbx_framedata.Add(str, new SSBX_FRAMEDATA(dic_ssbx_partdata));
                        }
                    }
                    dic_motiondata.Add(motionname, new SSBX_MOTIONDATA(motionname, fps, maxframe, dic_ssbx_framedata));
                }
                animedata = new SSBX_ANIMEDATA(sspbname, dic_texturedata, dic_motiondata);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }

            return(animedata);
        }