Ejemplo n.º 1
0
 def run(self):
     mainScene = Scene.MainScene(self.game)
     maidScene = Scene.MaidScene(self.game)
     mainScene.enterMaid()
     while True:
         maidScene.enterExercise()
         maidScene.leaveExercise()
Ejemplo n.º 2
0
    def __init__(self, w, h, title):
        self.cam = Camera(90.0, 800/600,1, 100000.0)
        self.eye = [0.0, -2000.0, 3800.0]
        self.target = [0.0, 0.0, 2500.0]
        self.up = [0.0, 0.0, 1.0]
        self.cam.setPos(self.eye, self.target)
        self.timer = Timer()
        self.gridMode = False
        self.gridAngle = 0
        self.gridAxis = [1,0,0]

        self.graphics = Graphics()
        self.lighting = Lighting()
        self.scene = Scene()
        self.background = Background()
        self.obj_basic = OBJ('island_basic_1.obj', swapyz=True)
        self.obj_snow = OBJ('island_basic_snow.obj', swapyz=True)
        self.obj_rain = OBJ('island_basic_rain.obj', swapyz=True)
        self.obj = self.obj_basic
        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
        glutInitWindowSize(w, h)
        glutInitWindowPosition(800, 600)


        glEnable(GL_DEPTH_TEST)
        glShadeModel(GL_SMOOTH)
        self.lighting.LightSet()
Ejemplo n.º 3
0
    def __init__(self, w, h, title):
        self.KeyInputState = {
            "reset": False,
            "space": False,
            "b": False,
            "v": False,
            "g": False,
            "h": False,
            "n": False
        }
        self.cam = Camera(60., 1.0, 0.1, 1000.0)
        #self.cam.setPos([0,10,1], [0,0,0])
        #self.cam.setPos([10,10,10], [0,0,0])
        #self.cam.setPos([10,5,10], [0,0,0])
        #self.cam.setPos([10,2,10], [0,0,0])
        self.cam.setPos([20, 10, 10], [0, 0, 0])
        self.timer = Timer()
        self.gridMode = False
        self.gridAngle = 0
        self.gridAxis = [1, 0, 0]
        self.graphics = Graphics()
        self.lighting = Lighting()
        self.scene = Scene()
        self.background = Background()

        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
        glutInitWindowSize(w, h)
        glutInitWindowPosition(100, 100)
        glutCreateWindow(title)
        glClearColor(0.25, 0.25, 0.25, 1.0)
        glEnable(GL_DEPTH_TEST)
        self.lighting.LightSet()
Ejemplo n.º 4
0
class SceneBuilder():
    def __init__(self, display):
        self.display = display
        self.scene = Scene(display)
        self.id_counter = 0

    def add_light(self):
        light = Light(self.display, color=(0, 0, 0))
        obj = Object_Instance(light=light, id=self.id_counter)
        self.scene.add_instance(obj)
        self.id_counter += 1

    def add_movement(self, light_id, type=None):
        obj_inst = self.get_light_with_id(light_id)
        s = MovementSchedule()

        if obj_inst.movement_schedule is None:
            obj_inst.movement_schedule = s
        else:
            obj_inst.movement_schedule.add_schedule(s)

    def get_light_with_id(self, id):
        for obj in self.scene:
            if obj.id == id:
                return obj
Ejemplo n.º 5
0
 def run(self):
     mainScene = Scene.MainScene(self.game)
     maidScene = Scene.MaidScene(self.game)
     battleScene = Scene.BattleScene(self.game)
     if not mainScene.enterMaid():
         return
     while True:
         maidScene.enterExercise()
         battleScene.leaveBattle(False)
Ejemplo n.º 6
0
 def run(self):
     mainScene = Scene.MainScene(self.game)
     precombatScene = Scene.PrecombatScene(self.game)
     exerciseScene = Scene.ExerciseScene(self.game)
     mainScene.enterPrecombat()
     precombatScene.enterExercise()
     for i in range(5):
         exerciseScene.enterExercise()
         exerciseScene.leaveExercise()
     exerciseScene.back()
     precombatScene.back()
