コード例 #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
コード例 #2
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 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            
コード例 #3
0
ファイル: testView.py プロジェクト: burito/PyUI
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()
コード例 #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
コード例 #5
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
    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 = []
コード例 #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 = []
コード例 #7
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
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
コード例 #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
コード例 #9
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
    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
コード例 #10
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def getTextSize(self, text, font = None):
     if font == 'fixed':
         font = self.fixedFont
     elif not font:
         font = self.font1
         
     return PyUnseen.getTextSize(font, text)
コード例 #11
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 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
コード例 #12
0
 def rotateObjectTo(self,
                    objectHandle,
                    orientation,
                    turnRate,
                    onCompleted=None):
     return PyUnseen.rotateObjectTo(objectHandle, orientation, turnRate,
                                    onCompleted)
コード例 #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
コード例 #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)
コード例 #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()
コード例 #16
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 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()
コード例 #17
0
 def attachObject(self,
                  objectHandle,
                  toObjectHandle,
                  connectionPointName="",
                  toConnectionPointName=""):
     return PyUnseen.attachObject(objectHandle, toObjectHandle,
                                  connectionPointName,
                                  toConnectionPointName)
コード例 #18
0
 def moveObject(self,
                objectHandle,
                delta,
                moveRate,
                turnRate=0,
                onCompleted=None):
     return PyUnseen.moveObject(objectHandle, delta, moveRate, turnRate,
                                onCompleted)
コード例 #19
0
 def moveObjectTo(self,
                  objectHandle,
                  location,
                  moveRate,
                  turnRate=0,
                  onCompleted=None):
     return PyUnseen.moveObjectTo(objectHandle, location, moveRate,
                                  turnRate, onCompleted)
コード例 #20
0
 def setObjectAnimation(self,
                        objectHandle,
                        animation,
                        onCompleted=None,
                        blendTime=0.0,
                        loop=1):
     return PyUnseen.setObjectAnimation(objectHandle, animation,
                                        onCompleted, blendTime, loop)
コード例 #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)
コード例 #22
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 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)
コード例 #23
0
 def addGeometryPiece(self,
                      node,
                      iType,
                      info,
                      offset,
                      ypr,
                      effect="",
                      effectParams={}):
     return PyUnseen.addGeometryPiece(node, iType, info, offset, ypr,
                                      effect, effectParams)
コード例 #24
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def playMusic(self, waveFileName, completionCallback = None):
     return PyUnseen.playMusic(waveFileName, completionCallback)
コード例 #25
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def stopSound(self, waveFileName):
     return PyUnseen.stopSound(waveFileName)
コード例 #26
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def destroyFont(self, fontHandle):
     del self.cache[fontHandle]
     return PyUnseen.destroyFont(fontHandle)
コード例 #27
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def getObjectNode(self, objectHandle, nodeName, iLOD):
 	return PyUnseen.getObjectNode(objectHandle, nodeName, iLOD)
コード例 #28
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def getObjectProjectedPos(self, objectHandle, viewHandle):
     return PyUnseen.getObjectProjectedPos(objectHandle, viewHandle)
コード例 #29
0
 def loadMusic(self, waveFileName):
     return PyUnseen.loadMusic(waveFileName)
コード例 #30
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def addGeometryNode(self, objectHandle, bone=0):
     return PyUnseen.addGeometryNode(objectHandle, bone)
コード例 #31
0
 def getNodeEffect(self, node, num):
     return PyUnseen.getNodeEffect(node, num)
コード例 #32
0
 def addGeometryNode(self, objectHandle, bone=0):
     return PyUnseen.addGeometryNode(objectHandle, bone)
コード例 #33
0
 def createEmptyBody(self, xyz=(0.0, 0.0, 0.0), label="emptyBody"):
     handle = PyUnseen.createEmptyBody(xyz)
     self.cache[handle] = label
     return handle
