Ejemplo n.º 1
0
        public virtual void ToStream(Stream s, bool id)
        {
            PmxHeader header = Header;

            header.ElementFormat.WithID = id;
            PmxTextureTable pmxTextureTable = new PmxTextureTable(MaterialList);

            UpdateElementFormatSize(header.ElementFormat, pmxTextureTable);
            header.ToStreamEx(s);
            ModelInfo.ToStreamEx(s, header.ElementFormat);
            PmxStreamHelper.WriteElement_Int32(s, VertexList.Count);
            for (int i = 0; i < VertexList.Count; i++)
            {
                VertexList[i].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, FaceList.Count);
            for (int j = 0; j < FaceList.Count; j++)
            {
                PmxStreamHelper.WriteElement_Int32(s, FaceList[j], header.ElementFormat.VertexSize, signed: false);
            }
            pmxTextureTable.ToStreamEx(s, header.ElementFormat);
            PmxStreamHelper.WriteElement_Int32(s, MaterialList.Count);
            for (int k = 0; k < MaterialList.Count; k++)
            {
                MaterialList[k].ToStreamEx_TexTable(s, pmxTextureTable, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, BoneList.Count);
            for (int l = 0; l < BoneList.Count; l++)
            {
                BoneList[l].ToStreamEx(s, header.ElementFormat);
            }
            if (header.Ver < 2.1f)
            {
                int num = MorphList.Where((PmxMorph mp) => mp.IsImpulse).Count();
                PmxStreamHelper.WriteElement_Int32(s, MorphList.Count - num);
            }
            else
            {
                PmxStreamHelper.WriteElement_Int32(s, MorphList.Count);
            }
            for (int m = 0; m < MorphList.Count; m++)
            {
                MorphList[m].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, NodeList.Count);
            for (int n = 0; n < NodeList.Count; n++)
            {
                NodeList[n].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, BodyList.Count);
            for (int num2 = 0; num2 < BodyList.Count; num2++)
            {
                BodyList[num2].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, JointList.Count);
            for (int num3 = 0; num3 < JointList.Count; num3++)
            {
                JointList[num3].ToStreamEx(s, header.ElementFormat);
            }
            if (header.Ver >= 2.1f)
            {
                PmxStreamHelper.WriteElement_Int32(s, SoftBodyList.Count);
                for (int num4 = 0; num4 < SoftBodyList.Count; num4++)
                {
                    SoftBodyList[num4].ToStreamEx(s, header.ElementFormat);
                }
            }
            if (id)
            {
                PmxStreamHelper.WriteString(s, FilePath, header.ElementFormat);
            }
            header.ElementFormat.WithID = false;
        }