Ejemplo n.º 7
0
 def run(self):
     mainScene = Scene.MainScene(self.game)
     precombatScene = Scene.PrecombatScene(self.game)
     c01s01Scene = Scene.C01S01Scene(self.game)
     battleScene = Scene.BattleScene(self.game)
     mainScene.enterPrecombat()
     precombatScene.enterSubcapter(1, 1)
     while True:
         c01s01Scene.enterAmbush()
         battleScene.leaveBattle()
         c01s01Scene.leaveAmbush()
Ejemplo n.º 8
0
 def run(self):
     mainScene = Scene.MainScene(self.game)
     precombatScene = Scene.PrecombatScene(self.game)
     c03s04Scene = Scene.C03S04Scene(self.game)
     battleScene = Scene.BattleScene(self.game)
     mainScene.enterPrecombat()
     while True:
         precombatScene.enterSubcapter(3, 4)
         while c03s04Scene.bossExist:
             c03s04Scene.weighAnchor()
             battleScene.enterBattle()
             battleScene.leaveBattle()
Ejemplo n.º 9
0
 def run(self):
     mainScene = Scene.MainScene(self.game)
     precombatScene = Scene.PrecombatScene(self.game)
     exerciseScene = Scene.ExerciseScene(self.game)
     battleScene = Scene.BattleScene(self.game)
     mainScene.enterPrecombat()
     precombatScene.enterExercise()
     while True:
         if not exerciseScene.enterExercise():
             break
         battleScene.leaveBattle(False)
     exerciseScene.back()
     precombatScene.back()
Ejemplo n.º 10
0
 def run(self):
     mainScene = Scene.MainScene(self.game)
     precombatScene = Scene.PrecombatScene(self.game)
     c01s01Scene = Scene.C01S01Scene(self.game)
     battleScene = Scene.BattleScene(self.game)
     mainScene.enterPrecombat()
     if not precombatScene.enterSubcapter(1, 1):
         precombatScene.back()
         return
     while True:
         c01s01Scene.enterAmbush()
         battleScene.enterBattle()
         battleScene.leaveBattle(False)
         c01s01Scene.leaveAmbush()
Ejemplo n.º 11
0
def Dialogue(screen, sceneN, line):
    scene = Scene.Scene(sceneN, line)

    inGame = True
    scene.draw(screen)
    while inGame:
        for event in pygame.event.get():
            if event.type == QUIT:
                return ["Quit", ""]
            if event.type == KEYDOWN:
                if event.key in [K_RETURN, K_SPACE]:
                    finish = scene.nextLine()
                    if finish:
                        next = scene.getEnd()
                        toReturn = []
                        if "Choice" in next:
                            toReturn = ["Choice", next, 0]
                        elif "Scene" in next:
                            toReturn = ["Dialogue", next, 1]
                        elif "End" in next:
                            toReturn = ["End", next, 0]
                        elif "battle" in next or "Battle" in next:
                            toReturn = ["Battle", next, 0]
                        elif "title" in next or "Title" in next:
                            toReturn = ["Title"]
                        return toReturn
                    scene.draw(screen)
                if event.key == K_s:
                    return [
                        "Save", "Dialogue", sceneN,
                        scene.getCurrentLine(),
                        screen.copy()
                    ]
        pygame.time.wait(50)
