コード例 #1
0
ファイル: main.py プロジェクト: wolfgangp/P3DFramework
    def __init__(self):

        loadPrcFileData("", "model-cache-dir")

        self.render_pipeline = RenderPipeline(self)
        self.render_pipeline.get_mount_manager().mount()
        self.render_pipeline.load_settings("Config/pipeline.yaml")
        self.render_pipeline.create()

        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(
            Vec3(-987.129, -2763.58, 211.47), Vec3(5.21728, 7.84863, 0))

        self.controller.setup()

        self.render_pipeline.create_default_skybox()

        self.accept("r", self._reload_shader)
        self.accept("f3", self._toggle_scene_wireframe)

        self.addTask(self.update, "update")

        self.scene_wireframe = False

        # Create some ocean
        # self.water = ProjectedWaterGrid(self.render_pipeline)
        # self.water.setWaterLevel(0)

        self._init_terrain()
        self._reload_shader()
コード例 #2
0
 def setUpClass(cls):
     loadPrcFileData("", "window-type offscreen")
     # ConfigVariableString("window-type","offscreen").setValue("offscreen")
     # print 'about to load world'
     # run in auto, 0
     cls.w = World(0, 'config_test.py')
     cls.w.setup_game()
コード例 #3
0
    def setUpClass(cls):
        loadPrcFileData("", "window-type offscreen")
        # all these tests are for manual
        # manual move is mode 1

        cls.w = World(1, 'config_test.py')
        cls.w.setup_game()
コード例 #4
0
ファイル: Options.py プロジェクト: muschter/CardJitsu
 def reload(self):
     for pref_key, pref_val in self._preferences.items():
         if pref_val is True:
             pref_val = '#t'
         else:
             pref_val = '#f'
         loadPrcFileData(f'Settings: {pref_key}', f'{pref_key} {pref_val}')
コード例 #5
0
 def setUpClass(cls):
     loadPrcFileData("", "window-type offscreen")
     # ConfigVariableString("window-type","offscreen").setValue("offscreen")
     # print 'about to load world'
     # run in auto, 0
     cls.w = World(0, 'config_test.py')
     cls.w.setup_game()
コード例 #6
0
    def __setattr__(self, name, value):
        try:
            super().__setattr__(name, value)
        except:
            pass

        if name == 'position':
            self.set_origin((value[0], value[1]))
            application.base.win.request_properties(self)
            object.__setattr__(self, name, value)

        if name == 'fullscreen':
            if value == True:
                self.size = self.fullscreen_size
            else:
                self.size = self.windowed_size

            self.center_on_screen()
            object.__setattr__(self, name, value)
            return

        if name == 'color':
            application.base.camNode.get_display_region(
                0).get_window().set_clear_color(value)

        if name == 'vsync':
            if value == True:
                loadPrcFileData('', 'sync-video True')
            else:
                loadPrcFileData('', 'sync-video False')
                print('set vsync to false')
            object.__setattr__(self, name, value)
コード例 #7
0
    def loadConfig(self, config_file_name, load_all=False):
        self.cfg = {}
        config_dict = {}
        self.debug.append('Loading config from: ' + config_file_name)
        try:
            with open(config_file_name, 'r') as f:
                for row in f:
                    if not row.startswith('#'):
                        loadPrcFileData('', row)
                        if row.split():
                            var_name = row.split()[0]
                            var_value = self.getValueFromConfigVariable(
                                var_name)
                            config_dict[var_name] = var_value
                            self.debug.append(var_name + ' set to ' +
                                              str(var_value))
        except IOError:
            self.warning.append('Could not load config file: ' +
                                config_file_name)

        if load_all:
            self.warning.append('Reading all known config variables!')
            for i in range(
                    ConfigVariableManager.getGlobalPtr().getNumVariables()):
                var_name = ConfigVariableManager.getGlobalPtr(
                ).getVariableName(i)
                var_value = self.getValueFromConfigVariable(var_name)
                config_dict[var_name] = var_value
        self.cfg = config_dict
コード例 #8
0
ファイル: dataIO.py プロジェクト: tgbugs/desc
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()
コード例 #9
0
    def initPanda(self):
        if hasattr(self, 'panda'):
            # Allow multiple entry
            return
        if self.do is None:
            self.do = DirectObject()

        # The undecorated config option can't be changed at runtime, so we need
        # to set it before the panda object is created.
        if self.displaySettings.displayMode == NO_BORDER:
            loadPrcFileData('', 'undecorated 1')

        # The resolution /can/ be changed at runtime, but there's a split second
        # flash of the window at the defualt resolution when first opening the
        # game which looks quite ugly.
        loadPrcFileData('', 'win-size %d %d' % self.displaySettings.size)

        loadPrcFile(data.getPandaPath(data, 'config/config.prc'))
        self.panda = ShowBase.ShowBase()
        self.pandaScene = None

        # See https://www.panda3d.org/manual/index.php/Mouse_Support
        self.panda.disableMouse()  # Name is misleading

        self.displaySettings.applyTimings()

        self.initPlaque()

        self.displaySettings.onDetailLevelChanged.addListener(self.setShader)
        self.setShader()
コード例 #10
0
 def applySettings(self, jsonfile):
     if not jsonfile:
         raise IOError('no file specified!')
     info = open(jsonfile, 'r')
     jsonInfo = json.load(info)
     settings = jsonInfo['settings']
     width, height = settings['resolution']
     fs = settings['fullscreen']
     music = settings['music']
     sfx = settings['sfx']
     tex_detail = settings['texture-detail']
     model_detail = settings['model-detail']
     aa = settings['aa']
     af = settings.get('af', None)
     if af == None:
         self.writeSettingToFile('af', 'off', 'settings.json')
     base.enableMusic(music)
     base.enableSoundEffects(sfx)
     if aa == 'on':
         render.set_antialias(AntialiasAttrib.MMultisample)
         aspect2d.set_antialias(AntialiasAttrib.MMultisample)
     else:
         render.clear_antialias()
     ts = TextureStage('ts')
     if tex_detail == 'high':
         pass
     else:
         if tex_detail == 'low':
             loadPrcFileData('', 'compressed-textures 1')
     wp = WindowProperties()
     wp.setSize(width, height)
     wp.setFullscreen(fs)
     base.win.requestProperties(wp)
     info.close()
     return
