当前位置: 首页>>代码示例>>Python>>正文


Python rpcore.RenderPipeline类代码示例

本文整理汇总了Python中rpcore.RenderPipeline的典型用法代码示例。如果您正苦于以下问题:Python RenderPipeline类的具体用法?Python RenderPipeline怎么用?Python RenderPipeline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RenderPipeline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Application

class Application(ShowBase):
    def __init__(self):
        # Setup window size and title
        load_prc_file_data("", """
            # win-size 1600 900
            window-title Render Pipeline - Material Sample
        """)

        # Construct the render pipeline
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)
        self.render_pipeline.daytime_mgr.time = "19:17"
        # self.render_pipeline.daytime_mgr.time = "12:00"

        # Load the scene
        model = self.loader.load_model("scene/TestScene.bam")
        model.reparent_to(self.render)

        self.render_pipeline.prepare_scene(model)

        # Enable parallax mapping on the floor
        # self.render_pipeline.set_effect(
        #     model.find("**/FloorPlane"),
        #     "effects/default.yaml", {"parallax_mapping": True}, 100)

        # Initialize movement controller, this is a convenience class
        # to provide an improved camera control compared to Panda3Ds default
        # mouse controller.
        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(
            Vec3(-17.2912578583, -13.290019989, 6.88211250305),
            Vec3(-39.7285499573, -14.6770210266, 0.0))
        self.controller.setup()
开发者ID:tobspr,项目名称:RenderPipeline-Samples,代码行数:33,代码来源:main.py

示例2: MainApp

class MainApp(ShowBase):
    def __init__(self):

        # Setup window size, title and so on
        load_prc_file_data("", """
            win-size 1600 900
            window-title Render Pipeline - Car Demo
        """)

        # ------ Begin of render pipeline code ------

        # Insert the pipeline path to the system path, this is required to be
        # able to import the pipeline classes
        pipeline_path = "../../"

        # Just a special case for my development setup, so I don't accidentally
        # commit a wrong path. You can remove this in your own programs.
        if not os.path.isfile(os.path.join(pipeline_path, "setup.py")):
            pipeline_path = "../../RenderPipeline/"

        sys.path.insert(0, pipeline_path)

        from rpcore import RenderPipeline, SpotLight
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)

        # This is a helper class for better camera movement - its not really
        # a rendering element, but it included for convenience
        from rpcore.util.movement_controller import MovementController

        # ------ End of render pipeline code, thats it! ------

        self.render_pipeline.daytime_mgr.time = "20:08"

        # Load the scene
        model = loader.loadModel("scene/scene.bam")
        # model = loader.loadModel("scene2/Scene.bam")

        model.reparent_to(render)
        self.render_pipeline.prepare_scene(model)

        # Init movement controller
        self.controller = MovementController(self)
        self.controller.set_initial_position(
            Vec3(-7.5, -5.3, 1.8), Vec3(-5.9, -4.0, 1.6))
        self.controller.setup()

        base.accept("l", self.tour)

    def tour(self):
        """ Camera flythrough """
        mopath = (
            (Vec3(-10.8645000458, 9.76458263397, 2.13306283951), Vec3(-133.556228638, -4.23447799683, 0.0)),
            (Vec3(-10.6538448334, -5.98406457901, 1.68028640747), Vec3(-59.3999938965, -3.32706642151, 0.0)),
            (Vec3(9.58458328247, -5.63625621796, 2.63269257545), Vec3(58.7906494141, -9.40668964386, 0.0)),
            (Vec3(6.8135137558, 11.0153560638, 2.25509500504), Vec3(148.762527466, -6.41223621368, 0.0)),
            (Vec3(-9.07093334198, 3.65908527374, 1.42396306992), Vec3(245.362503052, -3.59927511215, 0.0)),
            (Vec3(-8.75390911102, -3.82727789879, 0.990055501461), Vec3(296.090484619, -0.604830980301, 0.0)),
        )
        self.controller.play_motion_path(mopath, 3.0)
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:60,代码来源:main.py

示例3: MainBase