Ejemplo n.º 12
0
    def __init__(self, filepath):
        # Load GLTF file
        self.gltf = GLTF2().load(filepath)
        self.path = filepath
        self.buffer = None
        self.bufferviews = None

        self.scene = Scene()

        # Load Buffer
        with open(path.dirname(self.path) + '/' + self.gltf.buffers[0].uri,
                  mode='rb') as file:
            buffer = file.read()
        print(self.path + ' loaded.')
        self.buffer = buffer

        # Get buffferviews
        self.bufferviews = []
        for item in self.gltf.bufferViews:
            if item.byteOffset:
                self.bufferviews.append(
                    buffer[item.byteOffset:item.byteOffset + item.byteLength])
            else:
                self.bufferviews.append(buffer[:item.byteLength])

        # Fill Scene object.
        self.scene.texture_list = self.create_texture_list()
        self.scene.material_list = self.create_material_list()
        self.scene.mesh_list = self.create_mesh_list()
        self.scene.nodelist = self.create_node_list()
Ejemplo n.º 13
0
def show_scene(scene_id):
    if app.director.hue_bridge is None:
        flash("Hue bridge settings must be saved first", category="error")
        return redirect(url_for('show_settings'), code=302)
    if request.method == "POST":
        scene = parse_scene(request.values)
        if scene_id != scene.name and scene_id != 'new':
            app.director.rename_scene(scene_id, scene.name)
            flash("Scene renamed from " + scene_id + " to " + scene.name +
                  " and updated")
        elif scene_id == "new":
            flash("Scene " + scene.name + " added")
        else:
            flash("Scene " + scene.name + " updated")
        app.director.update_scene(scene)
        app.director.save_config()
        return redirect(url_for('show_scenes'), code=303)
    else:
        if scene_id == 'new':
            scene = Scene.Scene()
        else:
            scene = app.director.scenes[scene_id]
        return render_template('scene.html',
                               lights=app.director.get_lights_by_id(),
                               groups=app.director.get_groups(),
                               scene=scene)
Ejemplo n.º 14
0
    def getSources(self, people, locations, duration):
        '''Accepts DataFrame of people, and returns a source
            with a random location in the corresponding to each person a.'''
        sources = []
        for index, person in enumerate(people["ID"]):
            fullPath = f"{self.directory}/{person}"
            chapters = os.listdir(fullPath)
            book = random.choice(chapters)
            sentences = [
                clip.replace("\\", "/")
                for clip in sorted(glob.glob(fullPath + f"/{book}/*.flac"))
            ]
            name = f"s{person}-b{book}-d"

            line = sentences.pop(0)
            currDur = sf.info(line).duration
            data, sampRate = sf.read(line)
            lastNum = "0000"
            for line in sentences:
                if currDur < duration:
                    currDur += sf.info(line).duration
                    data = np.append(data, sf.read(line)[0])
                    lastNum = line[-9:
                                   -5]  #isolate the line number from filename
                else:
                    break
            sources.append(
                Scene.Source(location=locations[index],
                             name=name + lastNum,
                             data=(data[:sampRate * duration], sampRate)))
            del data
        return sources
Ejemplo n.º 15
0
def init(data):
    data.level = Scene(Node(Mesh.triangularPyramid(Vec3(0, 0, 500))),
                       Camera(Vec3(0, 0, 0), 250, data.width, data.height))
    data.level.root.addChildren(Node(Mesh.cube(Vec3(200, 200, 500))))
    data.screen = Display(data.level)
    data.paused = True
    data.looking = False
    data.prevX = 0
    data.prevY = 0
Ejemplo n.º 16
0
 def run(self):
     # mainScene = Scene.MainScene(self.game)
     # precombatScene = Scene.PrecombatScene(self.game)
     c03s04Scene = Scene.C03S04Scene(self.game)
     # battleScene = Scene.BattleScene(self.game)
     # while True:
     #    precombatScene.enterSubcapter(3, 4)
     #    while c03s04Scene.bossExist:
     c03s04Scene.enterBattle()
