(skin)
return out.getvalue()
Serializes a `Skin` named tuple into the contents of a MuJoCo skin file.

  Args:
    skin: a `Skin` named tuple.

  Returns:
    A `bytes` object representing the content of a MuJoCo skin file.
Serializes a `Skin` named tuple into the contents of a MuJoCo skin file.
Serializes a Skin named tuple into the contents of a MuJoCo skin file .
def serialize(skin):
  """Serializes a `Skin` named tuple into the contents of a MuJoCo skin file.

  Args:
    skin: a `Skin` named tuple.

  Returns:
    A `bytes` object representing the content of a MuJoCo skin file.
  """
  out = io.BytesIO()
  nvertex = len(skin.vertices)
  ntexcoord = len(skin.texcoords)
  nface = len(skin.faces)
  nbone = len(skin.bones)
  out.write(struct.pack('<iiii', nvertex, ntexcoord, nface, nbone))
  out.write(skin.vertices.astype('<f4').tobytes())
  out.write(skin.texcoords.astype('<f4').tobytes())
  out.write(skin.faces.astype('<i4').tobytes())
  for bone in skin.bones:
    body_bytes = bone.body().full_identifier.encode('utf-8')
    if len(body_bytes) > MAX_BODY_NAME_LENGTH:
      raise ValueError(
          'body name is longer than  permitted by the skin file format '
          '(maximum 40): {:r}'.format(body_bytes))
    out.write(body_bytes)
    out.write(b'\0'*(MAX_BODY_NAME_LENGTH - len(body_bytes)))
    out.write(bone.bindpos.astype('<f4').tobytes())
    out.write(bone.bindquat.astype('<f4').tobytes())
    assert len(bone.vertex_ids) == len(bone.vertex_weights)
    out.write(struct.pack('<i', len(bone.vertex_ids)))
    out.write(bone.vertex_ids.astype('<i4').tobytes())
    out.write(bone.vertex_weights.astype('<f4').tobytes())
  return out.getvalue()
def serialize ( skin ) : out = io . BytesIO ( ) nvertex = len ( skin . vertices ) ntexcoord = len ( skin . texcoords ) nface = len ( skin . faces ) nbone = len ( skin . bones ) out . write ( struct . pack ( '<iiii' , nvertex , ntexcoord , nface , nbone ) ) out . write ( skin . vertices . astype ( '<f4' ) . tobytes ( ) ) out . write ( skin . texcoords . astype ( '<f4' ) . tobytes ( ) ) out . write ( skin . faces . astype ( '<i4' ) . tobytes ( ) ) for bone in skin . bones : body_bytes = bone . body ( ) . full_identifier . encode ( 'utf-8' ) if len ( body_bytes ) > MAX_BODY_NAME_LENGTH : raise ValueError ( 'body name is longer than  permitted by the skin file format ' '(maximum 40): {:r}' . format ( body_bytes ) ) out . write ( body_bytes ) out . write ( b'\0' * ( MAX_BODY_NAME_LENGTH - len ( body_bytes ) ) ) out . write ( bone . bindpos . astype ( '<f4' ) . tobytes ( ) ) out . write ( bone . bindquat . astype ( '<f4' ) . tobytes ( ) ) assert len ( bone . vertex_ids ) == len ( bone . vertex_weights ) out . write ( struct . pack ( '<i' , len ( bone . vertex_ids ) ) ) out . write ( bone . vertex_ids . astype ( '<i4' ) . tobytes ( ) ) out . write ( bone . vertex_weights . astype ( '<f4' ) . tobytes ( ) ) return out . getvalue ( )