def do_stretch_select(camname, objid, scale=None): color = arblib.CLR_STRETCH delim = "_" + Mode.STRETCH.value + "_" callback = stretchline_callback if not scale: pobjs = arena.get_network_persisted_obj(objid, BROKER, SCENE) if not pobjs: return obj = arblib.ObjectPersistence(pobjs[0]) if obj.object_type == arena.Shape.gltf_model: # scale too unpredictable return if obj.rotation != (0, 0, 0, 1): # scale too unpredictable return position = obj.position scale = obj.scale # scale and reposition on one of 6 sides make_clickline("x", 1, objid, position, delim, color, callback) make_clickline("x", -1, objid, position, delim, color, callback) make_clickline("y", 1, objid, position, delim, color, callback) make_clickline("y", -1, objid, position, delim, color, callback) make_clickline("z", 1, objid, position, delim, color, callback) make_clickline("z", -1, objid, position, delim, color, callback) make_followspot(objid, position, delim, color) sca = (round(scale[0], 3), round(scale[1], 3), round(scale[2], 3)) USERS[camname].set_textright(USERS[camname].target_style + " s" + str(sca))
def show_redpill_obj(camname, object_id): # any scene changes must not persist pobjs = arena.get_network_persisted_obj(object_id, BROKER, SCENE) if not pobjs: return obj = arblib.ObjectPersistence(pobjs[0]) # enable mouse enter/leave pos/rot/scale USERS[camname].set_textstatus(object_id + ' p' + str(obj.position) + ' r' + str(obj.rotation) + ' s' + str(obj.scale))
def do_rename(camname, old_id, new_id): if new_id == old_id: return pobjs = arena.get_network_persisted_obj(old_id, BROKER, SCENE) if not pobjs: return data = json.dumps(pobjs[0]["attributes"]) arena.Object(objName=new_id, persist=True, data=data) USERS[camname].target_id = new_id print("Duplicating " + old_id + " to " + new_id) arblib.delete_obj(REALM, SCENE, old_id)
def do_move_select(camname, object_id): pobjs = arena.get_network_persisted_obj(object_id, BROKER, SCENE) if not pobjs: return obj = arblib.ObjectPersistence(pobjs[0]) USERS[camname].target_id = object_id USERS[camname].set_clipboard( callback=clipboard_callback, obj_type=obj.object_type, scale=obj.scale, color=obj.color, url=obj.url, )
def do_scale_select(camname, objid, scale=None): color = arblib.CLR_SCALE delim = "_" + Mode.SCALE.value + "_" callback = scaleline_callback if not scale: pobjs = arena.get_network_persisted_obj(objid, BROKER, SCENE) if not pobjs: return obj = arblib.ObjectPersistence(pobjs[0]) position = obj.position scale = obj.scale # scale entire object + or - on all axis make_clickline("x", 1, objid, position, delim, color, callback) make_followspot(objid, position, delim, color) sca = (round(scale[0], 3), round(scale[1], 3), round(scale[2], 3)) USERS[camname].set_textright(USERS[camname].target_style + " s" + str(sca))
def do_nudge_select(camname, objid, position=None): color = arblib.CLR_NUDGE delim = "_" + Mode.NUDGE.value + "_" callback = nudgeline_callback if not position: pobjs = arena.get_network_persisted_obj(objid, BROKER, SCENE) if not pobjs: return obj = arblib.ObjectPersistence(pobjs[0]) position = obj.position # nudge object + or - on 3 axis make_clickline("x", 1, objid, position, delim, color, callback) make_clickline("y", 1, objid, position, delim, color, callback) make_clickline("z", 1, objid, position, delim, color, callback) make_followspot(objid, position, delim, color) pos = (round(position[0], 3), round(position[1], 3), round(position[2], 3)) USERS[camname].set_textright(USERS[camname].target_style + " p" + str(pos))
def do_rotate_select(camname, objid, rotation=None): color = arblib.CLR_ROTATE delim = "_" + Mode.ROTATE.value + "_" callback = rotateline_callback if not rotation: pobjs = arena.get_network_persisted_obj(objid, BROKER, SCENE) if not pobjs: return obj = arblib.ObjectPersistence(pobjs[0]) position = obj.position rotation = obj.rotation # rotate object + or - on 3 axis, plus show original axis as after # effect make_clickline("x", 1, objid, position, delim, color, callback, True) make_clickline("y", 1, objid, position, delim, color, callback, True) make_clickline("z", 1, objid, position, delim, color, callback, True) make_followspot(objid, position, delim, color) rote = arblib.rotation_quat2euler(rotation) euler = (round(rote[0], 1), round(rote[1], 1), round(rote[2], 1)) USERS[camname].set_textright(USERS[camname].target_style + "d r" + str(euler))
def handle_clickline_event(event, mode): # naming order: objectname_clicktype_axis_direction click_id = event.object_id.split("_" + mode.value + "_") object_id = click_id[0] direction = (click_id[1])[0:2] move = (click_id[1])[1:4] if event.event_type == arena.EventType.mouseenter: CONTROLS[object_id][event.object_id].update( transparency=arena.Transparency(True, arblib.OPC_CLINE_HOVER)) elif event.event_type == arena.EventType.mouseleave: CONTROLS[object_id][event.object_id].update( transparency=arena.Transparency(True, arblib.OPC_CLINE)) # allow any user to change an object if event.event_type != arena.EventType.mousedown: return None, None, None if USERS[event.source].mode != mode: return None, None, None pobjs = arena.get_network_persisted_obj(object_id, BROKER, SCENE) if not pobjs: return None, None, None obj = arblib.ObjectPersistence(pobjs[0]) return (obj, direction, move)