Ejemplo n.º 17
0
Archivo: ain.py Proyecto: fengxxx/Rhino
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'fengxEngine', size=MAIN_WINDOW_SIZE,style=wx.DEFAULT_FRAME_STYLE)
        #---------------main Window settings----->>>>
        self.SetBackgroundColour((225,225,225))#MAIN_BG_COLOR)
        self.icon = wx.Icon(ICON_PATH, wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)
        self.CreateStatusBar()
        #self.SetStatusText("fengxEngine: tartPos: "+str(TARGET_POS)+"eyePos: "+str(EYE_POS) )

        self.scene=Scene.mainGlCanvas(self)
Ejemplo n.º 18
0
    def __init__(self, w, h, title):
        self.cam = Camera(60., w / h, 0.1, 1000.0)
        self.cam.setPos([10, 5, 10], [0, 0, 0], [0, 1, 0])
        self.timer = Timer()
        self.gridMode = False
        self.gridAngle = 0
        self.gridAxis = [1, 0, 0]

        self.graphics = Graphics()
        #self.lighting = Lighting()
        self.scene = Scene()
        self.background = Background()

        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
        glutInitWindowSize(w, h)
        glutInitWindowPosition(0, 0)
        glutCreateWindow(title)
        glClearColor(0.25, 0.25, 0.25, 1.0)
        glEnable(GL_DEPTH_TEST)
Ejemplo n.º 19
0
    def collectScenes(self):
        self.groupdir = datadir + self.featuresFolder +  '/'
        print self.groupdir
        self.scenes=[]

        for subdir, dirs, files in os.walk(self.groupdir):
            for dir in dirs: 
                type, id = self.extractSceneFolder(dir)
               
                if (type==self.type):
                    s = Scene(type,id,featuresFolder=self.featuresFolder,maxInstances=self.maxInstances,loadNPZ=self.loadNPZ)
                    self.scenes.append(s)

        self.scenes = np.array(self.scenes)
Ejemplo n.º 20
0
def set_level(lvl, plr):
    global board, all
    dmg = int(lvl)
    all = pygame.sprite.Group()
    board = Scene.Board(offset, "Levels/tileset_named", load_image("board.png", (255, 255, 255, 255)), "Levels/" + lvl,
                        "Levels/obj_" + lvl, ["1", "2"], "5", "3", "6", 64)
    for coord in board.enemyes:
        x, y = coord
        vraszina = Persona.Enemy(player, 200, offset, load_image("enemy.png", (0, 0, 0, 255)), x, y, 64, 64, 3, 4, 6,
                                 ["move", "attack", "stay"], board, damage=dmg)
        all.add(vraszina)
    for coord in board.obj:
        x, y, t = coord
        if t:
            Scene.Exit(offset, all, load_image("ext.png"), player, x, y)
        else:
            Scene.Chest(offset, all, load_image("cht.png", (255, 255, 255, 255)), player, x, y, 2)
    x, y = plr
    player.set_coords(x, y)
    player.win = 0
    player.inventory = 0
    all.add(player)
    player.board = board
    player.hp = player.mx_hp
Ejemplo n.º 21
0
class Map():
    scenes = {
        'Scene': Scene(),
        'Intro Setup': Intro_Setup(),
        #'Choose Character': Choose_Character(),
        'Intro World Opening': Intro_World_Opening(),
        'Talihu': Talihu()
    }

    def __init__(self, start_scene):
        self.start_scene = start_scene

    def next_scene(self, scene_name):
        return Map.scenes.get(scene_name)

    def opening_scene(self):
        return self.next_scene(self.start_scene)
Ejemplo n.º 22
0
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title)
        self.scene = Scene(self)

######## MENU ################
        self.menu = SeqMenu(self)
        self.SetMenuBar(self.menu)

######## TOOL BAR ############ 
        #self.tb = Tb(self.scene)

######## create status bar ###

        status = self.CreateStatusBar()

######## METHODES ############  
        self.Maximize()
        self.Show()