コード例 #11
0
    def __updateAA(self, degree):
        loadPrcFileData("", "framebuffer-multisample 0")
        loadPrcFileData("", "multisamples 0")
        loadPrcFileData("", "accum-bits 0")

        if "FXAA" in degree:
            # fxaa
            try:
                base.setFXAA(True)
            except:
                pass
        elif "MSAA" in degree:
            degree = int(degree.split('x')[0])
            loadPrcFileData("", "framebuffer-multisample 1")
            loadPrcFileData("", "multisamples {0}".format(degree))

            try:
                render.setAntialias(AntialiasAttrib.MMultisample)
                aspect2d.setAntialias(AntialiasAttrib.MMultisample)
            except:
                pass
        else:
            try:
                render.clearAntialias()
                aspect2d.clearAntialias()
            except:
                pass
コード例 #12
0
ファイル: window.py プロジェクト: flipcoder/ursina
    def __init__(self):
        super().__init__()
        loadPrcFileData('', 'window-title ursina')
        loadPrcFileData('', 'notify-level-util error')
        loadPrcFileData('', 'textures-auto-power-2 #t')
        loadPrcFileData('', 'load-file-type p3assimp')
        # loadPrcFileData("", "framebuffer-multisample 1")
        # loadPrcFileData('', 'multisamples 2')
        # loadPrcFileData('', 'textures-power-2 none')

        # loadPrcFileData('', 'cursor-filename mycursor.ico')
        # loadPrcFileData('', 'threading-model Cull/Draw')
        loadPrcFileData('', 'coordinate-system y-up-left')
        self.setForeground(True)
        self.vsync = True  # can't be set during play
        self.show_ursina_splash = False

        self.title = application.asset_folder.name
        try:
            self.screen_resolution = (get_monitors()[0].width,
                                      get_monitors()[0].height)
        except:
            print('using default sceen resolution.', 'OS:', os.name)
            self.screen_resolution = Vec2(1366, 768)

        print('screen resolution:', self.screen_resolution)
        self.fullscreen_size = Vec2(self.screen_resolution[0] + 1,
                                    self.screen_resolution[1] + 1)
        self.windowed_size = self.fullscreen_size / 1.25
        self.windowed_position = None  # gets set when entering fullscreen so position will be correct when going back to windowed mode
        self.size = self.windowed_size
        self.borderless = True
コード例 #13
0
 def __init__(self):
     # we must ensure that gl is ok before starting showbase initialization
     import kivy.core.gl
     loadPrcFileData('',
                     'win-size 800 1080')  # Up to us... at init time only.
     ShowBase.__init__(self)
     self.setup_lights()
コード例 #14
0
ファイル: base.py プロジェクト: apleonhardt/flytracker
    def __init__(self, shared):
        loadPrcFileData("",
                        """load-display pandagl
                        sync-video #t
                        fullscreen #f
                        win-origin 0 0
                        undecorated #t
                        cursor-hidden #t
                        win-size 7680 1080
                        show-frame-rate-meter #t
                        auto-single-cpu-affinity #f
                        """)

        TrueClock.getGlobalPtr().setCpuAffinity(0xFFFFFFFF)

        self.shared = shared

        ShowBase.__init__(self)

        self.global_time = 0.0

        self.statustex1 = create_color_texture([0, 0, 0])
        self.statustex2 = create_color_texture([255, 255, 255])

        self.statusimage1 = OnscreenImage(self.statustex1, scale=(0.015, 0.015, 0.015), sort=20,
                                          pos=(self.getAspectRatio() - 0.01, 0, -1 + 0.01))

        self.taskMgr.add(self.loop, "Primary loop")

        # Calibration details:
        self.calibrated_length = 4 * 56.9
コード例 #15
0
    def setUpClass(cls):
        loadPrcFileData("", "window-type offscreen")
        # all these tests are for manual
        # manual move is mode 1

        cls.w = World(1, 'config_test.py')
        cls.w.setup_game()
コード例 #16
0
def main():
    args = docopt(__doc__)

    schema = Schema({
        '--help': bool,
        '--width': Use(int),
        '--height': Use(int),
    })

    try:
        args = schema.validate(args)
    except SchemaError as e:
        exit(e)

    model_path = 'models'

    loadPrcFileData('', 'window-title Babble')
    loadPrcFileData('', 'win-size %d %d' % (args['--width'], args['--height']))
    loadPrcFileData('', 'audio-library-name null') # suppress warning
    loadPrcFileData('', 'model-path %s' % model_path)
    loadPrcFileData('', 'bullet-filter-algorithm groups-mask')
    # loadPrcFileData('', 'framebuffer-multisample 1')
    # loadPrcFileData('', 'multisamples 1')

    app = App(args)
    app.run()
コード例 #17
0
 def panda_config(self):
     data = []
     request_opengl_config(data)
     self.app_panda_config(data)
     data.append("text-encoding utf8")
     data.append("paste-emit-keystrokes #f")
     #TODO: Still needed ?
     data.append("bounds-type box")
     data.append("screenshot-extension png")
     data.append("screenshot-filename %~p-%Y-%m-%d-%H-%M-%S-%~f.%~e")
     data.append("fullscreen %d" % settings.win_fullscreen)
     if settings.win_fullscreen:
         data.append("win-size %d %d" %
                     (settings.win_fs_width, settings.win_fs_height))
     else:
         data.append("win-size %d %d" %
                     (settings.win_width, settings.win_height))
     data.append("lens-far-limit %g" % settings.lens_far_limit)
     loadPrcFileData("", '\n'.join(data))
     if settings.prc_file is not None:
         config_file = settings.prc_file
         if not os.path.isabs(config_file):
             config_file = os.path.join(settings.config_dir, config_file)
         filename = Filename.from_os_specific(config_file)
         if filename.exists():
             print("Loading panda config", filename)
             loadPrcFile(filename)
         else:
             print("Panda config file", filename)
