コード例 #1
0
    void LoadFile(MegaCacheParticle mod, string filename)
    {
        //mod.frames.Clear();

        StreamReader stream     = File.OpenText(filename);
        string       entireText = stream.ReadToEnd();

        stream.Close();

        char[] splitIdentifier = { ' ' };
        char[] fsplit          = { 'f' };

        StringReader reader = new StringReader(entireText);

        int max = int.Parse(reader.ReadLine());
        //Debug.Log("max " + max);

        int frames = int.Parse(reader.ReadLine());
        //Debug.Log("frames " + frames);

        MegaCacheParticleImage img = CreateInstance <MegaCacheParticleImage>();

        for (int i = 0; i < frames; i++)
        {
            MegaCacheParticleFrame fr = new MegaCacheParticleFrame();

            int p = int.Parse(reader.ReadLine());
            //Debug.Log("parts " + p);

            for (int j = 0; j < p; j++)
            {
                string ps = reader.ReadLine();

                string[] brokenString = ps.Split(splitIdentifier, 50);

                Vector3 pos = Vector3.zero;

                pos.x = float.Parse(brokenString[0]);
                pos.y = float.Parse(brokenString[1]);
                pos.z = float.Parse(brokenString[2]);

                if (brokenString.Length > 3)
                {
                    float life = float.Parse(brokenString[4].Split(fsplit)[0]) / 30.0f;
                    fr.life.Add(life);

                    float age = life - (float.Parse(brokenString[3].Split(fsplit)[0])) / 30.0f;
                    fr.age.Add(age);
                }

                fr.positions.Add(pos * mod.importscale);
            }

            img.frames.Add(fr);
        }

        mod.image = img;
    }
コード例 #2
0
    void LoadFile(MegaCacheParticle mod, string filename)
    {
        //mod.frames.Clear();

        StreamReader stream = File.OpenText(filename);
        string entireText = stream.ReadToEnd();
        stream.Close();

        char[] splitIdentifier = { ' ' };
        char[] fsplit = { 'f' };

        StringReader reader = new StringReader(entireText);

        int max = int.Parse(reader.ReadLine());
        //Debug.Log("max " + max);

        int frames = int.Parse(reader.ReadLine());
        //Debug.Log("frames " + frames);

        MegaCacheParticleImage img = CreateInstance<MegaCacheParticleImage>();

        for ( int i = 0; i < frames; i++ )
        {
            MegaCacheParticleFrame fr = new MegaCacheParticleFrame();

            int p = int.Parse(reader.ReadLine());
            //Debug.Log("parts " + p);

            for ( int j = 0; j < p; j++ )
            {
                string ps = reader.ReadLine();

                string[] brokenString = ps.Split(splitIdentifier, 50);

                Vector3 pos = Vector3.zero;

                pos.x = float.Parse(brokenString[0]);
                pos.y = float.Parse(brokenString[1]);
                pos.z = float.Parse(brokenString[2]);

                if ( brokenString.Length > 3 )
                {
                    float life = float.Parse(brokenString[4].Split(fsplit)[0]) / 30.0f;
                    fr.life.Add(life);

                    float age = life - (float.Parse(brokenString[3].Split(fsplit)[0])) / 30.0f;
                    fr.age.Add(age);

                }

                fr.positions.Add(pos * mod.importscale);
            }

            img.frames.Add(fr);
        }

        mod.image = img;
    }