src/bvhtoolbox/convert/bvh2egg.py
def bvh2egg(bvh_path, dst_path=None, scale=1.0):
    """ Converts a BVH file into the Panda3D egg animation file format.
    When passing keyword arguments, keywords must be used!

    :param bvh_path: File path(s) for BVH source.
    :type bvh_path: str|list
    :param dst_path: File or folder path for destination Panda3D Egg file.
    :type dst_path: str
    :param scale: Scale factor for root translation and offset values.
    :type scale: float
    :return: If the conversion was successful or not.
    :rtype: bool
    """
    with open(bvh_path) as file_handle:
        mocap = BvhTree(file_handle.read())
    
    # Even though the BVH is Y-up, because the skeleton got rotated by 90 degrees around X, Z is now up.
    coords_up = '<CoordinateSystem> { Z-up }\n'
    comment = '<Comment> {{ Converted from {0} }}\n'.format(os.path.basename(bvh_path))
    init_table_str = '<Table> {\n  <Bundle> Armature {\n    <Table> "<skeleton>" {\n'
    
    egg_str = coords_up + comment + init_table_str + get_egg_anim_tables(mocap, scale=scale)
    egg_str = close_tables(egg_str)
    
    if not dst_path:
        dst_path = bvh_path[:-3] + 'egg'
        
    if os.path.isdir(dst_path):
        dst_path = os.path.join(dst_path, os.path.basename(bvh_path)[:-3] + 'egg')
        
    try:
        with open(dst_path, 'w') as file_handle:
            file_handle.write(egg_str)
        return True
    except IOError as e:
        print("ERROR({}): Could not write to file {}.\n"
              "Make sure you have writing permissions.\n".format(e.errno, dst_path))
        return False
 Converts a BVH file into the Panda3D egg animation file format.
    When passing keyword arguments, keywords must be used!

    :param bvh_path: File path(s) for BVH source.
    :type bvh_path: str|list
    :param dst_path: File or folder path for destination Panda3D Egg file.
    :type dst_path: str
    :param scale: Scale factor for root translation and offset values.
    :type scale: float
    :return: If the conversion was successful or not.
    :rtype: bool
    
Converts a BVH file into the Panda3D egg animation file format.
When passing keyword arguments, keywords must be used!
Converts a BVH file into the Panda3D egg animation file format . When passing keyword arguments keywords must be used!
def bvh2egg(bvh_path, dst_path=None, scale=1.0):
    with open(bvh_path) as file_handle:
        mocap = BvhTree(file_handle.read())
    coords_up = '<CoordinateSystem> { Z-up }\n'
    comment = '<Comment> {{ Converted from {0} }}\n'.format(os.path.basename(bvh_path))
    init_table_str = '<Table> {\n  <Bundle> Armature {\n    <Table> "<skeleton>" {\n'
    egg_str = coords_up + comment + init_table_str + get_egg_anim_tables(mocap, scale=scale)
    egg_str = close_tables(egg_str)
    if not dst_path:
        dst_path = bvh_path[:-3] + 'egg'
    if os.path.isdir(dst_path):
        dst_path = os.path.join(dst_path, os.path.basename(bvh_path)[:-3] + 'egg')
    try:
        with open(dst_path, 'w') as file_handle:
            file_handle.write(egg_str)
        return True
    except IOError as e:
        print("ERROR({}): Could not write to file {}.\n"
              "Make sure you have writing permissions.\n".format(e.errno, dst_path))
        return False
def bvh2egg ( bvh_path , dst_path = None , scale = 1.0 ) : with open ( bvh_path ) as file_handle : mocap = BvhTree ( file_handle . read ( ) ) coords_up = '<CoordinateSystem> { Z-up }\n' comment = '<Comment> {{ Converted from {0} }}\n' . format ( os . path . basename ( bvh_path ) ) init_table_str = '<Table> {\n  <Bundle> Armature {\n    <Table> "<skeleton>" {\n' egg_str = coords_up + comment + init_table_str + get_egg_anim_tables ( mocap , scale = scale ) egg_str = close_tables ( egg_str ) if not dst_path : dst_path = bvh_path [ : - 3 ] + 'egg' if os . path . isdir ( dst_path ) : dst_path = os . path . join ( dst_path , os . path . basename ( bvh_path ) [ : - 3 ] + 'egg' ) try : with open ( dst_path , 'w' ) as file_handle : file_handle . write ( egg_str ) return True except IOError as e : print ( "ERROR({}): Could not write to file {}.\n" "Make sure you have writing permissions.\n" . format ( e . errno , dst_path ) ) return False
Converts a BVH file into the Panda3D egg animation file format.
Converts a BVH file into the Panda3D egg animation file format .
""" Converts a BVH file into the Panda3D egg animation file format.
    When passing keyword arguments, keywords must be used!

    :param bvh_path: File path(s) for BVH source.
    :type bvh_path: str|list
    :param dst_path: File or folder path for destination Panda3D Egg file.
    :type dst_path: str
    :param scale: Scale factor for root translation and offset values.
    :type scale: float
    :return: If the conversion was successful or not.
    :rtype: bool
    """ # Even though the BVH is Y-up, because the skeleton got rotated by 90 degrees around X, Z is now up.
If the conversion was successful or not.
If the conversion was successful or not .
bool
bvh_path
File path(s) for BVH source.
File path ( s ) for BVH source .
dst_path
File or folder path for destination Panda3D Egg file.
File or folder path for destination Panda3D Egg file .
scale
Scale factor for root translation and offset values.
Scale factor for root translation and offset values .