Пример #1
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})
Пример #2
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)
Пример #3
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)
Пример #4
0
# 	8. delete rigid body.
import better_cry
from user_values import UserValues

if __name__ == "__main__":
    PHY_OBJ_NAME = "brush_sim_temp"
    level = better_cry.Level()
    store = UserValues()
    # check if we have a stored brush
    stored_brush = store.get("simmed_brush")

    if stored_brush is None:
        # 	1. Get selected object.
        brush = level.selected[0]
        # store the users selection for setting the physics state later on
        store.set("simmed_brush", brush.name)
        # 	2. Create rigid body ex and copy model to rigidbodyex
        phys_obj = level.new_object("Entity", r"RigidBodyEx", PHY_OBJ_NAME, 0, 0, 0)
        # mark it with a special material so you know it's being simulated
        phys_obj.material = "Materials/Special/green_screen.mtl"
        # set the physobj to be the selected brush object
        phys_obj.geometry_file = brush.geometry_file
        # 	3. snap physobj to xform of selected object
        phys_obj.position = (brush.position[0], brush.position[1], brush.position[2])
        phys_obj.rotation = (brush.rotation[0], brush.rotation[1], brush.rotation[2])
        phys_obj.scale = (brush.scale[0], brush.scale[1], brush.scale[2])
        # 5 Hide user selection object
        brush.hide()
        # 	6. simulate physobj
        phys_obj.simulate()
Пример #5
0
from user_values import UserValues

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,
Пример #6
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"]
Пример #7
0
    try:
        io = IconObjectDB()
    except ValueError as val_err:
        general.message_box_ok(str(val_err))
        return False
    xml_path = store.get("todo")[0]
    name = get_item_name_from_xml(xml_path)
    if xml_path is not None:
        icon_object = io.get_obj_by_name(name)
        if icon_object:
            add_to_scene(icon_object)
        else:
            print('Inserting ' + name + 'to icon database')
            add_to_scene(
                get_default_object(
                    get_item_geometry_from_xml(xml_path),
                    mtl=get_item_material_from_xml(xml_path),
                    name=name
                )
            )
            save(name)
        add_item_to_processed_list(xml_path, store)


if __name__ == "__main__":
    store = UserValues()
    if store.get("todo") is None:
        store.set("todo", items)
        store.set("done", [])
    load_batch(store)