Ejemplo n.º 1
0
def main():
    from time import time

    from direct.showbase.ShowBase import ShowBase
    from panda3d.core import loadPrcFileData
    from panda3d.core import PStatClient

    from .selection import BoxSel
    from .util.util import ui_text, console, exit_cleanup
    from .ui import CameraControl, Axis3d, Grid3d
    from test_objects import makeSimpleGeom
    import sys
    sys.modules['core'] = sys.modules['panda3d.core']

    PStatClient.connect()  #run pstats in console
    loadPrcFileData('', 'view-frustum-cull 0')
    base = ShowBase()

    uiRoot = render.attachNewNode("uiRoot")
    level2Root = render.attachNewNode('collideRoot')

    base.setBackgroundColor(0, 0, 0)
    ut = ui_text()
    grid = Grid3d()
    axis = Axis3d()
    cc = CameraControl()
    base.disableMouse()
    con = console()
    exit_cleanup()

    #profileOctit()

    #counts = [1,250,510,511,512,513,1000,2000,10000]
    #counts = [1000,1000]
    counts = [999 for _ in range(99)]
    for i in range(len(counts)):
        nnodes = counts[i]
        #positions = np.random.uniform(-nnodes/10,nnodes/10,size=(nnodes,3))
        positions = np.cumsum(np.random.randint(-1, 2, (nnodes, 3)), axis=0)

        #positions = []
        #for j in np.linspace(-10,10,512):
        #positions += [[0,v+j,0] for v in np.arange(-1000,1000,100)]
        #positions = np.array(positions)
        #nnodes = len(positions)

        #uuids = np.arange(0,nnodes) * (i + 1)
        uuids = np.array(["%s" % uuid4() for _ in range(nnodes)])
        geomCollide = np.ones(nnodes) * .5
        out = treeMe(level2Root, positions, uuids, geomCollide)
        #print(out)
        render.attachNewNode(makeSimpleGeom(positions, np.random.rand(4)))

    #uiRoot = render.find('uiRoot')
    #uiRoot.detach()
    bs = BoxSel(
        False
    )  # TODO make it so that all the "root" nodes for the secen are initialized in their own space, probably in with defaults or something globalValues.py?
    #base.camLens.setFov(150)
    base.run()
Ejemplo n.º 2
0
 def __init__(self):
     DirectObject.__init__(self)
     self.base = ShowBase()
     resolution = (1024, 768)
     wp = WindowProperties()
     wp.setSize(int(resolution[0]), int(resolution[1]))
     wp.setOrigin(0, 0)
     self.base.win.requestProperties(wp)
     # depth completely doesn't matter for this, since just 2d, and no layers
     self.depth = 0
     self.base.setBackgroundColor(115 / 255, 115 / 255, 115 / 255)
     # set up a 2d camera
     camera = self.base.camList[0]
     lens = OrthographicLens()
     lens.setFilmSize(int(resolution[0]), int(resolution[1]))
     lens.setNearFar(-100, 100)
     camera.node().setLens(lens)
     camera.reparentTo(self.base.render)
     self.accept("escape", sys.exit)
     # spread out some positions
     self.positions = [(-200, 0, -200),
                       (0, 0, -200),
                       (200, 0, -200),
                       (-200, 0, 0),
                       (0, 0, 0),
                       (200, 0, 0),
                       (-200, 0, 200),
                       (0, 0, 200),
                       (200, 0, 200)]
     self.all_smiles()
Ejemplo n.º 3
0
    def _init_showbase(self, base):
        """ Inits the the given showbase object. This is part of an alternative
        method of initializing the showbase. In case base is None, a new
        ShowBase instance will be created and initialized. Otherwise base() is
        expected to either be an uninitialized ShowBase instance, or an
        initialized instance with pre_showbase_init() called inbefore. """
        if not base:
            self.pre_showbase_init()
            self._showbase = ShowBase()
        else:
            if not hasattr(base, "render"):
                self.pre_showbase_init()
                ShowBase.__init__(base)
            else:
                if not self._pre_showbase_initialized:
                    self.fatal(
                        "You constructed your own ShowBase object but you\n"
                        "did not call pre_show_base_init() on the render\n"
                        "pipeline object before! Checkout the 00-Loading the\n"
                        "pipeline sample to see how to initialize the RP.")
            self._showbase = base

        # Now that we have a showbase and a window, we can print out driver info
        self.debug("Driver Version =", self._showbase.win.gsg.driver_version)
        self.debug("Driver Vendor =", self._showbase.win.gsg.driver_vendor)
        self.debug("Driver Renderer =", self._showbase.win.gsg.driver_renderer)
