Beispiel #1
0
    def mousePressed(self, event):
        print 'got mouse pressed event from', event.sender
        if (not self.enabled
                or event.modifiers.isDown(KeyboardButton.control())):
            print 'short circuiting'
            return

        shiftDown = event.modifiers.isDown(KeyboardButton.shift())
        if event.sender == self.engine:
            if not shiftDown:
                self.deselectAll()
        else:
            self._setEditMode(event.modifiers.isDown(MouseButton.three()))
            node = event.sender
            if shiftDown:
                # Shift-clicking a node toggles its selected state.
                if node.isSelected():
                    self.selection.remove(node)
                    node.setSelected(False)
                else:
                    self.selection.append(node)
                    node.setSelected(True)
            elif len(self.selection) == 1 and node.isSelected():
                # This is already the only node selected.
                return
            else:
                print 'selecting', node
                self.deselectAll()
                node.setSelected(True)
                self.selection.append(node)
        if self.editMode:
            self.handle.setClients([NodePath(n) for n in self.selection],
                                   self.getSelectionCenter())
        else:
            self.handle.setClients([])
    def mousePressed(self, event):
        print 'got mouse pressed event from', event.sender
        if (not self.enabled or
                event.modifiers.isDown(KeyboardButton.control())):
            print 'short circuiting'
            return

        shiftDown = event.modifiers.isDown(KeyboardButton.shift())
        if event.sender == self.engine:
            if not shiftDown:
                self.deselectAll()
        else: 
            self._setEditMode(event.modifiers.isDown(MouseButton.three()))
            node = event.sender
            if shiftDown:
                # Shift-clicking a node toggles its selected state.
                if node.isSelected():
                    self.selection.remove(node)
                    node.setSelected(False)
                else:
                    self.selection.append(node)
                    node.setSelected(True)
            elif len(self.selection) == 1 and node.isSelected():
                # This is already the only node selected.
                return
            else:
                print 'selecting', node
                self.deselectAll()
                node.setSelected(True)
                self.selection.append(node)
        if self.editMode:
            self.handle.setClients([NodePath(n) for n in self.selection],
                    self.getSelectionCenter())
        else:
            self.handle.setClients([])
Beispiel #3
0
 def mouseReleaseEvent(self, event):
     btn = event.button()
     if btn == QtCore.Qt.LeftButton:
         self.inputDevice.buttonUp(MouseButton.one())
     elif btn == QtCore.Qt.MiddleButton:
         self.inputDevice.buttonUp(MouseButton.two())
     elif btn == QtCore.Qt.RightButton:
         self.inputDevice.buttonUp(MouseButton.three())
     QtWidgets.QWidget.mouseReleaseEvent(self, event)
Beispiel #4
0
 def update_camera(self, task):
     if base.mouseWatcherNode.is_button_down(MouseButton.three()):
         new_x = base.mouseWatcherNode.getMouseX()
         new_y = base.mouseWatcherNode.getMouseY()
         x = self.last_mouse[0] - new_x
         y = self.last_mouse[1] - new_y
         self.last_mouse = [new_x, new_y]
         pivot = self.cam_pivot
         pivot.set_z(pivot.get_z() + (y * self.move_speed))
         pivot.set_h(pivot.get_h() + (x * (self.move_speed * 640)))
     else:
         self.last_mouse = [0, 0]
     return task.cont
Beispiel #5
0
    def __init__(self):
        ShowBase.__init__(self)

        # Initialise the keyboard task.
        self.disableMouse()
        self.mouse_anchor = None
        self.accept("escape", sys.exit)
        m = self.win.getKeyboardMap()
        self.key = {
            "forward": m.getMappedButton("w"),
            "backward": m.getMappedButton("s"),
            "left": m.getMappedButton("a"),
            "right": m.getMappedButton("d"),
            "mouse1": MouseButton.one(),
            "mouse3": MouseButton.three()
        }
        self.taskMgr.add(self.move, "moveTask")
        self.reset_acceleration()
