コード例 #1
0
    vfs = VirtualFileSystem.getGlobalPtr()
    render_pipeline.create()
    # sandbox.base.camLens.set_far(100000)
    skybox = render_pipeline.getDefaultSkybox(scale=base.camLens.get_far() * 0.8)
    skybox.set_scale(base.camLens.get_far() * 0.8)
    skybox.reparent_to(base.render)

    mesh = Surface("Earth")
    mesh.set_textures(database["textures"])
    mesh.set_scale(6371)
    pos = 6371 + 9000
    mesh.set_pos(Point3(0, pos, 0))
    render_pipeline.setEffect(mesh.node_path, "Effects/Earth.effect")
    mesh.reparent_to(base.render)

    sun_light = DirectionalLight()
    sun_pos = Vec3(10000, pos, 0)
    sun_light.setSunDistance(20000)
    sun_light.setPos(sun_pos)
    sun_light.setPssmTarget(base.cam, base.camLens)
    sun_light.setColor(Vec3(1.0))
    sun_light.setShadowMapResolution(2048)
    sun_light.setCastsShadows(True)
    render_pipeline.addLight(sun_light)

    scattering = render_pipeline.getScattering()
    scattering.adjustSetting("atmosphereOffset", Vec3(0, pos, 0))
    scattering.adjustSetting("atmosphereScale", Vec3(1.0))
    render_pipeline.setScatteringSource(sun_light)

    controller = MovementController(base)
コード例 #2
0
    pos = 0
    print("Saturn position:", pos)
    saturn.set_pos(Point3(0, pos, 0))
    saturn.load_texture_special()
    saturn.load_shaders()
    saturn.reparent_to(base.render)

    rings = Ring("Rings")
    rings.set_pos(Point3(0, pos, 0))
    rings.set_scale(scale)
    rings.load_texture_special()
    render_pipeline.setEffect(rings.node_path, "Ring.effect", {
        "transparent": True
    })
    rings.reparent_to(base.render)

    sun_light = DirectionalLight()
    sun_light.setDirection(Vec3(10, pos, 5))
    sun_light.setPssmTarget(base.cam, base.camLens)
    sun_light.setColor(Vec3(1.0))
    sun_light.setShadowMapResolution(2048)
    sun_light.setCastsShadows(True)  # Must go last
    render_pipeline.addLight(sun_light)

    base.accept("f3", toggleSceneWireframe)
    base.accept("f4", toggleSceneWireframe2)
    render_pipeline.reloadShaders()
    render_pipeline.onSceneInitialized()

    base.run()