Ejemplo n.º 23
0
    def __init__(self):
        # Screen size
        screen_width = 1024
        screen_height = 768

        # Screen size
        self.screen = pygame.display.set_mode([screen_width, screen_height])

        pygame.mixer.init()

        # Start pygame
        pygame.init()

        pygame.display.set_caption('Obvious!')

        self.scene = Scene.Scene()
        self.ended = False
        self.clock = pygame.time.Clock()
Ejemplo n.º 24
0
def parse_scene(values):
    re_light = re.compile(r'light\[(\d+)\]\[(\w+)\]')
    re_color = re.compile(r'color\[(\d+)\]')
    scene = Scene.Scene()
    if values["name"] != '':
        scene.name = values["name"]

    if values["description"] != '':
        scene.description = values["description"]

    if values["transition-time"] != '':
        scene.transitiontime = values["transition-time"]

    if values["type"] != '':
        scene.type = values["type"]

    if values["interval"] != '':
        scene.interval = int(values["interval"])
    lights = {}
    colors = {}
    for value in values:
        m = re_light.match(value)
        if m is not None and m.lastindex == 2:
            index = int(m.group(1))
            if index not in lights:
                lights[index] = {}
            lights[index][m.group(2)] = values[value]
        else:
            m = re_color.match(value)
            if m is not None and m.lastindex == 1:
                colors[int(m.group(1))] = values[value]

    for key in sorted(lights):
        light = lights[key]
        (light_type, light_id) = light['light'].split('-')
        light['type'] = light_type
        light['id'] = int(light_id)
        del light['light']
        scene.add_member_rgb(light)

    for key in sorted(colors):
        scene.add_color_rgb(colors[key])

    return scene
Ejemplo n.º 25
0
	def main(self):
		# Create window at center
		os.environ['SDL_VIDEO_CENTERED'] = '1'

		# Initialize Pygame and set up the window
		pygame.init()

		size = [SCREEN_WIDTH, SCREEN_HEIGHT]
		screen = pygame.display.set_mode(size)

		pygame.mouse.set_visible(True)
	
		# Read resource
		ResourceManager.instance().read_resources(RM_path)
	
		# Create an instance of the Game class
		#game = GameManager()
		#game.change_state(Scene())
		GameManager.instance().change_state(Scene(ResourceManager.instance().scene_path_list['MAIN_SCENE']))
		
		clock = pygame.time.Clock()
	
		# Main game loop
		while not self.done:
			pygame.display.set_caption((' ' * 130) + 'UnBlock Me - FPS : ' + str(round(clock.get_fps(), 1)))

			# Check if exit game
			self.done = GameManager.instance().get_running_state()

			# Process events (keystrokes, mouse clicks, etc)
			GameManager.instance().process_events()
		
			# Update object positions, check for collisions
			GameManager.instance().update()
		
			# Draw the current frame
			GameManager.instance().draw(screen)
		
			# Pause for the next frame
			clock.tick(60)

		# Close window and exit
		pygame.quit()
		quit()
Ejemplo n.º 26
0
    def __init__( self, xmlfilePath, xmlfileName ):
        # retrieve working directory info
        self.workingDirPath = xmlfilePath
        self.sceneDecriptor = xmlfileName
        
        # check xml 
        self.parseWithValidation_xml( 'SceneDescription.dtd' )

        # initialize objects from roadscene
        self.scene = modulScene.Scene( self.root )
        self.targetParameters = modulTargetParameters.TargetParameters( self.root )
        self.lidcs = modulLIDCs.LIDCs( self.root )
        self.headlights = modulHeadlights.Headlights( self.root )
        self.poles = modulPoles.Poles( self.root )
        
        # start methods/functions
        self.checkSenseOfParameters( )
        self.calcMeasurementField( )
        self.calcOpeningAngle( )