コード例 #18
0
    def __init__(self, dev, trial_table, fullscreen):
        loadPrcFileData('', 'fullscreen ' + str(fullscreen))
        ShowBase.__init__(self)
        IndividuationStateMachine.__init__(self)
        self.render.setAntialias(AntialiasAttrib.MMultisample)
        self.render.setShaderAuto()  # allows shadows
        self.setFrameRateMeter(True)

        self.dev = dev
        self.disableMouse()
        self.countdown_timer = CountdownTimer()

        self.table = pd.read_table(trial_table)  # trial table
        self.setup_lights()
        self.setup_camera()
        self.load_models()
        self.load_audio()

        # add tasks (run every frame)
        taskMgr.add(self.get_user_input, 'move')
        taskMgr.add(self.update_target_color, 'target_color')
        taskMgr.add(self.update_state, 'update_state')
        self.accept('space', self.space_on)  # toggle a boolean somewhere

        # helpers
        self.space = False
        self.trial_counter = 0
        self.dist = 100
        self.queue = list()
コード例 #19
0
ファイル: main.py プロジェクト: PlumpMath/P3DFramework
    def __init__(self):

        loadPrcFileData("", "model-cache-dir")

        self.render_pipeline = RenderPipeline(self)
        self.render_pipeline.get_mount_manager().mount()
        self.render_pipeline.load_settings("Config/pipeline.yaml")
        self.render_pipeline.create()

        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(
            Vec3(-987.129, -2763.58, 211.47), Vec3(5.21728, 7.84863, 0))

        self.controller.setup()

        self.render_pipeline.create_default_skybox()

        self.accept("r", self._reload_shader)
        self.accept("f3", self._toggle_scene_wireframe)

        self.addTask(self.update, "update")

        self.scene_wireframe = False

        # Create some ocean
        # self.water = ProjectedWaterGrid(self.render_pipeline)
        # self.water.setWaterLevel(0)

        self._init_terrain()
        self._reload_shader()
コード例 #20
0
ファイル: dataIO.py プロジェクト: tgbugs/desc
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()
コード例 #21
0
ファイル: plugbase.py プロジェクト: Schwarzbaer/PlugBase
def run(config_file=None):
    loadPrcFileData("", "sync-video #t")
    global app
    if config_file is None:
        app = PlugBase()
    else:
        app = PlugBase(config_file=config_file)
    app.run()
コード例 #22
0
ファイル: pandawrapper.py プロジェクト: ekare/panda3d-glhost
 def __init__(self):
     # we must ensure that gl is ok before starting showbase initialization
     import kivy.core.gl
     from kivy.core.window import Window
     loadPrcFileData('', 'win-size %d %d' % Window.size)
     ShowBase.__init__(self)
     #self.render.setDepthTest(False, 100)
     self.setup_lights()
コード例 #23
0
ファイル: mesh.py プロジェクト: tarsbase/cosmonium
def init_mesh_loader():
    if settings.use_assimp:
        loadPrcFileData(
            "", "load-file-type p3assimp\n"
            "assimp-gen-normals #t\n"
            "assimp-smooth-normal-angle 90\n")
    path = cache.create_path_for("models")
    loadPrcFileData("", "model-cache-dir %s\n" % path)
コード例 #24
0
def run(config_file=None):
    loadPrcFileData("", "sync-video #t")
    global app
    if config_file is None:
        app = PlugBase()
    else:
        app = PlugBase(config_file=config_file)
    app.run()
コード例 #25
0
    def __updateFullscreen(self, flag):
        wp = WindowProperties()
        wp.setFullscreen(flag)

        try:
            base.win.requestProperties(wp)
        except:
            loadPrcFileData("", "fullscreen {0}".format(int(flag)))
コード例 #26
0
 def __init__(self):
     # we must ensure that gl is ok before starting showbase initialization
     import kivy.core.gl
     from kivy.core.window import Window
     loadPrcFileData('', 'win-size %d %d' % Window.size)
     ShowBase.__init__(self)
     #self.render.setDepthTest(False, 100)
     self.setup_lights()
コード例 #27
0
 def loadConfig(self):
     loadPrcFileData(
         "", """
     fullscreen """ + self.getData("FULL_SCREEN") + """
     win-size """ + self.getData("RESOLUTION") + """
     text-encoding """ + self.getData("TEXT_ENCODING") + """
     show-frame-rate-meter """ + self.getData("FRAME_METER") + """
     sync-video """ + self.getData("SYNC_VIDEO") + """
     """)
コード例 #28
0
ファイル: application.py プロジェクト: dKentDSU/HexEditor
 def initialConfiguration(self):
     loadPrcFileData('', 'fullscreen '+FULLSCREEN)
     loadPrcFileData('', 'win-size '+SCREEN_X+" "+SCREEN_Y)
     loadPrcFileData('', 'framebuffer-multisample 1')
     loadPrcFileData('', 'multisamples 2')
     loadPrcFileData('', 'compressed-textures 1')
     ShowBase.__init__(self)
     render.setAntialias(AntialiasAttrib.MAuto)
     base.win.setClearColor(Vec4(0,0,0,1))
コード例 #29
0
    def __updateResolution(self, resolutionValue):
        wp = WindowProperties()
        width, height = resolutionValue
        wp.setSize(width, height)

        try:
            base.win.requestProperties(wp)
        except:
            loadPrcFileData("", "win-size {0} {1}".format(width, height))
コード例 #30
0
ファイル: main.py プロジェクト: IlyaFaer/ForwardOnlyGame
def configure_cull_draw():
    """
    Check the game configurations and enable multithreading if
    needed. Must be done before ShowBase__init__(), otherwise
    the configuration will not be applied.
    """
    if not os.path.exists(Config.opts_file) or open(
            Config.opts_file).read().endswith("True"):
        loadPrcFileData("", "threading-model Cull/Draw")
