src/bvhtoolbox/convert/bvh2xsf.py
def bvh2xsf(bvh_filepath, dst_filepath=None, scale=1.0):
    """Converts a BVH file into the Cal3D XSF skeleton file format.

    :param bvh_filepath: File path for BVH source.
    :type bvh_filepath: str
    :param dst_filepath: File path for destination Cal3D skeleton file (XSF).
    :type dst_filepath: str
    :param scale: Scale factor for root translation and offset values.
    :type scale: float
    """
    try:
        with open(bvh_filepath) as file_handle:
            mocap = BvhTree(file_handle.read())
    except OSError as e:
        print("ERROR:", e)
        return False

    joints = mocap.get_joints_names(end_sites=True)
    
    xml_root = XmlTree.Element("SKELETON")
    xml_root.set('MAGIC', 'XSF')
    xml_root.set('VERSION', '1100')
    xml_root.set('NUMBONES', str(len(joints)))
    comment = XmlTree.Comment('Converted from {}'.format(os.path.basename(bvh_filepath)))
    xml_root.append(comment)
    # Use map to compute tracks.
    bones = list(map(get_bone_xml, itertools.repeat(mocap), joints, itertools.repeat(scale)))
    # Extend tracks to xml_root as children.
    xml_root.extend(bones)
    # Add indentation.
    xml_str = prettify(xml_root)

    if not dst_filepath:
        dst_filepath = bvh_filepath[:-3] + 'xsf'
    try:
        with open(dst_filepath, 'w') as file_handle:
            file_handle.write(xml_str)
    except IOError as e:
        print("ERROR({}): Could not write to file {}.\n"
              "Make sure you have writing permissions.\n".format(e.errno, dst_filepath))
        return False
    return True
Converts a BVH file into the Cal3D XSF skeleton file format.

    :param bvh_filepath: File path for BVH source.
    :type bvh_filepath: str
    :param dst_filepath: File path for destination Cal3D skeleton file (XSF).
    :type dst_filepath: str
    :param scale: Scale factor for root translation and offset values.
    :type scale: float
    
Converts a BVH file into the Cal3D XSF skeleton file format.
Converts a BVH file into the Cal3D XSF skeleton file format .
def bvh2xsf(bvh_filepath, dst_filepath=None, scale=1.0):
    try:
        with open(bvh_filepath) as file_handle:
            mocap = BvhTree(file_handle.read())
    except OSError as e:
        print("ERROR:", e)
        return False
    joints = mocap.get_joints_names(end_sites=True)
    xml_root = XmlTree.Element("SKELETON")
    xml_root.set('MAGIC', 'XSF')
    xml_root.set('VERSION', '1100')
    xml_root.set('NUMBONES', str(len(joints)))
    comment = XmlTree.Comment('Converted from {}'.format(os.path.basename(bvh_filepath)))
    xml_root.append(comment)
    bones = list(map(get_bone_xml, itertools.repeat(mocap), joints, itertools.repeat(scale)))
    xml_root.extend(bones)
    xml_str = prettify(xml_root)
    if not dst_filepath:
        dst_filepath = bvh_filepath[:-3] + 'xsf'
    try:
        with open(dst_filepath, 'w') as file_handle:
            file_handle.write(xml_str)
    except IOError as e:
        print("ERROR({}): Could not write to file {}.\n"
              "Make sure you have writing permissions.\n".format(e.errno, dst_filepath))
        return False
    return True
def bvh2xsf ( bvh_filepath , dst_filepath = None , scale = 1.0 ) : try : with open ( bvh_filepath ) as file_handle : mocap = BvhTree ( file_handle . read ( ) ) except OSError as e : print ( "ERROR:" , e ) return False joints = mocap . get_joints_names ( end_sites = True ) xml_root = XmlTree . Element ( "SKELETON" ) xml_root . set ( 'MAGIC' , 'XSF' ) xml_root . set ( 'VERSION' , '1100' ) xml_root . set ( 'NUMBONES' , str ( len ( joints ) ) ) comment = XmlTree . Comment ( 'Converted from {}' . format ( os . path . basename ( bvh_filepath ) ) ) xml_root . append ( comment ) bones = list ( map ( get_bone_xml , itertools . repeat ( mocap ) , joints , itertools . repeat ( scale ) ) ) xml_root . extend ( bones ) xml_str = prettify ( xml_root ) if not dst_filepath : dst_filepath = bvh_filepath [ : - 3 ] + 'xsf' try : with open ( dst_filepath , 'w' ) as file_handle : file_handle . write ( xml_str ) except IOError as e : print ( "ERROR({}): Could not write to file {}.\n" "Make sure you have writing permissions.\n" . format ( e . errno , dst_filepath ) ) return False return True
Converts a BVH file into the Cal3D XSF skeleton file format.
Converts a BVH file into the Cal3D XSF skeleton file format .
"""Converts a BVH file into the Cal3D XSF skeleton file format.

    :param bvh_filepath: File path for BVH source.
    :type bvh_filepath: str
    :param dst_filepath: File path for destination Cal3D skeleton file (XSF).
    :type dst_filepath: str
    :param scale: Scale factor for root translation and offset values.
    :type scale: float
    """ # Use map to compute tracks. # Extend tracks to xml_root as children. # Add indentation.
bvh_filepath
File path for BVH source.
File path for BVH source .
dst_filepath
File path for destination Cal3D skeleton file (XSF).
File path for destination Cal3D skeleton file ( XSF ) .
scale
Scale factor for root translation and offset values.
Scale factor for root translation and offset values .