示例#1
0
def main():
    selected = general.get_names_of_selected_objects()
    print(selected)
    input_axis = {"X": 0, "Y": 1, "Z": 2}
    axis = input_axis[str(general.edit_box("Axis: X, Y, Z")).upper()]
    num_copies = int(general.edit_box("Number of Clones"))
    distance = int(general.edit_box("Distance between clones"))
    for mesh_idx, mesh in enumerate(selected):
        start_pos = general.get_position(mesh)
        start_rot = general.get_rotation(mesh)
        start_scale = general.get_scale(mesh)
        for idx in xrange(num_copies):
            new_mesh = general.create_object(
                "Brush",
                general.get_entity_geometry_file(selected[mesh_idx]),
                mesh,
                0,
                0,
                0,
            )
            new_pos = [x for x in start_pos]
            new_pos[axis] += distance * (idx + 1)
            new_mesh.position = (new_pos[0], new_pos[1], new_pos[2])
            new_mesh.rotation = (start_rot[0], start_rot[1], start_rot[2])
            new_mesh.scale = (start_scale[0], start_scale[1], start_scale[2])
            new_mesh.update()
def create_variants():
    try:
        io = IconObjectDB()
    except ValueError as val_err:
        general.message_box_ok(str(val_err))
        return None
    general.clear_selection()
    general.select_object("icon_object_shot")
    # get the other items name mtl and brush
    item_filepaths = get_file_path_list(".xml", get_items_dir())
    # overwrite the name mtl and brush
    icon_object_variants = [
        {
            "name": get_item_name_from_xml(filepath),
            "brush": get_item_geometry_from_xml(filepath),
            "mtl": get_item_material_from_xml(filepath),
            "scale": general.get_scale("icon_object_shot"),
            "pos": general.get_position("icon_object_shot"),
            "rot": general.get_rotation("icon_object_shot"),
        }
        for filepath in item_filepaths
    ]
    # save it
    for icon_obj in icon_object_variants:
        io.insert_object(icon_obj, override=True)
示例#3
0
def align_min_z(selected_items):
    item_positions = [general.get_position(item) for item in selected_items]
    min_z = min([item[2] for item in item_positions])
    for idx, item in enumerate(selected_items):
        general.set_position(
            item, item_positions[idx][0], item_positions[idx][1], min_z
        )
示例#4
0
def align_x(selected_items):
    item_positions = [general.get_position(item) for item in selected_items]
    max_x = max([item[0] for item in item_positions])
    for idx, item in enumerate(selected_items):
        general.set_position(
            item, max_x, item_positions[idx][1], item_positions[idx][2]
        )
示例#5
0
def copy_xforms():
    store = UserValues()
    selected = general.get_names_of_selected_objects()[0]
    if selected is None:
        general.message_box_ok("Please Select an object")
    rot = general.get_rotation(selected)
    pos = general.get_position(selected)
    scale = general.get_scale(selected)
    store.set("xforms", {"rot": rot, "pos": pos, "scale": scale})
示例#6
0
def replace_selected():
    new_objects = list()
    # get the mesh to replace the selected item with
    replacement_mesh = general.open_file_box()
    # get all selected object
    selected = general.get_names_of_selected_objects()
    # clear the selection so we can work on one item at a time
    general.clear_selection()
    for item in selected:
        # store the items xforms
        [scale_x, scale_y, scale_z] = general.get_scale(item)
        [pos_x, pos_y, pos_z] = general.get_position(item)
        [rot_x, rot_y, rot_z] = general.get_rotation(item)
        general.delete_object(item)
        new_objects.append(
            general.new_object("Brush", replacement_mesh, item, pos_x, pos_y, pos_z)
        )
        general.set_rotation(item, rot_x, rot_y, rot_z)
        general.set_scale(item, scale_x, scale_y, scale_z)
        print("Replaced: %s with %s" % (item, replacement_mesh))
    general.select_objects(new_objects)
示例#7
0
def replace_selected():
    new_objects = list()
    # get the mesh to replace the selected item with
    replacement_mesh = general.open_file_box()
    # get all selected object
    selected = general.get_names_of_selected_objects()
    # clear the selection so we can work on one item at a time
    general.clear_selection()
    for item in selected:
        # store the items xforms
        [scale_x, scale_y, scale_z] = general.get_scale(item)
        [pos_x, pos_y, pos_z] = general.get_position(item)
        [rot_x, rot_y, rot_z] = general.get_rotation(item)
        general.delete_object(item)
        new_objects.append(
            general.new_object("Brush", replacement_mesh, item, pos_x, pos_y,
                               pos_z))
        general.set_rotation(item, rot_x, rot_y, rot_z)
        general.set_scale(item, scale_x, scale_y, scale_z)
        print("Replaced: %s with %s" % (item, replacement_mesh))
    general.select_objects(new_objects)