コード例 #31
0
def start(name="APE Test",
          engine=APE,
          base=APEPandaBase,
          app=APEApp,
          window=APEWindow,
          widget=PandaWidget,
          start=True,
          tobsprRenderPipeline=True):
    print(age.cTimeSStr(), ": ", name, "Window Startup")
    _app = app(sys.argv)
    _app.ModuleVersions += f"\nAstus Panda Engine {Version}\nPanda3D {p3d.__version__}"
    UseRenderPipeline = QtWidgets.QMessageBox.question(
        None, "Render Pipeline",
        "Do You want to use tobspr's Render Pipeline?\nThis will make everything look pretty at the cost of performance."
    ) == QtWidgets.QMessageBox.Yes
    if UseRenderPipeline:
        # Insert the pipeline path to the system path, this is required to be
        # able to import the pipeline classes. In case you placed the render
        # pipeline in a subfolder of your project, you have to adjust this.
        sys.path.insert(0, "../tobsprRenderPipeline")
        sys.path.insert(0, "tobsprRenderPipeline")
        # Import render pipeline classes
        from tobsprRenderPipeline.rpcore import RenderPipeline
        # Construct and create the pipeline
        render_pipeline = RenderPipeline()
        render_pipeline.pre_showbase_init()
    else:
        render_pipeline = False
    p3dc.loadPrcFileData("", "window-type none")
    _base = base(render_pipeline)
    _engine = engine(_base, render_pipeline)
    _app.init(_base, _engine)
    _window = window(widget)
    _app.setMainWindow(_window)
    _window.setWindowTitle(name)
    _app.setApplicationName(name + "-App")
    _base.registerWindow(_window)
    if UseRenderPipeline:
        render_pipeline.create(_base)
    # this basically creates an idle task
    timer = QtCore.QTimer(_window)
    timer.timeout.connect(_base.step)
    timer.start(0)
    #
    print(age.cTimeSStr(), ": ", name, "Window Started\n")
    _window.show()
    _window.positionReset()
    if start:
        _engine.start()
    _base.buttonThrowers[0].node().setKeystrokeEvent('keystroke')
    _base.buttonThrowers[0].node().setButtonDownEvent('buttonDown')
    _base.buttonThrowers[0].node().setButtonUpEvent('buttonUp')
    _base.accept('keystroke', _base.keystrokeSignal)
    _base.accept('buttonDown', _base.buttonDownSignal)
    _base.accept('buttonUp', _base.buttonUpSignal)
    _app.exec_()
コード例 #32
0
ファイル: app.py プロジェクト: PlumpMath/gravbot
    def __init__(self, args):
        ShowBase.__init__(self)
        loadPrcFileData('', 'bullet-enable-contact-events true')
        self.explore = None

        if args == "test":
            utilities.setDebug()
            self.explore = ExploreScreen(self)
        else:
            self.explore = ExploreScreen(self)
コード例 #33
0
ファイル: app.py プロジェクト: michaeltchapman/gravbot
    def __init__(self, args):
        ShowBase.__init__(self)
        loadPrcFileData('', 'bullet-enable-contact-events true') 
        self.explore = None

        if args == "test":
            utilities.setDebug()
            self.explore = ExploreScreen(self)
        else:
            self.explore = ExploreScreen(self)
コード例 #34
0
 def setUpClass(cls):
     if manual:
         print 'starting tests using manual'
     else:
         print 'starting tests using random'
     print manual
     loadPrcFileData("", "window-type offscreen")
     # print 'about to load world'
     cls.w = World(manual, 'config_test.py')
     cls.w.setup_game()
コード例 #35
0
ファイル: conftest.py プロジェクト: elthran/3d-ant-wars
def game_instance():
    main = import_module('main')

    # hack patch model path
    main_dir = os.path.dirname(main.__file__)
    loadPrcFileData(name='tests_Config.pry',
                    data=TESTS_CONFIG_PRC.format(main_dir=main_dir))

    game = main.Game()
    return game
コード例 #36
0
 def setUpClass(cls):
     if manual:
         print 'starting tests using manual'
     else:
         print 'starting tests using random'
     print manual
     loadPrcFileData("", "window-type offscreen")
     # print 'about to load world'
     cls.w = World(manual, 'config_test.py')
     cls.w.setup_game()
コード例 #37
0
ファイル: viewer_app.py プロジェクト: rstrudel/panda3d_viewer
    def __init__(self, config):
        """Open a window, setup a scene.

        Arguments:
            config {ViewerConfig} -- viewer configuration
        """
        # load config before base init
        loadPrcFileData('', str(config))

        ShowBase.__init__(self)

        self.render.set_shader_auto()
        self.render.set_antialias(AntialiasAttrib.MAuto)

        self._camera_defaults = [(4.0, -4.0, 1.5), (0, 0, 0.5)]
        self.reset_camera(*self._camera_defaults)

        self._spotlight = self.config.GetBool('enable-spotlight', False)
        self._shadow_size = self.config.GetInt('shadow-buffer-size', 1024)
        self._lights = [
            self._make_light_ambient((0.2, 0.2, 0.2)),
            self._make_light_direct(1, (0.6, 0.8, 0.8), pos=(8.0, 8.0, 10.0)),
            self._make_light_direct(2, (0.8, 0.6, 0.8), pos=(8.0, -8.0, 10.0)),
            self._make_light_direct(3, (0.8, 0.8, 0.6), pos=(-8.0, 8.0, 10.0)),
            self._make_light_direct(4, (0.6, 0.6, 0.8),
                                    pos=(-8.0, -8.0, 10.0)),
        ]
        self._lights_mask = [True, True, True, False, False]
        self.enable_lights(self.config.GetBool('enable-lights', True))
        self.enable_shadow(self.config.GetBool('enable-shadow', False))
        self.enable_hdr(self.config.GetBool('enable-hdr', False))

        self._fog = self._make_fog()
        self.enable_fog(self.config.GetBool('enable-fog', False))

        self._axes = self._make_axes()
        self.show_axes(self.config.GetBool('show-axes', True))

        self._grid = self._make_grid()
        self.show_grid(self.config.GetBool('show-grid', True))

        self._floor = self._make_floor()
        self.show_floor(self.config.GetBool('show-floor', False))

        self._scene_root = self.render.attach_new_node('scene_root')
        self._scene_scale = self.config.GetFloat('scene-scale', 1.0)
        self._scene_root.set_scale(self._scene_scale)
        self._groups = {}

        if self.windowType == 'onscreen':
            self._help_label = None
            self.trackball.node().set_forward_scale(
                self.config.GetFloat('trackball-scale', 0.01))
            self._setup_shortcuts()