Ejemplo n.º 4
0
    def __init__(self):

        self.isDebugOn = False

        if self.isDebugOn:
            ShowBase.__init__(self)
        else:
            # Start showbase(panda)
            ShowBase(windowType='none')

        ## CLIENT HOLDERS ##
        self.activeConnections = []
        self.activeCPlayers = {}

        # Start network manager
        self.networkManager = NetworkManager(self)
        # Start Server Game State
        self.serverState = ServerState(self)

        # Start the update tasks
        t = taskMgr.add(self.update, 'update')
        t.last = 0

        # Prints wtf ever
        print "Server: Active!"
        print "Waiting for connections...."
Ejemplo n.º 5
0
    def __init__(self):
        # Initialise Window
        self.showbase = ShowBase()

        # Disable Mouse Control for camera
        self.showbase.disableMouse()

        # Start our server up
        self.server = Server(9099, compress=True)
        self.db = DataBase()
        self.users = {
        }  # We should send the clients from the lobby to here somehow? or just get it from somewhere...

        for i in range(num_users):
            new_user = {}
            new_user['name'] = 'cake'
            new_user['connection'] = 'cake'
            new_user['ready'] = True
            new_user['new_dest'] = False
            new_user['new_spell'] = False
            self.users[len(self.users)] = new_user

        camera.setPos(0, 0, 45 * num_users)
        camera.lookAt(0, 0, 0)

        taskMgr.doMethodLater(0.5, self.pregame_loop, 'Lobby Loop')
Ejemplo n.º 6
0
def start():
    """ start a local renderManager with all the stuff needed for viewing """
    from direct.showbase.ShowBase import ShowBase
    from .render_manager import renderManager
    from .util.util import startup_data, exit_cleanup, ui_text, console, frame_rate
    from .ui import CameraControl, Axis3d, Grid3d, GuiFrame
    from .selection import BoxSel
    from .keys import AcceptKeys, callbacks  # FIXME this needs to be pulled in automatically if exit_cleanup is imported

    base = ShowBase()
    base.disableMouse()
    base.setBackgroundColor(0,0,0)
    startup_data()
    frame_rate()
    ec = exit_cleanup()
    uit = ui_text()
    con = console()
    cc = CameraControl()
    ax = Axis3d()
    gd = Grid3d()

    rendman = renderManager()
    frames = {
        'data':GuiFrame('Data view','f')
    }
    frames['data'].toggle_vis()
    bs = BoxSel(frames)  # FIXME must be loaded AFTER render manager or collRoot won't exist

    ak = AcceptKeys()
    return rendman, base
Ejemplo n.º 7
0
    def __init__(self, app=None, dt=None):
        self.app = app or ShowBase()
        self.app.accept('escape', sys.exit)
        self.root_node = self.app.render

        self._dt = 0.1 if dt is None else dt

        # setup visualization camera
        vfov = 45
        hfov = vfov * float(self.app.win.getSize()[0]) / float(
            self.app.win.getSize()[1])
        self.app.camLens.setFov(hfov, vfov)
        self.app.camLens.set_near_far(0.01, 10000.0)  # 1cm to 10km

        # The VirtualFileSystem, which has already initialized, doesn't see the mount
        # directives in the config(s) yet. We have to force it to load those manually:
        vfs = VirtualFileSystem.getGlobalPtr()
        mounts = ConfigVariableList('vfs-mount')
        for mount_desc in mounts:
            mount_desc = mount_desc.split(' ')
            physical_filename, mount_point = mount_desc[:2]
            physical_filename = os.path.expandvars(physical_filename)
            mount_point = os.path.expandvars(mount_point)
            if len(mount_desc) > 2:
                options = mount_desc[2]
            else:
                options = ''
            vfs.mount(Filename(physical_filename), Filename(mount_point),
                      *parse_options(options))
