Example #1
0
    def __init__(self, name):
        FSM.__init__(self, name)
        PandaNode.__init__(self, name)
        DirectObject.__init__(self)

        self.active = True

        self.lastClickState = PGButton.SReady
        self.clickState = PGButton.SReady

        self.__hovering = False

        self.clickEvent = ''
        self.clickExtraArgs = []

        self.contents = NodePath.anyPath(self).attachNewNode('contents')

        # Create a MouseWatcherRegion:
        self.regionName = self.getUniqueName() + '-region'
        self.region = MouseWatcherRegion(self.regionName, 0, 0, 0, 0)
        base.mouseWatcherNode.addRegion(self.region)

        # Accept the mouse events:
        enterPattern = base.mouseWatcherNode.getEnterPattern()
        leavePattern = base.mouseWatcherNode.getLeavePattern()
        buttonDownPattern = base.mouseWatcherNode.getButtonDownPattern()
        buttonUpPattern = base.mouseWatcherNode.getButtonUpPattern()
        self.accept(enterPattern.replace('%r', self.regionName), self.__handleMouseEnter)
        self.accept(leavePattern.replace('%r', self.regionName), self.__handleMouseLeave)
        self.accept(buttonDownPattern.replace('%r', self.regionName), self.__handleMouseDown)
        self.accept(buttonUpPattern.replace('%r', self.regionName), self.__handleMouseUp)
Example #2
0
    def __init__(self, name):
        FSM.__init__(self, name)
        PandaNode.__init__(self, name)
        DirectObject.__init__(self)

        self.active = True

        self.lastClickState = PGButton.SReady
        self.clickState = PGButton.SReady

        self.__hovering = False

        self.clickEvent = ''
        self.clickExtraArgs = []

        self.contents = NodePath.anyPath(self).attachNewNode('contents')

        # Create a MouseWatcherRegion:
        self.regionName = self.getUniqueName() + '-region'
        self.region = MouseWatcherRegion(self.regionName, 0, 0, 0, 0)
        base.mouseWatcherNode.addRegion(self.region)

        # Accept the mouse events:
        enterPattern = base.mouseWatcherNode.getEnterPattern()
        leavePattern = base.mouseWatcherNode.getLeavePattern()
        buttonDownPattern = base.mouseWatcherNode.getButtonDownPattern()
        buttonUpPattern = base.mouseWatcherNode.getButtonUpPattern()
        self.accept(enterPattern.replace('%r', self.regionName),
                    self.__handleMouseEnter)
        self.accept(leavePattern.replace('%r', self.regionName),
                    self.__handleMouseLeave)
        self.accept(buttonDownPattern.replace('%r', self.regionName),
                    self.__handleMouseDown)
        self.accept(buttonUpPattern.replace('%r', self.regionName),
                    self.__handleMouseUp)
Example #3
0
    def __init__(self, name):
        PandaNode.__init__(self, name)
        DirectObject.__init__(self)

        self.fsm = ClassicFSM(name, [
            State('off', self.enterOff, self.exitOff),
            State('rollover', self.enterRollover, self.exitRollover),
            State('ready', self.enterReady, self.exitReady),
            State('depressed', self.enterDepressed, self.exitDepressed),
            State('inactive', self.enterInactive, self.exitInactive)], 'off', 'off')
        self.fsm.enterInitialState()

        self.active = True
        self.lastClickState = PGButton.SReady
        self.clickState = PGButton.SReady
        self.__hovering = False
        self.clickEvent = ''
        self.clickExtraArgs = []
        self.contents = NodePath.anyPath(self).attachNewNode('contents')

        # Create a MouseWatcherRegion:
        self.regionName = self.getUniqueName() + '-region'
        self.region = MouseWatcherRegion(self.regionName, 0, 0, 0, 0)
        base.mouseWatcherNode.addRegion(self.region)

        # Accept the mouse events:
        enterPattern = base.mouseWatcherNode.getEnterPattern()
        leavePattern = base.mouseWatcherNode.getLeavePattern()
        buttonDownPattern = base.mouseWatcherNode.getButtonDownPattern()
        buttonUpPattern = base.mouseWatcherNode.getButtonUpPattern()
        self.accept(enterPattern.replace('%r', self.regionName), self.__handleMouseEnter)
        self.accept(leavePattern.replace('%r', self.regionName), self.__handleMouseLeave)
        self.accept(buttonDownPattern.replace('%r', self.regionName), self.__handleMouseDown)
        self.accept(buttonUpPattern.replace('%r', self.regionName), self.__handleMouseUp)