コード例 #38
0
ファイル: render.py プロジェクト: unaguil/r3const
    def __init__(self, size=(128, 128), step=0.1):
        loadPrcFileData('', f'win-size {size[0]} {size[1]}')

        ShowBase.__init__(self, windowType='offscreen')

        self.setBackgroundColor(0, 0, 0)

        self.__models = []
        self.__selectedIndex = -1
        self.__model = None
        self.__size = size
コード例 #39
0
def main():
    model_path = 'models'
    width = 640
    height = 640

    loadPrcFileData('', 'window-title Babble')
    loadPrcFileData('', 'win-size %d %d' % (width, height))
    loadPrcFileData('', 'audio-library-name null') # suppress warning
    loadPrcFileData('', 'model-path %s' % model_path)
    loadPrcFileData('', 'bullet-filter-algorithm groups-mask')

    app = App(width, height)
    app.run()
コード例 #40
0
    def __init__(self):
        self.emitter = EventEmitter()
        self.cManager = ConnectionManager(self)

        self.tester = Tester(self)

        if self.startConnection():
            loadPrcFileData("", "window-type none") # disable graphics
            loadPrcFileData("", "audio-library-name null") # disable audio
            ShowBase.__init__(self)
            self.cManager.initTasks()
            self.emitter.emit('connection')
            self.run()
コード例 #41
0
    def __setattr__(self, name, value):
        try:
            super().__setattr__(name, value)
        except:
            pass

        if name == 'position':
            self.setOrigin(int(value[0]), int(value[1]))
            application.base.win.request_properties(self)
            object.__setattr__(self, name, value)

        if name == 'fullscreen':
            try:
                if value == True:
                    self.windowed_size = self.size
                    self.windowed_position = self.position
                    self.size = self.fullscreen_size
                    self.center_on_screen()
                else:
                    self.size = self.windowed_size
                    if self.windowed_position is not None:
                        self.position = self.windowed_position
                    else:
                        self.center_on_screen()

                object.__setattr__(self, name, value)
                return
            except:
                print('failed to set fullscreen', value)
                pass

        if name == 'borderless':
            self.setUndecorated(value)
            try:
                application.base.win.request_properties(self)
            except:
                pass
            object.__setattr__(self, name, value)

        if name == 'color':
            application.base.camNode.get_display_region(
                0).get_window().set_clear_color(value)

        if name == 'vsync':
            if value == True:
                loadPrcFileData('', 'sync-video True')
            else:
                loadPrcFileData('', 'sync-video False')
                print('set vsync to false')
            object.__setattr__(self, name, value)
コード例 #42
0
ファイル: worldgenerator.py プロジェクト: lrq3000/waCaptcha
    def __init__(self, nbElem=10, minClickablePercentage=2.0, maxClickablePercentage=100.0, uniqueColors=False, minModelSize=15, maxModelSize=25, modelsPath='models', modelsCacheList='modelscache.txt', modelsExceptionList='modelsexception.txt', backgroundsPath='backgrounds', backgroundsCacheList='backgroundslist.txt', colorTint=True, windowWidth=640, windowHeight=480, debug=False):
        # Vars
        self.debug = debug
        self.minClickablePercentage = minClickablePercentage
        self.maxClickablePercentage = maxClickablePercentage
        self.nbElem = nbElem
        self.uniqueColors = uniqueColors # The reference object has a unique color?
        self.modelsPath = modelsPath
        self.modelsCacheList = modelsCacheList
        self.modelsExceptionList = modelsExceptionList
        self.minModelSize = minModelSize
        self.maxModelSize = maxModelSize
        self.rangeModelSize = maxModelSize - minModelSize # precompute the range (optimization)
        self.backgroundsPath = backgroundsPath
        self.backgroundsCacheList = backgroundsCacheList
        self.colorTint = colorTint

        # Set commandline rendering mode (unloading as many rendering module as possible and hiding rendering window)
        if debug: # show rendering window if in debug mode
            loadPrcFileData("",
            """
               load-display p3tinydisplay # to force CPU only rendering (to make it available as an option if everything else fail, use aux-display p3tinydisplay)
               window-type onscreen # Spawn an offscreen buffer (use window-type none if you don't need any rendering)
               audio-library-name null # Prevent ALSA errors
               show-frame-rate-meter 0
               sync-video 0
               win-size """+str(windowWidth)+' '+str(windowHeight)+"""
            """)
        else: # hide rendering window if not in debug mode
            loadPrcFileData("",
            """
               load-display p3tinydisplay # to force CPU only rendering (to make it available as an option if everything else fail, use aux-display p3tinydisplay)
               window-type offscreen # Spawn an offscreen buffer (use window-type none if you don't need any rendering)
               audio-library-name null # Prevent ALSA errors
               show-frame-rate-meter 0
               sync-video 0
               win-size """+str(windowWidth)+' '+str(windowHeight)+"""
            """)

        # Init 3D world
        from direct.showbase.ShowBase import ShowBase
        self.base = ShowBase()

        # Init Cache
        self.cacher = WorldCacher(base=self.base)

        # Init scene camera
        self.base.camLens.setFov(45)
コード例 #43
0
ファイル: AppRunner.py プロジェクト: Just-D/panda3d
    def loadMultifilePrcFiles(self, mf, root):
        """ Loads any prc files in the root of the indicated
        Multifile, which is presumed to have been mounted already
        under root. """

        # We have to load these prc files explicitly, since the
        # ConfigPageManager can't directly look inside the vfs.  Use
        # the Multifile interface to find the prc files, rather than
        # vfs.scanDirectory(), so we only pick up the files in this
        # particular multifile.
        cpMgr = ConfigPageManager.getGlobalPtr()
        for f in mf.getSubfileNames():
            fn = Filename(f)
            if fn.getDirname() == '' and fn.getExtension() == 'prc':
                pathname = '%s/%s' % (root, f)

                alreadyLoaded = False
                for cpi in range(cpMgr.getNumImplicitPages()):
                    if cpMgr.getImplicitPage(cpi).getName() == pathname:
                        # No need to load this file twice.
                        alreadyLoaded = True
                        break

                if not alreadyLoaded:
                    data = file.open(Filename(pathname), 'r').read()
                    cp = loadPrcFileData(pathname, data)
                    # Set it to sort value 20, behind the implicit pages.
                    cp.setSort(20)
