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, AntialiasAttrib
+from panda3d.bullet import BulletWorld, BulletDebugNode
from direct.showbase.ShowBase import ShowBase
+from pmachines.scene import Scene
class Pmachines:
self.base = ShowBase()
info('platform: %s' % platform)
info('exists main.py: %s' % exists('main.py'))
- self._prepare_windows()
+ self._prepare_window()
args = self._parse_args()
self.updating = args.update
self.version = args.version
if args.update:
return
+ self._set_physics()
+ Scene(self.world)
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()
args = parser.parse_args(cmd_line)
return args
- def _prepare_windows(self):
+ def _prepare_window(self):
data_path = ''
if (platform.startswith('win') or platform.startswith('linux')) and (
not exists('main.py') or __file__.startswith('/app/bin/')):
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)
+ self.base.set_background_color(0, 0, 0, 1)
+ self.base.disable_mouse()
+
+ def _set_physics(self):
+ debug_node = BulletDebugNode('Debug')
+ debug_node.show_wireframe(True)
+ debug_node.show_constraints(True)
+ debug_node.show_bounding_boxes(True)
+ debug_node.show_normals(True)
+ debug_np = render.attach_new_node(debug_node)
+ debug_np.show()
+ self.world = BulletWorld()
+ self.world.set_gravity((0, 0, -9.81))
+ self.world.set_debug_node(debug_np.node())
+ def update(task):
+ dt = globalClock.get_dt()
+ self.world.do_physics(dt)
+ return task.cont
+ taskMgr.add(update, 'update')