Beispiel #6
0
def test_mousebutton():
    btns = [
        MouseButton.one(),
        MouseButton.two(),
        MouseButton.three(),
        MouseButton.four(),
        MouseButton.five()
    ]

    for i, btn in enumerate(btns):
        assert MouseButton.button(i) == btn
        assert MouseButton.is_mouse_button(btn)

    assert MouseButton.button(5) == ButtonHandle.none()

    assert MouseButton.is_mouse_button(MouseButton.wheel_up())
    assert MouseButton.is_mouse_button(MouseButton.wheel_down())
    assert MouseButton.is_mouse_button(MouseButton.wheel_left())
    assert MouseButton.is_mouse_button(MouseButton.wheel_right())
Beispiel #7
0
    def updateStateTask(self, task):
        if base.mouseWatcherNode.hasMouse():
            if base.mouseWatcherNode.isButtonDown(MouseButton.three()):
                if not self.wasClicked:
                    self.wasClicked = True
            else:
                if self.wasClicked:
                    self.wasClicked = False
                    X, Y, Z = self.positions["drone"]
                    new_position = (X, Y, Z+0.05)
                    self.positions["drone"] = new_position
                    self.drone.setPos(*new_position)
            if base.mouseWatcherNode.isButtonDown(MouseButton.one()):
                if not self.wasClicked:
                    self.wasClicked = True
            else:
                if self.wasClicked:
                    self.wasClicked = False
                    X, Y, Z = self.positions["drone"]
                    new_position = (X, Y, Z-0.05)
                    self.positions["drone"] = new_position
                    self.drone.setPos(*new_position)

        return Task.cont
