public void Serialize(BinaryWriter writer) { Header.Serialize(writer); Vertices.ForEach(vertex => vertex.Serialize(writer)); Normals.ForEach(normal => normal.Serialize(writer)); Faces.ForEach(face => face.Serialize(writer)); SubObjects.ForEach(subObject => subObject.Serialize(writer)); PartAnimations?.ForEach(partAnimation => partAnimation.Serialize(writer)); CollisionPlaneVectors.ForEach(plane => plane.Serialize(writer)); CollisionVolumes.ForEach(volume => volume.Serialize(writer)); Materials.ForEach(material => material.Serialize(writer)); }
private int CalculateLength() { using (MemoryStream buffer = new MemoryStream()) using (BinaryWriter writer = new BinaryWriter(buffer)) { Vertices.ForEach(vertex => vertex.Serialize(writer)); Normals.ForEach(normal => normal.Serialize(writer)); Faces.ForEach(face => face.Serialize(writer)); SubObjects.ForEach(subObject => subObject.Serialize(writer)); CollisionPlaneVectors.ForEach(collisionPlane => collisionPlane.Serialize(writer)); CollisionVolumes.ForEach(collisionVolume => collisionVolume.Serialize(writer)); Materials.ForEach(material => material.Serialize(writer)); return((int)buffer.Length); } }