Example #1
0
    def start_mouse_grab(self):
        soya.cursor_set_visible(0)
        soya.set_grab_input(1)
        soya.set_mouse_pos(camera.width / 2, camera.height / 2)
        soya.clear_events()
        Rx, ry = soya.get_mouse_rel_pos()

        self.grab_cursor = 1
Example #2
0
 def deactivate(self, event=None):
     if self.active:
         self.active = 0
         soya.cursor_set_visible(1)
         self.dialog.after_cancel(self.cancel)
Example #3
0
 def activate(self, event=None):
     if not self.active:
         self.active = 1
         soya.set_root_widget(self.camera)
         soya.cursor_set_visible(0)
         self.auto_render()
Example #4
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))
Example #5
0
 def stop_mouse_grab(self):
     self.grab_cursor = 0
     soya.cursor_set_visible(1)
     soya.set_grab_input(0)
Example #6
0
if __name__ == '__main__':
    args = argparser()
    args['resolution'] = map(int, args['resolution'].split('x'))
    FPS = args['fps']
    soya.init(title='SwarmViewer',
              fullscreen=args['full_screen'],
              width=args['resolution'][0],
              height=args['resolution'][1])
    soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))

    # Creates the scene.

    scene = soya.World()

    light = soya.Light(scene)
    light.set_xyz(10.0, 10.2, 11.0)

    soya.cursor_set_visible(0)

    #scene.atmosphere = soya.Atmosphere()
    #scene.atmosphere.ambient = (0.0, 1.0, 1.0, 1.0)

    camera = MovableCamera(scene, light)
    camera.set_xyz(-10.0, 4.0, 10.0)
    camera.fov = 140.0
    soya.set_root_widget(camera)
    cubes = {}
    reader = Reader(args['input'])
    reader.start()
    MainLoop(scene).main_loop()
Example #7
0
# Adds a light.

light = soya.Light(scene)
light.set_xyz(0.0, 0.2, 1.0)

# Creates a camera.

camera = soya.Camera(scene)
camera.set_xyz(0.0, 0.0, 3.0)

soya.set_root_widget(camera)

# Hide the mouse cursor

soya.cursor_set_visible(0)


# MouseLaser is a subclass of laser that is controlled by the mouse.


class MouseLaser(soya.laser.Laser):
    def begin_round(self):
        soya.laser.Laser.begin_round(self)

        # Processes the events

        for event in soya.MAIN_LOOP.events:
            if event[0] == soya.sdlconst.MOUSEMOTION:

                # For mouse motion event, rotate the laser (quite) toward the mouse.
print 'escape: quit'

import sys, os
from random import choice, gauss as normalvariate, randint, random, expovariate
from math import sqrt, pi
import soya
import soya.widget
import soya.sphere
import soya.laser
from soya import Vector, Point

if '-f' in sys.argv:
	soya.init("ode-collision-7-hit_func-3-contacts",width=1280,height=854,fullscreen=True)
else:
	soya.init("ode-collision-7-hit_func-3-contacts",width=1024,height=768)
soya.cursor_set_visible(False)
soya.set_mouse_pos(1280/2,854/2)

soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
scene = soya.World()

class Nova(soya.Smoke):
	def __init__(self,parent,nb_particles=12):
		soya.Smoke.__init__(self,parent,nb_particles=nb_particles)
		#self.set_colors((1.0, 1.0, 1.0, 1.0), (1.0, 0.0, 0.0,0.5),(1.0,1.0,0.,0.5),(0.5,0.5,0.5,0.5),(0.,0.,0.,0.5))
		#self.set_sizes ((0.19, 0.19), (0.35, 0.35))
		#self.auto_generate_particle=1
	def added_into(self,parent):
		#print 'former:',self.parent
		if self.parent is not None:
			self.parent.parent.remove(self.parent)