Beispiel #1
0
 def loadImage(self, filename, label=None):
     if label:
         handle = PyUnseen.createTexture(filename)
         self.images[label] = handle
     else:
         handle = PyUnseen.createTexture(filename)
         self.images[filename] = handle
Beispiel #2
0
 def loadImage(self, filename, label = None):
     if label:
         handle = PyUnseen.createTexture(filename)
         self.images[label] = handle            
     else:
         handle = PyUnseen.createTexture(filename)
         self.images[filename] = handle            
Beispiel #3
0
def run():
    done = 1
    frame = 0
    t = time.time()

    import testopt

    opts = testopt.parseCommandLine(800, 600, "dx")
    pyui.init(*opts)

    # w = pyui.widgets.ViewWindow(10, 10, 400, 300)
    # w.pack()

    terrainDetails = CreateTestTerrainDetails()
    terrain = PyUnseen.createTerrainRegion(terrainDetails)  # will take dictionary of stuff
    rootWorld = PyUnseen.getRootWorld()

    PyUnseen.addToWorld(rootWorld, terrain)  # just like any other object

    cameraPos = (-10, 6, -10)
    cameraDir = (45, -45, 0)

    view1 = PyUnseen.createView(rootWorld)  # will also take zMin, zMax?
    PyUnseen.setCameraParameters(view1, cameraPos, cameraDir)

    rootView = PyUnseen.getRootView()
    PyUnseen.setCameraParameters(rootView, cameraPos, cameraDir)

    while done:
        pyui.draw()
        done = pyui.update()

    print "done"
    pyui.quit()
Beispiel #4
0
def gotEvent(event, wParam, lParam):
    global keydown, keystate, debugEnabled
    if event in mouseMsgs:
        x = lParam & 0xffff
        y = lParam >> 16
        #print "Mouse Event: %d (%d,%d)" % (event, x, y)
        mods = pyui.locals.MOD_NONE
        if event in [
                WM_LBUTTONDOWN, WM_LBUTTONUP, WM_RBUTTONDOWN, WM_RBUTTONUP,
                WM_MOUSEMOVE
        ]:
            if keystate[VK_SHIFT]:
                mods |= pyui.locals.MOD_SHIFT
            if keystate[VK_CONTROL]:
                mods |= pyui.locals.MOD_CONTROL
            if keystate[VK_MENU]:
                mods |= pyui.locals.MOD_ALT
        if getDesktop():
            getDesktop().postUserEvent(event, x, y, wParam, mods)
        return

    # mods for key events
    if event in [WM_CHAR, WM_KEYDOWN, WM_KEYUP]:
        mods = pyui.locals.MOD_NONE
        if keystate[VK_SHIFT]:
            mods |= pyui.locals.MOD_SHIFT
        if keystate[VK_CONTROL]:
            mods |= pyui.locals.MOD_CONTROL
        if keystate[VK_MENU]:
            mods |= pyui.locals.MOD_ALT

    # This is the handler for character keys.
    if event == WM_CHAR:
        getDesktop().postUserEvent(pyui.locals.CHAR, 0, 0, chr(wParam), mods)
        return

    if event == WM_KEYDOWN:
        if debugEnabled and (DEBUG_KEY == wParam):
            PyUnseen.debug(0)
            return
        global keydown, keystate
        keystate[wParam] += 1
        getDesktop().postUserEvent(pyui.locals.KEYDOWN, 0, 0, wParam, mods)
        return

    if event == WM_KEYUP:
        global keydown, keystate
        keystate[wParam] = 0
        getDesktop().postUserEvent(pyui.locals.KEYUP, 0, 0, wParam, mods)
        return

    # special event handlers
    if event == WM_CLOSE:
        getDesktop().postUserEvent(pyui.locals.QUIT, 0, 0, 0)
        return
Beispiel #5
0
    def draw(self, windows):
        """run the python widgets drawing code. This calls describeWindow on any windows
        that have changed. The actual drawing is done within PyUnseen.render.
        """
        for w in windows:
            w.drawWindow(self)

        PyUnseen.render()
        PyUnseen.messagepump()
        
        self.mustFill = 0
        self.dirtyRects = []
Beispiel #6
0
    def draw(self, windows):
        """run the python widgets drawing code. This calls describeWindow on any windows
        that have changed. The actual drawing is done within PyUnseen.render.
        """
        for w in windows:
            w.drawWindow(self)

        PyUnseen.render()
        PyUnseen.messagepump()

        self.mustFill = 0
        self.dirtyRects = []