class MainBase(ShowBase):

    def __init__(self):

        load_prc_file_data("", "win-size {} {}".format(w, h))
        load_prc_file_data("", "window-type offscreen")

        self.rp = RenderPipeline(self)
        self.rp.load_settings(
            os.path.join(base_path, "pipeline.yaml"))
        self.rp.set_empty_loading_screen()
        self.rp.create()

        self.rp.daytime_mgr.time = 0.45

        model = loader.loadModel("preview.bam")
        model.reparent_to(render)
        model.set_two_sided(True)
        self.rp.prepare_scene(model)

        base.disable_mouse()
        base.camLens.set_fov(110)

        base.render2d.hide()
        base.pixel2d.hide()
        base.pixel2dp.hide()

        main_cam = model.find("**/Camera")
        if main_cam:
            transform_mat = main_cam.get_transform(render).get_mat()
            transform_mat = Mat4.convert_mat(CS_zup_right, CS_yup_right) * transform_mat
            base.camera.set_mat(transform_mat)
        else:
            print("WARNING: No camera found")
开发者ID:pmp-p,项目名称:Panda3D-Bam-Exporter,代码行数:34,代码来源:generate.py

示例4: __init__

    def __init__(self):

        # Setup window size, title and so on
        load_prc_file_data("", """
            win-size 1600 900
            window-title Render Pipeline - Material Sample
        """)

        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)

        # Set time of day
        self.render_pipeline.daytime_mgr.time = "19:17"

        # Load the scene
        model = loader.load_model("scene/TestScene.bam")
        model.reparent_to(render)
        self.render_pipeline.prepare_scene(model)

        # Enable parallax mapping on the floor
        self.render_pipeline.set_effect(model.find("**/FloorPlane"),
            "effects/default.yaml", {"parallax_mapping": True}, 100)

        # Initialize movement controller
        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(
            Vec3(-17.2912578583, -13.290019989, 6.88211250305),
            Vec3(-39.7285499573, -14.6770210266, 0.0))
        self.controller.setup()
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:29,代码来源:main.py

示例5: __init__

    def __init__(self):
        """ Inits the showbase """

        # Load options
        load_prc_file_data("", """
        model-cache-dir
        fullscreen #f
        win-size 1920 1080
        window-title Render Pipeline by tobspr 
        icon-filename dataGUI/icon.ico
        """)

        # Load render pipeline
        self.render_pipeline = RenderPipeline(self)
        self.render_pipeline.create()


        # Init movement controller
        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()

        # Hotkeys
        self.accept("r", self._reload_shader)

        self.addTask(self.update, "update")
        self.scene_wireframe = False

        self._init_terrain()
        self._reload_shader()
开发者ID:2lost4u,项目名称:P3DFramework,代码行数:31,代码来源:main.py

示例6: Application

class Application(ShowBase):

    def __init__(self):
        # Notice that you must not call ShowBase.__init__ (or super), the render
        # pipeline does that for you.

        # 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, "../../")
        sys.path.insert(0, "../../RenderPipeline")

        # Import render pipeline classes
        from rpcore import RenderPipeline, SpotLight

        # Construct and create the pipeline
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:18,代码来源:main.py

示例7: __init__

    def __init__(self):

        load_prc_file_data("", "textures-power-2 none")
        load_prc_file_data("", "win-size 1600 900")
        # load_prc_file_data("", "fullscreen #t")
        load_prc_file_data("", "window-title cuboid")
        load_prc_file_data("", "icon-filename res/icon.ico")

        # I found openal works better for me
        load_prc_file_data("", "audio-library-name p3openal_audio")

         # ------ Begin of render pipeline code ------

        # Insert the pipeline path to the system path, this is required to be
        # able to import the pipeline classes
        pipeline_path = "../../"

        # Just a special case for my development setup, so I don't accidentally
        # commit a wrong path. You can remove this in your own programs.
        if not os.path.isfile(os.path.join(pipeline_path, "setup.py")):
            pipeline_path = "../../RenderPipeline/"

        sys.path.insert(0, pipeline_path)

        # Use the utility script to import the render pipeline classes
        from rpcore import RenderPipeline

        self.render_pipeline = RenderPipeline()
        self.render_pipeline.mount_mgr.mount()
        self.render_pipeline.load_settings("/$$rpconfig/pipeline.yaml")
        self.render_pipeline.settings["pipeline.display_debugger"] = False
        self.render_pipeline.set_empty_loading_screen()
        self.render_pipeline.create(self)

        # [Optional] use the default skybox, you can use your own skybox as well
        # self.render_pipeline.create_default_skybox()

        # ------ End of render pipeline code, thats it! ------


        # Set time of day
        self.render_pipeline.daytime_mgr.time = 0.812

        self.menu = Menu(self)
        self.level = Level(self)
        self.cube = Cube(self.level)
        self.camControl = CamControl(self.cube)
        self.gui = GUI(self)
        self.menu.showMenu()
        base.accept("i",self.camControl.zoomIn)
        base.accept("o",self.camControl.zoomOut)
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:51,代码来源:GameControl.py

