Пример #1
0
    def main(self):
        displayservice = Display3D.getDisplayService()
        self.link((self,"display_signal"), displayservice)
        self.send(self.disprequest, "display_signal");

        # load texture
        if self.tex is not None:
            # load image
            image = pygame.image.load(self.tex)
            # create power of 2 dimensioned surface
            pow2size = (int(2**(ceil(log(image.get_width(), 2)))), int(2**(ceil(log(image.get_height(), 2)))))
            if pow2size != image.get_size():
                textureSurface = pygame.Surface(pow2size, pygame.SRCALPHA, 32)
                # determine texture coordinates
                self.tex_w = float(image.get_width())/pow2size[0]
                self.tex_h = float(image.get_height())/pow2size[1]
                # copy image data to pow2surface
                textureSurface.blit(image, (0,0))
            else:
                textureSurface = image
                self.tex_w = 1.0
                self.tex_h = 1.0
            # set plane size
            self.size = Vector(float(image.get_width())/100.0, float(image.get_height())/100.0, 0)
            # prepare vertices for intersection test
            x = float(self.size.x/2)
            y = float(self.size.y/2)
            self.vertices = [ Vector(-x, y, 0.0), Vector(x, y, 0.0), Vector(x, -y, 0.0), Vector(-x, -y, 0.0) ]
            # read pixel data
            textureData = pygame.image.tostring(textureSurface, "RGBX", 1)
            # gen tex name
            self.texID = glGenTextures(1)
            # create texture
            glEnable(GL_TEXTURE_2D)
            glBindTexture(GL_TEXTURE_2D, self.texID)
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
            glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, textureSurface.get_width(), textureSurface.get_height(), 0,
                            GL_RGBA, GL_UNSIGNED_BYTE, textureData );
            glDisable(GL_TEXTURE_2D)

        while 1:

#            for _ in self.waitBox("callback"): yield 1
#            self.display = self.recv("callback")

# There is no need for a callback yet
            
            yield 1
            
            self.handleEvents()
            self.handleMovementCommands()
            self.applyTransforms()
            self.draw()
Пример #2
0
    def __init__(self, **argd):
        super(SimpleRotationInteractor, self).__init__()

        # get display service
        displayservice = Display3D.getDisplayService()
        # link display_signal to displayservice
        self.link((self, "display_signal"), displayservice)

        self.victim = id(argd.get("victim"))

        self.grabbed = False
        self.rotationfactor = argd.get("rotationfactor", 1.0)
    def __init__(self, **argd):
        super(SimpleRotationInteractor, self).__init__()

        # get display service
        displayservice = Display3D.getDisplayService()
        # link display_signal to displayservice
        self.link((self, "display_signal"), displayservice)

        self.victim = id(argd.get("victim"))

        self.grabbed = False
        self.rotationfactor = argd.get("rotationfactor", 1.0)
    def __init__(self, **argd):
        super(MatchedTranslationInteractor, self).__init__()

        # get display service
        displayservice = Display3D.getDisplayService()
        # link display_signal to displayservice
        self.link((self,"display_signal"), displayservice)

        self.victim = id(argd.get("victim"))
                                         
        self.grabbed = False
        self.position = None
        self.oldpoint = None
Пример #5
0
    def __init__(self, **argd):
        super(MatchedTranslationInteractor, self).__init__()

        # get display service
        displayservice = Display3D.getDisplayService()
        # link display_signal to displayservice
        self.link((self, "display_signal"), displayservice)

        self.victim = id(argd.get("victim"))

        self.grabbed = False
        self.position = None
        self.oldpoint = None
Пример #6
0
    def main(self):
        displayservice = Display3D.getDisplayService()
        self.link((self, "display_signal"), displayservice)
        self.send(self.disprequest, "display_signal")

        while 1:
            try:
                self.wraprequest = {
                    "WRAPPERREQUEST": True,
                    "wrapcallback": (self, "wrapcallback"),
                    "eventrequests": (self, "eventrequests"),
                    "surface": self.wrapped_comp.display
                }
                self.send(self.wraprequest, "display_signal")
                break
            except AttributeError:
                yield 1

        for _ in self.waitBox("wrapcallback"):
            yield 1
        b = self.recv("wrapcallback")
        self.texname = b.texname
        self.tex_w = b.tex_w
        self.tex_h = b.tex_h
        self.width = float(b.width)
        self.height = float(b.height)
        #prepare vertices for intersection test
        x = self.width / 200.0
        y = self.height / 200.0
        self.vertices = [
            Vector(-x, y, 0.0),
            Vector(x, y, 0.0),
            Vector(x, -y, 0.0),
            Vector(-x, -y, 0.0)
        ]
        # setup event communications
        if b.eventservice is not None:
            self.link((self, "wrapped_eventsfeedback"), b.eventservice)

        while 1:
            yield 1
            self.handleEventRequests()
            self.handleEvents()
            self.handleMovementCommands()
            self.applyTransforms()
            self.draw()