コード例 #34
0
 def setWindowEffect(self, windowHandle, effectName):
     return PyUnseen.setWindowViewEffect(windowHandle, effectName)
コード例 #35
0
 def toggleDebugInfo(self):
     return PyUnseen.togglePerfInfo()
コード例 #36
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def loadMusic(self, waveFileName):
     return PyUnseen.loadMusic(waveFileName)
コード例 #37
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def setWindowEffect(self, windowHandle, effectName):
     return PyUnseen.setWindowViewEffect(windowHandle, effectName)
コード例 #38
0
 def setEffectParameters(self, effect, parms):
     return PyUnseen.setEffectParameters(effect, parms)
コード例 #39
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def getNodeEffect(self, node, num):
     return PyUnseen.getNodeEffect(node, num)
コード例 #40
0
 def playMusic(self, waveFileName, completionCallback=None):
     return PyUnseen.playMusic(waveFileName, completionCallback)
コード例 #41
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def detachController(self, objectHandle, controllerHandle):
     return PyUnseen.detachController(objectHandle, controllerHandle)
コード例 #42
0
 def loadSound(self, waveFileName):
     return PyUnseen.loadSound(waveFileName)
コード例 #43
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def getNodeProjectedPos(self, nodeHandle, viewHandle):
     return PyUnseen.getNodeProjectedPos(nodeHandle, viewHandle)
コード例 #44
0
 def stopSound(self, waveFileName):
     return PyUnseen.stopSound(waveFileName)
コード例 #45
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def createFont(self, fontName, size, flag):
     handle = PyUnseen.createFont(fontName, size, flag)
     self.cache[handle] = "font %s %s" % ( fontName, size)
     return handle
コード例 #46
0
 def getScreenSize(self):
     return PyUnseen.getScreenSize()
コード例 #47
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def getScreenSize(self):
     return PyUnseen.getScreenSize()
コード例 #48
0
 def destroyFont(self, fontHandle):
     del self.cache[fontHandle]
     return PyUnseen.destroyFont(fontHandle)
コード例 #49
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def loadSound(self, waveFileName):
     return PyUnseen.loadSound(waveFileName)
コード例 #50
0
 def createFont(self, fontName, size, flag):
     handle = PyUnseen.createFont(fontName, size, flag)
     self.cache[handle] = "font %s %s" % (fontName, size)
     return handle
コード例 #51
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def stopMusic(self, waveFileName):
     return PyUnseen.stopMusic(waveFileName)
コード例 #52
0
 def getObjectNode(self, objectHandle, nodeName, iLOD):
     return PyUnseen.getObjectNode(objectHandle, nodeName, iLOD)
コード例 #53
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def toggleDebugInfo(self):
     return PyUnseen.togglePerfInfo()
コード例 #54
0
 def getNodeProjectedPos(self, nodeHandle, viewHandle):
     return PyUnseen.getNodeProjectedPos(nodeHandle, viewHandle)
コード例 #55
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def createEmptyBody(self, xyz=(0.0,0.0,0.0), label="emptyBody"):
     handle= PyUnseen.createEmptyBody(xyz)
     self.cache[handle] = label
     return handle
コード例 #56
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def attachController(self, objectHandle, controllerType, boneName):
     return PyUnseen.attachController(objectHandle, controllerType, boneName)
コード例 #57
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def addGeometryPiece(self, node, iType, info, offset, ypr, effect = "", effectParams = {}):
     return PyUnseen.addGeometryPiece(node, iType, info, offset, ypr, effect, effectParams)
コード例 #58
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def setController(self, controllerHandle, **parms):
     return PyUnseen.setController(controllerHandle, parms)
コード例 #59
0
ファイル: unseen.py プロジェクト: BackupTheBerlios/street-svn
 def setEffectParameters(self, effect, parms):
     return PyUnseen.setEffectParameters(effect, parms)
コード例 #60
0
 def stopMusic(self, waveFileName):
     return PyUnseen.stopMusic(waveFileName)