def __init__(self, end_scale=.5, scale_velocity=.025, *args, **kwargs):
        """Grows and Shrinks between its scale and the end_scale (relative to its current scale) endpoints with speed scale_velocity."""

        super(Scaler, self).__init__(*args, **kwargs)
        self.scale_endpoints = tuple(sorted((self.scale, self.scale * end_scale)))
        self.scale_velocity = scale_velocity
        self.scale_direction = -1 if end_scale < self.scale else 1.
        self.timer = timers.countdown_timer(0)
Exemple #2
0
    def __init__(self, spin_velocity=180., axis=1, *args, **kwargs):
        """Spins in direction "axis" with speed "velocity" when Spinner.update_physics(dt) is called!"""
        super(Spinner, self).__init__(*args, **kwargs)

        self.velocity = 0.
        self.spin_velocity = spin_velocity
        self.axis = axis
        self.timer = timers.countdown_timer(0)
    def __init__(self, spin_velocity=180., axis=1, *args, **kwargs):
        """Spins in direction "axis" with speed "velocity" when Spinner.update_physics(dt) is called!"""
        super(Spinner, self).__init__(*args, **kwargs)

        self.velocity = 0.
        self.spin_velocity = spin_velocity
        self.axis = axis
        self.timer = timers.countdown_timer(0)
    def __init__(self, run_speed=.3, return_time=.3, *args, **kwargs):
        super(Runner, self).__init__(*args, **kwargs)
        self.run_speed = run_speed
        self.return_time = return_time
        self.timer = timers.countdown_timer(0)
        self.orig_x = self.x
        self.orig_z = self.z

        self.run_direction = 0., 0.
Exemple #5
0
    def __init__(self, end_scale=.5, scale_velocity=.025, *args, **kwargs):
        """Grows and Shrinks between its scale and the end_scale (relative to its current scale) endpoints with speed scale_velocity."""

        super(Scaler, self).__init__(*args, **kwargs)
        self.scale_endpoints = tuple(
            sorted((self.scale, self.scale * end_scale)))
        self.scale_velocity = scale_velocity
        self.scale_direction = -1 if end_scale < self.scale else 1.
        self.timer = timers.countdown_timer(0)
Exemple #6
0
 def start(self, *args, **kwargs):
     # FIXME: Calculation of run directoin is completely wrong because of the local/world coordinate distinction
     if self.timer.next() < 0.02:
         run_direction = np.subtract(
             self.position, kwargs['from_obj'].position
         )[::2]  # Calculate direction away from from_obj
         self.run_direction = run_direction / np.linalg.norm(
             run_direction)  # Normalilze vector
         self.timer = timers.countdown_timer(self.return_time)
Exemple #7
0
    def __init__(self, run_speed=.3, return_time=.3, *args, **kwargs):
        super(Runner, self).__init__(*args, **kwargs)
        self.run_speed = run_speed
        self.return_time = return_time
        self.timer = timers.countdown_timer(0)
        self.orig_x = self.x
        self.orig_z = self.z

        self.run_direction = 0., 0.
def random_scan(window, scene, n_points=300):

    circle = scene.root.children[0]
    screenPos, pointPos = [], []
    collect_fmt, missed_fmt, missed_cnt = ", Points Collected: ", ", Points Missed: ", 0
    pbar = pb.ProgressBar(widgets=[pb.Bar(), pb.ETA(), collect_fmt +'0', missed_fmt+'0'], maxval=n_points)
    pbar.start()
    while len(pointPos) < n_points and 'escape' not in event.getKeys():

        # Update position of circle, and draw.
        circle.visible = True
        homogenous_pos = np.random.random(2) - .5
        circle.x, circle.y = homogenous_pos * [1.8, 1]
        slow_draw(window, scene)
        motive.update()

        # Try to isolate a single point.
        for _ in timers.countdown_timer(.2, stop_iteration=True):
            motive.flush_camera_queues()
            motive.update()
            markers = motive.get_unident_markers()
            if markers and markers[0][1] > 0.:
                screenPos.append(circle.position[:2])
                # Update Progress Bar
                pointPos.append(markers[0])

                pbar.widgets[2] = collect_fmt + str(len(pointPos))
                pbar.update(len(pointPos))
                break
        else:
            # Update Progress bar
            missed_cnt += 1
            pbar.widgets[3] = missed_fmt + str(missed_cnt)
            pbar.update(len(pointPos))

        # Hide circle, and wait again for a new update.
        circle.visible = False
        slow_draw(window, scene)
        motive.update()
        motive.flush_camera_queues()
        while len(motive.get_unident_markers()) > 0:
            motive.update()
            motive.flush_camera_queues()

    return np.array(screenPos), np.array(pointPos)
def ray_scan(window):

    circle = window.active_scene.meshes[0]
    circle.visible = True

    # Do some non-random points to so human can change height range.
    pointPos, screenPos = [], []
    for pos in [(0, 0), (-.5, 0), (.5, 0)]:
        circle.x, circle.y = pos
        window.draw()
        window.flip()
        for _ in timers.countdown_timer(5, stop_iteration=True):
            motive.update()
            markers = motive.get_unident_markers()
            old_time = motive.frame_time_stamp()
            if motive.frame_time_stamp() > old_time + .3 and len(markers) == 1:
                if markers[0][1] > 0.1:
                    screenPos.append(circle.position[:2])
                    pointPos.append(markers[0])
                    old_time = motive.frame_time_stamp()

    return screenPos, pointPos
 def start(self, *args, **kwargs):
     self.timer = timers.countdown_timer(2.)
 def start(self, *args, **kwargs):
     if self.velocity:
         self.timer = timers.countdown_timer(2.)
     else:
         self.velocity = self.spin_velocity * random.choice([1., -1.])
 def start(self, *args, **kwargs):
     # FIXME: Calculation of run directoin is completely wrong because of the local/world coordinate distinction
     if self.timer.next() < 0.02:
         run_direction = np.subtract(self.position, kwargs['from_obj'].position)[::2]  # Calculate direction away from from_obj
         self.run_direction = run_direction / np.linalg.norm(run_direction)  # Normalilze vector
         self.timer = timers.countdown_timer(self.return_time)
Exemple #13
0
 def start(self, *args, **kwargs):
     self.timer = timers.countdown_timer(2.)
Exemple #14
0
 def start(self, *args, **kwargs):
     if self.velocity:
         self.timer = timers.countdown_timer(2.)
     else:
         self.velocity = self.spin_velocity * random.choice([1., -1.])