Example #1
0
    def advance_time(self, proportion):

        mouse_pos_x = soya.get_mouse_rel_pos()[0]

        if self.left >= self.left_limit and self.left <= self.right_limit and soya.get_grab_input() == 1:

            # move slider puck to relative mouse pos:
            self.left += mouse_pos_x
            self.label.left = self.left + self.width / 4

            # find relative position of puck inside limits:
            relative_pos = self.range - (self.right_limit - self.left)

            # generate value from 0 - 1, round to three decimal places:
            self.val = round(relative_pos / (self.range), 3)

        elif self.val <= self.val_min:
            soya.set_grab_input(0)
            self.left = self.left_limit + 1
            # safe lower limit:
            self.val = 0.01

        elif self.val >= self.val_max:
            soya.set_grab_input(0)
            self.left = self.right_limit - 1
            self.val = .99

        elif soya.get_grab_input() == 0:
            self.left += 0 

        else:
            self.left += 0

        # update label value as a percentage each cycle:
        self.label.label = str(self.val * 100)[:-2]
Example #2
0
    def advance_time(self, proportion):

        mouse_pos_x = soya.get_mouse_rel_pos()[0]

        if self.left >= self.left_limit and self.left <= self.right_limit and soya.get_grab_input(
        ) == 1:

            # move slider puck to relative mouse pos:
            self.left += mouse_pos_x
            self.label.left = self.left + self.width / 4

            # find relative position of puck inside limits:
            relative_pos = self.range - (self.right_limit - self.left)

            # generate value from 0 - 1, round to three decimal places:
            self.val = round(relative_pos / (self.range), 3)

        elif self.val <= self.val_min:
            soya.set_grab_input(0)
            self.left = self.left_limit + 1
            # safe lower limit:
            self.val = 0.01

        elif self.val >= self.val_max:
            soya.set_grab_input(0)
            self.left = self.right_limit - 1
            self.val = .99

        elif soya.get_grab_input() == 0:
            self.left += 0

        else:
            self.left += 0

        # update label value as a percentage each cycle:
        self.label.label = str(self.val * 100)[:-2]
Example #3
0
    def on_key_down(self, event):
        if event[1] == sdlconst.K_ESCAPE:
            # i have always used sys.exit but i noticed that this is probably nicer
            self.stop()

        elif event[1] == sdlconst.K_w:
            self.speed.z += -0.8
        elif event[1] == sdlconst.K_s:
            self.speed.z += 0.8

        elif event[1] == sdlconst.K_a:
            self.speed.x += -0.8
        elif event[1] == sdlconst.K_d:
            self.speed.x += 0.8

        elif event[1] == sdlconst.K_LCTRL:
            self.zoom = 1

        elif event[1] == sdlconst.K_SPACE:
            self.speed.x = 0.0
            self.speed.y = 0.0
            self.speed.z = 0.0

            # soya.Idler(scene).idle()

        elif event[1] == sdlconst.K_F1:
            if soya.get_grab_input() == 0:
                soya.cursor_set_visible(0)
                soya.set_grab_input(1)
            else:
                soya.cursor_set_visible(1)
                soya.set_grab_input(0)
        elif event[1] == sdlconst.K_F2:
            print "save"
            level.save(options.output)

        elif event[1] == sdlconst.K_g and self.selectedObject:
            if self.drag == 0:
                self.drag = 1
                self.axis = self.NOAXIS
            else:
                self.drag = 0

        elif event[1] == sdlconst.K_r and self.selectedObject:
            if self.rotating == 0:
                self.rotating = 1
            else:
                self.rotating = 0

        elif event[1] == sdlconst.K_x:
            self.axis = self.XAXIS
        elif event[1] == sdlconst.K_y:
            self.axis = self.YAXIS
        elif event[1] == sdlconst.K_z:
            self.axis = self.ZAXIS
        elif event[1] == sdlconst.K_n:
            self.axis = self.NOAXIS

        elif event[1] == sdlconst.K_t:
            # see if we can pick something and then "teleport" to it
            context = scene.RaypickContext(camera.position(), 50.0)
            r = context.raypick(camera.position(), soya.Vector(camera, 0.0, 0.0, -1.0), 50.0, 3)

            if r:
                camera.move(r[0] - soya.Vector(camera, 0.0, 0.0, -3.0))