コード例 #44
0
ファイル: AppRunner.py プロジェクト: Just-D/panda3d
    def setupWindow(self, windowType, x, y, width, height,
                    parent):
        """ Applies the indicated window parameters to the prc
        settings, for future windows; or applies them directly to the
        main window if the window has already been opened.  This is
        called by the browser. """

        if self.started and base.win:
            # If we've already got a window, this must be a
            # resize/reposition request.
            wp = WindowProperties()
            if x or y or windowType == 'embedded':
                wp.setOrigin(x, y)
            if width or height:
                wp.setSize(width, height)
            if windowType == 'embedded':
                wp.setParentWindow(parent)
            wp.setFullscreen(False)
            base.win.requestProperties(wp)
            self.windowProperties = wp
            return

        # If we haven't got a window already, start 'er up.  Apply the
        # requested setting to the prc file, and to the default
        # WindowProperties structure.

        self.__clearWindowProperties()

        if windowType == 'hidden':
            data = 'window-type none\n'
        else:
            data = 'window-type onscreen\n'

        wp = WindowProperties.getDefault()

        wp.clearParentWindow()
        wp.clearOrigin()
        wp.clearSize()

        wp.setFullscreen(False)
        if windowType == 'fullscreen':
            wp.setFullscreen(True)

        if windowType == 'embedded':
            wp.setParentWindow(parent)

        if x or y or windowType == 'embedded':
            wp.setOrigin(x, y)

        if width or height:
            wp.setSize(width, height)

        self.windowProperties = wp
        self.windowPrc = loadPrcFileData("setupWindow", data)
        WindowProperties.setDefault(wp)

        self.gotWindow = True

        # Send this call to the main thread; don't call it directly.
        messenger.send('AppRunner_startIfReady', taskChain = 'default')
コード例 #45
0
 def __init__(self,name ='TestGameBase'):
   
   # configure to use group-mask collision filtering mode in the bullet physics world
   loadPrcFileData('', 'bullet-filter-algorithm groups-mask')
   
   ShowBase.__init__(self)   
   
   self.name_ = name
   self.setupRendering()
   self.setupResources()
   self.setupControls()
   self.setupScene()
   self.clock_ = ClockObject()
   self.delta_time_accumulator_ = 0.0 # Used to keep simulation time consistent (See https://www.panda3d.org/manual/index.php/Simulating_the_Physics_World)
   self.desired_frame_rate_ = TestGameBase.__DESIRED_FRAME_RATE__
 
   # Task
   taskMgr.add(self.update, 'updateWorld')
コード例 #46
0
ファイル: scene.py プロジェクト: zhicai/friendlyfruit
    def create_scene(self, directory):
        self.__directory = directory
        loadPrcFileData("", "model-path %s" % directory)
        self.__scene = FruitConfigParser()
        self.__scene.read(self.__path("scene.cfg"))
        for thing in self.__scene.get("scene", "things").split(" "):
            egg = self.__scene.get(thing, "egg")
            egg = self.loader.loadModel(egg)
            egg.reparentTo(self.render)

            egg.setPos(*self.__scene.getfloats(thing, "location"))
            egg.setQuat(LQuaternionf(*self.__scene.getfloats(thing, "rotation")))
            egg.setScale(*self.__scene.getfloats(thing, "scale"))

        if self.__scene.has_option("scene", "stencil"):
            self.__create_terrain()

        if self.__scene.has_option("scene", "skybox"):
            self.__create_skybox()
コード例 #47
0
ファイル: worldgenerator.py プロジェクト: lrq3000/waCaptcha
    def __init__(self, base=None, debug=False):
        # Set commandline rendering mode (unloading as many rendering module as possible and hiding rendering window)

        # hide rendering window (we don't need it)
        loadPrcFileData("",
        """
           load-display p3tinydisplay # to force CPU only rendering (to make it available as an option if everything else fail, use aux-display p3tinydisplay)
           window-type offscreen # Spawn an offscreen buffer (use window-type none if you don't need any rendering)
           audio-library-name null # Prevent ALSA errors
           show-frame-rate-meter 0
           sync-video 0
        """)

        # Init 3D world
        if base:
            self.base = base
        else:
            from direct.showbase.ShowBase import ShowBase
            self.base = ShowBase()
コード例 #48
0
ファイル: pandautil.py プロジェクト: brettbarbaro/autoPACK
    def setupODE(self,*args,**kw):
        if self.world is None :
            if panda3d is None :
                return
            from panda3d.core import loadPrcFileData            
            loadPrcFileData("", "window-type none" ) 
            # Make sure we don't need a graphics engine 
            #(Will also prevent X errors / Display errors when starting on linux without X server)
            loadPrcFileData("", "audio-library-name null" ) # Prevent ALSA errors 
#            loadPrcFileData('', 'bullet-enable-contact-events true')
#            loadPrcFileData('', 'bullet-max-objects 50')#10240
            
            import direct.directbase.DirectStart 
#            bullet.bullet-max-objects = 1024 * 10#sum of all predicted n Ingredient ?
#            self.worldNP = render.attachNewNode('World')            
            self.world = OdeWorld()
            self.world.setGravity(Vec3(0, 0, 0))
            self.static=[]
            self.moving = None
            self.rb_panda = []
            return self.world
コード例 #49
0
ファイル: test_colors.py プロジェクト: codedragon/color_world
 def test_change_background_two_axis(self):
     config = {'colors': ['g', 'r'],
               'c_range': [0.2, 0.7],
               'static': 0.1,
               'win': False,
               'tolerance': 0.1}
     loadPrcFileData("", "window-type offscreen")
     test_cw = cw.ColorWorld(config)
     # force some variables to be what we want them to be.
     test_cw.color_list = [0.5, 0.5, 0.5]
     new_color = test_cw.color_list
     # x, y, z; r, g, b
     # {x: r, y: b, z: None} corresponds to {0: 0, 1: 2, 2: None}
     test_cw.color_dict = {0: 0, 1: 2, 2: None}
     move = LVector3(0.1, 0.1, 0)
     stop = test_cw.change_background(move)
     new_color[0] = 0.5 + (0.1 * test_cw.speed)
     new_color[1] = 0.5 + (0.1 * test_cw.speed)
     self.assertEqual(test_cw.color_list, new_color)
     self.assertEqual(stop, [False, False, True])
     test_cw.base.destroy()
