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_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 show_redpill_scene(enabled): # any scene changes must not persist # show gridlines glen = arblib.GRIDLEN y = arblib.FLOOR_Y hcolor = arblib.rgb2hex(arblib.CLR_GRID) for z in range(-glen, glen + 1): name = "grid_z" + str(z) if enabled: arena.Object(objName=name, objType=arena.Shape.line, line=arena.Line((-glen, y, z), (glen, y, z), 1, hcolor)) else: arblib.delete_obj(REALM, SCENE, name) for x in range(-glen, glen + 1): name = "grid_x" + str(x) if enabled: arena.Object(objName=name, objType=arena.Shape.line, line=arena.Line((x, y, -glen), (x, y, glen), 1, hcolor)) else: arblib.delete_obj(REALM, SCENE, name) pobjs = arena.get_network_persisted_scene(BROKER, SCENE) for pobj in pobjs: obj = arblib.ObjectPersistence(pobj) # show occluded objects if obj.transparent_occlude: name = "redpill_" + obj.object_id if enabled: arena.Object( objName=name, objType=obj.object_type, location=obj.position, rotation=obj.rotation, scale=obj.scale, color=obj.color, clickable=True, url=obj.url, transparency=arena.Transparency(True, 0.5), ) print("Wrapping occlusion " + name) else: arblib.delete_obj(REALM, SCENE, name)
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)