2cfbd61108bb3f225200f82696feee6b7a9fbe50
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
12 from pmachines
.music
import MusicMgr
19 self
.base
= ShowBase()
20 info('platform: %s' % platform
)
21 info('exists main.py: %s' % exists('main.py'))
22 self
._prepare
_window
()
23 args
= self
._parse
_args
()
24 self
.updating
= args
.update
25 self
.version
= args
.version
33 load_prc_file_data('', 'window-title pmachines')
34 load_prc_file_data('', 'framebuffer-multisample 1')
35 load_prc_file_data('', 'multisamples 4')
36 load_prc_file_data('', 'framebuffer-srgb true')
38 def _parse_args(self
):
39 parser
= argparse
.ArgumentParser()
40 parser
.add_argument('--update', action
='store_true')
41 parser
.add_argument('--version', action
='store_true')
42 cmd_line
= [arg
for arg
in iter(argv
[1:]) if not arg
.startswith('-psn_')]
43 args
= parser
.parse_args(cmd_line
)
46 def _prepare_window(self
):
48 if (platform
.startswith('win') or platform
.startswith('linux')) and (
49 not exists('main.py') or __file__
.startswith('/app/bin/')):
50 # it is the deployed version for windows
51 data_path
= str(Filename
.get_user_appdata_directory()) + '/pmachines'
52 home
= '/home/flavio' # we must force this for wine
53 if data_path
.startswith('/c/users/') and exists(home
+ '/.wine/'):
54 data_path
= home
+ '/.wine/drive_' + data_path
[1:]
55 info('creating dirs: %s' % data_path
)
56 makedirs(data_path
, exist_ok
=True)
57 gltf
.patch_loader(base
.loader
)
58 pipeline
= simplepbr
.init(
60 use_emission_maps
=False,
61 use_occlusion_maps
=True,
63 render
.setAntialias(AntialiasAttrib
.MAuto
)
64 self
.base
.set_background_color(0, 0, 0, 1)
65 self
.base
.disable_mouse()
67 def _set_physics(self
):
68 debug_node
= BulletDebugNode('Debug')
69 debug_node
.show_wireframe(True)
70 debug_node
.show_constraints(True)
71 debug_node
.show_bounding_boxes(True)
72 debug_node
.show_normals(True)
73 debug_np
= render
.attach_new_node(debug_node
)
75 self
.world
= BulletWorld()
76 self
.world
.set_gravity((0, 0, -9.81))
77 self
.world
.set_debug_node(debug_np
.node())
79 dt
= globalClock
.get_dt()
80 self
.world
.do_physics(dt
)
82 taskMgr
.add(update
, 'update')