コード例 #50
0
ファイル: test_objects.py プロジェクト: tgbugs/desc
def _main():
    from .util.util import ui_text
    from .ui import CameraControl, Axis3d, Grid3d
    #from panda3d.core import ConfigVariableBool
    #ConfigVariableString('view-frustum-cull',False)
    from panda3d.core import loadPrcFileData
    from time import time
    from panda3d.core import PStatClient
    from dragsel import BoxSel
    PStatClient.connect()
    loadPrcFileData('','view-frustum-cull 0')
    #loadPrcFileData('','threading-model Cull/Draw') #bad for lots of nodes
    base = ShowBase()
    base.setBackgroundColor(0,0,0)
    ut = ui_text()
    grid = Grid3d()
    axis = Axis3d()
    cc = CameraControl()
    base.disableMouse()
    #pt = PointsTest(999,99999)
    #pt = PointsTest(1,9999999)
    #pt = PointsTest(1,999999) #SLOW AS BALLS: IDEA: render faraway nodes as static meshes and transform them to live as we get closer!
    #pt = PointsTest(9999999,1)
    #pt = PointsTest(99999,100) #runs fine when there is only 1 node >_<
    #pt = PointsTest(999,10) #runs fine when there is only 1 node >_<
    #pt = PointsTest(1,99999) #still slow :/
    #pt = PointsTest(1,9999) #still slow :/ #deep trees segfault!
    #pt = PointsTest(1,4000) #still slow :/ #this one is ok
    #pt = PointsTest(1,999) #still slow
    #pt = PointsTest(1,499) #still slow 15 fps with 0,0,0 positioned geom points
    #pt = PointsTest(1,249) #about 45fps :/
    bins = 1 #999=.057, below 200 ~.044 so hard to tell (for n = 99)
    #FIXME low numbers of points causes major problems!
    #nt = NodeTest(999999,bins) #the inscreased time is more pronounced with larger numbers of nodes... is it the serialization?
    #ct = CollTest(9999,bins) #the inscreased time is more pronounced with larger numbers of nodes... is it the serialization?
    #nt = NodeTest(999,5)
    #base.camLens.setFar(9E12) #view-frustum-cull 0
    bs = BoxSel() #some stuff
    ft = FullTest(999,bins)
    base.run() #looks like this is the slow case... probably should look into non blocking model loading?
コード例 #51
0
def main():
    width = 640
    height = 640

    loadPrcFileData('', 'window-title Animate')
    loadPrcFileData('', 'win-size %d %d' % (width, height))
    loadPrcFileData('', 'audio-library-name null') # suppress warning
    loadPrcFileData('', 'model-path %s' % '.')

    model_path = sys.argv[1]
    animation_path = sys.argv[2] if len(sys.argv) > 2 else None

    app = App(width, height, model_path, animation_path)
    app.run()
コード例 #52
0
ファイル: main.py プロジェクト: jonathanopalise/grid-leader
	def __init__(self):

		base.makeDefaultPipe()
		width=base.pipe.getDisplayWidth()
		height=base.pipe.getDisplayHeight()
		print('screen dimensions are '+str(width)+','+str(height))

		base.windowType = 'onscreen' 
		props=WindowProperties.getDefault()
		props.setSize(width,height)
		props.setFullscreen(True) 
		base.openDefaultWindow(props) 

		PStatClient.connect()
		loadPrcFileData("", "framebuffer-stencil #t")
		self.sessionManager=SessionManager()

		FPS = 60
		globalClock = ClockObject.getGlobalClock() 
		globalClock.setMode(ClockObject.MLimited) 
		globalClock.setFrameRate(FPS)

		taskMgr.add(self.move,"moveTask")
コード例 #53
0
ファイル: test_objects.py プロジェクト: tgbugs/desc
def main():
    from .util.util import ui_text, frame_rate, exit_cleanup, startup_data
    from .ui import CameraControl, Axis3d, Grid3d
    from panda3d.core import loadPrcFileData
    from time import time
    from panda3d.core import PStatClient

    from .selection import BoxSel
    from .render_manager import renderManager


    PStatClient.connect()
    loadPrcFileData('','view-frustum-cull 0')
    base = ShowBase()
    base.setBackgroundColor(0,0,0)
    ut = ui_text()
    grid = Grid3d()
    axis = Axis3d()
    cc = CameraControl()
    base.disableMouse()
    frame_rate()
    startup_data()

    #render something
    #ct = CollTest(2000)
    #ft = FullTest(99,1)

    renderManager()
    frames = {'data':GuiFrame('data','f')}
    bs = BoxSel(frames) # FIXME must be started after renderManager >_<

    dnd = dond()
    #d4d = do4d()

    ec = exit_cleanup()
    ac = AcceptKeys()
    base.run() # we don't need threading for this since panda has a builtin events interface
コード例 #54
0
ファイル: main.py プロジェクト: wezu/a4p
    def loadConfig(self, config_file_name, load_all=False):
        self.cfg={}
        config_dict={}
        self.debug.append('Loading config from: '+config_file_name)
        try:
            with open(config_file_name,'r') as f:
                for row in f:
                    if not row.startswith('#'):
                        loadPrcFileData('',row)
                        if row.split():
                            var_name=row.split()[0]
                            var_value=self.getValueFromConfigVariable(var_name)
                            config_dict[var_name]=var_value
                            self.debug.append(var_name+' set to '+str(var_value))
        except IOError:
            self.warning.append('Could not load config file: '+config_file_name)

        if load_all:
            self.warning.append('Reading all known config variables!')
            for i in range(ConfigVariableManager.getGlobalPtr().getNumVariables()):
                var_name=ConfigVariableManager.getGlobalPtr().getVariableName(i)
                var_value=self.getValueFromConfigVariable(var_name)
                config_dict[var_name]=var_value
        self.cfg=config_dict