示例8: World

class World(ShowBase):

    def __init__(self):

        # Setup window size, title and so on
        load_prc_file_data("", """
        win-size 1600 900
        window-title Render Pipeline - Roaming Ralph Demo
        """)

        # ------ Begin of render pipeline code ------

        # Insert the pipeline path to the system path, this is required to be
        # able to import the pipeline classes
        pipeline_path = "../../"

        # Just a special case for my development setup, so I don't accidentally
        # commit a wrong path. You can remove this in your own programs.
        if not os.path.isfile(os.path.join(pipeline_path, "setup.py")):
            pipeline_path = "../../RenderPipeline/"

        sys.path.insert(0, pipeline_path)

        from rpcore import RenderPipeline, SpotLight
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)

        # ------ End of render pipeline code, thats it! ------

        # Set time of day
        self.render_pipeline.daytime_mgr.time = "7:40"

        # Use a special effect for rendering the scene, this is because the
        # roaming ralph model has no normals or valid materials
        self.render_pipeline.set_effect(render, "scene-effect.yaml", {}, sort=250)

        self.keyMap = {"left":0, "right":0, "forward":0, "backward":0, "cam-left":0, "cam-right":0}
        self.speed = 1.0
        base.win.setClearColor(Vec4(0,0,0,1))

        # Post the instructions

        self.inst1 = addInstructions(0.95, "[ESC]  Quit")
        self.inst4 = addInstructions(0.90, "[W]  Run Ralph Forward")
        self.inst4 = addInstructions(0.85, "[S]  Run Ralph Backward")
        self.inst2 = addInstructions(0.80, "[A]  Rotate Ralph Left")
        self.inst3 = addInstructions(0.75, "[D]  Rotate Ralph Right")
        self.inst6 = addInstructions(0.70, "[Left Arrow]  Rotate Camera Left")
        self.inst7 = addInstructions(0.65, "[Right Arrow]  Rotate Camera Right")

        # Set up the environment
        #
        # This environment model contains collision meshes.  If you look
        # in the egg file, you will see the following:
        #
        #    <Collide> { Polyset keep descend }
        #
        # This tag causes the following mesh to be converted to a collision
        # mesh -- a mesh which is optimized for collision, not rendering.
        # It also keeps the original mesh, so there are now two copies ---
        # one optimized for rendering, one for collisions.

        self.environ = loader.loadModel("resources/world")
        self.environ.reparentTo(render)
        self.environ.setPos(0,0,0)


        # Remove wall nodes
        self.environ.find("**/wall").remove_node()

        # Create the main character, Ralph
        self.ralph = Actor("resources/ralph",
                                 {"run":"resources/ralph-run",
                                  "walk":"resources/ralph-walk"})
        self.ralph.reparentTo(render)
        self.ralph.setScale(.2)
        self.ralph.setPos(Vec3(-110.9, 29.4, 1.8))

        # Create a floater object.  We use the "floater" as a temporary
        # variable in a variety of calculations.

        self.floater = NodePath(PandaNode("floater"))
        self.floater.reparentTo(render)

        # Accept the control keys for movement and rotation

        self.accept("escape", sys.exit)
        self.accept("a", self.setKey, ["left",1])
        self.accept("d", self.setKey, ["right",1])
        self.accept("w", self.setKey, ["forward",1])
        self.accept("s", self.setKey, ["backward",1])
        self.accept("arrow_left", self.setKey, ["cam-left",1])
        self.accept("arrow_right", self.setKey, ["cam-right",1])
        self.accept("a-up", self.setKey, ["left",0])
        self.accept("d-up", self.setKey, ["right",0])
        self.accept("w-up", self.setKey, ["forward",0])
        self.accept("s-up", self.setKey, ["backward",0])
        self.accept("arrow_left-up", self.setKey, ["cam-left",0])
        self.accept("arrow_right-up", self.setKey, ["cam-right",0])
        self.accept("=", self.adjustSpeed, [0.25])
