Example #1
0
def _import_vertices_mod156(mod, mesh):
    box_width = abs(mod.box_min_x) + abs(mod.box_max_x)
    box_height = abs(mod.box_min_y) + abs(mod.box_max_y)
    box_length = abs(mod.box_min_z) + abs(mod.box_max_z)

    vertices_array = get_vertices_array(mod, mesh)

    if mesh.vertex_format != 0:
        vertices = (transform_vertices_from_bbox(vf, box_width, box_height,
                                                 box_length)
                    for vf in vertices_array)
    else:
        vertices = ((vf.position_x, vf.position_y, vf.position_z)
                    for vf in vertices_array)
    vertices = (y_up_to_z_up(vertex_tuple) for vertex_tuple in vertices)
    vertices = ((x / 100, y / 100, z / 100) for x, y, z in vertices)

    # TODO: investigate why uvs don't appear above the image in the UV editor
    list_of_tuples = [(unpack_half_float(v.uv_x),
                       unpack_half_float(v.uv_y) * -1) for v in vertices_array]
    return {
        'locations': list(vertices),
        'uvs': list(chain.from_iterable(list_of_tuples)),
        'weights_per_bone': _get_weights_per_bone(mod, mesh, vertices_array)
    }
Example #2
0
def _import_vertices_mod210(mod, mesh):
    vertices_array = get_vertices_array(mod, mesh)
    vertices = ((vf.position_x / 32767, vf.position_y / 32767, vf.position_z / 32767)
                for vf in vertices_array)
    vertices = (y_up_to_z_up(vertex_tuple) for vertex_tuple in vertices)

    # TODO: investigate why uvs don't appear above the image in the UV editor
    list_of_tuples = [(unpack_half_float(v.uv_x), unpack_half_float(v.uv_y) * -1) for v in vertices_array]
    return {'locations': list(vertices),
            'uvs': list(chain.from_iterable(list_of_tuples)),
            'weights_per_bone': {}
            }
Example #3
0
def _import_vertices_mod210(mod, mesh):
    vertices_array = get_vertices_array(mod, mesh)
    vertices = ((vf.position_x / 32767, vf.position_y / 32767,
                 vf.position_z / 32767) for vf in vertices_array)
    vertices = (y_up_to_z_up(vertex_tuple) for vertex_tuple in vertices)

    # TODO: investigate why uvs don't appear above the image in the UV editor
    list_of_tuples = [(unpack_half_float(v.uv_x),
                       unpack_half_float(v.uv_y) * -1) for v in vertices_array]
    return {
        'locations': list(vertices),
        'uvs': list(chain.from_iterable(list_of_tuples)),
        'weights_per_bone': {}
    }
Example #4
0
def _import_vertices_mod156(mod, mesh):
    box_width = abs(mod.box_min_x) + abs(mod.box_max_x)
    box_height = abs(mod.box_min_y) + abs(mod.box_max_y)
    box_length = abs(mod.box_min_z) + abs(mod.box_max_z)

    vertices_array = get_vertices_array(mod, mesh)

    if mesh.vertex_format != 0:
        vertices = (transform_vertices_from_bbox(vf, box_width, box_height, box_length)
                    for vf in vertices_array)
    else:
        vertices = ((vf.position_x, vf.position_y, vf.position_z) for vf in vertices_array)
    vertices = (y_up_to_z_up(vertex_tuple) for vertex_tuple in vertices)
    vertices = ((x / 100, y / 100, z / 100) for x, y, z in vertices)

    # TODO: investigate why uvs don't appear above the image in the UV editor
    list_of_tuples = [(unpack_half_float(v.uv_x), unpack_half_float(v.uv_y) * -1) for v in vertices_array]
    return {'locations': list(vertices),
            'uvs': list(chain.from_iterable(list_of_tuples)),
            'weights_per_bone': _get_weights_per_bone(mod, mesh, vertices_array)
            }
Example #5
0
def test_unpack_pack_half_float():
    # FIXME: Research half float and find out if these are actual limitations or
    # a bug in the function.
    # if it's not an actual limitation, raise an exception
    # https://en.wikipedia.org/wiki/Half-precision_floating-point_format
    expected_fail = 0
    for short_input in range(0, 65535):
        if (short_input in range(31745, 33792)
                or short_input in range(1, 1024)
                or short_input in range(64512, 65535)):
            expected_fail += 1
        else:
            float_output = unpack_half_float(short_input)
            short_again = pack_half_float(float_output)
            assert short_input == short_again
    assert expected_fail == 4093
Example #6
0
def test_unpack_pack_half_float():
    # FIXME: Research half float and find out if these are actual limitations or
    # a bug in the function.
    # if it's not an actual limitation, raise an exception
    # https://en.wikipedia.org/wiki/Half-precision_floating-point_format
    expected_fail = 0
    for short_input in range(0, 65535):
        if (short_input in range(31745, 33792) or
                short_input in range(1, 1024) or
                short_input in range(64512, 65535)):
            expected_fail += 1
        else:
            float_output = unpack_half_float(short_input)
            short_again = pack_half_float(float_output)
            assert short_input == short_again
    assert expected_fail == 4093