Example #4
0
    def __init__(self, *args, **argv):
        PandaNode.__init__(self, *args, **argv)

        self.pandaActor = Actor("panda-model",
                                {"walk": "panda-walk4"})
        self.pandaActor.reparentTo(self)
        print("self:" + str(self.is_empty()))
        self.pandaActor.loop("walk")
Example #5
0
    def __init__(self, base_object):
        PandaNode.__init__(self, "Moon")

        self.geom = GeomNode("Moon")
        self.vertexData = GeomVertexData("Basis", GeomVertexFormat.getV3cpt2(),
                                         Geom.UHStatic)
        self.vertex = GeomVertexWriter(self.vertexData, 'vertex')
        self.tex_coord = GeomVertexWriter(self.vertexData, 'texcoord')
        self.mesh = Geom(self.vertexData)
        self.tris = GeomTristrips(Geom.UHStatic)

        size = 700
        z = 1000
        dx = 0
        dy = 500

        self.vertex.addData3f(z, size + dx, -size + dy)
        self.tex_coord.addData2f(1.0, 0.0)

        self.vertex.addData3f(z, -size + dx, -size + dy)
        self.tex_coord.addData2f(1.0, 1.0)

        self.vertex.addData3f(z, size + dx, size + dy)
        self.tex_coord.addData2f(0.0, 0.0)

        self.vertex.addData3f(z, -size + dx, size + dy)
        self.tex_coord.addData2f(0.0, 1.0)

        self.tris.add_vertices(0, 1, 2, 3)

        self.tris.closePrimitive()
        self.mesh.addPrimitive(self.tris)
        self.geom.addGeom(self.mesh)

        self.node = base_object.render.attachNewNode(self.geom)
        self.node.set_p(90)
        # self.node.set_r(-90)
        # self.node.set_h(90)

        # self.node.set_p(90)
        # self.node.set_scale(500)

        # self.node.set_pos(1.7 * self.node.get_scale()[0],
        #                   0,
        #                   self.node.get_scale()[0] * 0.5)

        self.texture = base_object.loader.loadTexture(
            base_object.params("moon_texture"))
        self.node.set_texture(self.texture)

        self.node.setLightOff()
        self.node.setColorOff()
        self.node.setTransparency(True)

        self.node.set_bin('fixed', 2)
        self.node.set_depth_write(0)
        self.node.set_depth_test(0)
Example #6
0
    def __init__(self, parent, direction: MovementType):

        PandaNode.__init__(self, "arrow_path_%s" % id(self))
        DirectObject.__init__(self)

        self.parent = parent
        self.path = parent.attachNewNode(self)
        self.direction = direction
        self._instantiate_arrow()
    def __init__(self, name, patch):
        PandaNode.__init__(self, name)

        self.patch = patch

        self.wantReflect = False
        self.wantColor = False
        self.wantNormal = False
        self.wantUv = False
Example #8
0
 def __init__(self, name, engine=None):
     PandaNode.__init__(self, name)
     self.path = NodePath(self)
     self.mouseListeners = []
     self.hi_id = Vec4()
     if engine == None:
         engine = SelectionEngine.getDefault()
     self.engine = engine
     self.engine.register(self)
     self.path.setTag('sel', 'sel')
Example #9
0
 def __init__(self, name, engine=None):
     PandaNode.__init__(self, name)
     self.path = NodePath(self)
     self.mouseListeners = []
     self.hi_id = Vec4()
     if engine == None:
         engine = SelectionEngine.getDefault()
     self.engine = engine
     self.engine.register(self)
     self.path.setTag('sel', 'sel')
Example #10
0
    def __init__(self, parent, data_model: Entity, fsm: FSM, model_file: str):
        # Components are bound to the panda node system via their UUID.
        PandaNode.__init__(self, "%s" % data_model.entity_id)

        # Bind a new node to the hierarchy, and leave it empty.
        self.path = parent.attachNewNode(self)

        # Save information into easily accessible variables.
        self.id = data_model.entity_id
        self.parent = parent
        self.data_model = data_model
        self.fsm = fsm
        self.model_file = model_file