Beispiel #7
0
def gotEvent(event, wParam, lParam):
    global keydown, keystate, debugEnabled
    if event in mouseMsgs:
        x = lParam & 0xffff
        y = lParam >> 16
        #print "Mouse Event: %d (%d,%d)" % (event, x, y)
        mods = pyui.locals.MOD_NONE
        if event in [WM_LBUTTONDOWN, WM_LBUTTONUP, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_MOUSEMOVE]:
            if keystate[VK_SHIFT]:
                mods |= pyui.locals.MOD_SHIFT
            if keystate[VK_CONTROL]:
                mods |= pyui.locals.MOD_CONTROL
            if keystate[VK_MENU]:
                mods |= pyui.locals.MOD_ALT
        if getDesktop():
            getDesktop().postUserEvent(event, x, y, wParam, mods)
        return

    # mods for key events
    if event in [WM_CHAR, WM_KEYDOWN, WM_KEYUP]:
        mods = pyui.locals.MOD_NONE
        if keystate[VK_SHIFT]:
            mods |= pyui.locals.MOD_SHIFT
        if keystate[VK_CONTROL]:
            mods |= pyui.locals.MOD_CONTROL
        if keystate[VK_MENU]:
            mods |= pyui.locals.MOD_ALT

    # This is the handler for character keys.
    if event == WM_CHAR:
        getDesktop().postUserEvent(pyui.locals.CHAR, 0, 0, chr(wParam), mods)
        return

    if event == WM_KEYDOWN:
        if debugEnabled and (DEBUG_KEY == wParam):
            PyUnseen.debug(0)
            return
        global keydown, keystate
        keystate[wParam] += 1
        getDesktop().postUserEvent(pyui.locals.KEYDOWN, 0, 0, wParam, mods)
        return

    if event == WM_KEYUP:
        global keydown, keystate
        keystate[wParam] = 0
        getDesktop().postUserEvent(pyui.locals.KEYUP, 0, 0, wParam, mods)
        return
        
    # special event handlers
    if event == WM_CLOSE:
        getDesktop().postUserEvent(pyui.locals.QUIT, 0, 0, 0)
        return
Beispiel #8
0
    def __init__(self, w, h, fullscreen, title="Unseen"):
        Renderer3DBase.__init__(self, w, h, fullscreen)
        PyUnseen.initialize(w, h, gotEvent, messageMap, title)
        self.font1 = PyUnseen.createFont("Arial", 9, 0)
        self.fixedFont = PyUnseen.createFont("Courier", 7, 0)
        self.populateConstants()

        # store the actual height and width surface created (might be less than requested)
        #(getDesktop().width, getDesktop().height) = PyUnseen.getDesktopSize()

        (w, pyui.locals.TEXT_HEIGHT) = self.getTextSize(" ")
        self.images = {}

        self.cache = {}  # tracks all objects by Handle. useful for debugging
Beispiel #9
0
    def __init__(self, w, h, fullscreen, title="Unseen"):
        Renderer3DBase.__init__(self, w, h, fullscreen)
        PyUnseen.initialize(w, h, gotEvent, messageMap, title )
        self.font1 = PyUnseen.createFont( "Arial", 9, 0 )
        self.fixedFont = PyUnseen.createFont( "Courier", 7, 0 )        
        self.populateConstants()

        # store the actual height and width surface created (might be less than requested)
        #(getDesktop().width, getDesktop().height) = PyUnseen.getDesktopSize()
        
        (w, pyui.locals.TEXT_HEIGHT) = self.getTextSize(" ")
        self.images = {}

        self.cache = {} # tracks all objects by Handle. useful for debugging
Beispiel #10
0
 def getTextSize(self, text, font = None):
     if font == 'fixed':
         font = self.fixedFont
     elif not font:
         font = self.font1
         
     return PyUnseen.getTextSize(font, text)
Beispiel #11
0
 def createView(self, world):
     """Create a view object and return the handle to it.
         Width and height ignored by PyUnseen
     """
     handle = PyUnseen.createView(world)
     self.cache[handle] = "view"
     return handle
Beispiel #12
0
 def rotateObjectTo(self,
                    objectHandle,
                    orientation,
                    turnRate,
                    onCompleted=None):
     return PyUnseen.rotateObjectTo(objectHandle, orientation, turnRate,
                                    onCompleted)