Пример #7
0
    def main(self):
        displayservice = Display3D.getDisplayService()
        self.link((self, "display_signal"), displayservice)
        self.send(self.disprequest, "display_signal")

        while 1:

            #            for _ in self.waitBox("callback"): yield 1
            #            self.display = self.recv("callback")

            # There is no need for a callback yet

            yield 1

            self.handleEvents()
            self.handleMovementCommands()
            self.applyTransforms()
            self.draw()
Пример #8
0
    def main(self):
        displayservice = Display3D.getDisplayService()
        self.link((self,"display_signal"), displayservice)
        self.send(self.disprequest, "display_signal");

        while 1:

#            for _ in self.waitBox("callback"): yield 1
#            self.display = self.recv("callback")

# There is no need for a callback yet
            
            yield 1
            
            self.handleEvents()
            self.handleMovementCommands()
            self.applyTransforms()
            self.draw()
Пример #9
0
    def main(self):
        displayservice = Display3D.getDisplayService()
        self.link((self,"display_signal"), displayservice)
        self.send(self.disprequest, "display_signal");

        while 1:
            try: 
                self.wraprequest = { "WRAPPERREQUEST" : True,
                                                  "wrapcallback" : (self, "wrapcallback"),
                                                  "eventrequests" : (self, "eventrequests"),
                                                  "surface": self.wrapped_comp.display }
                self.send( self.wraprequest, "display_signal")
                break
            except AttributeError:
                yield 1
                
        for _ in self.waitBox("wrapcallback"): yield 1
        b = self.recv("wrapcallback")
        self.texname = b.texname
        self.tex_w = b.tex_w
        self.tex_h = b.tex_h
        self.width = float(b.width)
        self.height = float(b.height)
        #prepare vertices for intersection test
        x = self.width/200.0
        y = self.height/200.0
        self.vertices = [ Vector(-x, y, 0.0), Vector(x, y, 0.0), Vector(x, -y, 0.0), Vector(-x, -y, 0.0) ]
        # setup event communications
        if b.eventservice is not None:
            self.link((self, "wrapped_eventsfeedback"), b.eventservice)

        while 1:
            yield 1
            self.handleEventRequests()            
            self.handleEvents()
            self.handleMovementCommands()
            self.applyTransforms()
            self.draw()
Пример #10
0
    def __init__(self, **argd):
        super(Object3D, self).__init__()

        # transformation data
        self.size = argd.get("size", None)
        self.pos = argd.get("pos",Vector(0,0,-15))
        self.rot = Vector(0.0,0.0,0.0)
        self.scaling = argd.get("scaling",Vector(1,1,1))
        
        # for detection of changes
        self.oldrot = Vector()
        self.oldpos = Vector()
        self.oldscaling = Vector()

        # name        
        self.name = argd.get("name", "nameless")

        # get display service
        displayservice = Display3D.getDisplayService()
        # link display_signal to displayservice
        self.link((self,"display_signal"), displayservice)
        
        self.transform = Transform()