コード例 #55
0
ファイル: pandautil.py プロジェクト: brettbarbaro/autoPACK
 def setupPanda(self,*args,**kw):
     if panda3d is None :
         return
     from panda3d.core import loadPrcFileData
     
     loadPrcFileData("", "window-type none" ) 
     # Make sure we don't need a graphics engine 
     #(Will also prevent X errors / Display errors when starting on linux without X server)
     loadPrcFileData("", "audio-library-name null" ) # Prevent ALSA errors 
     loadPrcFileData('', 'bullet-max-objects 100240')#what number here ?
     import direct.directbase.DirectStart
     self.scale  = 10.0   
     self.worldNP = render.attachNewNode('World')            
     self.world = BulletWorld()
     if "gravity" in kw and kw["gravity"]:
         self.world.setGravity(Vec3(0, -9.81, 0))
     else :
         self.world.setGravity(Vec3(0, 0, 0))
     self.static=[]
     self.moving = None
     self.rb_panda = []
コード例 #56
0
ファイル: theater.py プロジェクト: fgcapo/cthuloid
Author: Josh Enes
Last Updated: 2015-03-13

This is a demo of Panda's portal-culling system. It demonstrates loading
portals from an EGG file, and shows an example method of selecting the
current cell using geoms and a collision ray.
"""

# Some config options which can be changed.
ENABLE_PORTALS = False # Set False to disable portal culling and see FPS drop!
DEBUG_PORTALS = False # Set True to see visually which portals are used

# Load PRC data
from panda3d.core import loadPrcFileData
if ENABLE_PORTALS:
    loadPrcFileData('', 'allow-portal-cull true')
    if DEBUG_PORTALS:
        loadPrcFileData('', 'debug-portal-cull true')
loadPrcFileData('', 'window-title Portal Demo')
loadPrcFileData('', 'sync-video false')
loadPrcFileData('', 'show-frame-rate-meter true')
loadPrcFileData('', 'texture-minfilter linear-mipmap-linear')

# Import needed modules
import random, math
from direct.showbase.ShowBase import ShowBase
from direct.gui.OnscreenText import OnscreenText
from direct.actor.Actor import Actor
from panda3d.core import PerspectiveLens, NodePath, LVector3, LPoint3, \
    TexGenAttrib, TextureStage, TransparencyAttrib, CollisionTraverser, \
    CollisionHandlerQueue, TextNode, CollisionRay, CollisionNode, AmbientLight, \
コード例 #57
0
ファイル: main.py プロジェクト: wezu/p3d_launcher
import __builtin__ as builtins
from panda3d.core import loadPrcFileData
loadPrcFileData("", "window-type none")
from direct.showbase.AppRunnerGlobal import appRunner
if appRunner: #run from binary/p3d
    path=appRunner.p3dFilename.getDirname()+'/'
else:  #run from python 
    path=''
from panda3d.core import *
from direct.showbase import ShowBase
from launcher import Launcher
from collections import OrderedDict
from direct.stdpy.file import exists
import json
import sys

class App():
    def __init__(self):
        #init ShowBase
        base = ShowBase.ShowBase()        
        #make the path a builtin
        builtins.path=path 
        
        if exists(path+'setup.json'):
            #the setup dict can be loaded from
            #-a json file
            #-a pickeled dict
            #-xml
            #-yaml
            #-any other file that can serialize a python dict
            #-or it could be here as a python dict
コード例 #58
0
# Gold: https://pixabay.com/en/gold-texture-swabs-gradient-1000665/
# Golden Monkey: http://www.goldbad-sargans.com/baden-in-gold.html
# Lava Stone: http://wpaulsen.blogspot.com/2014/07/lava-texture.html
# Lava: http://www.outworldz.com/cgi/free-seamless-textures.plx?c=Lava
# Water: http://www.123rf.com/photo_20535240_seamless-water-texture-computer-graphic-big-collection.html
# Tree Bark: http://www.lughertexture.com/wood-old-and-new-hires-textures/bark-wood-hires-textures
# Diamond: https://www.c4dmodelshop.com/ipos/description.php?path=37&sort=Id&page=0&id=306
# Rainbow: https://www.flickr.com/photos/pareeerica/4016548266/player/afd68403be
# sky: http://e2ua.com/data/wallpapers/92/WDF_1366223.jpg
# hand: http://www.lowes.com/creative-ideas/images/2012_03/101844092.jpg
# Blood: http://nobacks.com/blood-splatter-thirty-nine/
# Blood2: https://slate.adobe.com/a/AvZyl/
# red: http://globe-views.com/dreams/red.html
# bg: http://wallpapercave.com/w/vdzssS4

loadPrcFileData("", "win-size 1440 760")
# loadPrcFileData('', 'fullscreen true')
class Player(object):
    def __init__(self,camera):
        self.model = loader.loadModel('models/gold.egg') 
        self.model.clearModelNodes()
        self.model.reparentTo(render)
        self.camera = camera
        self.hand = []
        self.level = 0
        self.health = self.magic = 100
        self.exp = 1

    def discard(self):
        if len(self.hand)>0:
            block = self.hand.pop(-1)
コード例 #59
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# Author: CJT
# Date: 2016/6/16

# A simple skybox.

from panda3d.core import loadPrcFileData

loadPrcFileData("", "window-title CJT Skybox Demo")
loadPrcFileData("", "win-size 1280 720")
loadPrcFileData("", "sync-video true")
loadPrcFileData("", "show-frame-rate-meter true")
loadPrcFileData("", "texture-minfilter linear-mipmap-linear")
loadPrcFileData("", "cursor-hidden true")

from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
from direct.task.Task import Task
from direct.actor.Actor import Actor
from direct.gui.OnscreenText import OnscreenText
from direct.showbase.DirectObject import DirectObject
from direct.showbase.BufferViewer import BufferViewer
import sys
import os
from math import *

MouseSensitivity = 100
CameraSpeed = 25
zoomRate = 5