Beispiel #13
0
 def createView(self, world):
     """Create a view object and return the handle to it.
         Width and height ignored by PyUnseen
     """
     handle = PyUnseen.createView(world)
     self.cache[handle] = "view"
     return handle
Beispiel #14
0
    def getTextSize(self, text, font=None):
        if font == 'fixed':
            font = self.fixedFont
        elif not font:
            font = self.font1

        return PyUnseen.getTextSize(font, text)
Beispiel #15
0
 def quit(self):
     print "PyUnseen Quitting."
     PyUnseen.destroyFont(self.font1)
     PyUnseen.destroyFont(self.fixedFont)
     for filename in self.images.keys():
         handle = self.images[filename]
         PyUnseen.destroyTexture(handle)
     self.dumpCache()
     PyUnseen.cleanup()
Beispiel #16
0
 def quit(self):
     print "PyUnseen Quitting."
     PyUnseen.destroyFont(self.font1)
     PyUnseen.destroyFont(self.fixedFont)
     for filename in self.images.keys():
         handle = self.images[filename]
         PyUnseen.destroyTexture(handle)
     self.dumpCache()        
     PyUnseen.cleanup()
Beispiel #17
0
 def attachObject(self,
                  objectHandle,
                  toObjectHandle,
                  connectionPointName="",
                  toConnectionPointName=""):
     return PyUnseen.attachObject(objectHandle, toObjectHandle,
                                  connectionPointName,
                                  toConnectionPointName)
Beispiel #18
0
 def moveObject(self,
                objectHandle,
                delta,
                moveRate,
                turnRate=0,
                onCompleted=None):
     return PyUnseen.moveObject(objectHandle, delta, moveRate, turnRate,
                                onCompleted)
Beispiel #19
0
 def moveObjectTo(self,
                  objectHandle,
                  location,
                  moveRate,
                  turnRate=0,
                  onCompleted=None):
     return PyUnseen.moveObjectTo(objectHandle, location, moveRate,
                                  turnRate, onCompleted)
Beispiel #20
0
 def setObjectAnimation(self,
                        objectHandle,
                        animation,
                        onCompleted=None,
                        blendTime=0.0,
                        loop=1):
     return PyUnseen.setObjectAnimation(objectHandle, animation,
                                        onCompleted, blendTime, loop)
Beispiel #21
0
 def describeWindow(self, handle, drawList):
     if not handle:
         return
     #print "Describing window (%d): %s" % (handle, drawList)
     #print "Describing window ",  handle
     #for d in drawList:
     #    print d
     return PyUnseen.describeWindow(handle, drawList)
Beispiel #22
0
 def describeWindow(self, handle, drawList):
     if not handle:
         return
     #print "Describing window (%d): %s" % (handle, drawList)
     #print "Describing window ",  handle
     #for d in drawList:
     #    print d
     return PyUnseen.describeWindow(handle, drawList)
Beispiel #23
0
 def addGeometryPiece(self,
                      node,
                      iType,
                      info,
                      offset,
                      ypr,
                      effect="",
                      effectParams={}):
     return PyUnseen.addGeometryPiece(node, iType, info, offset, ypr,
                                      effect, effectParams)
Beispiel #24
0
 def playMusic(self, waveFileName, completionCallback = None):
     return PyUnseen.playMusic(waveFileName, completionCallback)
Beispiel #25
0
 def stopSound(self, waveFileName):
     return PyUnseen.stopSound(waveFileName)
Beispiel #26
0
 def destroyFont(self, fontHandle):
     del self.cache[fontHandle]
     return PyUnseen.destroyFont(fontHandle)
Beispiel #27
0
 def getObjectNode(self, objectHandle, nodeName, iLOD):
 	return PyUnseen.getObjectNode(objectHandle, nodeName, iLOD)
Beispiel #28
0
 def getObjectProjectedPos(self, objectHandle, viewHandle):
     return PyUnseen.getObjectProjectedPos(objectHandle, viewHandle)
Beispiel #29
0
 def loadMusic(self, waveFileName):
     return PyUnseen.loadMusic(waveFileName)
Beispiel #30
0
 def addGeometryNode(self, objectHandle, bone=0):
     return PyUnseen.addGeometryNode(objectHandle, bone)
Beispiel #31
0
 def getNodeEffect(self, node, num):
     return PyUnseen.getNodeEffect(node, num)
