def enter_mode(mode): logging.debug('entering mode: %s' % mode) if mode not in _mode_mapping: logging.error('unrecognized mode %s' % mode) mode_command = _mode_mapping[mode] if mode_command: send_command('mode_%s' % mode_command) set_current_controller(mode)
def stop(self): self.is_activated = False self.loc_x_hand.empty() self.loc_y_hand.empty() self.loc_z_hand.empty() self.rot_x_hand.empty() self.rot_y_hand.empty() self.rot_z_hand.empty() send_command('object_move_end', {}) send_command('object_rotate_end', {})
def point_finger(self, tip, direction): # TODO send as long command ? tip = rescale_position(tip) send_command( 'finger_touch', { 'x': tip.z, 'y': tip.x, 'z': tip.y, 'vx': direction.z, 'vy': direction.x, 'vz': direction.y })
def start(self, hand): self.is_activated = True # move origin pos = hand.stabilized_palm_position self.loc_x_origin = pos.x self.loc_y_origin = pos.y self.loc_z_origin = pos.z send_command('object_move_origin', {}) # rotate origin self.rot_x_origin = hand.direction.pitch self.rot_y_origin = hand.direction.yaw self.rot_z_origin = hand.direction.roll send_command('object_rotate_origin', {})
def swipe(self, gesture): swipe_time = time.time() if abs(swipe_time - self.last_swipe_time) < self.swipe_min_delay: return self.last_swipe_time = swipe_time swipe_gesture = SwipeGesture(gesture) # don't handle vertical swipes if abs(swipe_gesture.direction[0]) < abs(swipe_gesture.direction[1]): return if swipe_gesture.direction[0] > 0: #print 'Rotating left' send_command('do_rotation_left') else: #print 'Rotating right' send_command('do_rotation_right')
def run(self, hand): pos = hand.stabilized_palm_position self.loc_x_hand.add_value(pos.x) self.loc_y_hand.add_value(pos.y) self.loc_z_hand.add_value(pos.z) self.rot_x_hand.add_value(hand.direction.pitch) self.rot_y_hand.add_value(hand.direction.yaw) self.rot_z_hand.add_value(hand.direction.roll) # send motion dx = self.loc_x_hand.value - self.loc_x_origin dy = self.loc_y_hand.value - self.loc_y_origin dz = self.loc_z_hand.value - self.loc_z_origin send_command('object_move', {'loc_x': dx, 'loc_y': dy, 'loc_z': dz}) # send rotation rx = self.rot_x_hand.value - self.rot_x_origin ry = self.rot_y_hand.value - self.rot_y_origin rz = self.rot_z_hand.value - self.rot_z_origin send_command('object_rotate', {'rot_x': rx, 'rot_y': ry, 'rot_z': rz})
def run(self, hand): pos = hand.stabilized_palm_position self.loc_x_hand.add_value(pos.x) self.loc_y_hand.add_value(pos.y) self.loc_z_hand.add_value(pos.z) self.rot_x_hand.add_value(hand.direction.pitch) self.rot_y_hand.add_value(hand.direction.yaw) self.rot_z_hand.add_value(hand.direction.roll) # send motion dx = self.loc_x_hand.value - self.loc_x_origin dy = self.loc_y_hand.value - self.loc_y_origin dz = self.loc_z_hand.value - self.loc_z_origin send_command('object_move', { 'loc_x': dx, 'loc_y': dy, 'loc_z': dz}) # send rotation rx = self.rot_x_hand.value - self.rot_x_origin ry = self.rot_y_hand.value - self.rot_y_origin rz = self.rot_z_hand.value - self.rot_z_origin send_command('object_rotate', { 'rot_x': rx, 'rot_y': ry, 'rot_z': rz})
def view_from(direction): logging.debug('viewing from %s' % direction) send_command('view_%s' % direction)
def run(self, first_hand, second_hand): dis = first_hand.stabilized_palm_position - second_hand.stabilized_palm_position self.magnitude.add_value(dis.magnitude) mag = self.magnitude.value / self.magnitude_origin send_command('object_scale', {'sx': mag, 'sy': mag, 'sz': mag})
def start(self, first_hand, second_hand): self.is_activated = True send_command('object_scale_origin') dis = first_hand.stabilized_palm_position - second_hand.stabilized_palm_position self.magnitude_origin = dis.magnitude
def on_exit(self, controller): send_command('stop_rotation')
def run(self, first_hand, second_hand): dis = first_hand.stabilized_palm_position - second_hand.stabilized_palm_position self.magnitude.add_value(dis.magnitude) mag = self.magnitude.value / self.magnitude_origin send_command('object_scale', { 'sx': mag, 'sy': mag, 'sz': mag })
def stop(self): self.history = [] send_command('stop_rotation')
def point_finger(self, tip, direction): # TODO send as long command ? tip = rescale_position(tip) send_command('finger_touch', { 'x': tip.z, 'y': tip.x, 'z': tip.y, 'vx': direction.z, 'vy': direction.x, 'vz': direction.y })