Пример #11
0
    class datasource(Axon.Component.component):
        def main(self):
            for x in text.split():
                self.send(x, "outbox")
                yield 1

    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Kamaelia.Util.Graphline import Graphline
    from Kamaelia.UI.Pygame.Ticker import Ticker
    from Kamaelia.UI.Pygame.Button import Button
    from SimpleCube import *
    import sys
    sys.path.append("../../pygame/")
    from MagnaDoodle import *

    display3d = Display3D.getDisplayService()
    PygameDisplay.setDisplayService(display3d[0])

    TEXT = datasource().activate()
    TICKER1 = Ticker(size=(150, 150),
                     render_left=0,
                     render_right=350,
                     render_top=0,
                     render_bottom=250).activate()
    TICKER1WRAPPER = PygameWrapperPlane(wrap=TICKER1,
                                        pos=Vector(-4, 1, -15),
                                        name="1st Wrapper Plane").activate()
    TICKER2 = Ticker(size=(150, 150),
                     render_left=0,
                     render_right=350,
                     render_top=0,
Пример #12
0
        def main(self):
            for x in text.split():
                self.send(x,"outbox")
                yield 1
    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Kamaelia.Util.Graphline import Graphline
    from Kamaelia.UI.Pygame.Ticker import Ticker
    from Kamaelia.UI.Pygame.Button import Button
    from SimpleCube import *
    import sys;
    sys.path.append("../pygame/")
    from MagnaDoodle import *
    sys.path.append("../../MPS/Systems/Paint/")
    from Paint import *

    Display3D.getDisplayService()[0].overridePygameDisplay()
   
    TEXT = datasource().activate()
    TICKER1 = Ticker(position = (400, 300), render_left = 0, render_right=350, render_top=0, render_bottom=250).activate()
    TICKER1WRAPPER = PygameWrapperPlane(wrap=TICKER1, pos=Vector(-2, 1,-10), name="1st Wrapper Plane").activate()
    TICKER2 = Ticker(position = (400, 300), render_left = 0, render_right=350, render_top=0, render_bottom=250).activate()
    TICKER2WRAPPER = PygameWrapperPlane(wrap=TICKER2, pos=Vector(2, 1,-10),  name="2nd Wrapper Plane").activate()
    BUTTON = Button(caption="This button...",msg="...can be moved AND activated!", key=pygame.K_SPACE).activate()
    BUTTONWRAPPER = PygameWrapperPlane(wrap=BUTTON, pos=Vector(0, 1.5,-5),  name="2nd Wrapper Plane").activate()
    MAGNADOODLE = MagnaDoodle(size=(255,255)).activate()
    MAGNADOODLEWRAPPER = PygameWrapperPlane(wrap=MAGNADOODLE, pos=Vector(-2, -2,-10),  name="Magna Doodle Wrapper Plane").activate() 
    ECHO = consoleEchoer().activate()
    CUBE = SimpleCube(pos = Vector(2,-2,-10)).activate()
    CUBEROTATOR = CubeRotator().activate()
    TICKER1WRAPPER.link((TICKER1WRAPPER, "outbox"), (TICKER2, "inbox"))
    TICKER2WRAPPER.link((TICKER2WRAPPER, "outbox"), (TICKER2, "inbox"))
Пример #13
0
#            self.steadyMovement()
            
            self.handleEvents()
            self.handleMovementCommands()
            self.applyTransforms()
            self.draw()

# Later it might be a good idea to provide a set of drawing functions
# so the component developer does not need to know about opengl
# This way opengl could later easily be replaced by an other mechanism
# for drawing
# e.g. TOGRA


if __name__=='__main__':
    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Display3D import *
    from Button3D import *
    from Scrollbar3D import *
    from Movement3D import *
    path1 = LinearPath3D([Vector(3,3,-20), Vector(4,0,-20), Vector(3,-3,-20), Vector(0,-4,-20), Vector(-3,-3,-20),Vector(-4,0,-20),  Vector(-3,3,-20),Vector(0,4,-20),  Vector(3,3,-20)], 1000)
    
    Display3D.overridePygameDisplay()

    PROGRESS = Progress3D(size = Vector(3, 0.5, 0.5), pos=Vector(0,-1,-10)).activate()    
    SCROLL = Scrollbar3D(size = Vector(3, 0.5, 0.5), pos=Vector(0,-2,-10)).activate()    
    
    SCROLL.link((SCROLL,"scroll"), (PROGRESS, "progress"))
        
    Axon.Scheduler.scheduler.run.runThreads()  
Пример #14
0
    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Display3D import *
    from Movement3D import *
    path1 = LinearPath3D([
        Vector(3, 3, -20),
        Vector(4, 0, -20),
        Vector(3, -3, -20),
        Vector(0, -4, -20),
        Vector(-3, -3, -20),
        Vector(-4, 0, -20),
        Vector(-3, 3, -20),
        Vector(0, 4, -20),
        Vector(3, 3, -20)
    ], 1000)

    Display3D.overridePygameDisplay()

    ECHO = consoleEchoer().activate()
    BUTTON1 = Button3D(caption="<<", msg="Previous",
                       pos=Vector(-3, 0, -10)).activate()
    BUTTON2 = Button3D(caption=">>", msg="Next", pos=Vector(3, 0,
                                                            -10)).activate()
    BUTTON3 = Button3D(caption="Play", msg="Play", pos=Vector(-1, 0,
                                                              -10)).activate()
    BUTTON4 = Button3D(caption="Stop", msg="Stop", pos=Vector(1, 0,
                                                              -10)).activate()
    PATHMOVER = PathMover(path1).activate()
    CUBE = SimpleCube().activate()

    BUTTON1.link((BUTTON1, "outbox"), (PATHMOVER, "inbox"))
    BUTTON2.link((BUTTON2, "outbox"), (PATHMOVER, "inbox"))
Пример #15
0
    def main(self):
        displayservice = Display3D.getDisplayService()
        self.link((self, "display_signal"), displayservice)
        self.send(self.disprequest, "display_signal")

        # load texture
        if self.tex is not None:
            # load image
            image = pygame.image.load(self.tex)
            # create power of 2 dimensioned surface
            pow2size = (int(2**(ceil(log(image.get_width(), 2)))),
                        int(2**(ceil(log(image.get_height(), 2)))))
            if pow2size != image.get_size():
                textureSurface = pygame.Surface(pow2size, pygame.SRCALPHA, 32)
                # determine texture coordinates
                self.tex_w = float(image.get_width()) / pow2size[0]
                self.tex_h = float(image.get_height()) / pow2size[1]
                # copy image data to pow2surface
                textureSurface.blit(image, (0, 0))
            else:
                textureSurface = image
                self.tex_w = 1.0
                self.tex_h = 1.0
            # set plane size
            self.size = Vector(
                float(image.get_width()) / 100.0,
                float(image.get_height()) / 100.0, 0)
            # prepare vertices for intersection test
            x = float(self.size.x / 2)
            y = float(self.size.y / 2)
            self.vertices = [
                Vector(-x, y, 0.0),
                Vector(x, y, 0.0),
                Vector(x, -y, 0.0),
                Vector(-x, -y, 0.0)
            ]
            # read pixel data
            textureData = pygame.image.tostring(textureSurface, "RGBX", 1)
            # gen tex name
            self.texID = glGenTextures(1)
            # create texture
            glEnable(GL_TEXTURE_2D)
            glBindTexture(GL_TEXTURE_2D, self.texID)
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSurface.get_width(),
                         textureSurface.get_height(), 0, GL_RGBA,
                         GL_UNSIGNED_BYTE, textureData)
            glDisable(GL_TEXTURE_2D)

        while 1:

            #            for _ in self.waitBox("callback"): yield 1
            #            self.display = self.recv("callback")

            # There is no need for a callback yet

            yield 1

            self.handleEvents()
            self.handleMovementCommands()
            self.applyTransforms()
            self.draw()