Beispiel #32
0
 def addGeometryNode(self, objectHandle, bone=0):
     return PyUnseen.addGeometryNode(objectHandle, bone)
Beispiel #33
0
 def createEmptyBody(self, xyz=(0.0, 0.0, 0.0), label="emptyBody"):
     handle = PyUnseen.createEmptyBody(xyz)
     self.cache[handle] = label
     return handle
Beispiel #34
0
 def setWindowEffect(self, windowHandle, effectName):
     return PyUnseen.setWindowViewEffect(windowHandle, effectName)
Beispiel #35
0
 def toggleDebugInfo(self):
     return PyUnseen.togglePerfInfo()
Beispiel #36
0
 def loadMusic(self, waveFileName):
     return PyUnseen.loadMusic(waveFileName)
Beispiel #37
0
 def setWindowEffect(self, windowHandle, effectName):
     return PyUnseen.setWindowViewEffect(windowHandle, effectName)
Beispiel #38
0
 def setEffectParameters(self, effect, parms):
     return PyUnseen.setEffectParameters(effect, parms)
Beispiel #39
0
 def getNodeEffect(self, node, num):
     return PyUnseen.getNodeEffect(node, num)
Beispiel #40
0
 def playMusic(self, waveFileName, completionCallback=None):
     return PyUnseen.playMusic(waveFileName, completionCallback)
Beispiel #41
0
 def detachController(self, objectHandle, controllerHandle):
     return PyUnseen.detachController(objectHandle, controllerHandle)
Beispiel #42
0
 def loadSound(self, waveFileName):
     return PyUnseen.loadSound(waveFileName)
Beispiel #43
0
 def getNodeProjectedPos(self, nodeHandle, viewHandle):
     return PyUnseen.getNodeProjectedPos(nodeHandle, viewHandle)
Beispiel #44
0
 def stopSound(self, waveFileName):
     return PyUnseen.stopSound(waveFileName)
Beispiel #45
0
 def createFont(self, fontName, size, flag):
     handle = PyUnseen.createFont(fontName, size, flag)
     self.cache[handle] = "font %s %s" % ( fontName, size)
     return handle
Beispiel #46
0
 def getScreenSize(self):
     return PyUnseen.getScreenSize()
Beispiel #47
0
 def getScreenSize(self):
     return PyUnseen.getScreenSize()
Beispiel #48
0
 def destroyFont(self, fontHandle):
     del self.cache[fontHandle]
     return PyUnseen.destroyFont(fontHandle)
Beispiel #49
0
 def loadSound(self, waveFileName):
     return PyUnseen.loadSound(waveFileName)
Beispiel #50
0
 def createFont(self, fontName, size, flag):
     handle = PyUnseen.createFont(fontName, size, flag)
     self.cache[handle] = "font %s %s" % (fontName, size)
     return handle
Beispiel #51
0
 def stopMusic(self, waveFileName):
     return PyUnseen.stopMusic(waveFileName)
Beispiel #52
0
 def getObjectNode(self, objectHandle, nodeName, iLOD):
     return PyUnseen.getObjectNode(objectHandle, nodeName, iLOD)
Beispiel #53
0
 def toggleDebugInfo(self):
     return PyUnseen.togglePerfInfo()
Beispiel #54
0
 def getNodeProjectedPos(self, nodeHandle, viewHandle):
     return PyUnseen.getNodeProjectedPos(nodeHandle, viewHandle)
Beispiel #55
0
 def createEmptyBody(self, xyz=(0.0,0.0,0.0), label="emptyBody"):
     handle= PyUnseen.createEmptyBody(xyz)
     self.cache[handle] = label
     return handle
Beispiel #56
0
 def attachController(self, objectHandle, controllerType, boneName):
     return PyUnseen.attachController(objectHandle, controllerType, boneName)
Beispiel #57
0
 def addGeometryPiece(self, node, iType, info, offset, ypr, effect = "", effectParams = {}):
     return PyUnseen.addGeometryPiece(node, iType, info, offset, ypr, effect, effectParams)
Beispiel #58
0
 def setController(self, controllerHandle, **parms):
     return PyUnseen.setController(controllerHandle, parms)
Beispiel #59
0
 def setEffectParameters(self, effect, parms):
     return PyUnseen.setEffectParameters(effect, parms)
Beispiel #60
0
 def stopMusic(self, waveFileName):
     return PyUnseen.stopMusic(waveFileName)