def setupScene(self): sceneManager = self.root.createSceneManager(ogre.ST_GENERIC, "Default SceneManager") level = Level.newLevel(sceneManager) self.camera = sceneManager.createCamera("Camera") self.camera.position = (0, 150, -500) self.camera.lookAt ((0, 0, 0)) self.camera.nearClipDistance = 5 Input.onKey('W', self.forward) Input.onKey('S', self.back) viewPort = self.root.getAutoCreatedWindow().addViewport(self.camera) self.camera.aspectRatio = float (viewPort.actualWidth) / float (viewPort.actualHeight)
def setupInputSystem(self): windowHandle = 0 renderWindow = self.root.getAutoCreatedWindow() windowHandle = renderWindow.getCustomAttributeInt("WINDOW") paramList = [("WINDOW", str(windowHandle))] self.inputManager = OIS.createPythonInputSystem(paramList) # Now InputManager is initialized for use. Keyboard and Mouse objects # must still be initialized separately try: Input.init( self.inputManager.createInputObjectKeyboard(OIS.OISKeyboard, False), self.inputManager.createInputObjectMouse(OIS.OISMouse, False) ) except Exception, e: raise e
def createFrameListener(self): self.root.addFrameListener(Input.getFrameListener())