4 from sys
import platform
, argv
5 from logging
import info
6 from os
.path
import exists
7 from os
import makedirs
8 from panda3d
.core
import Filename
, load_prc_file_data
, AntialiasAttrib
9 from panda3d
.bullet
import BulletWorld
, BulletDebugNode
10 from direct
.showbase
.ShowBase
import ShowBase
11 from pmachines
.scene
import Scene
18 self
.base
= ShowBase()
19 info('platform: %s' % platform
)
20 info('exists main.py: %s' % exists('main.py'))
21 self
._prepare
_window
()
22 args
= self
._parse
_args
()
23 self
.updating
= args
.update
24 self
.version
= args
.version
31 load_prc_file_data('', 'window-title pmachines')
32 load_prc_file_data('', 'framebuffer-multisample 1')
33 load_prc_file_data('', 'multisamples 4')
34 load_prc_file_data('', 'framebuffer-srgb true')
36 def _parse_args(self
):
37 parser
= argparse
.ArgumentParser()
38 parser
.add_argument('--update', action
='store_true')
39 parser
.add_argument('--version', action
='store_true')
40 cmd_line
= [arg
for arg
in iter(argv
[1:]) if not arg
.startswith('-psn_')]
41 args
= parser
.parse_args(cmd_line
)
44 def _prepare_window(self
):
46 if (platform
.startswith('win') or platform
.startswith('linux')) and (
47 not exists('main.py') or __file__
.startswith('/app/bin/')):
48 # it is the deployed version for windows
49 data_path
= str(Filename
.get_user_appdata_directory()) + '/pmachines'
50 home
= '/home/flavio' # we must force this for wine
51 if data_path
.startswith('/c/users/') and exists(home
+ '/.wine/'):
52 data_path
= home
+ '/.wine/drive_' + data_path
[1:]
53 info('creating dirs: %s' % data_path
)
54 makedirs(data_path
, exist_ok
=True)
55 gltf
.patch_loader(base
.loader
)
56 pipeline
= simplepbr
.init(
58 use_emission_maps
=False,
59 use_occlusion_maps
=True,
61 render
.setAntialias(AntialiasAttrib
.MAuto
)
62 self
.base
.set_background_color(0, 0, 0, 1)
63 self
.base
.disable_mouse()
65 def _set_physics(self
):
66 debug_node
= BulletDebugNode('Debug')
67 debug_node
.show_wireframe(True)
68 debug_node
.show_constraints(True)
69 debug_node
.show_bounding_boxes(True)
70 debug_node
.show_normals(True)
71 debug_np
= render
.attach_new_node(debug_node
)
73 self
.world
= BulletWorld()
74 self
.world
.set_gravity((0, 0, -9.81))
75 self
.world
.set_debug_node(debug_np
.node())
77 dt
= globalClock
.get_dt()
78 self
.world
.do_physics(dt
)
80 taskMgr
.add(update
, 'update')