def do_wall_start(camname): # start (red) USERS[camname].wloc_start = USERS[camname].location USERS[camname].wrot_start = USERS[camname].rotation arblib.temp_loc_marker(USERS[camname].wloc_start, (255, 0, 0)) arblib.temp_rot_marker(USERS[camname].wloc_start, USERS[camname].wrot_start)
def do_wall_end(camname): # end (green) USERS[camname].wloc_end = USERS[camname].position USERS[camname].wrot_end = USERS[camname].rotation scene.add_object( arblib.temp_loc_marker(USERS[camname].wloc_end, Color(0, 255, 0))) scene.add_object( arblib.temp_rot_marker(USERS[camname].wloc_end, USERS[camname].wrot_end))
def do_wall_start(camname): # start (red) USERS[camname].wloc_start = USERS[camname].position USERS[camname].wrot_start = USERS[camname].rotation scene.add_object( arblib.temp_loc_marker(USERS[camname].wloc_start, Color(255, 0, 0))) scene.add_object( arblib.temp_rot_marker(USERS[camname].wloc_start, USERS[camname].wrot_start))
def make_wall(camname): # Wall theory: capture two poses and use them to place a wall object. # Also assumes first corner easier to capture accurate rotation than last. # Click 1: Capture the position and rotation. # Click 2: Capture the position only. sloc = USERS[camname].wloc_start eloc = USERS[camname].wloc_end srot = USERS[camname].wrot_start erot = USERS[camname].wrot_end print("S POS " + str((sloc[0], sloc[1], sloc[2]))) print("E POS " + str((eloc[0], eloc[1], eloc[2]))) # center point (blue) locx = arena.agran(statistics.median([sloc[0], eloc[0]])) locy = arena.agran(statistics.median([sloc[1], eloc[1]])) locz = arena.agran(statistics.median([sloc[2], eloc[2]])) arblib.temp_loc_marker((locx, locy, locz), (0, 0, 255)) print("wall position " + str((locx, locy, locz))) # rotation print("S ROT " + str((srot[0], srot[1], srot[2], srot[3]))) print("E ROT " + str((erot[0], erot[1], erot[2], erot[3]))) rotx = arblib.probable_quat(srot[0]) roty = arblib.probable_quat(srot[1]) rotz = arblib.probable_quat(srot[2]) rotw = arblib.probable_quat(srot[3]) rot = (rotx, roty, rotz, rotw) arblib.temp_rot_marker((locx, locy, locz), rot) print("wall rotation " + str(rot)) # which axis to use for wall? use camera gaze # TODO: rotation still off if rot in arblib.GAZES[0]: height = abs(sloc[1] - eloc[1]) width = abs(sloc[0] - eloc[0]) elif rot in arblib.GAZES[1]: height = abs(sloc[1] - eloc[1]) width = abs(sloc[2] - eloc[2]) elif rot in arblib.GAZES[2]: height = abs(sloc[2] - eloc[2]) width = abs(sloc[0] - eloc[0]) else: # TODO: (placeholder) add direction and hypotenuse height = abs(sloc[1] - eloc[1]) width = abs(sloc[0] - eloc[0]) print("Non-axis parallel rotation: " + str(rot)) # scale scax = width scay = height scaz = arblib.WALL_WIDTH print("wall scale " + str((scax, scay, scaz))) # make wall randstr = str(random.randrange(0, 1000000)) new_wall = arena.Object( persist=True, clickable=True, objName="wall_" + randstr, objType=arena.Shape.cube, location=(locx, locy, locz), rotation=(rotx, roty, rotz, rotw), scale=(scax, scay, scaz), color=(200, 200, 200), transparency=arena.Transparency(True, 0.5), ) USERS[camname].target_id = new_wall.objName print("Created " + new_wall.objName + " r" + str((rotx, roty, rotz, rotw)) + " s" + str((scax, scay, scaz)))
def do_wall_end(camname): # end (green) USERS[camname].wloc_end = USERS[camname].location USERS[camname].wrot_end = USERS[camname].rotation arblib.temp_loc_marker(USERS[camname].wloc_end, (0, 255, 0)) arblib.temp_rot_marker(USERS[camname].wloc_end, USERS[camname].wrot_end)
def make_wall(camname): # Wall theory: capture two poses and use them to place a wall object. # Also assumes first corner easier to capture accurate rotation than last. # Click 1: Capture the position and rotation. # Click 2: Capture the position only. sloc = USERS[camname].wloc_start eloc = USERS[camname].wloc_end srot = USERS[camname].wrot_start erot = USERS[camname].wrot_end print(f"S POS {str(sloc)}") print(f"E POS {str(eloc)}") # center point (blue) locx = statistics.median([sloc.x, eloc.x]) locy = statistics.median([sloc.y, eloc.y]) locz = statistics.median([sloc.z, eloc.z]) pos = Position(locx, locy, locz) scene.add_object(arblib.temp_loc_marker(pos, Color(0, 0, 255))) print(f"wall position {str(pos)}") # rotation print(f"S ROT {str(srot)}") print(f"E ROT {str(erot)}") rotx = arblib.probable_quat(srot.x) roty = arblib.probable_quat(srot.y) rotz = arblib.probable_quat(srot.z) rotw = arblib.probable_quat(srot.w) rot = Rotation(rotx, roty, rotz, rotw) gaze = (rotx, roty, rotz, rotw) scene.add_object(arblib.temp_rot_marker(pos, rot)) print(f"wall rotation {str(rot)}") # which axis to use for wall? use camera gaze # TODO: rotation still off if gaze in arblib.GAZES[0]: height = abs(sloc.y - eloc.y) width = abs(sloc.x - eloc.x) elif gaze in arblib.GAZES[1]: height = abs(sloc.y - eloc.y) width = abs(sloc.z - eloc.z) elif gaze in arblib.GAZES[2]: height = abs(sloc.z - eloc.z) width = abs(sloc.x - eloc.x) else: # TODO: (placeholder) add direction and hypotenuse height = abs(sloc.y - eloc.y) width = abs(sloc.x - eloc.x) print(f"Non-axis parallel rotation: {str(rot)}") # scale scax = width scay = height scaz = arblib.WALL_WIDTH sca = Scale(scax, scay, scaz) print(f"wall scale {str(sca)}") # make wall randstr = str(random.randrange(0, 1000000)) new_wall = Box( persist=True, clickable=True, object_id=f"wall_{randstr}", position=pos, rotation=rot, scale=sca, material=Material(color=Color(200, 200, 200), transparent=True, opacity=0.5), ) scene.add_object(new_wall) USERS[camname].target_id = new_wall.object_id print(f"Created {new_wall.object_id} r{str(rot)} s{str(sca)}")