Ejemplo n.º 8
0
def main():
    base = ShowBase()

    cm = CardMaker('')
    cm.set_frame(-.5, .5, -.5, .5)

    # Node which contains all the cards equally spaced apart and which is
    # animated to move the cards in front of the camera.
    cards = base.render.attach_new_node(PandaNode(''))
    cards.setPos(-2, 5, 0)
    cards.posInterval(2, Point3(-6, 5, 0)).loop()

    for i in range(5):
        card = cards.attach_new_node(cm.generate())
        card.setPos(i * 2, 0, 0)

    def on_every_frame(task):
        # Time which has elapsed since the last frame measured in units of
        # the time quota available at 60 fps (e.g. 1/60 second).
        time_quota = taskMgr.globalClock.get_dt() * 60

        # Print time use as percent of the 60-fps-quota.
        print(f'{round(time_quota * 100):4}', end='', flush=True)

        return Task.DSCont

    taskMgr.add(on_every_frame)
    taskMgr.run()
    def __init__(self, fullscreen, sceneName=None):
        # Start Panda
        preSetWindowIcon("media/heavy_destruction.ico")
        ShowBase()

        # Some non-gameplay setup.
        self.name = "Heavy Destruction"
        self.version = 1.0
        base.setBackgroundColor(0, 0, 0)
        centerWindow()
        render.setAntialias(AntialiasAttrib.MAuto)
        if fullscreen: toggleFullscreen()
        self.setupKeys()
        self.setupFps()
        self.setupTitle()

        # Setup game objects.
        self.world = World(self)
        self.character = Character(self.world)
        self.cameraHandler = CameraHandler(self.character)
        self.shooter = Shooter(self.character)

        # Select a scene.
        if sceneName == "balls":
            self.scene = scene.FallingBalls(self.world, render,
                                            self.cameraHandler, self.character)
        else:
            self.scene = scene.BasicWall(self.world, render,
                                         self.cameraHandler, self.character)
Ejemplo n.º 10
0
def showbase(request):
    extra_prc = request.param if hasattr(request, 'param') else ''
    print(extra_prc)
    p3d.load_prc_file_data('', f'{PRC_BASE}\n{extra_prc}')
    showbase = ShowBase()
    yield showbase
    showbase.destroy()
Ejemplo n.º 11
0
def main():
    from direct.showbase.ShowBase import ShowBase
    from .util.util import startup_data, exit_cleanup, ui_text, console, frame_rate
    base = ShowBase()
    base.disableMouse()
    base.setBackgroundColor(0, 0, 0)
    startup_data()
    frame_rate()
    ec = exit_cleanup()
    uit = ui_text()
    con = console()
    cc = CameraControl()
    ax = Axis3d()
    gd = Grid3d()

    items = [('testing%s' % i, lambda self, index: self.__del_item__(index))
             for i in range(8)]
    frames = [
        #GuiFrame('MegaTyj', x=-.5, y=.5, height=.25, width=-.25),
        #GuiFrame('MegaTyj', x=-.3, y=-.3, height=.25, width=-.25, text_h=.2),
        #GuiFrame('testing', x=0, y=0, height=.25, width=.25, items = items),
        #GuiFrame('cookies', x=1, y=1, height=-.25, width=-.25, items = items),
        #GuiFrame('neg x', x=-.25, y=0, height=.1, width=-.25, items = items),
        #GuiFrame('text', x=.5, y=.5, height=.25, width=-.25, items = items),
        #GuiFrame('text', x=.5, y=.5, height=-.25, width=-.25, items = items),
        #GuiFrame('text', x=.5, y=.25, height=.25, width=.25, items = items),
    ]
    frames = [
        GuiFrame('%s' % i, x=-.1, y=.1, height=.25, width=-.25, items=items)
        for i in range(10)
    ]
    # FIXME calling add_item after this causes weird behvaior

    base.run()
Ejemplo n.º 12
0
def showbase(request):
    extra_prc = request.param
    from direct.showbase.ShowBase import ShowBase
    print(extra_prc)
    p3d.load_prc_file_data('', f'{PRC_BASE}\n{extra_prc}')
    showbase = ShowBase()
    yield showbase
    showbase.destroy()
Ejemplo n.º 13
0
def showbase():
    from direct.showbase.ShowBase import ShowBase
    p3d.load_prc_file_data(
        '',
        'window-type offscreen\n'
        'framebuffer-hardware false\n'
    )
    return ShowBase()
