예제 #1
0
파일: conftest.py 프로젝트: Moteesh/panda3d
def graphics_pipe():
    from panda3d.core import GraphicsPipeSelection

    pipe = GraphicsPipeSelection.get_global_ptr().make_default_pipe()

    if pipe is None or not pipe.is_valid():
        pytest.skip("GraphicsPipe is invalid")

    yield pipe
예제 #2
0
파일: conftest.py 프로젝트: whztt07/panda3d
def graphics_pipe():
    from panda3d.core import GraphicsPipeSelection

    pipe = GraphicsPipeSelection.get_global_ptr().make_default_pipe()

    if pipe is None or not pipe.is_valid():
        pytest.skip("GraphicsPipe is invalid")

    yield pipe
예제 #3
0
def graphics_pipe(scope='session'):
    from panda3d.core import GraphicsPipeSelection

    pipe = GraphicsPipeSelection.get_global_ptr().make_default_pipe()

    if not pipe.is_valid():
        pytest.xfail("GraphicsPipe is invalid")

    yield pipe
예제 #4
0
 def __init__(self, frame_size: tuple, fb_props: FrameBufferProperties):
     self._window = None
     # make default graphics pipe
     pipe = GraphicsPipeSelection.get_global_ptr().make_default_pipe()
     if pipe is None or not pipe.is_valid():
         raise RuntimeError("GraphicsPipe is invalid")
     self._pipe = pipe
     self._engine = GraphicsEngine.get_global_ptr()
     self._fb_props = fb_props
     if frame_size is not None:
         self._configure_window(frame_size)
예제 #5
0
    def __init__(self, screen_size=84):
        ShowBase.__init__(self)
        self.render.setShaderAuto()

        # Offscreen Buffer
        winprops = WindowProperties.size(screen_size, screen_size)
        fbprops = FrameBufferProperties()
        self.pipe = GraphicsPipeSelection.get_global_ptr().make_module_pipe(
            'pandagl')
        self.imageBuffer = self.graphicsEngine.makeOutput(
            self.pipe, "image buffer", 1, fbprops, winprops,
            GraphicsPipe.BFRefuseWindow)

        # Camera
        self.camera = Camera('cam')
        self.cam = NodePath(self.camera)
        self.cam.reparentTo(self.render)
        self.cam.setPos(0, 0, 7)
        self.cam.lookAt(0, 0, 0)

        #Display Region
        self.dr = self.imageBuffer.makeDisplayRegion()
        self.dr.setCamera(self.cam)

        # Spotlight with shadows
        self.light = Spotlight('light')
        self.lightNP = self.render.attachNewNode(self.light)
        self.lightNP.setPos(0, 10, 10)
        self.lightNP.lookAt(0, 0, 0)
        self.lightNP.node().setShadowCaster(True, 1024, 1024)
        self.render.setLight(self.lightNP)

        # Block
        node = PandaNode('Block')
        block_np = self.render.attachNewNode(node)
        model = loader.loadModel('box.egg')
        model.reparentTo(block_np)

        self.start_time = time.time()
예제 #6
0
파일: conv_env.py 프로젝트: Shirnia/l_sim
    def __init__(self, screen_size=84, DEBUGGING=False, human_playable=False):
        ShowBase.__init__(self)
        self.forward_button = KeyboardButton.ascii_key(b'w')
        self.backward_button = KeyboardButton.ascii_key(b's')

        self.fps = 20
        self.human_playable = human_playable
        self.actions = 3
        self.last_frame_start_time = time.time()
        self.action_buffer = [1, 1, 1]
        self.last_teleport_time = 0.0
        self.time_to_teleport = False

        if self.human_playable is False:
            winprops = WindowProperties.size(screen_size, screen_size)
            fbprops = FrameBufferProperties()
            fbprops.set_rgba_bits(8, 8, 8, 0)
            fbprops.set_depth_bits(24)
            self.pipe = GraphicsPipeSelection.get_global_ptr().make_module_pipe('pandagl')
            self.imageBuffer = self.graphicsEngine.makeOutput(
                self.pipe,
                "image buffer",
                1,
                fbprops,
                winprops,
                GraphicsPipe.BFRefuseWindow)


            self.camera = Camera('cam')
            self.cam = NodePath(self.camera)
            self.cam.reparentTo(self.render)

            self.dr = self.imageBuffer.makeDisplayRegion()
            self.dr.setCamera(self.cam)

        self.render.setShaderAuto()
        self.cam.setPos(0.5, 0, 6)
        self.cam.lookAt(0.5, 0, 0)

        # Create Ambient Light
        self.ambientLight = AmbientLight('ambientLight')
        self.ambientLight.setColor((0.2, 0.2, 0.2, 1))
        self.ambientLightNP = self.render.attachNewNode(self.ambientLight)
        self.render.setLight(self.ambientLightNP)

        # Spotlight
        self.light = Spotlight('light')
        self.light.setColor((0.9, 0.9, 0.9, 1))
        self.lightNP = self.render.attachNewNode(self.light)
        self.lightNP.setPos(0, 10, 10)
        self.lightNP.lookAt(0, 0, 0)
        self.lightNP.node().getLens().setFov(40)
        self.lightNP.node().getLens().setNearFar(10, 100)
        self.lightNP.node().setShadowCaster(True, 1024, 1024)
        self.render.setLight(self.lightNP)

        self.world = BulletWorld()
        self.world.setGravity(Vec3(0, 0, -9.81))

        if DEBUGGING is True:
            debugNode = BulletDebugNode('Debug')
            debugNode.showWireframe(True)
            debugNode.showConstraints(True)
            debugNode.showBoundingBoxes(False)
            debugNode.showNormals(False)
            debugNP = render.attachNewNode(debugNode)
            debugNP.show()
            self.world.setDebugNode(debugNP.node())

        self.finger_speed_mps = 0.0
        self.penalty_applied = False
        self.teleport_cooled_down = True
        self.fps = 20
        self.framecount = 0
        self.reset()