Пример #16
0
"""
    class datasource(Axon.Component.component):
        def main(self):
            for x in text.split():
                self.send(x,"outbox")
                yield 1
    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Kamaelia.Util.Graphline import Graphline
    from Kamaelia.UI.Pygame.Ticker import Ticker
    from Kamaelia.UI.Pygame.Button import Button
    from SimpleCube import *
    import sys;
    sys.path.append("../../pygame/")
    from MagnaDoodle import *

    display3d = Display3D.getDisplayService()
    PygameDisplay.setDisplayService(display3d[0])
   
    TEXT = datasource().activate()
    TICKER1 = Ticker(size = (150, 150), render_left = 0, render_right=350, render_top=0, render_bottom=250).activate()
    TICKER1WRAPPER = PygameWrapperPlane(wrap=TICKER1, pos=Vector(-4, 1,-15), name="1st Wrapper Plane").activate()
    TICKER2 = Ticker(size = (150, 150), render_left = 0, render_right=350, render_top=0, render_bottom=250).activate()
    TICKER2WRAPPER = PygameWrapperPlane(wrap=TICKER2, pos=Vector(4, 1,-15),  name="2nd Wrapper Plane").activate()
    BUTTON = Button(caption="This button...",msg="...can be moved AND activated!", key=pygame.K_SPACE).activate()
    BUTTONWRAPPER = PygameWrapperPlane(wrap=BUTTON, pos=Vector(0, 0,-10),  name="Button Wrapper Plane").activate()
    BUTTON1 = Button(caption="This button...",msg="...also!", key=pygame.K_LCTRL).activate()
    BUTTONWRAPPER1 = PygameWrapperPlane(wrap=BUTTON1, pos=Vector(0, 0.4,-10),  name="Button1 Wrapper Plane").activate()
    MAGNADOODLE = MagnaDoodle(size=(200,200)).activate()
    MAGNADOODLEWRAPPER = PygameWrapperPlane(wrap=MAGNADOODLE, pos=Vector(-2, -2,-15),  name="Magna Doodle Wrapper Plane").activate() 
    ECHO = consoleEchoer().activate()
    CUBE = SimpleCube(pos = Vector(2,-2,-10)).activate()
Пример #17
0
            for x in text.split():
                self.send(x, "outbox")
                yield 1

    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Kamaelia.Util.Graphline import Graphline
    from Kamaelia.UI.Pygame.Ticker import Ticker
    from Kamaelia.UI.Pygame.Button import Button
    from SimpleCube import *
    import sys
    sys.path.append("../pygame/")
    from MagnaDoodle import *
    sys.path.append("../../MPS/Systems/Paint/")
    from Paint import *

    Display3D.getDisplayService()[0].overridePygameDisplay()

    TEXT = datasource().activate()
    TICKER1 = Ticker(position=(400, 300),
                     render_left=0,
                     render_right=350,
                     render_top=0,
                     render_bottom=250).activate()
    TICKER1WRAPPER = PygameWrapperPlane(wrap=TICKER1,
                                        pos=Vector(-2, 1, -10),
                                        name="1st Wrapper Plane").activate()
    TICKER2 = Ticker(position=(400, 300),
                     render_left=0,
                     render_right=350,
                     render_top=0,
                     render_bottom=250).activate()