Ejemplo n.º 27
0
    def __init__(self, parent = None, scene = None):
        qt.QWidget.__init__(self, parent)
        self.setWindowTitle('Scene Control Widget')
        if scene is None:
            self.scene = Scene.Scene(name='Scene')
        else:
            self.scene = scene

        self.mainLayout = qt.QHBoxLayout(self)
        self.mainLayout.setMargin(0)
        self.mainLayout.setSpacing(0)
        self.sceneWidget = SceneWidget.SceneWidget(self, scene=self.scene)
        self.selectedObjectControl = Object3DConfig.Object3DConfig(self)
        self.mainTab = self.selectedObjectControl.mainTab
        self.tabScene = qt.QWidget(self.mainTab)
        self.tabScene.mainLayout = qt.QGridLayout(self.tabScene) 
        self.tabScene.mainLayout.setMargin(0)
        self.tabScene.mainLayout.setSpacing(0)
        self.coordinatesWidget = SceneCoordinates.SceneCoordinates(self.tabScene)
        self.coordinatesWidget.observerWidget.hide()
        #self.movementsWidget  = Object3DMovement.Object3DMovement(self.tabScene)
        #self.movementsWidget.anchorWidget.hide()
        self.tabScene.mainLayout.addWidget(self.coordinatesWidget, 0, 0)
        #self.tabScene.mainLayout.addWidget(self.movementsWidget, 1, 0)
        vspacer = VerticalSpacer(self.tabScene) 
        self.tabScene.mainLayout.addWidget(vspacer, 2, 0)
        self.mainTab.addTab(self.tabScene, "SCENE")
        self.mainLayout.addWidget(self.sceneWidget)
        self.mainLayout.addWidget(self.selectedObjectControl)
        configDict = self.scene[self.scene.name()].root[0].getConfiguration()
        self.selectedObjectControl.setConfiguration(configDict)

        self.connect(self.sceneWidget,
                     qt.SIGNAL('SceneWidgetSignal'),
                     self._sceneWidgetSignal)

        self.connect(self.coordinatesWidget,
                     qt.SIGNAL('SceneCoordinatesSignal'),
                     self._sceneCoordinatesSlot)
        return
        self.connect(self.movementsWidget,
                     qt.SIGNAL('Object3DMovementSignal'),
                     self._movementsSlot)
Ejemplo n.º 28
0
def createReceivers(steering, origin, numRecs=8, spacing=0.0186):
    '''Creates a linear microphone array normal in the xy-plane
        to the given steering vector. Returns a list of receivers
        centered around the origin. Default parameters are based
        on the microphone array used in:

        M. H. Anderson et al., “Towards mobile gaze-directed
        beamforming: a novel neuro-technology for hearing loss,”
        in 2018 40th Annual International Conference of the IEEE
        Engineering in Medicine and Biology Society (EMBC), Jul.
        2018, pp. 5806–5809, doi: 10.1109/EMBC.2018.8513566.
    '''
    direction = Geo.Vec(steering["y"], -steering["x"], 0).unit()
    arrayLength = direction * (numRecs * spacing * 0.5)
    receivers = [
        Scene.Receiver(origin + direction * index - arrayLength,
                       name=f"channel {index}") for index in range(numRecs)
    ]
    return receivers
Ejemplo n.º 29
0
def main():
    # Create window at center
    os.environ['SDL_VIDEO_CENTERED'] = '1'

    # Initialize Pygame and set up the window
    pygame.init()

    size = [SCREEN_WIDTH, SCREEN_HEIGHT]
    screen = pygame.display.set_mode(size)

    pygame.mouse.set_visible(False)

    # Read resource
    ResourceManager.read_resources(RM_path)

    # Create an instance of the Game class
    game = GameManager()
    game.change_state(Scene())

    done = False
    clock = pygame.time.Clock()

    # Main game loop
    while not done:
        pygame.display.set_caption("Troll Shooting - FPS : " +
                                   str(round(clock.get_fps(), 1)))

        # Process events (keystrokes, mouse clicks, etc)
        done = game.process_events()

        # Update object positions, check for collisions
        game.update()

        # Draw the current frame
        game.draw(screen)

        # Pause for the next frame
        clock.tick(60)

    # Close window and exit
    pygame.quit()
