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


Python RenderPipeline.add_light方法代码示例

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


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

示例1: MainApp

# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import add_light [as 别名]
class MainApp(ShowBase):

    """ Main Testing Showbase """

    def __init__(self):

        # Setup window size, title and so on
        load_prc_file_data("", """
        win-size 1600 900
        window-title Render Pipeline - Lights 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! ------

        # Set time of day
        self.render_pipeline.daytime_mgr.time = "4:50"

        self.half_energy = 5000
        self.lamp_fov = 70
        self.lamp_radius = 10
        # Load the scene
        model = loader.loadModel("scene/Scene.bam")
        model.reparent_to(render)

        # Animate balls, this is for testing the motion blur
        blend_type = "noBlend"

        np = model.find("**/MBRotate")
        np.hprInterval(1.5, Vec3(360, 360, 0), Vec3(0, 0, 0), blendType=blend_type).loop()

        np = model.find("**/MBUpDown")
        np_pos = np.get_pos() - Vec3(0, 0, 2)
        Sequence(
            np.posInterval(0.15, np_pos + Vec3(0, 0, 6), np_pos, blendType=blend_type),
            np.posInterval(0.15, np_pos, np_pos + Vec3(0, 0, 6), blendType=blend_type)).loop()

        np = model.find("**/MBFrontBack")
        np_pos = np.get_pos() - Vec3(0, 0, 2)
        Sequence(
            np.posInterval(0.15, np_pos + Vec3(0, 6, 0), np_pos, blendType=blend_type),
            np.posInterval(0.15, np_pos, np_pos + Vec3(0, 6, 0), blendType=blend_type)).loop()

        np = model.find("**/MBScale")
        Sequence(
            np.scaleInterval(0.2, Vec3(1.5), Vec3(1), blendType=blend_type),
            np.scaleInterval(0.2, Vec3(1), Vec3(1.5), blendType=blend_type)).loop()


        # Generate temperature lamps
        # This shows how to procedurally create lamps. In this case, we
        # base the lights positions on empties created in blender.
        self._lights = []
        light_key = lambda light: int(light.get_name().split("LampLum")[-1])
        lumlamps = sorted(model.find_all_matches("**/LampLum*"), key=light_key)
        for lumlamp in lumlamps:
            lum = float(lumlamp.get_name()[len("LampLum"):])
            light = SpotLight()
            light.direction = (0, -1.5, -1)
            light.fov = self.lamp_fov
            light.set_color_from_temperature(lum * 1000.0)
            light.energy = self.half_energy
            light.pos = lumlamp.get_pos(self.render)
            light.radius = self.lamp_radius
            light.casts_shadows = False
            light.shadow_map_resolution = 256
            self.render_pipeline.add_light(light)

            # Put Pandas on the edges
            if lumlamp in lumlamps[0:2] + lumlamps[-2:]:
                panda = loader.loadModel("panda")
                panda.reparent_to(render)
                panda_mat = Material("default")
                panda_mat.emission = 0
                panda.set_material(panda_mat)
                panda.set_pos(light.pos)
                panda.set_z(0.65)
                panda.set_h(180 + randint(-60, 60))
                panda.set_scale(0.2)
                panda.set_y(panda.get_y() - 3.0)
#.........这里部分代码省略.........
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:103,代码来源:main.py

示例2: Application

# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import add_light [as 别名]
class Application(ShowBase):

    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)

    def reload(self):
        print("Reloading")
        self.render_pipeline.reload_shaders()

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

        self.win.save_screenshot("scene-rp.png")
开发者ID:aimoonchen,项目名称:RenderPipeline,代码行数:79,代码来源:run_renderpipeline.py


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