loadPrcFileData("", "want-pstats 1")
    loadPrcFileData("", "textures-power-2 none")
    loadPrcFileData("", "win-size 1600 960")
    base = ShowBase()
    base.setSleep(0.001)
    base.wireframe = False
    base.planetframe = False
    render_pipeline = RenderingPipeline(base)
    cache_dir = appdirs.user_cache_dir("spacedrive", "croxis")
    render_pipeline.getMountManager().setBasePath(os.path.dirname(os.path.realpath(renderpipeline.__file__)))
    render_pipeline.getMountManager().setWritePath(os.path.join(cache_dir, "Shaders"))
    render_pipeline.loadSettings("pipeline.ini")
    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)
Exemple #2
0
    os.path.join(cache_dir, 'Shaders'))
render_pipeline.loadSettings('pipeline.ini')

from spacedrive.renderpipeline.Code.DirectionalLight import DirectionalLight
render_pipeline.create()
dPos = Vec3(40, 40, 40)
dirLight = DirectionalLight()
dirLight.setDirection(dPos)
dirLight.setShadowMapResolution(2048)
dirLight.setCastsShadows(True)
dirLight.setPos(dPos)
dirLight.setColor(Vec3(6))
render_pipeline.addLight(dirLight)


def toggleSceneWireframe():
    sandbox.base.wireframe = not sandbox.base.wireframe
    if sandbox.base.wireframe:
        sandbox.base.render.setRenderModeWireframe()
    else:
        sandbox.base.render.clearRenderMode()

sandbox.base.accept("f3", toggleSceneWireframe)
sandbox.base.wireframe = False

render_pipeline.onSceneInitialized()
skybox = render_pipeline.getDefaultSkybox()
skybox.reparentTo(render)

spacedrive.run()