public void Save(Stream stream) { using (var bw = new BinaryWriterEx(stream, true)) { void WriteVector2(Vector2 v) { bw.WriteSingle(v.X); bw.WriteSingle(v.Y); } void WriteVector3(Vector3 v) { bw.WriteSingle(v.X); bw.WriteSingle(v.Y); bw.WriteSingle(v.Z); } bw.Write(VertexCount); bw.Write(IndexCount); bw.Write(IsTextured); bw.Write(IsFlexible); for (int i = 0; i < VertexCount; i++) { WriteVector3(Vertices[i].Position); } for (int i = 0; i < VertexCount; i++) { WriteVector3(Vertices[i].Normal); } if (IsTextured) { for (int i = 0; i < VertexCount; i++) { WriteVector2(Vertices[i].TexCoord); } } int[] triIndices = GetTriangleIndices(); bw.WriteArray(triIndices); for (int i = 0; i < triIndices.Length; i++) { WriteVector3(Indices[i].AverageNormal); } for (int i = 0; i < triIndices.Length; i++) { for (int j = 0; j < 6; j++) { WriteVector2(Indices[i].RoundEdgeData.Coords[j]); } } if (IsFlexible) { for (int i = 0; i < VertexCount; i++) { bw.Write(Vertices[i].BoneWeights.Count); for (int j = 0; j < Vertices[i].BoneWeights.Count; j++) { bw.Write(Vertices[i].BoneWeights[j].BoneID); bw.Write(Vertices[i].BoneWeights[j].Weight); } } } } }