Beispiel #8
0
    def __init__(self, mainWin=base.win, mainCam=base.cam, scene=render):
        self.lastMousePos = Vec2(-2, -2)
        self.lastId = 0
        self.pressedNode = None
        self.mDownId = 0
        self.idStack = range(1, 256)
        self.idTable = {}
        self.aspectRatio = 1
        self.checkCursorTask = Task(self.checkCursor, 'checkCursorTask')
        self.enabled = True
        self.mouseListeners = []

        self.mainCam = mainCam
        mainCam.node().setCameraMask(BitMask32(1))

        tempnode = NodePath(PandaNode('temp node'))
        tempnode.setShaderAuto()
        tempnode.setShaderInput('hi_id', Vec4(0, 0, 0, 0), 2)
        mainCam.node().setInitialState(tempnode.getState())

        # Set up a node with the silhouetteGen shader. We'll apply this node's
        # state to custom cameras below.
        tempnode.setShader(loader.loadShader('silhouetteGen.sha'), 100)
        tempnode.setShaderInput('hi_id', Vec4(0, 0, 0, 0), 0)
        tempnode.setAntialias(AntialiasAttrib.MNone, 100)
        tempnode.setBin('inactive', 0, 1)
        initialState = tempnode.getState()
        tempnode.setBin('opaque', 0, 1)
        selnodeState = tempnode.getState()

        # We'll be using this a few times, so make an easy name for it.
        mainLens = mainCam.node().getLens()

        # Set up a buffer to which we draw a silhouette of any geometry that
        # we want to outline. We draw the outline by applying a Sobel edge
        # detection shader to the contents of this buffer.
        silhouetteBuffer = mainWin.makeTextureBuffer('silhouetteBuffer', 0, 0)
        silhouetteBuffer.setClearColor(Vec4(0, 0, 0, 1))
        self.silhouetteBuffer = silhouetteBuffer
        silhouetteCamera = base.makeCamera(silhouetteBuffer, lens=mainLens)
        silhouetteCamera.node().setScene(scene)
        silhouetteCamera.node().setInitialState(initialState)
        silhouetteCamera.node().setTagState('sel', selnodeState)
        silhouetteCamera.node().setTagStateKey('sel')
        silhouetteCamera.node().setCameraMask(BitMask32(8))

        tempnode.setShader(loader.loadShader('mousePicker.sha'), 100)
        selnodeState = tempnode.getState()
        tempnode.setBin('inactive', 0, 1)
        initialState = tempnode.getState()

        # Set up a 1-by-1 buffer to which we'll just render the pixel under
        # the mouse.
        selectBuffer = mainWin.makeTextureBuffer('selectBuffer', 1, 1)
        selectBuffer.setClearColor(Vec4(0, 0, 0, 1))
        self.selectBuffer = selectBuffer
        selectLens = PerspectiveLens()
        selectLens.setNearFar(mainLens.getNear(), mainLens.getFar())
        selectLens.setFocalLength(mainLens.getFocalLength())
        selectCamera = base.makeCamera(selectBuffer, lens=selectLens)
        selectCamera.node().setScene(scene)
        selectCamera.node().setInitialState(initialState)
        selectCamera.node().setTagState('sel', selnodeState)
        selectCamera.node().setTagStateKey('sel')
        selectCamera.node().setCameraMask(BitMask32(16))
        self.selectLens = selectLens

        self.selectTex = selectBuffer.getTexture()
        self.selectTex.makeRamImage()
        self.gsg = mainWin.getGsg()

        # Set up a texture card to render the silhouette texture with the
        # Sobel shader, which will draw the edges of the silhouettes.
        silhouetteCard = silhouetteBuffer.getTextureCard()
        silhouetteCard.setTransparency(1)
        inkGen = loader.loadShader('sobel.sha')
        silhouetteCard.setShader(inkGen)
        silhouetteCard.setShaderInput('separation', 0.001, 0)
        silhouetteCard.reparentTo(render2d)
        self.silhouetteCard = silhouetteCard

        self.accept(mainWin.getWindowEvent(), self.windowEventHandler)
        self.accept('mouse1', self.mouseDownHandler, ['l'])
        self.accept('mouse1-up', self.mouseUpHandler, ['l'])
        self.accept('mouse3', self.mouseDownHandler, ['r'])
        self.accept('mouse3-up', self.mouseUpHandler, ['r'])
        self.buttonWatcher = ButtonWatcher([
            KeyboardButton.shift(),
            KeyboardButton.control(),
            MouseButton.one(),
            MouseButton.three(),
        ])

        CameraController.getInstance().addEventHandler(EVT_CAMERA_MODE,
                                                       self._cameraModeHandler)

        self.enable(False)
