func writeOBJSurface(w io.Writer, surf *md3.Surface, posNorms, texCoords, triangles map[*md3.Surface]string) error { fmt.Fprintf(w, "g %s\n", surf.Name()) n, err := io.WriteString(w, posNorms[surf]) if err != nil { return err } else if n < len(posNorms[surf]) { return fmt.Errorf("Error writing positions and normals: only %d of %d bytes written") } n, err = io.WriteString(w, texCoords[surf]) if err != nil { return err } else if n < len(texCoords[surf]) { return fmt.Errorf("Error writing texcoords: only %d of %d bytes written") } n, err = io.WriteString(w, triangles[surf]) if n < len(triangles[surf]) { return fmt.Errorf("Error writing triangles: only %d of %d bytes written") } return err }