Ejemplo n.º 14
0
    def __init__(self, tick_rate):
        from direct.showbase.ShowBase import ShowBase

        self._base = ShowBase()
        self._hive = hive.get_run_hive()

        self._read_event = None
        self._add_handler = None
Ejemplo n.º 15
0
    def __init__(self, verbose=False):

        self._base = ShowBase()
        self._verbose = verbose
        self._updaters = {}
        self._state_mgrs = {}
        self._key_handlers = {}
        self._cursor_manager = None
        GlobalData["mod_key_codes"] = {"alt": 1, "ctrl": 2, "shift": 4}
Ejemplo n.º 16
0
 def __init__(self):
     # referencias externos  # extrenal references
     self.base = ShowBase()
     # referencias internas  # internal references
     self._proveedores = dict()
     # componentes externos  # external components
     self.config = ConfigParser()
     # componentes internos  # internal components
     self._proveedores_defecto = dict()  # default providers
Ejemplo n.º 17
0
def main():
    print "Please wait while initializing Panda3d..."
    stub = ShowBase()
    stub.destroy()

    print "Now launching the real thing in a loop..."
    exec("import game")
    while True:
        exec("game.Game().run()")
        exec("reload(game)")
Ejemplo n.º 18
0
 def render(self):
     user32 = ctypes.windll.user32
     screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
     resolution = ConfigVariableString('win-size')
     val = '{0} {1}'.format(*screensize)
     resolution.setValue(val)
     app = ShowBase()
     self.env.render(render, base)
     taskMgr.doMethodLater(0.01, self.update, 'update')
     app.run()
Ejemplo n.º 19
0
 def __init__(self):
     self.base = ShowBase()
     self.base.disableMouse()
     self.base.camera.setPos(0, -10, 0)
     color_vertices = [(0.2, 0.2, 0.1, 1), (0.2, 0.7, 0.1, 1),
                       (0.7, 0.7, 0.1, 1), (0.7, 0.2, 0.1, 1)]
     square = make_square(color_vertices)
     sq_node = GeomNode('square')
     sq_node.addGeom(square)
     self.base.render.attachNewNode(sq_node)
Ejemplo n.º 20
0
 def __init__(self):
     base = ShowBase()
     self.text = TextNode("node name")
     textfile = open("Dedicatory.txt")
     self.text.setText(textfile.read())
     textNodePath = aspect2d.attachNewNode(self.text)
     textNodePath.setScale(0.5)
     textNodePath.setPos(0, 30, 0)
     textNodePath.reparentTo(render)
     self.text.setTextColor(0, 0, 0, 1)
     base.setBackgroundColor(1, 1, 1)
     #font = loader.loadFont("tnr.bam")
     #font.setPixelsPerUnit(25)
     self.text.setWordwrap(35)
     #self.text.setFont(font)
     base.accept("escape", sys.exit)
     base.useTrackball()
     self.output = "Psalms.txt"
     base.trackball.node().setPos(-7.55, 0, 6)
     menu = DirectOptionMenu(
         text="New",
         scale=0.04,
         items=[
             "Matthew", "Mark", "Luke", "John", "Acts", "Romans",
             "1 Corinthians", "2 Corinthians", "Galatians", "Ephesians",
             "Philippians", "Colossians", "1 Thessalonians",
             "2 Thessalonians", "1 Timothy", "2 Timothy", "Titus",
             "Philemon", "Hebrews", "James", "1 Peter", "2 Peter", "1 John",
             "2 John", "3 John", "Jude", "Revelation"
         ],
         highlightColor=(0.65, 0.65, 0.65, 1),
         command=self.itemSel)
     menuold = DirectOptionMenu(
         text="Old",
         scale=0.04,
         items=[
             "Genesis", "Exodus", "Leviticus", "Numbers", "Deuteronomy",
             "Joshua", "Judges", "Ruth", "1 Samuel", "2 Samuel", "1 Kings",
             "2 Kings", "1 Chronicles", "2 Chronicles", "Ezra", "Nehemiah",
             "Esther", "Job", "Psalms", "Proverbs", "Ecclesiastes",
             "SongofSolomon", "Isaiah", "Jeremiah", "Lamentations",
             "Ezekiel", "Daniel", "Hosea", "Joel", "Amos", "Obadiah",
             "Jonah", "Micah", "Nahum", "Habakkuk", "Zephaniah", "Haggai",
             "Zechariah", "Malachi"
         ],
         highlightColor=(0.65, 0.65, 0.65, 1),
         command=self.itemSel)
     menu.setPos(-1.31, 0, 0.8)
     menuold.setPos(-1.31, 0, 0.9)
     onebutton = DirectButton(text=("NextSection"),
                              scale=.04,
                              command=self.one)
     onebutton.setPos(-1.2, 0, 0.7)
     self.sectnum = 1
     taskMgr.add(self.exampleTask, "MyTaskName")