Ejemplo n.º 30
0
    def load_config(self):
        try:
            config_fp = open(os.path.join(self._config_path, 'HueISY.json'))
            config = json.load(config_fp)
            config_fp.close()
        except IOError:
            config = {}

        secret_key = config.get("SecretKey")

        if secret_key is not None:
            self._secret_key = base64.b64decode(secret_key)
        else:
            self._secret_key = None

        self._Hue_IP = config.get("HueIP", "")
        if self._Hue_IP == "":
            self._Hue_IP = phue.Bridge.get_ip_address()
        self._Hue_Username = config.get("HueUsername", "")

        self._Isy_IP = config.get("IsyIP", "")
        if self._Isy_IP == "":
            from ISY.IsyDiscover import isy_discover
            result = isy_discover(timeout=30, count=1)
            if len(result) == 1:
                import urlparse
                self._Isy_IP = urlparse.urlparse(
                    result.values()[0]['URLBase']).netloc

        self._Isy_User = config.get("IsyUser", "")
        self._Isy_Pass = config.get("IsyPass", "")

        for action_cfg in config.get("actions", {}):
            action = Action.Action(settings=action_cfg)
            self._actions[action.name] = action
            for trigger_id in action.triggers:
                self._trigger_actions[trigger_id] = action

        for scene_cfg in config.get("scenes", {}):
            scene = Scene.Scene(settings=scene_cfg)
            self._scenes[scene.name] = scene
Ejemplo n.º 31
0
    def buildScene(self, file):
        '''Makes a new scene from the given file.'''
        switch = {
            'vv': self.parseVertex,
            'am': self.parseAmbiMat,
            'dm': self.parseDiffMat,
            'sm': self.parseSpecMat,
            'ts': self.parseTriangle,
            'ss': self.parseSphere,
            'ps': self.parsePlane,
            'se': self.parseSettings,
            'pl': self.parsePointLight,
            'dl': self.parseDirecLight,
            'cc': self.parseCamera
        }

        def f(x):
            input = x.split()
            if input and not input[0].startswith('#'):
                try:
                    switch[input[0][:2]](*input[1:])
                except KeyError:
                    print 'No build-case for "' + input[0] + '"'

        map(f, file)

        def g(x):
            return x[0](*x[1])

        scene = Scene(
            self.camera[0](**self.camera[1]),
            map(g, self.lights),
            map(g, self.shapes),
            self.settings['d'],
            self.settings['s'],
            self.settings['a'],
            self.settings['m'],
            self.settings['i'],
        )
        return scene
Ejemplo n.º 32
0
def test_scene():
  GAME_STATE.player = characters.Player(name='Testy', gender='f')
  Scene.run_scene(TEST_SCENE_PROMPT, 'troid')
  Scene.run_scene(TEST_SCENE_NO_PROMPT, 'gelliot', 'ille', wombat='I am a wombat')