Beispiel #9
0
class DialogMask(DirectButton):
    '''used to generate a full-screen mask to prevent button-clicking below the focused window/dialog
    Added some tricks to make panda3d mouse events still available
    '''
    B1PRESS = PGButton.getPressPrefix() + MouseButton.one().getName() + '-'
    B2PRESS = PGButton.getPressPrefix() + MouseButton.two().getName() + '-'
    B3PRESS = PGButton.getPressPrefix() + MouseButton.three().getName() + '-'
    B4PRESS = PGButton.getPressPrefix() + MouseButton.four().getName() + '-'
    B5PRESS = PGButton.getPressPrefix() + MouseButton.five().getName() + '-'
    WHEELUP = PGButton.getReleasePrefix() + MouseButton.wheelUp().getName(
    ) + '-'
    WHEELDOWN = PGButton.getReleasePrefix() + MouseButton.wheelDown().getName(
    ) + '-'
    WHEELLEFT = PGButton.getReleasePrefix() + MouseButton.wheelLeft().getName(
    ) + '-'
    WHEELRIGHT = PGButton.getReleasePrefix() + MouseButton.wheelRight(
    ).getName() + '-'
    B1RELEASE = PGButton.getReleasePrefix() + MouseButton.one().getName() + '-'
    B2RELEASE = PGButton.getReleasePrefix() + MouseButton.two().getName() + '-'
    B3RELEASE = PGButton.getReleasePrefix() + MouseButton.three().getName(
    ) + '-'
    B4RELEASE = PGButton.getReleasePrefix() + MouseButton.four().getName(
    ) + '-'
    B5RELEASE = PGButton.getReleasePrefix() + MouseButton.five().getName(
    ) + '-'

    def __init__(self):
        DirectButton.__init__(self,
                              parent=aspect2d,
                              frameColor=(1, 1, 1, 0),
                              relief=DGG.FLAT,
                              commandButtons=[])
        self.accept('window-event', self.windowResize)
        self.windowResize(None)
        #trick: make this re-throw mouse events
        self.bind(self.B1PRESS, self.rethrowEvent, ['mouse1'])
        self.bind(self.B2PRESS, self.rethrowEvent, ['mouse2'])
        self.bind(self.B3PRESS, self.rethrowEvent, ['mouse3'])
        self.bind(self.B4PRESS, self.rethrowEvent, ['mouse4'])
        self.bind(self.B5PRESS, self.rethrowEvent, ['mouse5'])

        self.bind(self.WHEELUP, self.rethrowEvent, ['wheel_up'])
        self.bind(self.WHEELDOWN, self.rethrowEvent, ['wheel_down'])
        self.bind(self.WHEELLEFT, self.rethrowEvent, ['wheel_left'])
        self.bind(self.WHEELRIGHT, self.rethrowEvent, ['wheel_right'])

        self.bind(self.B1RELEASE, self.rethrowEvent, ['mouse1-up'])
        self.bind(self.B2RELEASE, self.rethrowEvent, ['mouse2-up'])
        self.bind(self.B3RELEASE, self.rethrowEvent, ['mouse3-up'])
        self.bind(self.B4RELEASE, self.rethrowEvent, ['mouse4-up'])
        self.bind(self.B5RELEASE, self.rethrowEvent, ['mouse5-up'])

    def windowResize(self, arg):
        #fill the screen
        aspect = base.getAspectRatio()
        if aspect > 1:
            self['frameSize'] = (-aspect, aspect, -1, 1)
        elif aspect:
            hh = 1.0 / aspect
            self['frameSize'] = (-1, 1, -hh, hh)

    def setCommandButtons(self, *args, **kwargs):
        #inherited
        pass

    def rethrowEvent(self, sevent, event):
        messenger.send(sevent)

    def destroy(self):
        self.ignoreAll()
        DirectButton.destroy(self)
