Exemplo n.º 1
0
def _make_common_part(item, index, col_type):
    scs_root = _get_scs_root(item)

    if not item.scs_props.locator_collider_centered:
        if item.scs_props.locator_collider_type == 'Box':
            offset_matrix = (item.matrix_world *
                             Matrix.Translation((0.0, -item.scs_props.locator_collider_box_y / 2, 0.0)) *
                             (Matrix.Scale(item.scs_props.locator_collider_box_x, 4, (1.0, 0.0, 0.0)) *
                              Matrix.Scale(item.scs_props.locator_collider_box_y, 4, (0.0, 1.0, 0.0)) *
                              Matrix.Scale(item.scs_props.locator_collider_box_z, 4, (0.0, 0.0, 1.0))))
        elif item.scs_props.locator_collider_type == 'Sphere':
            offset_matrix = (item.matrix_world *
                             Matrix.Translation((0.0, -item.scs_props.locator_collider_dia / 2, 0.0)) *
                             Matrix.Scale(item.scs_props.locator_collider_dia, 4))
        elif item.scs_props.locator_collider_type in ('Capsule', 'Cylinder'):
            offset_matrix = (item.matrix_world *
                             Matrix.Translation((0.0, -item.scs_props.locator_collider_len / 2, 0.0)) *
                             Matrix.Scale(item.scs_props.locator_collider_dia, 4))
        else:
            offset_matrix = item.matrix_world

        loc, qua, sca = _convert_utils.get_scs_transformation_components(scs_root.matrix_world.inverted() * offset_matrix)
    else:
        loc, qua, sca = _convert_utils.get_scs_transformation_components(scs_root.matrix_world.inverted() * item.matrix_world)

    section = _SectionData("Locator")
    section.props.append(("Name", _name_utils.tokenize_name(item.name)))
    section.props.append(("Index", index))
    section.props.append(("Position", ["&&", loc]))
    section.props.append(("Rotation", ["&&", qua]))
    section.props.append(("Alias", ""))
    section.props.append(("Weight", ["&", (item.scs_props.locator_collider_mass,)]))
    section.props.append(("Type", col_type))
    return section
Exemplo n.º 2
0
def _fill_locator_sections(model_locator_list):
    """
    Fills up "Locator" sections.
    :param model_locator_list:
    :return:
    """
    locator_sections = []
    locator_i = 0

    for item in model_locator_list:
        # print('locator: "%s" - "%s"' % (item.name, str(item.scs_props.locator_model_hookup)))
        part_section = _SectionData("Locator")
        loc_name = _name_utils.tokenize_name(item.name)
        part_section.props.append(("Name", loc_name))
        if item.scs_props.locator_model_hookup:
            part_section.props.append(
                ("Hookup",
                 item.scs_props.locator_model_hookup.split(':', 1)[1].strip()))
        part_section.props.append(("Index", locator_i))
        loc, qua, sca = _convert_utils.get_scs_transformation_components(
            item.matrix_world)
        part_section.props.append(("Position", ["&&", loc]))
        part_section.props.append(("Rotation", ["&&", qua]))
        part_section.props.append(("Scale", ["&&", sca]))
        locator_sections.append(part_section)
        locator_i += 1
    return locator_sections
Exemplo n.º 3
0
def _fill_semaphore_sections(data_list, scs_tsem_profile_inventory):
    """Fills up "Traffic Semaphore" sections."""
    sections = []
    for item_i, item in enumerate(data_list):
        # section = data_structures.section_data("TrafficLight")
        section = _SectionData("Semaphore")
        loc, qua, sca = _convert_utils.get_scs_transformation_components(item.matrix_world)
        section.props.append(("Position", ["&&", loc]))
        section.props.append(("Rotation", ["&&", qua]))
        section.props.append(("Type", int(item.scs_props.locator_prefab_tsem_type)))
        if item.scs_props.locator_prefab_tsem_id == 'none':
            item_id = -1
        else:
            item_id = int(item.scs_props.locator_prefab_tsem_id)
        section.props.append(("SemaphoreID", item_id))
        if item.scs_props.locator_prefab_tsem_type == '6':
            section.props.append(("Intervals", ["&&", (
                item.scs_props.locator_prefab_tsem_gm, item.scs_props.locator_prefab_tsem_om1, item.scs_props.locator_prefab_tsem_rm,
                item.scs_props.locator_prefab_tsem_om1)]))
        else:
            section.props.append(("Intervals", ["&&", (
                item.scs_props.locator_prefab_tsem_gs, item.scs_props.locator_prefab_tsem_os1, item.scs_props.locator_prefab_tsem_rs,
                item.scs_props.locator_prefab_tsem_os2)]))
        section.props.append(("Cycle", ["&", (item.scs_props.locator_prefab_tsem_cyc_delay, )]))
        # section.props.append(("Model", item.scs_props.locator_prefab_tsem_model))
        # section.props.append(("Profile", item.scs_props.locator_prefab_tsem_profile))
        if item.scs_props.locator_prefab_tsem_profile:
            profile = scs_tsem_profile_inventory[item.scs_props.locator_prefab_tsem_profile].item_id
        else:
            profile = ""
        section.props.append(("Profile", profile))
        sections.append(section)
    return sections
Exemplo n.º 4
0
def _fill_spawn_point_sections(data_list):
    """Fills up "Spawn Point" sections."""
    sections = []
    for item_i, item in enumerate(data_list):
        section = _SectionData("SpawnPoint")
        section.props.append(("Name", _name_utils.tokenize_name(item.name)))
        loc, qua, sca = _convert_utils.get_scs_transformation_components(item.matrix_world)
        section.props.append(("Position", ["&&", loc]))
        section.props.append(("Rotation", ["&&", qua]))
        section.props.append(("Type", int(item.scs_props.locator_prefab_spawn_type)))
        sections.append(section)
    return sections