#.........这里部分代码省略.........
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:101,代码来源:main.py

示例9: __init__

    def __init__(self):
        # Setup window size and title
        load_prc_file_data(
            "",
            """
            # win-size 1600 900
            window-title Render Pipeline - Instancing Example
        """,
        )

        # Construct the render pipeline
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)
        self.render_pipeline.daytime_mgr.time = "19:17"
        # self.render_pipeline.daytime_mgr.time = "12:00"

        # Load the scene
        model = self.loader.load_model("scene/Scene.bam")
        model.reparent_to(self.render)

        # Find the prefab object, we are going to in instance this object
        # multiple times
        prefab = model.find("**/InstancedObjectPrefab")

        # Collect all instances
        matrices = []
        for elem in model.find_all_matches("**/PREFAB*"):
            matrices.append(elem.get_mat(self.render))
            elem.remove_node()

        print("Loaded", len(matrices), "instances!")

        # Allocate storage for the matrices, each matrix has 16 elements,
        # but because one pixel has four components, we need amount * 4 pixels.
        buffer_texture = Texture()
        buffer_texture.setup_buffer_texture(len(matrices) * 4, Texture.T_float, Texture.F_rgba32, GeomEnums.UH_static)

        float_size = len(struct.pack("f", 0.0))
        floats = []

        # Serialize matrices to floats
        ram_image = buffer_texture.modify_ram_image()

        for idx, mat in enumerate(matrices):
            for i in range(4):
                for j in range(4):
                    floats.append(mat.get_cell(i, j))

        # Write the floats to the texture
        data = struct.pack("f" * len(floats), *floats)
        ram_image.set_subdata(0, len(data), data)

        # Load the effect
        self.render_pipeline.set_effect(prefab, "effects/basic_instancing.yaml", {})

        prefab.set_shader_input("InstancingData", buffer_texture)
        prefab.set_instance_count(len(matrices))

        # We have do disable culling, so that all instances stay visible
        prefab.node().set_bounds(OmniBoundingVolume())
        prefab.node().set_final(True)

        # Initialize movement controller, this is a convenience class
        # to provide an improved camera control compared to Panda3Ds default
        # mouse controller.
        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(Vec3(-23.2, -32.5, 5.3), Vec3(-33.8, -8.3, 0.0))
        self.controller.setup()
开发者ID:tobspr,项目名称:RenderPipeline-Samples,代码行数:68,代码来源:main.py

示例10: GameControl