示例#8
0
def create_variants():
    try:
        io = IconObjectDB()
    except ValueError as val_err:
        general.message_box_ok(str(val_err))
        return None
    general.clear_selection()
    general.select_object("icon_object_shot")
    # get the other items name mtl and brush
    item_filepaths = get_file_path_list(".xml", get_items_dir())
    # overwrite the name mtl and brush
    icon_object_variants = [{
        "name": get_item_name_from_xml(filepath),
        "brush": get_item_geometry_from_xml(filepath),
        "mtl": get_item_material_from_xml(filepath),
        "scale": general.get_scale("icon_object_shot"),
        "pos": general.get_position("icon_object_shot"),
        "rot": general.get_rotation("icon_object_shot"),
    } for filepath in item_filepaths]
    # save it
    for icon_obj in icon_object_variants:
        io.insert_object(icon_obj, override=True)
示例#9
0
def align_x(selected_items):
    item_positions = [general.get_position(item) for item in selected_items]
    max_x = max([item[0] for item in item_positions])
    for idx, item in enumerate(selected_items):
        general.set_position(item, max_x, item_positions[idx][1],
                             item_positions[idx][2])
示例#10
0
def align_min_z(selected_items):
    item_positions = [general.get_position(item) for item in selected_items]
    min_z = min([item[2] for item in item_positions])
    for idx, item in enumerate(selected_items):
        general.set_position(item, item_positions[idx][0],
                             item_positions[idx][1], min_z)
示例#11
0
PHYS_OBJECT_NAME = "brush_sim_temp"

if __name__ == "__main__":
    store = UserValues()
    stored_brush = store.get("simmed_brush")
    # 	1. Get selected object.
    # grab some properties for our selected object
    user_selection = general.get_names_of_selected_objects()[0]

    if stored_brush is None:
        print('Simulating Brush')
        # store the users selection for setting the physics state later on
        store.set("simmed_brush", user_selection)
        # grab the transforms of the object
        obj_pos = general.get_position(user_selection)
        obj_rot = general.get_rotation(user_selection)
        obj_scale = general.get_scale(user_selection)

        # 	2. Create rigid body ex and copy model to rigidbodyex
        # create the object at 0,0,0
        PHYS_OBJECT_NAME = general.new_object("Entity", r"RigidBodyEx",
                                              PHYS_OBJECT_NAME, 0, 0, 0)
        # mark it with a special material so you know it's being simulated
        general.set_custom_material(PHYS_OBJECT_NAME,
                                    'Materials/Special/green_screen.mtl')
        # set the physobj to be the selected brush object
        user_selection_brush = str(lodtools.getselected())
        general.set_entity_geometry_file(PHYS_OBJECT_NAME,
                                         user_selection_brush)
示例#12
0
def save(name=False, overwrite=False, embellishment=None):
    """
	Save an Icon Setup
	:return: string name of the entity class name
	"""
    # name of icon_object in icon_level.cry
    ico_obj = "icon_object_shot"
    store = UserValues()

    # the obj to insert
    obj = dict()

    # instantiate our iodb
    try:
        io = IconObjectDB()
    except ValueError as val_err:
        general.message_box_ok(str(val_err))
        return None

    # clear the selection
    general.clear_selection()

    # get the info from the icon_object_shot
    obj["pos"] = general.get_position(ico_obj)
    obj["scale"] = general.get_scale(ico_obj)
    obj["rot"] = general.get_rotation(ico_obj)
    obj["mtl"] = general.get_assigned_material(ico_obj)
    obj["tod"] = general.get_cvar("e_timeOfDay")

    # get the brush by selecting the ico_obj
    general.select_object(ico_obj)
    obj["brush"] = lodtools.getselected().lower()
    general.clear_selection()
    stored = io.get_obj_by_brush_and_mtl(obj["brush"], obj["mtl"])

    if embellishment:
        print("Saving Embellishments")
        obj["embellishment_48"] = embellishment["embellishment_48"]
        obj["embellishment_200"] = embellishment["embellishment_200"]
        obj["embellishment_2048"] = embellishment["embellishment_2048"]
        if "embellishment_under" in embellishment.keys():
            obj["embellishment_under"] = True
    else:
        icon_obj = store.get("current_icon_object")
        if icon_obj:
            keys = icon_obj.keys()
            if "embellishment_under" in keys:
                obj["embellishment_under"] = True
            if "embellishment_48" in keys:
                obj["embellishment_48"] = icon_obj["embellishment_48"]
            if "embellishment_200" in keys:
                obj["embellishment_200"] = icon_obj["embellishment_200"]
            if "embellishment_2048" in keys:
                obj["embellishment_2048"] = icon_obj["embellishment_2048"]

    if name:
        obj["name"] = name
    elif stored:
        obj["name"] = stored["name"]
        if not general.message_box_yes_no(str("Save " + stored["name"] + "?")):
            obj["name"] = general.edit_box("Entity ClassName")
        else:
            overwrite = True
    else:
        obj["name"] = general.edit_box("Entity ClassName")

    if io.insert_object(obj) is False:
        if overwrite:
            io.insert_object(obj, override=True)
        else:
            if general.message_box_yes_no("Overwrite?"):
                io.insert_object(obj, override=True)
    print("Storing Item into UserValues")
    store.set("current_icon_object", obj)
    return obj["name"]