Example #1
0
 def interp(self, t, c2):
     """
     Returns a Color based on a time t between two colors
     parameters:
     t: current time
     c2: transition color
     """
     return Color(StaticNumerics.staticLerp(t, self.r, c2.r),
                  StaticNumerics.staticLerp(t, self.g, c2.g),
                  StaticNumerics.staticLerp(t, self.b, c2.b),
                  StaticNumerics.staticLerp(t, self.a, c2.a))
Example #2
0
def initEvents():
    base.disableMouse()
    directObj = PandaGlobals.direct
    directObj.accept("mouse1", lambda: postEvent("mouse1"))
    directObj.accept("mouse3", lambda: postEvent("mouse3"))
    directObj.accept("mouse1-up", lambda: postEvent("mouse1-up"))
    directObj.accept("mouse3-up", lambda: postEvent("mouse3-up"))
    PandaGlobals.mousePos = StaticNumerics.SP2(0, 0)
    PandaGlobals.lbutton = False
    PandaGlobals.rbutton = False
    PandaGlobals.lbuttonPull = StaticNumerics.SP2(0, 0)
    PandaGlobals.rbuttonPull = StaticNumerics.SP2(0, 0)
Example #3
0
def pollGUI():
    if base.mouseWatcherNode.hasMouse():
        lbp = pythonfrp.Globals.events.has_key("mouse1")
        rbp = pythonfrp.Globals.events.has_key("mouse3")
        lbr = pythonfrp.Globals.events.has_key("mouse1-up")
        rbr = pythonfrp.Globals.events.has_key("mouse3-up")
        if lbp:
            PandaGlobals.lbutton = True
        if rbp:
            PandaGlobals.rbutton = True
        if lbr:
            PandaGlobals.lbutton = False
        if rbr:
            PandaGlobals.rbutton = False
        mpos = base.mouseWatcherNode.getMouse(
        )  #get the mouse position in Panda3D form
        lastMousePos = PandaGlobals.mousePos
        PandaGlobals.mousePos = StaticNumerics.SP2(mpos.getX(), mpos.getY())
        if PandaGlobals.lbutton and lastMousePos is not None:
            PandaGlobals.lbuttonPull = PandaGlobals.lbuttonPull + PandaGlobals.mousePos - lastMousePos
        if PandaGlobals.rbutton and lastMousePos is not None:
            PandaGlobals.rbuttonPull = PandaGlobals.rbuttonPull + PandaGlobals.mousePos - lastMousePos
        # If a left / right mouse click has happened, ask Panda which model was clicked on.  Post an event
        # if there is a model where the mouse clicked
        if lbp or rbp:
            m = Click.findClickedModels()
            if m is not None:
                if pythonfrp.Globals.events.has_key("mouse1"):
                    pythonfrp.Globals.events[m + "-leftclick"] = True
                else:
                    pythonfrp.Globals.events[m + "-rightclick"] = True
Example #4
0
 def __init__(self, text, position=None, size=1, name='Button', e=True):
     if position is None:
         position = StaticNumerics.SP2(-.95, Globals.nextNW2dY)
         Globals.nextNW2dY = Globals.nextNW2dY - .1
     self._name = name + str(Globals.nextModelId)
     Globals.nextModelId += 1
     self._click = Factory.eventObserver(self._name, e)
     self._pandaModel = DirectButton(
         text=text,
         pos=(position.x, 0, position.y),
         scale=size * 0.1,
         command=lambda: Externals.postEvent(self._name))