Beispiel #10
0
    def __init__(self, name):
        NodePath.__init__(self, name)
        DirectObject.__init__(self)
        self.setPythonTag('Sprite', self)

        global SpriteCounter
        SpriteCounter += 1
        self.__id = int(SpriteCounter)

        #- Use PGItem to detect mouse and keyboard input via PGTop (eg, aspect2d, pixel2d, etc)
        self.__pgItem = PGItem(name)
        self.__pgItem.setActive(True)
        self.__pgItemNp = self.attachNewNode(self.__pgItem)

        #- Use TextNode to generate both text and cards for displaying background images
        self.__textNode = TextNode(name)
        self.__textNodeNp = None
        #self.__textNodeNp = self.attachNewNode(self.__textNode)
        #self.__textNode.setCardDecal(True) #- This is what we would do, should Sprite support being non-under PGTop

        self.accept(self.__pgItem.getPressEvent(MouseButton.one()),
                    self.__onMouse, [Sprite.MouseLeftDown])
        self.accept(self.__pgItem.getPressEvent(MouseButton.two()),
                    self.__onMouse, [Sprite.MouseCenterDown])
        self.accept(self.__pgItem.getPressEvent(MouseButton.three()),
                    self.__onMouse, [Sprite.MouseRightDown])
        self.accept(self.__pgItem.getPressEvent(MouseButton.four()),
                    self.__onMouse, [Sprite.MouseFourDown])
        self.accept(self.__pgItem.getPressEvent(MouseButton.five()),
                    self.__onMouse, [Sprite.MouseFiveDown])

        self.accept(self.__pgItem.getReleaseEvent(MouseButton.one()),
                    self.__onMouse, [Sprite.MouseLeftUp])
        self.accept(self.__pgItem.getReleaseEvent(MouseButton.two()),
                    self.__onMouse, [Sprite.MouseCenterUp])
        self.accept(self.__pgItem.getReleaseEvent(MouseButton.three()),
                    self.__onMouse, [Sprite.MouseRightUp])
        self.accept(self.__pgItem.getReleaseEvent(MouseButton.four()),
                    self.__onMouse, [Sprite.MouseFourUp])
        self.accept(self.__pgItem.getReleaseEvent(MouseButton.five()),
                    self.__onMouse, [Sprite.MouseFiveUp])

        self.accept(self.__pgItem.getPressEvent(MouseButton.wheelDown()),
                    self.__onMouse, [Sprite.MouseScrollDown])
        self.accept(self.__pgItem.getPressEvent(MouseButton.wheelUp()),
                    self.__onMouse, [Sprite.MouseScrollUp])

        self.accept(self.__pgItem.getEnterEvent(), self.__onMouse,
                    [Sprite.MouseEnter])
        self.accept(self.__pgItem.getExitEvent(), self.__onMouse,
                    [Sprite.MouseExit])
        self.accept(self.__pgItem.getWithinEvent(), self.__onMouse,
                    [Sprite.MouseWithin])
        self.accept(self.__pgItem.getWithoutEvent(), self.__onMouse,
                    [Sprite.MouseWithout])

        self.__beastDebug = ConfigVariableBool('beast-debug', False).getValue()

        self.__mouseInside = False
        self.__disabled = False

        #- Setup state configuration
        self.__lastStateOptions = None
        self.__state = None
        self.__states = {
            'default': SpriteOptions(),
            'hover': SpriteOptions(),
            'click': SpriteOptions(),
            'focus': SpriteOptions(),
            'disabled': SpriteOptions(),
        }
        self.updateToState('default')
    def __init__(self, mainWin=base.win, mainCam=base.cam, scene=render):
        self.lastMousePos = Vec2(-2, -2)
        self.lastId = 0
        self.pressedNode = None
        self.mDownId = 0
        self.idStack = range(1, 256)
        self.idTable = {}
        self.aspectRatio = 1
        self.checkCursorTask = Task(self.checkCursor, 'checkCursorTask')
        self.enabled = True
        self.mouseListeners = []

        self.mainCam = mainCam
        mainCam.node().setCameraMask(BitMask32(1))

        tempnode = NodePath(PandaNode('temp node'))
        tempnode.setShaderAuto()
        tempnode.setShaderInput('hi_id', Vec4(0, 0, 0, 0), 2)
        mainCam.node().setInitialState(tempnode.getState())
        
        # Set up a node with the silhouetteGen shader. We'll apply this node's
        # state to custom cameras below.
        tempnode.setShader(loader.loadShader('silhouetteGen.sha'), 100)
        tempnode.setShaderInput('hi_id', Vec4(0, 0, 0, 0), 0)
        tempnode.setAntialias(AntialiasAttrib.MNone, 100)
        tempnode.setBin('inactive', 0, 1)
        initialState = tempnode.getState()
        tempnode.setBin('opaque', 0, 1)
        selnodeState = tempnode.getState()

        # We'll be using this a few times, so make an easy name for it.
        mainLens = mainCam.node().getLens()

        # Set up a buffer to which we draw a silhouette of any geometry that
        # we want to outline. We draw the outline by applying a Sobel edge
        # detection shader to the contents of this buffer.
        silhouetteBuffer = mainWin.makeTextureBuffer('silhouetteBuffer', 0, 0)
        silhouetteBuffer.setClearColor(Vec4(0, 0, 0, 1))
        self.silhouetteBuffer = silhouetteBuffer
        silhouetteCamera = base.makeCamera(silhouetteBuffer, lens=mainLens)
        silhouetteCamera.node().setScene(scene)
        silhouetteCamera.node().setInitialState(initialState)
        silhouetteCamera.node().setTagState('sel', selnodeState)
        silhouetteCamera.node().setTagStateKey('sel')
        silhouetteCamera.node().setCameraMask(BitMask32(8))

        tempnode.setShader(loader.loadShader('mousePicker.sha'), 100)
        selnodeState = tempnode.getState()
        tempnode.setBin('inactive', 0, 1)
        initialState = tempnode.getState()

        # Set up a 1-by-1 buffer to which we'll just render the pixel under
        # the mouse.
        selectBuffer = mainWin.makeTextureBuffer('selectBuffer', 1, 1)
        selectBuffer.setClearColor(Vec4(0, 0, 0, 1))
        self.selectBuffer = selectBuffer
        selectLens = PerspectiveLens()
        selectLens.setNearFar(mainLens.getNear(), mainLens.getFar())
        selectLens.setFocalLength(mainLens.getFocalLength())
        selectCamera = base.makeCamera(selectBuffer, lens=selectLens)
        selectCamera.node().setScene(scene)
        selectCamera.node().setInitialState(initialState)
        selectCamera.node().setTagState('sel', selnodeState)
        selectCamera.node().setTagStateKey('sel')
        selectCamera.node().setCameraMask(BitMask32(16))
        self.selectLens = selectLens

        self.selectTex = selectBuffer.getTexture()
        self.selectTex.makeRamImage()
        self.gsg = mainWin.getGsg()

        # Set up a texture card to render the silhouette texture with the
        # Sobel shader, which will draw the edges of the silhouettes.
        silhouetteCard = silhouetteBuffer.getTextureCard()
        silhouetteCard.setTransparency(1)
        inkGen = loader.loadShader('sobel.sha')
        silhouetteCard.setShader(inkGen)
        silhouetteCard.setShaderInput('separation', 0.001, 0)
        silhouetteCard.reparentTo(render2d)
        self.silhouetteCard = silhouetteCard
        
        self.accept(mainWin.getWindowEvent(), self.windowEventHandler)
        self.accept('mouse1', self.mouseDownHandler, ['l'])
        self.accept('mouse1-up', self.mouseUpHandler, ['l'])
        self.accept('mouse3', self.mouseDownHandler, ['r'])
        self.accept('mouse3-up', self.mouseUpHandler, ['r'])
        self.buttonWatcher = ButtonWatcher([
                KeyboardButton.shift(),
                KeyboardButton.control(),
                MouseButton.one(),
                MouseButton.three(),
            ])
        
        CameraController.getInstance().addEventHandler(EVT_CAMERA_MODE,
                self._cameraModeHandler)
        
        self.enable(False)
