def __init__(self, window, sceneKey): # Save window and sceneKey in instance variables self.window = window self.sceneKey = sceneKey self.backgroundImage = pygwidgets.Image(self.window, (0, 0), "images/GameOverBackground.jpg") # The following will create a list of lists # Either by building a blank one from scratch, or by reading from a text file # The result will look like: # [[name, score], [name, score], [name, score] ...] # and will always be kept in order of the score (highest to lowest) if not SceneManager.fileExists(SceneGameOver.DATA_FILE_PATH): self.setEmptyGameOver() else: data = SceneManager.readFile(SceneGameOver.DATA_FILE_PATH) # read in all the data in json format, converts to a list of lists self.scoresList = json.loads(data) self.scoresField = pygwidgets.DisplayText(self.window, (25, 84), '', \ fontSize=48, textColor=BLACK, width=175, justified='right') self.namesField = pygwidgets.DisplayText(self.window, (260, 84), '', \ fontSize=48, textColor=BLACK, width=300, justified='left') self.quitButton = pygwidgets.TextButton(self.window, (30, 650), 'Quit') self.resetScoresButton = pygwidgets.TextButton(self.window, (240, 650), 'Reset high scores') self.startNewGameButton = pygwidgets.TextButton(self.window, (450, 650), 'Start new game') self.showGameOver()
def __init__(self, window, sceneKey): # Save window and sceneKey in instance variables self.window = window self.sceneKey = sceneKey # Set background self.backgroundImage = pygwidgets.Image( self.window, (0, 0), "images/GameOverBackground.jpg") # Read/load game data if not SceneManager.fileExists(SceneGameOver.DATA_FILE_PATH): pass else: data = SceneManager.readFile(SceneGameOver.DATA_FILE_PATH) # read in all the data in json format, converts to a list of lists self.scoresList = json.loads(data) self.deathCount = pygwidgets.DisplayText(self.window, (25, 84), 'Deaths: ', \ fontSize=48, textColor=DARKVIOLET, width=175, justified='right') # + str(nameScoreList[1]),\ self.deathMessage = pygwidgets.DisplayText(self.window, (260, 84), 'YOU DIED', \ fontSize=48, textColor=DARKVIOLET, width=300, justified='left') self.quitButton = pygwidgets.TextButton(self.window, (30, 650), 'Quit') self.startNewGameButton = pygwidgets.TextButton( self.window, (450, 650), 'Try Again')
def main(): pygame.init() screen = pygame.display.set_mode(GameSettings.WindowSize) pygame.display.set_caption(GameSettings.GameTitle) pygame.key.set_repeat(1) clock = pygame.time.Clock() IScene.IScene.setScreen(screen) while True: ''' メインループ ''' screen.fill((0, 0, 0)) SceneManager.getScene().update() SceneManager.getScene().draw() pygame.display.update() for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() clock.tick(GameSettings.FrameRate)
def test_search_by_ID(self): scene_manager = SceneManager() first_child = scene_manager.create_node() scene_manager.add_scene_node(node=first_child) node1 = scene_manager.get_node_from_ID(first_child.get_ID()) assert node1 == first_child and node1 is first_child
def deletePolygonModel(self,name): try: SceneManager.deleteModel(name) self.polyModelDict.pop(name) except: print("deletePolygonModel - something happened") #print("name: "+name) return 1 return 0
def cheangeScene(scene): ''' シーンの切り替えを行う関数 Parameters ---------- scene : string 切り替えたいシーン名 ''' SceneManager.setScene(scene)
def __init__(self,path,name): self.model = None self.name = name self.path = path self.rigidBodyId = None if (SceneManager.doesModelExist(name) != True): SceneManager.loadPolygonModel(path,name) self.model = SceneManager.getModel(name) addToScene("mainView") else: self.model = SceneManager.getModel(name)
def test_create_nodes(self): number_of_nodes_to_test = 5 test_nodes = [] scene_manager = SceneManager() for i in range(0, number_of_nodes_to_test): test_nodes.append(scene_manager.create_node()) test_result = True for i in range(0, number_of_nodes_to_test - 1): for j in range(i + 1, number_of_nodes_to_test): if test_nodes[i].get_ID() == test_nodes[j].get_ID(): assert False and "Created nodes with same IDs!"
def loadPolygonModel(self,path,name): try: if not(SceneManager.doesModelExist(name)): SceneManager.loadPolygonModel(path,name) self.polyModelDict[name] = SceneManager.getModel(name) else: print("loadPolygonModel - a model with specified name already exists") except: print("loadPolygonModel - something happened") #print("path: "+path) #print("name: "+name) return 1 return 0
def enter(self, data): # This can be called two different ways: # 1. If there is no new high score, data will be None # 2. Otherwise, data will be the score of the current game if data is not None: self.draw() # We have a new high score sent in from the play scene newHighScoreValue = data # this is the score # Show the new high scores table self.showGameOver() # Write out updated file of high scores SceneManager.writeFile(SceneGameOver.DATA_FILE_PATH, json.dumps(self.scoresList))
def setEmptyGameOver(self): self.scoresList = [ ['-----', 0], ['-----', 0], ['-----', 0], ['-----', 0], ['-----', 0], ['-----', 0], ['-----', 0], ['-----', 0], ['-----', 0], ['-----', 0]] SceneManager.writeFile(SceneGameOver.DATA_FILE_PATH, json.dumps(self.scoresList)) self.showGameOver()
def __init__( self ): self.engine = annchienta.getEngine() self.videoManager = annchienta.getVideoManager() self.inputManager = annchienta.getInputManager() self.cacheManager = annchienta.getCacheManager() self.mapManager = annchienta.getMapManager() self.mathManager = annchienta.getMathManager() self.sceneManager = SceneManager.getSceneManager() # Background spriteace self.background = annchienta.Surface( "images/backgrounds/sky.png" ) self.backgroundY = 0.0 # Create a ship for the player self.ship = GameObject( annchienta.Vector( videoManager.getScreenWidth()/2, videoManager.getScreenHeight()/2 ), annchienta.Surface( "sprites/ship_small.png" ) ) # Load sprites into cache self.enemySprite = annchienta.Surface("sprites/ship_pirate.png") # All enemies self.enemies = [] # The final enemy self.captain = None # Number of miliseconds we need to fly to gain victory self.victoryTime = 60000
def runMiniGame(): sceneManager = SceneManager.getSceneManager() videoManager = annchienta.getVideoManager() mapManager = annchienta.getMapManager() sceneManager.initDialog( [] ) # Clear entire screen. videoManager.clear() videoManager.setColor(0,0,0) videoManager.drawRectangle( 0, 0, videoManager.getScreenWidth(), videoManager.getScreenHeight() ) videoManager.flip() # Some intro talk. sceneManager.text( "August:\nAnd so we took Banver's ship in attempt to reach the Jemor continent.", None ) sceneManager.text( "August:\nBut soon we were noticed by these sky pirates Banver mentioned.", None ) sceneManager.text( "August:\nAt first, it seemed like there weren't too many, so we tried to evade them.", None ) sceneManager.text( "August:\nBut then...", None ) # Save first sceneManager.text( "Info: Your game was saved automatically.", None ) path = os.path.join(os.path.expanduser("~"), ".fall-of-imiryn/save.xml") partyManager.save(path) game = Game() game.run() sceneManager.quitDialog() # If we made it... if mapManager.isRunning(): partyManager.addRecord("fleet_caught_by_captain") partyManager.refreshMap()
def __init__(self): super(MainWindow, self).__init__() centralWidget = QtGui.QWidget() self.setCentralWidget(centralWidget) self.glWidget = GLWidget() self.glWidgetArea = QtGui.QScrollArea() self.glWidgetArea.setWidget(self.glWidget) self.glWidgetArea.setWidgetResizable(True) self.glWidgetArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored) self.glWidgetArea.setMinimumSize(50,50) self.createActions() self.createMenus() centralLayout = QtGui.QGridLayout() centralLayout.addWidget(self.glWidgetArea, 0, 0) centralWidget.setLayout(centralLayout) self.setWindowTitle("3D Brain Network Analysis Tool") self.resize(800, 600) self.renderSystem = RenderSystem() self.sourceManager = SourceManager() self.sceneManager = SceneManager() self.renderSystem.setRenderWidget(self.glWidget) self.renderSystem.setSceneManager(self.sceneManager) self.sceneManager.addSource(self.sourceManager) self.glWidget.addRenderSystem(self.renderSystem)
def askForBone(expectedPosition): global CORRECT global verdict global CURRENT global usersAns global correctAns # Set up button buttonZ = polyModel(buttonPath, buttonModel) #buttonPosition = util.addTuple(buttonZ.getPositionOffset(), rbButton.getPositionOffset()) buttonPosition = buttonZ.getPositionOffset() print("buttonPosition: " + str(buttonPosition)) # Set up button hand and navigation hand hand = polyModel(handPath, handButtModel) navHand = polyModel(navPath, handNavModel) print("Waiting for button press") # Wait for button press while (1): #print(" Model: " + str(hand.getPositionOffset())) #print(str(rbButtHand)+" has id: "+str(rbButtHand.getID())) #print(" Rigid: " + str(rbButtHand.getPosition())) handPosition = util.addTuple(hand.getPositionOffset(), rbButtHand.getPosition()) #print("handPosition:" +str(handPosition)) time.sleep(0.1) if (util.isOver(buttonPosition, handPosition, 0.3, 0.3)): # Get the position of the navigation hand and check if it is in the right place navPosition = util.addTuple(navHand.getPositionOffset(), rbNavHand.getPosition()) #print("navPosition: " + str(navPosition)) if (util.isOver(navPosition, expectedPosition, 0.3, 0.3)): CORRECT += 1 verdict = "Correct!" print("Got the correct answer!") else: verdict = "Incorrect" print("Answer was wrong") navRBHand = rbNavHand.getPosition() SceneManager.getModel(greenModel).setPositionOffset(navRBHand[0], navRBHand[1], navRBHand[2]) SceneManager.addNodeToScene(greenModel, "projectorView") # Results tab housekeeping CURRENT += 1 usersAns = str(navPosition) correctAns = str(expectedPosition) break
def new_game(self): """ Provides functionality to the new game Button and returns a Flow. Flow.RETURN is returned to reach NewGameScene. Flow.PASS is returned to remain on the MenuScene. """ self.game.last_valid_command = "m" if self.has_save: msg = ("You are about to override your save file with a new " "game. Do you want to proceed?") popup = Popup(self, "OVERRIDE SAVE", msg) if popup.query(): self.game.change_scene(sm.mk_NewGameScene(self.game)) return Flow.RETURN else: self.game.change_scene(sm.mk_NewGameScene(self.game)) return Flow.RETURN return Flow.PASS
def test_add_nodes(self): scene_manager = SceneManager() first_child = scene_manager.create_node() second_child = scene_manager.create_node() scene_manager.add_scene_node(node=first_child) scene_manager.add_scene_node(node=second_child, parent=first_child)
def __init__(self): self.initWindow() # window title title = "ASTRO.SYNTH" pygame.display.set_caption(title, title) # screen scene manager self.scene_mngr = SceneManager.SceneManager()
def __new__(cls): if cls.__instance is None: cls.__instance = super(Managers, cls).__new__(cls) cls.__instance.app = QtWidgets.QApplication(sys.argv) cls.__instance.input = inputManager.InputManager() cls.__instance.scene = scene.SceneManager() cls.__instance.scene.resize(1550, 1000) cls.__instance.objects = objMan.ObjectManager(cls.__instance.scene) cls.__instance.collisionDetection = collision.CollisionDetection( cls.__instance.objects) return cls.__instance
def test_search_by_name(self): test_name = "Find_me!" scene_manager = SceneManager() first_child = scene_manager.create_node() second_child = scene_manager.create_node() second_child.set_name(test_name) scene_manager.add_scene_node(node=first_child) scene_manager.add_scene_node(node=second_child, parent=first_child) node1 = scene_manager.get_node_from_name(test_name) assert node1 == second_child and node1 is second_child
def __init__(self,path,name): self.model = None self.name = name self.path = path if not(SceneManager.doesModelExist(name)): SceneManager.loadPolygonModel(path,name) self.model = SceneManager.getModel(name) SceneManager.addNodeToScene(name,"mainView") else: self.model = SceneManager.getModel(name)
def handleInputs(self, eventsList, keyPressedList): for event in eventsList: if self.startNewGameButton.handleEvent(event): self.goToScene(SCENE_PLAY) elif self.quitButton.handleEvent(event): self.quit() elif self.resetScoresButton.handleEvent(event): confirmed = SceneManager.textYesNoDialog(self.window, (35, 450, DIALOG_BOX_WIDTH, 150), \ "Are you sure you want to RESET the high scores?") if confirmed: self.setEmptyGameOver()
def openFile(self): path = QtGui.QFileDialog.getOpenFileName(self, "Open Module", "") # convert path to a string path = str(path) # get filename from path (dir, file) = os.path.split(path) # based on the file, pick the name for the model if (file == 'Skeleton_FULL.OSGB'): model = "skeleton1" elif (file == 'Skeleton_Back.OSGB'): model = "skeleton2" else: title = "Invalid File" error = "Please choose Skeleton_FULL or Skeleton_Back." QtGui.QMessageBox.critical(None, title, error, QtGui.QMessageBox.Close) return # Send the model to scene manager SceneManager.loadPolygonModel(path, model) return
def __init__(self): super(MainWindow, self).__init__() centralWidget = QtGui.QWidget() self.setCentralWidget(centralWidget) self.glWidget = GLWidget() self.glWidgetArea = QtGui.QScrollArea() self.glWidgetArea.setWidget(self.glWidget) self.glWidgetArea.setWidgetResizable(True) self.glWidgetArea.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored) self.glWidgetArea.setMinimumSize(50, 50) self.createActions() self.createMenus() centralLayout = QtGui.QGridLayout() centralLayout.addWidget(self.glWidgetArea, 0, 0) centralWidget.setLayout(centralLayout) self.setWindowTitle("3D Brain Network Analysis Tool") self.resize(800, 600) self.renderSystem = RenderSystem() self.sourceManager = SourceManager() self.sceneManager = SceneManager() self.renderSystem.setRenderWidget(self.glWidget) self.renderSystem.setSceneManager(self.sceneManager) self.sceneManager.addSource(self.sourceManager) self.glWidget.addRenderSystem(self.renderSystem)
def start(): # disable logger warningss logger = avango.gua.nodes.Logger(EnableWarning=False) workspace_config = sys.argv[1] if sys.argv[2] == "True": start_clients = True else: start_clients = False # preload materials and shading models avango.gua.load_shading_models_from("data/materials") avango.gua.load_materials_from("data/materials") # initialize application manager application_manager = ApplicationManager() application_manager.my_constructor(WORKSPACE_CONFIG=workspace_config, START_CLIENTS=start_clients) # initialize scene scene_manager = SceneManager() # initialize touch devices multi_touch_device = None for _workspace in application_manager.workspaces: for _display_group in _workspace.display_groups: for _display in _display_group.displays: if "TUIO" in _display.get_touch_protocols(): if None == multi_touch_device: device = TUIODevice() device.my_constructor(scenegraphs[0], _display, scenegraphs[0]["/net"], scene_manager, application_manager) multi_touch_device = device # initialize animation manager #animation_manager = AnimationManager() #animation_manager.my_constructor([ graph["/net/platform_0"]] # , [ application_manager.navigation_list[0]]) ## distribute all nodes in the scenegraph distribute_all_nodes(scenegraphs[0]["/net"], scenegraphs[0]["/net"]) # run application loop application_manager.run(locals(), globals())
def __init__( self, name, toolTip=None ): # Stuff for sounds self.cacheManager = annchienta.getCacheManager() self.audioManager = annchienta.getAudioManager() self.soundClickRev = self.cacheManager.getSound('sounds/click-reverse.ogg') self.soundClickNeg = self.cacheManager.getSound('sounds/click-negative.ogg') self.soundClickPos = self.cacheManager.getSound('sounds/click-positive.ogg') self.soundClickNeu = self.cacheManager.getSound('sounds/click-neutral.ogg') self.soundSave = self.cacheManager.getSound('sounds/save.ogg') # Base constructor MenuItem.MenuItem.__init__( self, name, toolTip ) # Get references self.inputManager = annchienta.getInputManager() self.videoManager = annchienta.getVideoManager() self.mapManager = annchienta.getMapManager() self.sceneManager = SceneManager.getSceneManager() # Flags self.done = False self.canceled = False # Size of the menu self.width, self.height = 0, 0 # Position on the screen self.x, self.y = 0, 0 self.columns = 1 self.rows = 1 # If the tooltip should be drawn on top of the screen self.toolTipOnTop = True # Kinda self explanatory self.maxItemsInColumn = 4 # The options in the menu. Use setOptions() to set them! self.options = [] # The currently selected item index self.selectedOptionIndex = 0 self.selectedOption = None
def showCustomAnswerDialog(theWindow, theText): oDialogBackground = pygwidgets.Image(theWindow, (35, 450), 'images/dialog.png') oPromptDisplayText = pygwidgets.DisplayText(theWindow, (0, 480), theText, \ width=WINDOW_WIDTH, justified='center', fontSize=36) oUserInputText = pygwidgets.InputText(theWindow, (200, 550), '', fontSize=36, initialFocus=True) oNoButton = pygwidgets.CustomButton(theWindow, (65, 595), \ 'images/noThanksNormal.png',\ over='images/noThanksOver.png',\ down='images/noThanksDown.png',\ disabled='images/noThanksDisabled.png') oYesButton = pygwidgets.CustomButton(theWindow, (330, 595), \ 'images/addNormal.png',\ over='images/addOver.png',\ down='images/addDown.png',\ disabled='images/addDisabled.png') choiceAsBoolean, userAnswer = SceneManager.customAnswerDialog(theWindow, oDialogBackground, \ oPromptDisplayText, oUserInputText, oYesButton, oNoButton) return choiceAsBoolean, userAnswer
def __init__(self): # Get some references self.engine = annchienta.getEngine() self.inputManager = annchienta.getInputManager() self.mapManager = annchienta.getMapManager() self.cacheManager = annchienta.getCacheManager() self.mathManager = annchienta.getMathManager() self.sceneManager = SceneManager.getSceneManager() # Set variables self.player = 0 self.records = [] self.inventory = 0 self.lastMaps = [] self.currentMap = 0 self.startTime = 0 # Create a map loader self.mapLoader = MapLoader() # Battle variables self.randomBattleDelay = self.mathManager.randInt(300, 400)
def __init__(self, combatants, background, canFlee): # Set variables self.combatants = combatants self.running = True self.background = background self.canFlee = canFlee self.won = False self.actionLock = False # Get references self.engine = annchienta.getEngine() self.videoManager = annchienta.getVideoManager() self.inputManager = annchienta.getInputManager() self.cacheManager = annchienta.getCacheManager() self.mathManager = annchienta.getMathManager() self.mapManager = annchienta.getMapManager() self.audioManager = annchienta.getAudioManager() self.sceneManager = SceneManager.getSceneManager() self.partyManager = PartyManager.getPartyManager() # Lines for the 'console' window self.lines = []
def deleteModel(self): SceneManager.deleteModel(self.getName()) return
import annchienta import PartyManager, SceneManager, BattleManager mapManager = annchienta.getMapManager() videoManager = annchienta.getVideoManager() partyManager = PartyManager.getPartyManager() sceneManager = SceneManager.getSceneManager() currentMap = partyManager.getCurrentMap() partyManager.addRecord("inaran_cave3_scene") # Create a whole bunch of objects/persons and set them to # their positions. august = partyManager.getPlayer() augustPosition = august.getPosition().to(annchienta.TilePoint) march = annchienta.Person("march", "locations/common/march.xml") currentMap.addObject( march, annchienta.Point(annchienta.TilePoint, augustPosition.x + 1, augustPosition.y)) avril = annchienta.Person("avril", "locations/common/avril.xml") currentMap.addObject( avril, annchienta.Point(annchienta.TilePoint, augustPosition.x, augustPosition.y + 1)) # Init our dialog. sceneManager.initDialog([august, march, avril])
#Inital stuff pygame.init() clock = pygame.time.Clock() width = 800 height = 600 size = width, height screen = pygame.display.set_mode(size) bgColor = r,g,b = 0, 0, 0 font = pygame.font.Font(None,36) player = Player([width/2, height-150]) UIManager = UIManager() SceneManager = SceneManager() scene = None testItem = Item(screen, "weapon", "universal", "Health Potion", "*Description*", "Images/Other/Items/HealthPotion.png") TextManager = TextManager(screen, scene) newText = Text("Testing", [20,20]) p = PlayerAnimation([width/2, height/2]) #Move UI Elements #UIManager.MBRect = UIManager.MBRect.move(UIManager.MBPose) #UIManager.HBRect = UIManager.HBRect.move(UIManager.HBPose) while True: #if player.health <= 2:
def __init__(self, xmlElement): # Call super constructor BattleEntity.BattleEntity.__init__(self, xmlElement) # We need to log stuff self.logManager = annchienta.getLogManager() # Get references self.videoManager = annchienta.getVideoManager() self.cacheManager = annchienta.getCacheManager() self.mathManager = annchienta.getMathManager() self.sceneManager = SceneManager.getSceneManager() # Create a dictionary describing the level stuff self.level = {} levelElement = xmlElement.getElementsByTagName("level")[0] for k in levelElement.attributes.keys(): self.level[k] = int(levelElement.attributes[k].value) # Create a dictionary describing the health stats self.healthStats = {} healthStatsElement = xmlElement.getElementsByTagName("healthstats")[0] for k in healthStatsElement.attributes.keys(): self.healthStats[k] = int(healthStatsElement.attributes[k].value) # Get all possible actions. The actual actions are in the first child # of the element, hence the code. <actions> action1 action2 </actions> actionsElement = xmlElement.getElementsByTagName("actions")[0] actionNames = str(actionsElement.firstChild.data).split() # Prepare to get the from the xml data self.actions = [] # Get them for a in actionNames: self.addAction(a) # Create a dictionary describing the elemental properties # Only enemies have them, usually self.primaryElemental = {} elementalElements = xmlElement.getElementsByTagName("elemental") if len(elementalElements): for k in elementalElements[0].attributes.keys(): self.primaryElemental[k] = float( elementalElements[0].attributes[k].value) # Load sprite spriteElement = xmlElement.getElementsByTagName("sprite")[0] # Keep the filename so we can save it later on self.spriteFilename = str(spriteElement.getAttribute("filename")) self.sprite = annchienta.Surface(self.spriteFilename) if spriteElement.hasAttribute("x1"): self.sx1 = int(spriteElement.getAttribute("x1")) self.sy1 = int(spriteElement.getAttribute("y1")) self.sx2 = int(spriteElement.getAttribute("x2")) self.sy2 = int(spriteElement.getAttribute("y2")) else: self.sx1, self.sy1 = 0, 0 self.sx2 = self.sprite.getWidth() self.sy2 = self.sprite.getHeight() # Get width and height from those facts. self.width = self.sx2 - self.sx1 self.height = self.sy2 - self.sy1 self.position = annchienta.Vector(0, 0) # We will draw a mark upon ourselves sometimes self.active = False self.selected = False # Damage done by an attack self.damage = 0 self.damageTimer = 0.0 self.reset()
def selectTest(self): # Grab currently displayed test from combo box chosenTest = str(self.combo.currentText()) # Based on displayed test, send model to projectDr if chosenTest == TEST1: model = MODEL1 else: model = MODEL2 # Before we try to add a model, we should make sure one doesn't already exist if SceneManager.doesModelExist(MODEL1) or SceneManager.doesModelExist(MODEL2): title = "A skeleton model is already loaded!" error = "Please wait for current test to finish before attempting to start another." QtGui.QMessageBox.critical(None, title, error, QtGui.QMessageBox.Close) return # We can load the model in projectDr now if model == MODEL1: path = PATH1 else: path = PATH2 # Notify the user that model was successfully loaded. title = "Model Loaded" error = "Model was successfully loaded into ProjectDr." QtGui.QMessageBox.information(None, title, error, QtGui.QMessageBox.Ok) # Send the model to scene manager print("LOADING NEW TEST") # Load Skeleton SceneManager.loadPolygonModel(path, model) #Scale Skeleton SceneManager.getModel(model).setScale(.025,.025,.025) SceneManager.getModel(model).setRotationOffset(0,0,-1,1) SceneManager.getModel(model).setPositionOffset(0.105,0.15,-0.711) SceneManager.addNodeToScene(model,"mainView") SceneManager.addNodeToScene(model,"projectorView") # Load Skeleton C1 Answer SceneManager.loadPolygonModel(C1Ans, C1Ans) #Scale Skeleton SceneManager.getModel(C1Ans).setScale(.025,.025,.025) SceneManager.getModel(C1Ans).setRotationOffset(0,0,-1,1) SceneManager.getModel(C1Ans).setPositionOffset(0.105,0.15,-0.711) SceneManager.addNodeToScene(C1Ans,"mainView") # Load Skeleton T1 Answer SceneManager.loadPolygonModel(T1Ans, T1Ans) #Scale Skeleton SceneManager.getModel(T1Ans).setScale(.025,.025,.025) SceneManager.getModel(T1Ans).setRotationOffset(0,0,-1,1) SceneManager.getModel(T1Ans).setPositionOffset(0.105,0.15,-0.711) SceneManager.addNodeToScene(T1Ans,"mainView") # Load Skeleton SceneManager.loadPolygonModel(L1Ans, L1Ans) #Scale Skeleton SceneManager.getModel(L1Ans).setScale(.025,.025,.025) SceneManager.getModel(L1Ans).setRotationOffset(0,0,-1,1) SceneManager.getModel(L1Ans).setPositionOffset(0.105,0.15,-0.711) SceneManager.addNodeToScene(L1Ans,"mainView") # Start thread for running test! self.thread = WorkThread() self.thread.start() return
def start(self): """Starts the game loop at the menu scene.""" self.change_scene(sm.mk_MenuScene(self)) self.loop()
def test_get_root(self): scene_manager = SceneManager() root_tester = scene_manager.get_root_node() assert root_tester == scene_manager.get_root_node() and root_tester is scene_manager.get_root_node()
# Init MapManager. mapManager = annchienta.getMapManager() mapManager.setTileWidth(64) mapManager.setTileHeight(32) mapManager.setUpdatesPerSecond(60) mapManager.setMaxAscentHeight(32) mapManager.setMaxDescentHeight(32) mapManager.setOnUpdateScript("src/onUpdate.py") # Init InputManager. inputManager = annchienta.getInputManager() inputManager.setInteractKey(annchienta.SDLK_SPACE) # Init SceneManager. import SceneManager SceneManager.init() sceneManager = SceneManager.getSceneManager() # Init PartyManager. import PartyManager PartyManager.init() partyManager = PartyManager.getPartyManager() # Init BattleManager. import BattleManager BattleManager.init() # Start Main menu. import Menu import MenuItem
class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() centralWidget = QtGui.QWidget() self.setCentralWidget(centralWidget) self.glWidget = GLWidget() self.glWidgetArea = QtGui.QScrollArea() self.glWidgetArea.setWidget(self.glWidget) self.glWidgetArea.setWidgetResizable(True) self.glWidgetArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored) self.glWidgetArea.setMinimumSize(50,50) self.createActions() self.createMenus() centralLayout = QtGui.QGridLayout() centralLayout.addWidget(self.glWidgetArea, 0, 0) centralWidget.setLayout(centralLayout) self.setWindowTitle("3D Brain Network Analysis Tool") self.resize(800, 600) self.renderSystem = RenderSystem() self.sourceManager = SourceManager() self.sceneManager = SceneManager() self.renderSystem.setRenderWidget(self.glWidget) self.renderSystem.setSceneManager(self.sceneManager) self.sceneManager.addSource(self.sourceManager) self.glWidget.addRenderSystem(self.renderSystem) def loadFile(self): fileName = QtGui.QFileDialog.getOpenFileName(self,'Open file','./', 'Surface Template(*.nv)') self.surface = Surface() self.surface.LoadIn(fileName) self.sceneManager.rootNode.localObjectDict['Surface'] = self.surface def about(self): QtGui.QMessageBox.about(self, "About 3D Brain Network Analysis Tool", "The <b>3D Brain Network Analysis Tool</b> is developed by Gushu Li, " "from NICS Lab in E.E. Dept at Tsinghua University. " "If you find any problem, " "please email me at <b>[email protected]</b>.") def grabFrameBuffer(self): image = self.glWidget.grabFrameBuffer() pixmap = QtGui.QPixmap.fromImage(image) filename = QtGui.QFileDialog.getSaveFileName(self,'Save file','./', 'Image Files (*.png)') pixmap.save(filename) def createActions(self): self.loadAct = QtGui.QAction('Load', self, shortcut = 'Ctrl+L', triggered = self.loadFile) self.exitAct = QtGui.QAction('Exit', self, shortcut = 'Ctrl+Q', triggered = self.close) self.grabFrameBufferAct = QtGui.QAction('&Grab Frame Buffer', self, shortcut = 'Ctrl+G', triggered = self.grabFrameBuffer) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt) def createMenus(self): self.fileMenu = self.menuBar().addMenu('&File') self.fileMenu.addAction(self.loadAct) self.fileMenu.addSeparator() self.fileMenu.addAction(self.exitAct) self.editMenu = self.menuBar().addMenu('&Edit') self.editMenu.addAction(self.grabFrameBufferAct) self.helpMenu = self.menuBar().addMenu("&Help") self.helpMenu.addAction(self.aboutAct) self.helpMenu.addSeparator() self.helpMenu.addAction(self.aboutQtAct)
def __init__ ( self, modname, mapname, is_server=False, graphics_enabled=True ): """Initialize the world from the given map""" self.modname = modname self.mapname = mapname self.playerEnt = None self.isServer = is_server self.graphicsEnabled = graphics_enabled self.idCounter = 0 self.ninjasKilled = 0 self.piratesKilled = 0 self.treasuresTaken = 0 self.deathBlotches = [] path = Mod.MapPath( modname, mapname) hmap = path+"heightmap.bin" projectdesc = ProjectDesc ( modname, mapname ) self.projectDesc = projectdesc self.seaLevel = float(projectdesc.SeaLevel) self.solver = Physics.Solver() self.solver.setMinimumFramerate(10) #create materials self.materialMap = Materials.DefaultMaterialMap(self.solver) #setup atmosphere self.atmosphere = Atmosphere.Atmosphere(projectdesc) self._extractShadowMap() self.terrainMaterial = TerrainMaterial.TerrainMaterial( modname, mapname ) self.terrain = Terrain.TerrainPatch( None, self, Heightmap.fromFile(hmap), self.terrainMaterial, projectdesc.Spacing ) #if self.graphicsEnabled: # self.terrain.initGraphics() self.ocean = Ocean.Ocean(float(projectdesc.SeaLevel), projectdesc.WaterTexture, self.terrain.getextent() ) mx = self.terrain.getextent() / 2 mz = self.terrain.getextent() / 2 my = self.terrain.getWorldHeightValue( mx, mz ) + 2.0 #Set the world size (Newton will disable anything that's not #within the world box extent = float(self.terrain.getextent()) self.solver.setWorldSize( (-extent, -2000.0, -extent ), (extent, 2000.0, extent) ) #Create scene. This should load all the entities as well self.scene = SceneManager.SceneManager(self, modname, mapname) #set camera if not self.graphicsEnabled: self.playerEnt = None self.camera = None else: if self.playerEnt == None or Settings.RunPhysics == False: self.camera = Camera.Freecam() self.camera.position = vec3( mx, my, mz) self.camera.yaw = 0 self.camera.pitch = 0 else: self.camera = Camera.AttachableCamera( self.playerEnt ) self.frustrum_camera = self.camera.asFreecam() print "World loaded"
import annchienta, SceneManager, PartyManager partyManager, sceneManager = PartyManager.getPartyManager( ), SceneManager.getSceneManager() mathManager = annchienta.getMathManager() messages = [ "He doesn't look to healthy.", "Spooky.", "I wonder what happened to him?", "I have a bad feeling about this...", "This is getting scary...", "I wonder how he died?", "I hope I don't end up like that..." ] sceneManager.initDialog([partyManager.player]) sceneManager.speak(partyManager.player, messages[mathManager.randInt(len(messages))]) sceneManager.quitDialog()
import ClientHandler import SceneManager import glob path = "C:\Users\w\Documents\Models\osg-data-master\glider.osg" name = "somethingyouwant" paths = glob.glob("C:\Users\Aedan\Desktop\Homework Folder\CMPUT 302\DICOM Models\COU\*.dcm") for i in paths: i = i[66:] print i local_IP = "25.79.169.119" OptiTrack_IP = "25.79.169.119" OptiTrack_DataPort = 1511 OptiTrack_CmdPort = 1510 ClientHandler.connect(local_IP,OptiTrack_IP,OptiTrack_DataPort,OptiTrack_CmdPort,ClientHandler.ConnectionType.Multicast) SceneManager.loadPolygonModel(path,name) model = SceneManager.getModel(name)
def run(self): old = 0 new = 0 print("Running the Test") # Begin timer startTime = time.time() print("Start Timer") for i in range(ITERATIONS): # Randomly choose a bone. Make sure we don't ask for same bone twice. print("Starting For Loop") while new == old: new = randint(1, 3) print("After While Loop") if new == 1: print("C1") SceneManager.getModel(C1Model).setPositionOffset(0.35, 0, -0.09) SceneManager.addNodeToScene(C1Model, "projectorView") askForBone(C1) SceneManager.removeNodeFromScene(MODEL1, "projectorView") SceneManager.addNodeToScene(C1Ans,"projectorView") time.sleep(4) SceneManager.removeNodeFromScene(C1Ans,"projectorView") SceneManager.removeNodeFromScene(C1Model, "projectorView") elif new == 2: print("T1") SceneManager.getModel(T1Model).setPositionOffset(0.35, 0, -0.09) SceneManager.addNodeToScene(T1Model, "projectorView") askForBone(T1) SceneManager.removeNodeFromScene(MODEL1, "projectorView") SceneManager.addNodeToScene(T1Ans,"projectorView") time.sleep(4) SceneManager.removeNodeFromScene(T1Ans,"projectorView") SceneManager.removeNodeFromScene(T1Model, "projectorView") else: print("L1") # Display text for bone we want in projector view SceneManager.getModel(L1Model).setPositionOffset(0.35, 0, -0.09) SceneManager.addNodeToScene(L1Model, "projectorView") askForBone(L1) SceneManager.removeNodeFromScene(MODEL1, "projectorView") SceneManager.addNodeToScene(L1Ans,"projectorView") time.sleep(4) SceneManager.removeNodeFromScene(L1Ans,"projectorView") SceneManager.removeNodeFromScene(L1Model, "projectorView") old = new SceneManager.removeNodeFromScene(greenModel, "projectorView") SceneManager.addNodeToScene(MODEL1,"projectorView") # Get the time after the 10 iterations endTime = time.time() elapsedTime = endTime - startTime elapsedTime = str(elapsedTime)+" Seconds" # Calculate the accuracy accuracy = str((CORRECT/ITERATIONS) * 100); # Write results to a file date = datetime.datetime.now().strftime("%B %d %I:%M%p") testName = "Skeleton Full" # Terminate the thread when we are done!! self.terminate()
def addToScene(self,scene): try: SceneManager.addNodeToScene(self.name,scene) except: "something blew up" return
##Dependencies: ##License: ###################################################################### # Pound Includes import viz import pregame import SceneManager import viztask import Human import GameWrap import vizcam import postgame viz.go() sceneManager = SceneManager.SceneManager() #Game def ZombieGame(): Status = True while (Status): print viz.MainScene viz.scene(1) ActiveProgram = pregame.Intro() #Destructions info yield ActiveProgram.done.wait() #Wailt for intro screen to be done sceneManager.switchtoScene('Charactor') ActiveProgram = pregame.CharacterCreation() playerName = yield ActiveProgram.done.wait( ) #Wailt for charactor creation to be done
def removeFromScene(self,scene): try: SceneManager.removeNodeFromScene(self.name,scene) except: "something blew up" return
#optitrack stuff local_IP = "25.79.169.119" OptiTrack_IP = "25.79.169.119" OptiTrack_DataPort = 1511 OptiTrack_CmdPort = 1510 #ClientHandler.connect(local_IP,OptiTrack_IP,OptiTrack_DataPort,OptiTrack_CmdPort,ClientHandler.ConnectionType.Multicast) #load model from path #modelist = list([0]*len(paths)) #test loading multiple models modellist = [] for i in range(3): print "loading"+name+paths[i] SceneManager.loadPolygonModel(paths[i],name+paths[i]) modellist.append(SceneManager.getModel(name+paths[i])) print str(len(modellist))+" length of list after adding models" print modellist for i in range(len(modellist)): SceneManager.deleteModel(name+paths[i]) print "deleting"+name+paths[i] print str(len(modellist))+" length of list after removing the models" print modellist #todo: remove all the references to the model after removing model (aka: call delete on list on specified index) #output test, replace with infinite loop with a keyboard event to break
def __init__(self, parent=None, manager=None, printpreview=None): qt.QWidget.__init__(self, parent) self.mainLayout = qt.QGridLayout(self) if printpreview is None: self.printPreview = Object3DPrintPreview.Object3DPrintPreview( modal=0) else: self.printPreview = printpreview self.buildToolBar() self.wheelSlider10 = WheelAndSpacer(self, orientation=qt.Qt.Vertical) # Wheel self.__applyingCube = False #self.wheelSlider10.wheel.setMass(0.5) self.wheelSlider10.wheel.setRange(-360., 360., 0.5) self.wheelSlider10.wheel.setValue(0.0) self.wheelSlider10.wheel.setTotalAngle(360.) self.connect(self.wheelSlider10.wheel, qt.SIGNAL("valueChanged(double)"), self.setTheta) self.glWidget = SceneGLWidget.SceneGLWidget(self) self.scene = weakref.proxy(self.glWidget.scene) self.glWidget.setObjectSelectionMode(True) self.wheelSlider12 = Qwt5.QwtSlider(self, qt.Qt.Vertical, Qwt5.QwtSlider.NoScale, Qwt5.QwtSlider.BgSlot) #self.axesObject = BlissGLAxesObject.BlissGLAxesObject("3D Axes") #self.glWidget.addObject3D(self.axesObject) #self.wheelSlider12.setScaleEngine(Qwt5.QwtLog10ScaleEngine()) #self.wheelSlider12.setThumbWidth(20) self.wheelSlider12.setRange(-10, 10, 0.05) #self.wheelSlider12.setScale(0.01, 100) self.wheelSlider12.setValue(0.0) #self.wheelSlider12.setScaleMaxMinor(10) self.connect(self.wheelSlider12, qt.SIGNAL("valueChanged(double)"), self.setZoomFactor) self.wheelSlider21 = WheelAndLineEdit(self, orientation=qt.Qt.Horizontal) #wheel #self.wheelSlider21.wheel.setMass(0.5) self.wheelSlider21.wheel.setRange(-360., 360., 0.5) self.wheelSlider21.wheel.setValue(0.0) self.wheelSlider21.wheel.setTotalAngle(360.) self.infoLine = self.wheelSlider21.lineEdit self.infoLine.setText("Scene is in object selection mode.") self.connect(self.wheelSlider21.wheel, qt.SIGNAL("valueChanged(double)"), self.setPhi) self.mainLayout.addWidget(self.toolBar, 0, 1) self.mainLayout.addWidget(self.wheelSlider10, 1, 0) self.mainLayout.addWidget(self.glWidget, 1, 1) self.mainLayout.addWidget(self.wheelSlider12, 1, 2) self.mainLayout.addWidget(self.wheelSlider21, 2, 1) if manager is None: self.manager = SceneManager.SceneManager(None, glwindow=self) self.sceneControl = self.manager.sceneControl #self.sceneControl = SceneControl.SceneControl(None, self.glWidget.scene) #self.manager.sceneControl self.connectSceneControl() #self.manager.show() #self.sceneControl.show() self.connect(self.manager, qt.SIGNAL('SceneManagerSignal'), self.sceneManagerSlot) else: self.manager = weakref.proxy(manager) self.activeObject = None self.connect(self.glWidget, qt.SIGNAL('objectSelected'), self.objectSelectedSlot) self.connect(self.glWidget, qt.SIGNAL('vertexSelected'), self.vertexSelectedSlot) self.setWindowTitle(self.tr("Object3D Scene"))
class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() centralWidget = QtGui.QWidget() self.setCentralWidget(centralWidget) self.glWidget = GLWidget() self.glWidgetArea = QtGui.QScrollArea() self.glWidgetArea.setWidget(self.glWidget) self.glWidgetArea.setWidgetResizable(True) self.glWidgetArea.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored) self.glWidgetArea.setMinimumSize(50, 50) self.createActions() self.createMenus() centralLayout = QtGui.QGridLayout() centralLayout.addWidget(self.glWidgetArea, 0, 0) centralWidget.setLayout(centralLayout) self.setWindowTitle("3D Brain Network Analysis Tool") self.resize(800, 600) self.renderSystem = RenderSystem() self.sourceManager = SourceManager() self.sceneManager = SceneManager() self.renderSystem.setRenderWidget(self.glWidget) self.renderSystem.setSceneManager(self.sceneManager) self.sceneManager.addSource(self.sourceManager) self.glWidget.addRenderSystem(self.renderSystem) def loadFile(self): fileName = QtGui.QFileDialog.getOpenFileName(self, 'Open file', './', 'Surface Template(*.nv)') self.surface = Surface() self.surface.LoadIn(fileName) self.sceneManager.rootNode.localObjectDict['Surface'] = self.surface def about(self): QtGui.QMessageBox.about( self, "About 3D Brain Network Analysis Tool", "The <b>3D Brain Network Analysis Tool</b> is developed by Gushu Li, " "from NICS Lab in E.E. Dept at Tsinghua University. " "If you find any problem, " "please email me at <b>[email protected]</b>.") def grabFrameBuffer(self): image = self.glWidget.grabFrameBuffer() pixmap = QtGui.QPixmap.fromImage(image) filename = QtGui.QFileDialog.getSaveFileName(self, 'Save file', './', 'Image Files (*.png)') pixmap.save(filename) def createActions(self): self.loadAct = QtGui.QAction('Load', self, shortcut='Ctrl+L', triggered=self.loadFile) self.exitAct = QtGui.QAction('Exit', self, shortcut='Ctrl+Q', triggered=self.close) self.grabFrameBufferAct = QtGui.QAction('&Grab Frame Buffer', self, shortcut='Ctrl+G', triggered=self.grabFrameBuffer) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt) def createMenus(self): self.fileMenu = self.menuBar().addMenu('&File') self.fileMenu.addAction(self.loadAct) self.fileMenu.addSeparator() self.fileMenu.addAction(self.exitAct) self.editMenu = self.menuBar().addMenu('&Edit') self.editMenu.addAction(self.grabFrameBufferAct) self.helpMenu = self.menuBar().addMenu("&Help") self.helpMenu.addAction(self.aboutAct) self.helpMenu.addSeparator() self.helpMenu.addAction(self.aboutQtAct)
def quit(self): """Returns to the main menu and returns Flow.RETURN.""" self.game.change_scene(sm.mk_MenuScene(self.game)) return Flow.RETURN
date = datetime.datetime.now().strftime("%B %d %I:%M%p") testName = "Skeleton Full" # Terminate the thread when we are done!! self.terminate() if __name__ == '__main__': import sys print("Starting") # Load button and hand models SceneManager.loadPolygonModel(navPath, handNavModel) SceneManager.loadPolygonModel(handPath, handButtModel) SceneManager.loadPolygonModel(buttonPath, buttonModel) SceneManager.loadPolygonModel(greenPath, greenModel) # Scale the Green Circle SceneManager.getModel(greenModel).setScale(0.01, 0.01, 0.01) SceneManager.addNodeToScene(greenModel, "mainView") # Create text but do not load into view SceneManager.loadPolygonModel("C1.OSGB", C1Model) SceneManager.getModel(C1Model).setScale(0.005, 0.005, 0.005) SceneManager.getModel(C1Model).setPositionOffset(0.350, 0, -0.090) SceneManager.getModel(C1Model).setRotationOffset(0, 0, -1, 1) SceneManager.addNodeToScene(C1Model,"mainView")