--- /dev/null
+from itertools import product
+from panda3d.core import NodePath
+
+
+class Background:
+
+ def __init__(self):
+ root = NodePath('background_root')
+ root.reparent_to(render)
+ ncols, nrows = 8, 5
+ start_size, end_size = 5, 2.5
+ offset = 5
+ for col, row in product(range(ncols), range(nrows)):
+ model = loader.load_model('assets/gltf/background/background.gltf')
+ model.set_scale(end_size / start_size)
+ model.reparent_to(root)
+ total_width, total_height = end_size * ncols, end_size * nrows
+ left, bottom = -total_width/2, -total_height/2
+ model.set_pos(left + end_size * col, -offset, bottom + end_size * row)
+ root.clear_model_nodes()
+ root.flatten_strong()
import argparse
+import simplepbr
+import gltf
from sys import platform, argv
from logging import info
from os.path import exists
from os import makedirs
-from panda3d.core import Filename, load_prc_file_data
+from panda3d.core import Filename, load_prc_file_data, AmbientLight, \
+ DirectionalLight, AntialiasAttrib
from direct.showbase.ShowBase import ShowBase
+from pmachines.items.background import Background
class Pmachines:
self.version = args.version
if args.update:
return
+ self._set_camera()
+ self._set_lights()
+ Background()
+
+ def _set_camera(self):
+ base.camera.set_pos(0, -20, 0)
+ base.camera.look_at(0, 0, 0)
+ self.base.disable_mouse()
+
+ def _set_lights(self):
+ alight = AmbientLight('alight') # for ao
+ alight.setColor((.4, .4, .4, 1))
+ alnp = render.attachNewNode(alight)
+ render.setLight(alnp)
+
+ directionalLight = DirectionalLight('directionalLight')
+ directionalLightNP = render.attachNewNode(directionalLight)
+ directionalLightNP.setHpr(315, -60, 0)
+ directionalLight.setColor((3.6, 3.6, 3.6, 1))
+ render.setLight(directionalLightNP)
+
+ directionalLight = DirectionalLight('directionalLight')
+ directionalLightNP = render.attachNewNode(directionalLight)
+ directionalLightNP.setHpr(195, -30, 0)
+ directionalLight.setColor((.4, .4, .4, 1))
+ render.setLight(directionalLightNP)
+
+ directionalLight = DirectionalLight('directionalLight')
+ directionalLightNP = render.attachNewNode(directionalLight)
+ directionalLightNP.setHpr(75, -30, 0)
+ directionalLight.setColor((.3, .3, .3, 1))
+ render.setLight(directionalLightNP)
def _configure(self):
load_prc_file_data('', 'window-title pmachines')
+ load_prc_file_data('', 'framebuffer-multisample 1')
+ load_prc_file_data('', 'multisamples 4')
+ load_prc_file_data('', 'framebuffer-srgb true')
def _parse_args(self):
parser = argparse.ArgumentParser()
data_path = home + '/.wine/drive_' + data_path[1:]
info('creating dirs: %s' % data_path)
makedirs(data_path, exist_ok=True)
+ gltf.patch_loader(base.loader)
+ pipeline = simplepbr.init(
+ use_normal_maps=True,
+ use_emission_maps=False,
+ use_occlusion_maps=True,
+ msaa_samples=4)
+ render.setAntialias(AntialiasAttrib.MAuto)
+ base.set_background_color(0, 0, 0, 1)