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)
示例#2
0
 def select_copy_paste(letter="", index=0):
     """
     select and copy our polygon item then return to original item and selCopyPast
     :param letter: letter to select
     :param index: position of the current letter
     :return: None
     """
     general.clear_selection()
     general.select_object(letter)
     general.set_position(letter, 0, -TEXT_WIDTH * index, 0)
示例#3
0
 def select_copy_paste(letter="", index=0):
     """
     select and copy our polygon item then return to original item and selCopyPast
     :param letter: letter to select
     :param index: position of the current letter
     :return: None
     """
     general.clear_selection()
     general.select_object(letter)
     general.set_position(letter, 0, -TEXT_WIDTH * index, 0)
示例#4
0
 def add_cgfs(self):
     """spawn in each of our items from self.item_names and then select them"""
     num_cols = 25
     x = 0
     for idx, item in enumerate(self.cgf_files):
         if idx % num_cols == 0:
             # increment by some amount set by the last objects x width
             x += self.increment_amount
         ob = general.new_object("Brush", self.norm_path_for_ce(item), "",
                                 x, (idx % num_cols) * 0.23, 32)
         self.items.append(ob)
         general.select_object(ob)
         self.set_increment_amount()
     general.log("Added %s CGF Files to the map." % len(self.cgf_files))
 def add_cgfs(self):
     """spawn in each of our items from self.item_names and then select them"""
     num_cols = 25
     x = 0
     for idx, item in enumerate(self.cgf_files):
         if idx % num_cols == 0:
             # increment by some amount set by the last objects x width
             x += self.increment_amount
         ob = general.new_object(
             "Brush", self.norm_path_for_ce(item), "", x, (idx % num_cols) * 0.23, 32
         )
         self.items.append(ob)
         general.select_object(ob)
         self.set_increment_amount()
     general.log("Added %s CGF Files to the map." % len(self.cgf_files))
示例#6
0
def add_cgfs(items):
    """spawn in each of our items from self.item_names and then select them"""
    num_cols = 25
    x = 0
    increment_amount = 0
    for idx, item in enumerate(items):
        if idx % num_cols == 0:
            # increment by some amount set by the last objects x width
            x += increment_amount
        general.select_object(
            general.new_object("Brush", norm_path_for_ce(item), "", x,
                               (idx % num_cols) * 55, 32))
        increment_amount = set_increment_amount()
    print("Added %s CGF Files to the map. Thanks for adding every damn CGF!" %
          len(items))
示例#7
0
def add_cgfs(items):
    """spawn in each of our items from self.item_names and then select them"""
    num_cols = 25
    x = 0
    increment_amount = 0
    for idx, item in enumerate(items):
        if idx % num_cols == 0:
            # increment by some amount set by the last objects x width
            x += increment_amount
        general.select_object(
            general.new_object(
                "Brush", norm_path_for_ce(item), "", x, (idx % num_cols) * 55, 32
            )
        )
        increment_amount = set_increment_amount()
    print(
        "Added %s CGF Files to the map. Thanks for adding every damn CGF!" % len(items)
    )
示例#8
0
def add_to_scene(obj):
    print("Adding: " + obj["name"])
    store = UserValues(init_funcs=[init_screenshot_values])
    store.set("current_icon_object", obj)
    ico_obj = "icon_object_shot"
    ico_obj_2 = "icon_object_shot_2"
    # update our ico_obj based on the settings from the collected icon_object
    general.set_position(ico_obj, obj["pos"][0], obj["pos"][1], obj["pos"][2])
    general.set_scale(ico_obj, obj["scale"][0], obj["scale"][1], obj["scale"][2])
    general.set_rotation(ico_obj, obj["rot"][0], obj["rot"][1], obj["rot"][2])
    general.set_entity_geometry_file(ico_obj, str(obj["brush"]))
    general.select_object(ico_obj)
    material.reset_selection()
    if obj["mtl"] is not None:
        general.set_custom_material(ico_obj, str(obj["mtl"]))
    if "tod" in obj.keys():
        tod_list = [str("e_TimeOfDay %s" % obj["tod"])]
        cycleConsolValue("mode_%s" % "e_TimeOfDay", tod_list)
def add_cgfs(items):
    """spawn in each of the cgfs from the array passed in and then return the names of the items"""
    added_names = []
    num_cols = 25
    x = 0
    increment_amount = 0
    for idx, item in enumerate(items):
        if idx % num_cols == 0:
            # increment by some amount set by the last objects x width
            x += increment_amount
        new_object = general.new_object("Brush", norm_path_for_ce(item), "", x,
                                        (idx % num_cols) * 55, 32)
        general.select_object(new_object)
        increment_amount = set_increment_amount()
        added_names.append(new_object)
    general.clear_selection()
    general.select_objects(added_names)
    return added_names