Ejemplo n.º 21
0
 def __init__(self):
     DirectObject.__init__(self)
     self.base = ShowBase()
     props = WindowProperties()
     props.setCursorHidden(True)
     props.set_size(1024, 768)
     props.set_origin(0, 0)
     self.base.win.requestProperties(props)
     self.color_list = [1, 1, 1]
     self.base.setBackgroundColor(self.color_list[:])
     self.accept('q', self.close)
Ejemplo n.º 22
0
 def startBase(showDefaultWindow = True, allowMultipleWindows = False):
   """Starts up Panda3D by loading the ShowBase modules."""
   WindowManager.allowMultipleWindows = allowMultipleWindows
   assert not (allowMultipleWindows and showDefaultWindow)
   # Load up showbase. If we want a default window, make sure one gets opened.
   nbase = ShowBase()
   nbase.windowType = "onscreen"
   if showDefaultWindow:
     activeWindow = Window()
   nbase.taskMgr.add(WindowManager.checkActiveWindow, "checkActiveWindow")
   return nbase
Ejemplo n.º 23
0
 def _gen_viewer(queue, max_points=17776, massage_que=None):
     base = ShowBase()
     base.setBackgroundColor(0, 0, 0)
     base.disableMouse()
     base.camera.setPos(0, -50, 20)
     base.camera.setHpr(0, -22, 0)
     base.mouseWatcherNode.set_modifier_buttons(ModifierButtons())
     base.buttonThrowers[0].node().set_modifier_buttons(ModifierButtons())
     base.setFrameRateMeter(True)
     pc_viewer = _PointCloudFrameViewer(point_cloud_size=max_points,
                                        queue=queue)
     base.run()
Ejemplo n.º 24
0
def main():
    from direct.showbase.ShowBase import ShowBase
    from test_objects import Grid3d,Axis3d
    from .util.util import ui_text
    base = ShowBase()
    base.setBackgroundColor(0,0,0)
    ut = ui_text()
    cc = CameraControl()
    grid = Grid3d()
    axis = Axis3d()
    base.disableMouse()
    base.run()
Ejemplo n.º 25
0
    def __init__(self):
        # start Panda3d
        base = ShowBase()
        # CollisionTraverser instance must be attached to base,
        # and must be called cTrav
        base.cTrav = CollisionTraverser()
        self.cHand = CollisionHandlerEvent()
        self.cHand.addInPattern('into-%in')
        
        # load smiley, which we will control
        # notice this is a little trickery. If we parent everything except smiley
        # to the camera, and the player is controlling the camera, then everything 
        # stays fixed in the same place relative to the camera, and when the camera
        # moves, the player is given the illusion that he is moving smiley, rather than 
        # the camera and the rest of the scene.
        self.smiley = base.loader.loadModel('smiley')
        self.smiley.reparentTo(render)
        self.smiley.setName('Smiley')
        
        # Setup a collision solid for this model. Our initCollisionSphere method returns
        # the cNodepath and the string representing it. We will use the cNodepath for 
        # adding to the traverser, and the string to accept it for event handling.
        #sColl = self.initCollisionSphere(self.smiley)
        sColl = self.initCollisionSphere(self.smiley, True)
        print 'smiley', sColl[0]
        print 'smiley', sColl[1]

        # Add this object to the traverser.
        base.cTrav.addCollider(sColl[0], self.cHand)

        # load frowney
        self.frowney = base.loader.loadModel('frowney')
        self.frowney.setName('Frowney')
        self.frowney.reparentTo(camera)
        
        # Setup a collision solid for this model.
        fColl = self.initCollisionSphere(self.frowney, True)
        #print 'frowney', fColl[0]
        #print 'frowney', fColl[1]
        
        # Add this object to the traverser.
        base.cTrav.addCollider(fColl[0], self.cHand)

        # Accept the events sent by the collisions.
        # smiley is the object we are 'moving', so by convention
        # it is the from object.
        # If we instead put smiley as the into object here,
        # it would work fine, but then smiley would disappear
        # when we collided them.
        self.accept('into-' + fColl[1], self.collide)        

        # set the initial positions of smiley and frowney
        self.set_initial_positions()