class GameControl(ShowBase):
    """
    controlling the game itself, menu, editors level selection... it's sorta a fake-fsm.
    did i mention i dont like fsm's and prefer totaly whicked logic instead?
    """
    def __init__(self):

        load_prc_file_data("", "textures-power-2 none")
        load_prc_file_data("", "win-size 1600 900")
        # load_prc_file_data("", "fullscreen #t")
        load_prc_file_data("", "window-title cuboid")
        load_prc_file_data("", "icon-filename res/icon.ico")

        # I found openal works better for me
        load_prc_file_data("", "audio-library-name p3openal_audio")

         # ------ Begin of render pipeline code ------

        # Insert the pipeline path to the system path, this is required to be
        # able to import the pipeline classes
        pipeline_path = "../../"

        # Just a special case for my development setup, so I don't accidentally
        # commit a wrong path. You can remove this in your own programs.
        if not os.path.isfile(os.path.join(pipeline_path, "setup.py")):
            pipeline_path = "../../RenderPipeline/"

        sys.path.insert(0, pipeline_path)

        # Use the utility script to import the render pipeline classes
        from rpcore import RenderPipeline

        self.render_pipeline = RenderPipeline()
        self.render_pipeline.mount_mgr.mount()
        self.render_pipeline.load_settings("/$$rpconfig/pipeline.yaml")
        self.render_pipeline.settings["pipeline.display_debugger"] = False
        self.render_pipeline.set_empty_loading_screen()
        self.render_pipeline.create(self)

        # [Optional] use the default skybox, you can use your own skybox as well
        # self.render_pipeline.create_default_skybox()

        # ------ End of render pipeline code, thats it! ------


        # Set time of day
        self.render_pipeline.daytime_mgr.time = 0.812

        self.menu = Menu(self)
        self.level = Level(self)
        self.cube = Cube(self.level)
        self.camControl = CamControl(self.cube)
        self.gui = GUI(self)
        self.menu.showMenu()
        base.accept("i",self.camControl.zoomIn)
        base.accept("o",self.camControl.zoomOut)

    def startGame(self,level=0):
        #debug purpose only: to directly play a certian lvl number
        from sys import argv
        if len(argv) >1:
            level = int(argv[1])

        self.menu.hideMenu()
        self.level.loadLevel(level)
        self.cube.resetCube()
        self.cube.resetStats()
        self.cube.enableGameControl()
        base.accept("escape", self.pauseGame)

    def pauseGame(self):
        self.cube.disableGameControl()
        self.menu.showMenu()
        self.menu.showResume()
        #base.accept("escape", self.resumeGame )

    def resumeGame(self):
        self.menu.hideMenu()
        self.menu.hideResume()
        self.cube.enableGameControl()
        base.accept("escape", self.pauseGame)

    def levelEnd(self):
        self.cube.disableGameControl()
        self.menu.showMenu()
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:85,代码来源:GameControl.py

示例11: __init__

    def __init__(self):
        sys.path.insert(0, "../../")
        load_prc_file_data("", "win-size 512 512")
        load_prc_file_data("", "textures-power-2 none")
        load_prc_file_data("", "print-pipe-types #f")
        load_prc_file_data("", "notify-level-glgsg error")
        # load_prc_file_data("", "win-size 1024 1024")

        from rpcore import RenderPipeline, PointLight

        self.render_pipeline = RenderPipeline()
        self.render_pipeline.mount_mgr.config_dir = "config/"
        self.render_pipeline.set_empty_loading_screen()
        self.render_pipeline.create(self)

        sphere = loader.loadModel("res/sphere.bam")
        sphere.reparent_to(render)

        self.disableMouse()
        self.camLens.setFov(40)
        self.camLens.setNearFar(0.03, 2000.0)
        self.camera.set_pos(0, -3.5, 0)
        self.camera.look_at(0, -2.5, 0)

        self.render2d.hide()
        self.aspect2d.hide()

        light = PointLight()
        light.pos = 10, -10, 10
        light.radius = 1e20
        light.color = (1, 1, 1)
        light.inner_radius = 4.0
        light.energy = 3
        self.render_pipeline.add_light(light)

        light = PointLight()
        light.pos = -10, -10, 10
        light.radius = 1e20
        light.color = (1, 1, 1)
        light.inner_radius = 4.0
        light.energy = 3
        self.render_pipeline.add_light(light)

        for mat in sphere.find_all_materials():
            mat.roughness = material.roughness
            mat.base_color = Vec4(*(list(material.basecolor) + [1]))
            mat.refractive_index = material.ior

            mat.metallic = 1.0 if material.mat_type == "metallic" else 0.0

            if material.mat_type == "clearcoat":
                mat.emission = (2, 0, 0, 0)
                mat.metallic = 1.0
                mat.refractive_index = 1.51

            if material.mat_type == "foliage":
                mat.emission = (5, 0, 0, 0)
                mat.metallic = 0.0
                mat.refractive_index = 1.51

        for i in range(10):
            self.taskMgr.step()

        self.win.save_screenshot("scene-rp.png")

        base.accept("r", self.reload)