示例#10
0
def add_to_scene(obj):
    print("Adding: " + obj["name"])
    store = UserValues(init_funcs=[init_screenshot_values])
    store.set("current_icon_object", obj)
    ico_obj = "icon_object_shot"
    ico_obj_2 = "icon_object_shot_2"
    # update our ico_obj based on the settings from the collected icon_object
    general.set_position(ico_obj, obj["pos"][0], obj["pos"][1], obj["pos"][2])
    general.set_scale(ico_obj, obj["scale"][0], obj["scale"][1],
                      obj["scale"][2])
    general.set_rotation(ico_obj, obj["rot"][0], obj["rot"][1], obj["rot"][2])
    general.set_entity_geometry_file(ico_obj, str(obj["brush"]))
    general.select_object(ico_obj)
    material.reset_selection()
    if obj["mtl"] is not None:
        general.set_custom_material(ico_obj, str(obj["mtl"]))
    if "tod" in obj.keys():
        tod_list = [str("e_TimeOfDay %s" % obj["tod"])]
        cycleConsolValue("mode_%s" % "e_TimeOfDay", tod_list)
示例#11
0
def add_cgfs(items):
    """spawn in each of the cgfs from the array passed in and then return the names of the items"""
    added_names = []
    num_cols = 25
    x = 0
    increment_amount = 0
    for idx, item in enumerate(items):
        if idx % num_cols == 0:
            # increment by some amount set by the last objects x width
            x += increment_amount
        new_object = general.new_object(
            "Brush", norm_path_for_ce(item), "", x, (idx % num_cols) * 55, 32
        )
        general.select_object(new_object)
        increment_amount = set_increment_amount()
        added_names.append(new_object)
    general.clear_selection()
    general.select_objects(added_names)
    return added_names
示例#12
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)
示例#13
0
def get_icon_object_in_scene():
    try:
        store = UserValues()
        io = IconObjectDB()
    except ValueError as val_err:
        general.message_box_ok(str(val_err))
        return None
    store_obj = store.get("current_icon_object")
    if store_obj:
        print('Returning Stored Object from User Values')
        print(store_obj)
        return store_obj
    # if we can't find a stored version try and find it
    if not store_obj:
        general.select_object("icon_object_shot")
        obj = io.get_obj_by_brush_and_mtl(
            lodtools.getselected().lower(),
            general.get_assigned_material("icon_object_shot"),
        )
        if obj:
            return obj
    # object was not set in store and is not set in io_db
    return None
示例#14
0
def get_icon_object_in_scene():
    try:
        store = UserValues()
        io = IconObjectDB()
    except ValueError as val_err:
        general.message_box_ok(str(val_err))
        return None
    store_obj = store.get("current_icon_object")
    if store_obj:
        print('Returning Stored Object from User Values')
        print(store_obj)
        return store_obj
    # if we can't find a stored version try and find it
    if not store_obj:
        general.select_object("icon_object_shot")
        obj = io.get_obj_by_brush_and_mtl(
            lodtools.getselected().lower(),
            general.get_assigned_material("icon_object_shot"),
        )
        if obj:
            return obj
    # object was not set in store and is not set in io_db
    return None
示例#15
0
        # 	3. snap physobj to xform of selected object
        general.set_position(PHYS_OBJECT_NAME, int(obj_pos[0]),
                             int(obj_pos[1]), int(obj_pos[2]))
        general.set_rotation(PHYS_OBJECT_NAME, int(obj_rot[0]),
                             int(obj_rot[1]), int(obj_rot[2]))
        general.set_scale(PHYS_OBJECT_NAME, int(obj_scale[0]),
                          int(obj_scale[1]), int(obj_scale[2]))

        # 5 Hide user selection object
        general.log("hiding " + user_selection)
        general.hide_object(user_selection)

        # 	6. simulate physobj
        # select the physics object
        general.select_object(PHYS_OBJECT_NAME)
        # simulate it
        physics.simulate_selection()

    else:
        print('Converting Physics Object to Brush')
        # get the state of the physics objects
        physics.get_state(PHYS_OBJECT_NAME)
        # get the transforms of the simulated physics object
        phys_pos = general.get_position(PHYS_OBJECT_NAME)
        phys_rot = general.get_rotation(PHYS_OBJECT_NAME)
        phys_scale = general.get_scale(PHYS_OBJECT_NAME)
        # unhide the original object
        general.unhide_object(user_selection)
        # set the transforms of the original object to have the transforms of the simulated object
        general.set_position(user_selection, phys_pos[0], phys_pos[1],
示例#16
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"]
示例#17
0
 def select(name, add=False):
     if not add:
         general.clear_selection()
     general.select_object(name)