Example #11
0
    def __init__(self):
        PandaNode.__init__(self, 'PositionHandle')

        CameraController.getInstance().addEventHandler(EVT_CAMERA_MOVE,
                                                       self._fixScale)
        self.path = NodePath(self)

        self.xHandle = DirectionHandle(self, Vec4(1, 0, 0, 0.6),
                                       Vec3(0, 0, 90), 'x')
        self.addChild(self.xHandle)

        self.yHandle = DirectionHandle(self, Vec4(0, 1, 0, 0.6),
                                       Vec3(0, -90, 0), 'y')
        self.addChild(self.yHandle)

        self.zHandle = DirectionHandle(self, Vec4(0, 0, 1, 0.6), Vec3(0, 0, 0),
                                       'z')
        self.addChild(self.zHandle)

        self.hHandle = RotationHandle(self, Vec4(0, 0, 1, 0.6), Vec3(0, 0, 0),
                                      'z')
        self.addChild(self.hHandle)
        NodePath(self.hHandle).setScale(1.02)

        self.pHandle = RotationHandle(self, Vec4(0, 1, 0, 0.6),
                                      Vec3(0, -90, 0), 'y')
        self.addChild(self.pHandle)
        NodePath(self.pHandle).setScale(0.98)

        self.rHandle = RotationHandle(self, Vec4(1, 0, 0, 0.6), Vec3(0, 0, 90),
                                      'x')
        self.addChild(self.rHandle)
        self._tPressed()

        self.path.setTransparency(1)
        self.path.setBin('transparent', 30, 50)
        #self.path.setDepthTest(False)
        self.path.setLightOff()
        self.path.setRenderModeThickness(2)
        self.setClients([])

        self.evtWatcher = DirectObject.DirectObject()
        self.evtWatcher.accept(base.win.getWindowEvent(),
                               self._windowEventHandler)
        self.evtWatcher.accept('r', self._rPressed)
        self.evtWatcher.accept('t', self._tPressed)

        self.originalPos = self.path.getPos()
        self.fLenPx = base.cam.node().getLens().getFocalLength(
        ) * base.win.getXSize()
        self._fixScale()
Example #12
0
    def __init__(self):
        PandaNode.__init__(self, 'PositionHandle')

        CameraController.getInstance().addEventHandler(EVT_CAMERA_MOVE,
                self._fixScale)
        self.path = NodePath(self)

        self.xHandle = DirectionHandle(self, Vec4(1, 0, 0, 0.6),
                Vec3(0, 0, 90), 'x')
        self.addChild(self.xHandle)

        self.yHandle = DirectionHandle(self, Vec4(0, 1, 0, 0.6),
                Vec3(0, -90, 0), 'y')
        self.addChild(self.yHandle)
        
        self.zHandle = DirectionHandle(self, Vec4(0, 0, 1, 0.6),
                Vec3(0, 0, 0), 'z')
        self.addChild(self.zHandle)
        
        self.hHandle = RotationHandle(self, Vec4(0, 0, 1, 0.6),
                Vec3(0, 0, 0), 'z')
        self.addChild(self.hHandle)
        NodePath(self.hHandle).setScale(1.02)

        self.pHandle = RotationHandle(self, Vec4(0, 1, 0, 0.6),
                Vec3(0, -90, 0), 'y')
        self.addChild(self.pHandle)
        NodePath(self.pHandle).setScale(0.98)

        self.rHandle = RotationHandle(self, Vec4(1, 0, 0, 0.6),
                Vec3(0, 0, 90), 'x')
        self.addChild(self.rHandle)
        self._tPressed()
        
        self.path.setTransparency(1)
        self.path.setBin('transparent', 30, 50)
        #self.path.setDepthTest(False)
        self.path.setLightOff()
        self.path.setRenderModeThickness(2)
        self.setClients([])

        self.evtWatcher = DirectObject.DirectObject()
        self.evtWatcher.accept(base.win.getWindowEvent(),
            self._windowEventHandler)
        self.evtWatcher.accept('r', self._rPressed)
        self.evtWatcher.accept('t', self._tPressed)

        self.originalPos = self.path.getPos()
        self.fLenPx = base.cam.node().getLens().getFocalLength() * base.win.getXSize()
        self._fixScale()