开发者ID:aimoonchen,项目名称:RenderPipeline,代码行数:66,代码来源:run_renderpipeline.py

示例12: __init__

    def __init__(self):
        
        self.renderPipeline = True
        
        if(self.renderPipeline is True):
            # Notice that you must not call ShowBase.__init__ (or super), the render
            # pipeline does that for you.
    
            # 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, "Game/render_pipeline")
            #sys.path.insert(0, "../../RenderPipeline")
            
            # Import render pipeline classes
            from rpcore import RenderPipeline, SpotLight
    
            # Construct and create the pipeline
            self.render_pipeline = RenderPipeline()
            self.render_pipeline.create(self)
    
            # Done! You can start setting up your application stuff as regular now.
        else:
            ShowBase.__init__(self)
        

                    
        
        #Debug stuff
        self.debug = True
        if(self.debug is True):
            base.setFrameRateMeter(True)
            render.analyze()
            
        #Disable modifiers Shift+Something/Alt+Something/Ctrl+Something
        base.mouseWatcherNode.set_modifier_buttons(ModifierButtons())
        base.buttonThrowers[0].node().set_modifier_buttons(ModifierButtons())
        

        #Create bullet world
        self.bWorld = bWorld('Game/models/maps/debug.egg')
                    
        #Add task to process physics
        taskMgr.add(self.update, 'updateWorld')

        
        #Set up the player
        self.bController = kCharacterController(self.bWorld.world, self.bWorld.worldNP, 1.75, 1.3, 0, 0.4)
        self.bController.setPos(render, Point3(0, 0, 10))        
        
        self.player = Player(self.bController,"Game/models/player/swifter",.1)
        
        self.keyboardSetup(self.player)
        
        # Create a camera to follow the player.
        #base.oobe()  

        # Attach the camera to the bullet controller's capsule node path 
        camera = Camera(self.bController)
        

        # Accept the Esc key to quit the game.
    
        self.accept("escape", sys.exit)   
开发者ID:Wully616,项目名称:Swifter,代码行数:65,代码来源:game.py

示例13: the

"""

This is an alternative possibility of initializing the RenderPipeline, which
uses the (deprecated!) DirectStart interface. This should not be used anymore,
except for fast prototyping.

"""

import sys

# 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, "../../")
sys.path.insert(0, "../../RenderPipeline")

# Import render pipeline classes
from rpcore import RenderPipeline

# Construct and create the pipeline
render_pipeline = RenderPipeline()
render_pipeline.pre_showbase_init()

# Import (deprecated!) DirectStart interface
import direct.directbase.DirectStart
render_pipeline.create(base)

base.run()
开发者ID:tobspr,项目名称:RenderPipeline-Samples,代码行数:28,代码来源:main-possibility3.py

示例14: Application