Ejemplo n.º 33
0
Archivo: CLA.py Proyecto: niamiot/RGPA
	def show3(self,l=-1,amb=False,sc='all'):
		""" Display constraints and theirs boxes through geomview. 


		geomview parameters are the following

		self.parmsh['display']=False   		# launch geomview interactively 
		self.parmsh['scene']=True      		# display whole scene
		self.parmsh['boxes']=True      		# display constraint box
		self.parmsh['constr_boxes']=False       # display constraint box
		self.parmsh['estimated']=True  		# display estimated point
		
		...


		.. todo:

			create a .ini file for geomview parameters

		:Parameters:

			l	: layer number to observe. If -1 estimation is made on the highest available layer. default = -1
			amb	: display ambiguous boxes. default = false
			sc 	: display all constraint or give a list with the constrinat number to observe ex: [0,1,3]. default 'all'

		:Returns:
			Nothing but calls a geomview instance 
		
		
		"""
		Nc = self.Nc
		filename = "./geom/cla.list"
		fd =open(filename,"w")
		fd.write("LIST\n")
		par=self.parmsh

		if par['constr_boxes']:

			if l==-1:
				if sc == 'all':
					for c in self.c:
						c.parmsh['display']=False
						c.parmsh['scene']=False
						fname = c.show3()
						fd.write("{<"+fname+".list}\n")
				else :
					try: 
						for vsc in sc:
							self.c[vsc].parmsh['display']=False
							self.c[vsc].parmsh['scene']=False
							fname = self.c[vsc].show3()
							fd.write("{<"+fname+".list}\n")
					except :
						self.c[sc].parmsh['display']=False
						self.c[sc].parmsh['scene']=False
						fname = self.c[sc].show3()
						fd.write("{<"+fname+".list}\n")

			else:
				self.c[l].parmsh['dispay']=False
				self.c[l].parmsh['scene']=False
				fname = self.c[l].show3()
				fd.write("{<"+fname+".list}\n")
		
		col = ['r','b','g','m','y','b','r']	

		

		if par['scene']:
			an= np.zeros(len(self.bn))
			for c in self.c:
				an=np.vstack((an,c.p))




			S=Scene(an=an,bn=self.bn)
			sce=S.generate()


		if par['estimated']:
			try :
				sce = g.cloud(self.pe,display=False,name='scene',color='k',dice=6,access='append')
			except : 
				pass

			fd.write("{<"+sce+"}\n")

		if par['boxes']:

			for l in self.dlayer.keys():
				self.dlayer[l][0].parmsh['display']=False
				self.dlayer[l][1].parmsh['display']=False

				try :
					fname = self.dlayer[l][0].show3(col=col[Nc-l+1],Id=l)
					fd.write("{<"+fname+"}\n")
				except :
					pass

				if amb :
					coco=['r','v','b','y']
					fname = self.dlayer[l][1].show3(col=col[Nc-l],Id=l+1)
#					fname = self.dlayer[l][1].show3(col=coco,Id=l+1)
					fd.write("{<"+fname+"}\n")

		
		fd.close()	
		chaine = "geomview  -nopanel  -b 1 1 1 " + filename + " 2>/dev/null &"

		os.system(chaine)
Ejemplo n.º 34
0
                elif scene.player.onLeft:
                    scene.player.vx += -3
                    scene.player.vx += 3

            if keys[K_LEFT]:
                if scene.player.onTop:
                    scene.player.vx += -2
                else:
                    scene.player.vx += -0.1
            if keys[K_RIGHT]:
                if scene.player.onTop:
                    scene.player.vx += 2
                else:
                    scene.player.vx += 0.1

scene = Scene(window_class, window, fpsClock)  # Load Scene
while not gameShouldClose: # game loop
    getevents()
    scene.update()

    # Graphics
    window.fill((0, 0, 0))
    scene.draw()

    fpsClock.tick(FPS)
    pygame.display.flip()


pygame.quit()
sys.exit(0)
Ejemplo n.º 35
0
from rtools import rsplit as rp

__author__ = 'astrowar'
from shlex import split as sp
import re
from  Scene import *

s = Scene()



#macro comandos
s << rp("Kind book Thing")
s << rp("Instance diary  book")

s << rp("Kind Animal Thing" )
s << rp("Kind Ox Animal" )
s << rp("Instance jairo Ox" )

s << rp("Set diary rare" )
s << rp("Set diary hidden" )
s << rp("Set [location book] library" )
s << rp("Set [title diary] untitled" )
s << rp("Set book portable" )

s << rp("Kind Color KindValue ")

s << rp("Instance red Color")
s << rp("Instance blue Color")
s << rp("Instance green Color")