Example #13
0
    def __init__(self, base_object):
        PandaNode.__init__(self, "Sun")

        self.geom = GeomNode("Sun")
        self.vertexData = GeomVertexData("Basis", GeomVertexFormat.getV3cpt2(),
                                         Geom.UHStatic)
        self.vertex = GeomVertexWriter(self.vertexData, 'vertex')
        self.tex_coord = GeomVertexWriter(self.vertexData, 'texcoord')
        self.mesh = Geom(self.vertexData)
        self.tris = GeomTristrips(Geom.UHStatic)

        self.vertex.addData3f(0.0, 0.0, 0.0)
        self.tex_coord.addData2f(1.0, 0.0)

        self.vertex.addData3f(1.0, 0.0, 0.0)
        self.tex_coord.addData2f(1.0, 1.0)

        self.vertex.addData3f(0.0, 1.0, 0.0)
        self.tex_coord.addData2f(0.0, 0.0)

        self.vertex.addData3f(1.0, 1.0, 0.0)
        self.tex_coord.addData2f(0.0, 1.0)

        self.tris.add_vertices(0, 1, 2, 3)

        self.tris.closePrimitive()
        self.mesh.addPrimitive(self.tris)
        self.geom.addGeom(self.mesh)

        self.node = base_object.render.attachNewNode(self.geom)
        self.node.set_r(-90)
        self.node.set_h(90)
        self.node.set_scale(40)

        self.node.set_pos(0, 500, 0)

        self.texture = base_object.loader.loadTexture(
            base_object.params("sun_texture"))
        self.node.set_texture(self.texture)

        self.node.setLightOff()
        self.node.setColorOff()
        self.node.setTransparency(True)

        self.node.set_bin('fixed', 1)
        self.node.set_depth_write(0)
        self.node.set_depth_test(0)

        self.node.setBillboardPointEye()
Example #14
0
    def __init__(self, parent, color, hpr, dim):
        PandaNode.__init__(self, dim + 'rotHandle')
        self.path = NodePath(self)
        self.parent = parent
        self.dim = dim

        circle = GeomNode('gnode')
        circle.addGeomsFrom(self.geomNode)

        self.clickable = ClickableNode('clickable')
        self.clickable.addChild(circle)
        self.clickable.addMouseListener(self)
        circlenp = self.path.attachNewNode(self.clickable)

        self.path.setColor(color)
        self.path.setHpr(hpr)
        self.mDownPos = Vec2()
Example #15
0
    def __init__(self, parent, color, hpr, dim):
        PandaNode.__init__(self, dim+'rotHandle')
        self.path = NodePath(self)
        self.parent = parent
        self.dim = dim

        circle = GeomNode('gnode')
        circle.addGeomsFrom(self.geomNode)

        self.clickable = ClickableNode('clickable')
        self.clickable.addChild(circle)
        self.clickable.addMouseListener(self)
        circlenp = self.path.attachNewNode(self.clickable)

        self.path.setColor(color)
        self.path.setHpr(hpr)
        self.mDownPos = Vec2()
Example #16
0
    def __init__(self, base_object):
        PandaNode.__init__(self, "Earth")

        self.geom = GeomNode("earth")
        self.vertexData = GeomVertexData("Basis", GeomVertexFormat.getV3cpt2(),
                                         Geom.UHStatic)
        self.vertex = GeomVertexWriter(self.vertexData, 'vertex')
        self.tex_coord = GeomVertexWriter(self.vertexData, 'texcoord')
        self.mesh = Geom(self.vertexData)
        self.tris = GeomTristrips(Geom.UHStatic)

        size = 200
        z = -1000
        dx = 0
        dy = -200

        self.vertex.addData3f(z, size + dx, -size + dy)
        self.tex_coord.addData2f(1.0, 0.0)

        self.vertex.addData3f(z, -size + dx, -size + dy)
        self.tex_coord.addData2f(1.0, 1.0)

        self.vertex.addData3f(z, size + dx, size + dy)
        self.tex_coord.addData2f(0.0, 0.0)

        self.vertex.addData3f(z, -size + dx, size + dy)
        self.tex_coord.addData2f(0.0, 1.0)

        self.tris.add_vertices(1, 0, 3, 2)

        self.tris.closePrimitive()
        self.mesh.addPrimitive(self.tris)
        self.geom.addGeom(self.mesh)

        self.node = base_object.render.attachNewNode(self.geom)
        self.node.set_p(90)
        # self.node.set_h(90)

        self.texture = base_object.loader.loadTexture(
            base_object.params("earth_texture"))
        self.node.set_texture(self.texture)

        self.node.setLightOff()
        self.node.setColorOff()
        self.node.setTransparency(True)
Example #17
0
    def __init__(self, parent, data_model: DatabaseBackedGridModel,
                 entity_component_manager):

        PandaNode.__init__(self, "grid_%s" % id(self))
        DirectObject.__init__(self)

        self.parent = parent
        self.path = parent.attachNewNode(self)
        self.data_model = data_model
        self.entity_component_manager = entity_component_manager

        self._hex_model = None
        self.cubic_spiral = cubic_spiral(np.array([0, 0, 0]),
                                         radius=data_model.chunk_radius + 1)
        self._instantiate_grid_()

        # Register for messages about each location.
        Event.register("notify_grid_update", self, self.update_grid)
