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)
def create_designer_text(self): # loop through our text and do the things to the letters letters = self.build_text_list_with_counts(self.text) for idx, letter in enumerate(letters): if letter is not " ": self.select_copy_paste(letter, idx) # select the letters we used general.clear_selection() general.select_objects(letters)
def create_designer_text(self): # loop through our text and do the things to the letters letters = self.build_text_list_with_counts(self.text) for idx, letter in enumerate(letters): if letter is not " ": self.select_copy_paste(letter, idx) # select the letters we used general.clear_selection() general.select_objects(filter(lambda char: char is not " ", letters))
def __init__(self): super(EntityGrabber, self).__init__() general.clear_selection() self.folder = str() # folder to get all item xml files from self.file_type = "*.xml" self.item_names = list() # a list of ItemNames from xml files self.xml_files = () # a list of a xml file paths self.excluded_files = (self.get_excluded_files_list() ) # a list of all the entity names not to spawn self.items = list()
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)
def __init__(self): super(EntityGrabber, self).__init__() general.clear_selection() self.folder = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "..", "GameSDK", "Objects")) self.file_type = "*.cgf" self.cgf_files = list() # a list of cgf paths self.items = list() self.increment_amount = 0
def __init__(self): super(EntityGrabber, self).__init__() general.clear_selection() self.folder = str() # folder to get all item xml files from self.file_type = "*.xml" self.item_names = list() # a list of ItemNames from xml files self.xml_files = () # a list of a xml file paths self.excluded_files = ( self.get_excluded_files_list() ) # a list of all the entity names not to spawn self.items = list()
def __init__(self): super(CGFGrabber, self).__init__() general.clear_selection() self.folder = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "..", "GameSDK", "Objects") ) self.file_type = ".cgf" self.cgf_files = list() # a list of normalized cgf paths self.items = ( list() ) # list of all names added in from created objects so you can select self.increment_amount = 0
def __init__(self): super(CGFGrabber, self).__init__() general.clear_selection() self.folder = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "..", "GameSDK", "Objects")) self.file_type = ".cgf" self.cgf_files = list() # a list of normalized cgf paths self.items = ( list() ) # list of all names added in from created objects so you can select self.increment_amount = 0
def capture(): scripts_dir = os.path.abspath(os.path.dirname(__file__)) screenshot_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "..", "user", "screenshots")) images = get_all_files(".jpg", screenshot_dir) general.clear_selection() if general.is_helpers_shown(): general.toggle_helpers() # if general.get_viewport_size() == (3840, 2160): # general.set_viewport_size(3840, 2160) if len(sys.argv) == 3: if sys.argv[2] == "--pink": general.set_position("icon_pink_screen", 992.4509, 1047.51, 47.6817) general.set_position("icon_green_screen", 0, 0, 0) else: general.set_position("icon_green_screen", 992.4509, 1047.51, 47.6817) general.set_position("icon_pink_screen", 0, 0, 0) general.run_console("r_getScreenshot 1") obj = get_icon_object_in_scene() keys = obj.keys() embellishment_string = "" if u"embellishment_48" in keys: embellishment_string += "--embellishment_48 " + obj[ "embellishment_48"] + " " if u"embellishment_200" in keys: embellishment_string += "--embellishment_200 " + obj[ "embellishment_200"] + " " if u"embellishment_2048" in keys: embellishment_string += "--embellishment_2048 " + obj[ "embellishment_2048"] + " " if u"embellishment_under" in keys: embellishment_string += "--embellishment_under" print(embellishment_string) if obj: # the object exists in our db # save it and overwrite the current version then execute_external_icon_exe the script execute_external_icon_exe( scripts_dir, save(obj["name"], overwrite=True), images, embellishments=embellishment_string, ) else: # the objects does not exist in our db # Ask the user what it is and save it and then execute_external_icon_exe the script execute_external_icon_exe(scripts_dir, save(), images, embellishments=embellishment_string)
def capture(): scripts_dir = os.path.abspath(os.path.dirname(__file__)) screenshot_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "..", "user", "screenshots") ) images = get_all_files(".jpg", screenshot_dir) general.clear_selection() if general.is_helpers_shown(): general.toggle_helpers() # if general.get_viewport_size() == (3840, 2160): # general.set_viewport_size(3840, 2160) if len(sys.argv) == 3: if sys.argv[2] == "--pink": general.set_position("icon_pink_screen", 992.4509, 1047.51, 47.6817) general.set_position("icon_green_screen", 0, 0, 0) else: general.set_position("icon_green_screen", 992.4509, 1047.51, 47.6817) general.set_position("icon_pink_screen", 0, 0, 0) general.run_console("r_getScreenshot 1") obj = get_icon_object_in_scene() keys = obj.keys() embellishment_string = "" if u"embellishment_48" in keys: embellishment_string += "--embellishment_48 " + obj["embellishment_48"] + " " if u"embellishment_200" in keys: embellishment_string += "--embellishment_200 " + obj["embellishment_200"] + " " if u"embellishment_2048" in keys: embellishment_string += "--embellishment_2048 " + obj["embellishment_2048"] + " " if u"embellishment_under" in keys: embellishment_string += "--embellishment_under" print(embellishment_string) if obj: # the object exists in our db # save it and overwrite the current version then execute_external_icon_exe the script execute_external_icon_exe( scripts_dir, save(obj["name"], overwrite=True), images, embellishments=embellishment_string, ) else: # the objects does not exist in our db # Ask the user what it is and save it and then execute_external_icon_exe the script execute_external_icon_exe( scripts_dir, save(), images, embellishments=embellishment_string )
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
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
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)
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)
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)
# 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], phys_pos[2]) general.set_rotation(user_selection, phys_rot[0], phys_rot[1], phys_rot[2]) general.set_scale(user_selection, phys_scale[0], phys_scale[1], phys_scale[2]) # delete the physics object general.clear_selection() general.delete_object(PHYS_OBJECT_NAME) # reselect the users original selection general.select_object(user_selection) # delete the simmed brush key so we can simulate another model store.delete("simmed_brush")
def set_increment_amount(self): x1, y1, z1, x2, y2, z2 = general.get_selection_aabb() # width of x + 1/2 width of x because it measures from center point self.increment_amount = (x2 - x1) + ((x2 - x1) * 0.5) general.clear_selection()
def set_increment_amount(): x1, y1, z1, x2, y2, z2 = general.get_selection_aabb() # width of x + 1/2 width of x because it measures from center point increment_amount = (x2 - x1) + ((x2 - x1) * 0.5) general.clear_selection() return increment_amount
def select(name, add=False): if not add: general.clear_selection() general.select_object(name)
def clear_selection(): general.clear_selection()
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"]
def function_wrapper(*args, **kwargs): selected = general.get_names_of_selected_objects() func(*args, **kwargs) general.clear_selection() general.select_objects(selected)