class Application(ShowBase):

    ICOMING_PORT = 62360

    def __init__(self):
        load_prc_file_data("", "win-size 512 512")
        # load_prc_file_data("", "window-type offscreen")
        load_prc_file_data("", "model-cache-dir")
        load_prc_file_data("", "model-cache-textures #f")
        load_prc_file_data("", "textures-power-2 none")
        load_prc_file_data("", "alpha-bits 0")
        load_prc_file_data("", "print-pipe-types #f")

        # Construct render pipeline
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.mount_mgr.config_dir = "config/"
        self.render_pipeline.set_empty_loading_screen()
        self.render_pipeline.create(self)

        self.setup_scene()

        # Disable model caching
        BamCache.get_global_ptr().cache_models = False

        self.update_queue = []
        self.start_listen()

        # Render initial frames
        for i in range(10):
            self.taskMgr.step()

        last_update = 0.0
        self.scene_node = None

        current_lights = []
        current_envprobes = []

        # Wait for updates
        while True:

            # Update once in a while
            curr_time = time.time()
            if curr_time > last_update + 1.0:
                last_update = curr_time
                self.taskMgr.step()

            if self.update_queue:
                if self.scene_node:
                    self.scene_node.remove_node()

                # Only take the latest packet
                payload = self.update_queue.pop(0)
                print("RENDERING:", payload)

                scene = loader.loadModel(Filename.from_os_specific(payload["scene"]))

                for light in scene.find_all_matches("**/+PointLight"):
                    light.remove_node()
                for light in scene.find_all_matches("**/+Spotlight"):
                    light.remove_node()

                # Find camera
                main_cam = scene.find("**/Camera")
                if main_cam:
                    transform_mat = main_cam.get_transform(render).get_mat()
                    transform_mat = Mat4.convert_mat(CS_zup_right, CS_yup_right) * transform_mat
                    base.camera.set_mat(transform_mat)
                else:
                    print("WARNING: No camera found")
                    base.camera.set_pos(0, -3.5, 0)
                    base.camera.look_at(0, -2.5, 0)

                base.camLens.set_fov(64.0)

                self.scene_node = scene
                scene.reparent_to(render)

                # Render scene
                for i in range(8):
                    self.taskMgr.step()

                dest_path = Filename.from_os_specific(payload["dest"])
                print("Saving screenshot to", dest_path)
                self.win.save_screenshot(dest_path)
                self.notify_about_finish(int(payload["pingback_port"]))

    def start_listen(self):
        """ Starts the listener thread """
        thread = Thread(target=self.listener_thread, args=(), name="ListenerThread")
        thread.setDaemon(True)
        thread.start()
        return thread

    def listener_thread(self):
        """ Thread which listens to incoming updates """
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        print("Listening on 127.0.0.1:" + str(self.ICOMING_PORT))
        try:
            sock.bind(("127.0.0.1", self.ICOMING_PORT))
#.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:RenderPipeline,代码行数:101,代码来源:service.py

示例15: __init__

    def __init__(self):
        load_prc_file_data("", "win-size 512 512")
        # load_prc_file_data("", "window-type offscreen")
        load_prc_file_data("", "model-cache-dir")
        load_prc_file_data("", "model-cache-textures #f")
        load_prc_file_data("", "textures-power-2 none")
        load_prc_file_data("", "alpha-bits 0")
        load_prc_file_data("", "print-pipe-types #f")

        # Construct render pipeline
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.mount_mgr.config_dir = "config/"
        self.render_pipeline.set_empty_loading_screen()
        self.render_pipeline.create(self)

        self.setup_scene()

        # Disable model caching
        BamCache.get_global_ptr().cache_models = False

        self.update_queue = []
        self.start_listen()

        # Render initial frames
        for i in range(10):
            self.taskMgr.step()

        last_update = 0.0
        self.scene_node = None

        current_lights = []
        current_envprobes = []

        # Wait for updates
        while True:

            # Update once in a while
            curr_time = time.time()
            if curr_time > last_update + 1.0:
                last_update = curr_time
                self.taskMgr.step()

            if self.update_queue:
                if self.scene_node:
                    self.scene_node.remove_node()

                # Only take the latest packet
                payload = self.update_queue.pop(0)
                print("RENDERING:", payload)

                scene = loader.loadModel(Filename.from_os_specific(payload["scene"]))

                for light in scene.find_all_matches("**/+PointLight"):
                    light.remove_node()
                for light in scene.find_all_matches("**/+Spotlight"):
                    light.remove_node()

                # Find camera
                main_cam = scene.find("**/Camera")
                if main_cam:
                    transform_mat = main_cam.get_transform(render).get_mat()
                    transform_mat = Mat4.convert_mat(CS_zup_right, CS_yup_right) * transform_mat
                    base.camera.set_mat(transform_mat)
                else:
                    print("WARNING: No camera found")
                    base.camera.set_pos(0, -3.5, 0)
                    base.camera.look_at(0, -2.5, 0)

                base.camLens.set_fov(64.0)

                self.scene_node = scene
                scene.reparent_to(render)

                # Render scene
                for i in range(8):
                    self.taskMgr.step()

                dest_path = Filename.from_os_specific(payload["dest"])
                print("Saving screenshot to", dest_path)
                self.win.save_screenshot(dest_path)
                self.notify_about_finish(int(payload["pingback_port"]))
开发者ID:gitter-badger,项目名称:RenderPipeline,代码行数:81,代码来源:service.py


注:本文中的rpcore.RenderPipeline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。