Beispiel #12
0
class _beastGlobals(DirectObject):
    enter = PGButton.getEnterPrefix()
    exit = PGButton.getExitPrefix()
    within = PGButton.getWithinPrefix()
    without = PGButton.getWithoutPrefix()
    leftPress = PGButton.getPressPrefix() + MouseButton.one().getName() + '-'
    centerPress = PGButton.getPressPrefix() + MouseButton.two().getName() + '-'
    rightPress = PGButton.getPressPrefix() + MouseButton.three().getName(
    ) + '-'
    leftClick = PGButton.getClickPrefix() + MouseButton.one().getName() + '-'
    centerClick = PGButton.getClickPrefix() + MouseButton.two().getName() + '-'
    rightClick = PGButton.getClickPrefix() + MouseButton.three().getName(
    ) + '-'
    leftRelease = PGButton.getReleasePrefix() + MouseButton.one().getName(
    ) + '-'
    centerRelease = PGButton.getReleasePrefix() + MouseButton.two().getName(
    ) + '-'
    rightRelease = PGButton.getReleasePrefix() + MouseButton.three().getName(
    ) + '-'
    wheelUp = PGButton.getPressPrefix() + MouseButton.wheelUp().getName() + '-'
    wheelDown = PGButton.getPressPrefix() + MouseButton.wheelDown().getName(
    ) + '-'

    def __init__(self, taskMgr, base):
        DirectObject.__init__(self)
        self.taskMgr = taskMgr
        self.base = base
        self.setupPoint2d()

        self.beastPointSize = ConfigVariableDouble('beast-point-size',
                                                   1.0).getValue()
        self.beastPointSizeAuto = ConfigVariableBool('beast-point-size-auto',
                                                     False).getValue()
        self.beastRenderBruteForce = ConfigVariableBool(
            'beast-render-brute-force', False).getValue()
        self.beastRenderDebug = ConfigVariableBool('beast-render-debug',
                                                   False).getValue()

        self.setPointSize(self.beastPointSize, update=False)
        self.setPointSizeAuto(self.beastPointSizeAuto, update=False)
        self.accept('window-event', self.windowEvent)
        self.originalResolution = (float(self.base.win.getXSize()),
                                   float(self.base.win.getYSize()))

        self.buffer = None
        #- If bruteForce == False then we will setup beast frame rendering system
        if self.beastRenderBruteForce == False:
            self._setupTextureBuffer()
            taskMgr.add(self.renderTask, 'beastRender', sort=-100000000)

        self.windowEvent()

    def _setupTextureBuffer(self):
        if self.buffer:
            self.card.remove()
            self.camera2d.remove()
            self.base.graphicsEngine.removeWindow(self.buffer)

        self.buffer = self.base.win.makeTextureBuffer("beastBuffer",
                                                      self.base.win.getXSize(),
                                                      self.base.win.getYSize())
        self.buffer.setActive(True)
        self.buffer.getTexture().setOrigFileSize(self.base.win.getXSize(),
                                                 self.base.win.getYSize())

        self.camera2d = self.base.makeCamera2d(self.buffer)
        self.camera2d.reparentTo(self.point2d.getParent())

        cm = CardMaker('beastDisplay')
        cm.setFrame(-1, 1, -1, 1)
        cm.setUvRange(self.buffer.getTexture())
        self.card = self.base.render2d.attachNewNode(cm.generate())
        self.card.setTransparency(TransparencyAttrib.MAlpha)
        self.card.setTexture(self.buffer.getTexture())

    def renderTask(self, task):
        if self.point2d.getRequiresUpdate():
            debug = self.beastRenderBruteForce == False and self.beastRenderDebug == True
            if debug:
                print ':beast::render'
            self.buffer.setActive(True)
            self.point2d.setRequiresUpdate(False)
        else:
            self.buffer.setActive(False)
        return task.cont

    def setupPoint2d(self):
        fakeRender2d = NodePath('render2d')
        fakeRender2d.setDepthTest(False)
        fakeRender2d.setDepthWrite(False)
        fakeRender2d.setMaterialOff(True)
        fakeRender2d.setTwoSided(True)

        self.point2d = beastNodePath(PGTop('point2d'))
        self.point2d.reparentTo(fakeRender2d)
        self.point2d.node().setMouseWatcher(self.base.mouseWatcherNode)

        self.p2dTopLeft = self.point2d.attachNewNode('p2dTopLeft')
        self.p2dTopRight = self.point2d.attachNewNode('p2dTopRight')
        self.p2dTopCenter = self.point2d.attachNewNode('p2dTopCenter')

        self.p2dCenterLeft = self.point2d.attachNewNode('p2dCenterLeft')
        self.p2dCenterRight = self.point2d.attachNewNode('p2dCenterRight')

        self.p2dBottomLeft = self.point2d.attachNewNode('p2dBottomLeft')
        self.p2dBottomRight = self.point2d.attachNewNode('p2dBottomRight')
        self.p2dBottomCenter = self.point2d.attachNewNode('p2dBottomCenter')

    def getMousePos(self):
        md = self.win.getPointer(0)
        x = md.getX()
        y = md.getY()
        p = self.point2d.getRelativePoint(self.pixel2d, (x, 0, -y))
        return p.getX(), p.getZ()

    def hasMouse(self):
        return self.mouseWatcherNode.hasMouse()

    def getAbsolutePointSize(self):
        fakePointSize = None
        if self.getPointSizeAuto():
            oldX, oldY = self.originalResolution
            newX, newY = float(self.win.getXSize()), float(self.win.getYSize())
            ratio = newY / oldY
            fakePointSize = ratio

        if self.getPointSizeAuto():
            ps = fakePointSize
        else:
            ps = self.getPointSize()
        return ps

    def windowEvent(self, win=None):
        ps = self.getAbsolutePointSize()
        x = self.base.win.getXSize()
        y = self.base.win.getYSize()

        xActual = (x / ps)
        yActual = (y / ps)
        self.point2d.setScale(2.0 / xActual, 1.0, 2.0 / yActual)

        #- Finish actuals
        self.p2dTopLeft.setPos(-xActual / 2.0, 1.0, yActual / 2.0)
        self.p2dTopRight.setPos(xActual / 2.0, 1.0, yActual / 2.0)
        self.p2dTopCenter.setPos(0, 1.0, yActual / 2.0)

        self.p2dCenterLeft.setPos(-xActual / 2.0, 1.0, 0.0)
        self.p2dCenterRight.setPos(xActual / 2.0, 1.0, 0.0)

        self.p2dBottomLeft.setPos(-xActual / 2.0, 1.0, -yActual / 2.0)
        self.p2dBottomRight.setPos(xActual / 2.0, 1.0, -yActual / 2.0)
        self.p2dBottomCenter.setPos(0, 1.0, -yActual / 2.0)

        if self.beastRenderBruteForce == False:
            debug = self.beastRenderBruteForce == False and self.beastRenderDebug == True
            bx = self.buffer.getTexture().getOrigFileXSize()
            by = self.buffer.getTexture().getOrigFileYSize()
            cx = self.base.win.getXSize()
            cy = self.base.win.getYSize()
            if bx != cx or by != by:
                if debug:
                    print ':beast::render::resolutionChanged from(%s, %s) to(%s, %s)' % (
                        bx, by, cx, cy)
                self._setupTextureBuffer()
        messenger.send('beast.windowEvent')

    ''' Point size '''

    def getPointSize(self):
        return self.pointSize

    def setPointSize(self, value, update=True):
        self.pointSize = float(value)
        if update:
            self.update()

    ''' Point size auto resolution '''

    def setPSAutoResolution(self, x, y):
        self.originalResolution = (float(base.win.getXSize()),
                                   float(base.win.getYSize()))

    def getPSAutoResolution(self):
        return self.originalResolution

    ''' Point size auto '''

    def setPointSizeAuto(self, value, update=True):
        self.pointSizeAuto = bool(value)
        if update:
            self.update()

    def getPointSizeAuto(self):
        return self.pointSizeAuto

    def togglePointSizeAuto(self):
        if self.getPointSizeAuto():
            self.setPointSizeAuto(False)
        else:
            self.setPointSizeAuto(True)

    ''' Data folder '''

    def getDataFolder(self):
        if sys.platform.startswith('win'):
            slash = '\\'
        else:
            slash = '/'
        point = __file__.rindex(slash)
        f = __file__[:point] + slash + 'data' + slash
        return Filename().fromOsSpecific(f).getFullpath()

    ''' Destroy beast now '''

    def destroy(self):
        self.ignoreAll()