Ejemplo n.º 26
0
 def __init__(self, parent, res=(1024, 768)):
     self.parent = parent
     # Init pipe
     ShowBase()
     base.makeDefaultPipe()
     screen = (base.pipe.getDisplayWidth(), base.pipe.getDisplayHeight())
     win = WindowProperties.getDefault()
     xsize = ConfigVariableInt("resx", res[0]).getValue()
     ysize = ConfigVariableInt("resy", res[1]).getValue()
     win.setSize(xsize, ysize)
     win.setFullscreen(False)
     base.openDefaultWindow(win)
Ejemplo n.º 27
0
def test_showbase_create_destroy():
    sb = ShowBase(windowType='none')
    try:
        assert builtins.base == sb
    finally:
        sb.destroy()
        sb = None

    assert not hasattr(builtins, 'base')
    assert not hasattr(builtins, 'run')
    assert not hasattr(builtins, 'loader')
    assert not hasattr(builtins, 'taskMgr')
Ejemplo n.º 28
0
 def __init__(self):
     DirectObject.__init__(self)
     # start Panda3d
     self.base = ShowBase()
     # get configurations from config file
     config_file = 'config.py'
     self.config = {}
     execfile(config_file, self.config)
     self.accept("cleanup", self.cleanup)
     self.accept("escape", self.close)
     self.photos = Photos(self.base, self.config)
     self.photos.load_all_photos()
     self.start_loop()
Ejemplo n.º 29
0
def main():
    from direct.showbase.ShowBase import ShowBase

    base = ShowBase()

    event_loop = asyncio.get_event_loop() 
    ppe = ProcessPoolExecutor()
    t = thing(event_loop, ppe)

    asyncThread = Thread(target=event_loop.run_forever)
    asyncThread.start()

    base.run()
Ejemplo n.º 30
0
    def __init__(self):
        self.base = ShowBase()
        self.model = self.base.loader.loadModel('device.egg')
        self.model.reparentTo(self.base.render)
        
        
        self.base.disableMouse()
        self.base.camera.setPos(0, -10, 0)
        self.model.setHpr(0,90,0)

        mat = Mat4(self.base.camera.getMat())
        mat.invertInPlace()
        self.base.mouseInterfaceNode.setMat(mat)
        self.base.enableMouse()

        self.screen = self.model.find("**/pantalla")
        
        self.list_app = ListApp(self)
        self.music_app = MusicApp(self)
        self.dial_app = DialApp(self)
        
        self.apps = {}
        self.events = EventDispatcher(self, "Sony Ericsson W200")
        
        self.apps["init"] = InitApp(self)
        self.apps["Dial"] = self.display_dial_screen
        self.apps["menu"] = MainMenu(self)
        self.apps["Reproductor"] = self.play
        
        self.apps["Reproductor de Audio"] = self.display_list
        self.apps["Camara"] = CameraApp(self)
        self.apps["Album Fotografico"] = PhotoApp(self)
        self.apps["Llamadas"] = self.display_list
        self.apps["Contactos"] = self.display_list
        self.apps["Mensajes"] = self.display_list
        self.apps["Juegos"] = self.display_list
        self.apps["Utileria"] = self.display_list
        
        self.apps["Reproducir Todas"] = self.play
        self.apps["Lista de Albums"] = self.list_albums
        self.apps["Lista de Artistas"] = self.list_artists
        
        self.apps["Lista de Contactos"] = self.list_contacts
        self.apps["Dial Contact"] = self.dial_contact
        
        self.apps["Llamadas Perdidas"] = self.list_lost_calls
        self.apps["Llamadas Contestadas"] = self.list_answered_calls
        self.apps["Llamadas Marcadas"] = self.list_done_calls
        
        self.launch("init")