Example #18
0
    def __init__(self, parent, data_model: Location, position: np.ndarray,
                 hex_model):
        PandaNode.__init__(
            self,
            "location.%s.%s.%s" % (position[0], position[1], position[2]))

        self.parent = parent
        self.path = parent.attachNewNode(self)
        self.position = position
        self.data_model = data_model
        self.hex_model = hex_model

        # Compute the offset cubic coordinate to offset coordinates.
        x, y = cube_to_offset(self.position)
        if y % 2 == 0:
            self.rw_position = LPoint3(self.delta_x_center * x,
                                       self.delta_y_center * -y, 0)
        else:
            # Offset of x += sqrt(3)*(r) / 2
            self.rw_position = LPoint3(self.delta_x_center * (x + .5),
                                       self.delta_y_center * -y, 0)
Example #19
0
    def __init__(self, parent, color, hpr, dim):
        PandaNode.__init__(self, dim + 'handle')
        self.path = NodePath(self)
        self.parent = parent
        self.dim = dim

        arrow = GeomNode('gnode')
        arrow.addGeomsFrom(self.geomNode)
        arrownp = self.path.attachNewNode(arrow)
        arrownp.hide(BitMask32(1))

        clickNode = ClickableNode('clicknode')
        clickNode.setDepthLevel(0.5)
        clickNode.addMouseListener(self)
        clicknp = self.path.attachNewNode(clickNode)

        clickgeom = clicknp.attachNewNode(GeomNode('clicknode'))
        clickgeom.hide(BitMask32(7))
        clickgeom.node().addGeomsFrom(self.clickableGeomNode)

        linesegs = LineSegs()
        linesegs.setColor(color)
        linesegs.setThickness(2)
        linesegs.moveTo(Vec3(0, 0, -30))
        linesegs.drawTo(Vec3(0, 0, -0.5))
        linesegs.moveTo(Vec3(0, 0, 0.5))
        linesegs.drawTo(Vec3(0, 0, 30))
        lines = self.path.attachNewNode(linesegs.create())
        lines.show(BitMask32(1))
        lines.hide(BitMask32(2 | 4 | 8 | 16))
        lines.setBin('opaque', 30, 100)
        lines.setAntialias(AntialiasAttrib.MNone)

        self.path.setColor(color)
        self.path.setHpr(hpr)

        self.mDownPos = Vec2()
Example #20
0
    def __init__(self, parent, color, hpr, dim):
        PandaNode.__init__(self, dim+'handle')
        self.path = NodePath(self)
        self.parent = parent
        self.dim = dim

        arrow = GeomNode('gnode')
        arrow.addGeomsFrom(self.geomNode)
        arrownp = self.path.attachNewNode(arrow)
        arrownp.hide(BitMask32(1))
        
        clickNode = ClickableNode('clicknode')
        clickNode.setDepthLevel(0.5)
        clickNode.addMouseListener(self)
        clicknp = self.path.attachNewNode(clickNode)
        
        clickgeom = clicknp.attachNewNode(GeomNode('clicknode'))
        clickgeom.hide(BitMask32(7))
        clickgeom.node().addGeomsFrom(self.clickableGeomNode)

        linesegs = LineSegs()
        linesegs.setColor(color)
        linesegs.setThickness(2)
        linesegs.moveTo(Vec3(0, 0, -30))
        linesegs.drawTo(Vec3(0, 0, -0.5))
        linesegs.moveTo(Vec3(0, 0, 0.5))
        linesegs.drawTo(Vec3(0, 0, 30))
        lines = self.path.attachNewNode(linesegs.create())
        lines.show(BitMask32(1))
        lines.hide(BitMask32(2|4|8|16))
        lines.setBin('opaque', 30, 100)
        lines.setAntialias(AntialiasAttrib.MNone)

        self.path.setColor(color)
        self.path.setHpr(hpr)
        
        self.mDownPos = Vec2()
Example #21
0
 def __init__(self, name, fromFile=None):
     PandaNode.__init__(self, name)
     self.elements = []
     self.fromFile = fromFile
Example #22
0
 def __init__(self, name, fromFile=None):
     PandaNode.__init__(self, name)
     self.elements = []
     self.fromFile = fromFile
Example #23
0
    def __init__(self):
        PandaNode.__init__(self, 'margins')

        self.cells = set()
        self.visibles = set()
    def __init__(self):
        PandaNode.__init__(self, 'margins')

        self.cells = set()
        self.visibles = set()
Example #25
0
 def __init__(self):
     PandaNode.__init__(self, 'MarginManager')