Exemplo n.º 5
0
def _fill_spawn_point_sections(data_list):
    """Fills up "Spawn Point" sections."""
    sections = []
    for item_i, item in enumerate(data_list):
        section = _SectionData("SpawnPoint")
        section.props.append(("Name", _name_utils.tokenize_name(item.name)))
        loc, qua, sca = _convert_utils.get_scs_transformation_components(
            item.matrix_world)
        section.props.append(("Position", ["&&", loc]))
        section.props.append(("Rotation", ["&&", qua]))
        section.props.append(
            ("Type", int(item.scs_props.locator_prefab_spawn_type)))
        sections.append(section)
    return sections
Exemplo n.º 6
0
def _fill_sign_sections(data_list, scs_sign_model_inventory):
    """Fills up "Sign" sections."""
    sections = []
    for item_i, item in enumerate(data_list):
        section = _SectionData("Sign")
        section.props.append(("Name", _name_utils.tokenize_name(item.name)))
        loc, qua, sca = _convert_utils.get_scs_transformation_components(item.matrix_world)
        section.props.append(("Position", ["&&", loc]))
        section.props.append(("Rotation", ["&&", qua]))
        if item.scs_props.locator_prefab_sign_model:
            model = scs_sign_model_inventory[item.scs_props.locator_prefab_sign_model].item_id
        else:
            model = ""
        section.props.append(("Model", model))
        section.props.append(("Part", item.scs_props.scs_part))
        sections.append(section)
    return sections
Exemplo n.º 7
0
def _fill_semaphore_sections(data_list, scs_tsem_profile_inventory):
    """Fills up "Traffic Semaphore" sections."""
    sections = []
    for item_i, item in enumerate(data_list):
        # section = data_structures.section_data("TrafficLight")
        section = _SectionData("Semaphore")
        loc, qua, sca = _convert_utils.get_scs_transformation_components(
            item.matrix_world)
        section.props.append(("Position", ["&&", loc]))
        section.props.append(("Rotation", ["&&", qua]))
        section.props.append(
            ("Type", int(item.scs_props.locator_prefab_tsem_type)))
        if item.scs_props.locator_prefab_tsem_id == 'none':
            item_id = -1
        else:
            item_id = int(item.scs_props.locator_prefab_tsem_id)
        section.props.append(("SemaphoreID", item_id))
        if item.scs_props.locator_prefab_tsem_type == '6':
            section.props.append(("Intervals", [
                "&&",
                (item.scs_props.locator_prefab_tsem_gm,
                 item.scs_props.locator_prefab_tsem_om1,
                 item.scs_props.locator_prefab_tsem_rm,
                 item.scs_props.locator_prefab_tsem_om1)
            ]))
        else:
            section.props.append(("Intervals", [
                "&&",
                (item.scs_props.locator_prefab_tsem_gs,
                 item.scs_props.locator_prefab_tsem_os1,
                 item.scs_props.locator_prefab_tsem_rs,
                 item.scs_props.locator_prefab_tsem_os2)
            ]))
        section.props.append(
            ("Cycle", ["&", (item.scs_props.locator_prefab_tsem_cyc_delay, )]))
        # section.props.append(("Model", item.scs_props.locator_prefab_tsem_model))
        # section.props.append(("Profile", item.scs_props.locator_prefab_tsem_profile))
        if item.scs_props.locator_prefab_tsem_profile:
            profile = scs_tsem_profile_inventory[
                item.scs_props.locator_prefab_tsem_profile].item_id
        else:
            profile = ""
        section.props.append(("Profile", profile))
        sections.append(section)
    return sections
Exemplo n.º 8
0
def _fill_sign_sections(data_list, scs_sign_model_inventory):
    """Fills up "Sign" sections."""
    sections = []
    for item_i, item in enumerate(data_list):
        section = _SectionData("Sign")
        section.props.append(("Name", _name_utils.tokenize_name(item.name)))
        loc, qua, sca = _convert_utils.get_scs_transformation_components(
            item.matrix_world)
        section.props.append(("Position", ["&&", loc]))
        section.props.append(("Rotation", ["&&", qua]))
        if item.scs_props.locator_prefab_sign_model:
            model = scs_sign_model_inventory[
                item.scs_props.locator_prefab_sign_model].item_id
        else:
            model = ""
        section.props.append(("Model", model))
        section.props.append(("Part", item.scs_props.scs_part))
        sections.append(section)
    return sections
Exemplo n.º 9
0
def _fill_locator_sections(model_locator_list):
    """
    Fills up "Locator" sections.
    :param model_locator_list:
    :return:
    """
    locator_sections = []
    locator_i = 0

    for item in model_locator_list:
        # print('locator: "%s" - "%s"' % (item.name, str(item.scs_props.locator_model_hookup)))
        part_section = _SectionData("Locator")
        loc_name = _name_utils.tokenize_name(item.name)
        part_section.props.append(("Name", loc_name))
        if item.scs_props.locator_model_hookup:
            part_section.props.append(("Hookup", item.scs_props.locator_model_hookup.split(':', 1)[1].strip()))
        part_section.props.append(("Index", locator_i))
        loc, qua, sca = _convert_utils.get_scs_transformation_components(item.matrix_world)
        part_section.props.append(("Position", ["&&", loc]))
        part_section.props.append(("Rotation", ["&&", qua]))
        part_section.props.append(("Scale", ["&&", sca]))
        locator_sections.append(part_section)
        locator_i += 1
    return locator_sections