def load_prefs(self, cfg): global prefs if 'general' in cfg.sections(): prefs['binpath'] = cfg.get('general', 'binary_path') prefs['assetdir'] = cfg.get('general', 'asset_dir') prefs['verbose'] = cfg.getboolean('general', 'verbose') else: prefs['binpath'] = os.path.abspath(util.get_exec_dir(__file__) + '/../../bin/h3dimport') prefs['assetdir'] = os.path.abspath(util.get_exec_dir(__file__) + '/../..') prefs['verbose'] = False if platform.system() == "Windows": prefs['binpath'] += ".exe"
def load_prefs(self, cfg): global prefs if 'general' in cfg.sections(): prefs['binpath'] = cfg.get('general', 'binary_path') prefs['assetdir'] = cfg.get('general', 'asset_dir') prefs['verbose'] = cfg.getboolean('general', 'verbose') else: prefs['binpath'] = os.path.abspath( util.get_exec_dir(__file__) + '/../../bin/h3dimport') prefs['assetdir'] = os.path.abspath( util.get_exec_dir(__file__) + '/../..') prefs['verbose'] = False if platform.system() == "Windows": prefs['binpath'] += ".exe"
def initialize(assetdir, widget): global is_init, rts name = str(widget.winId().__hex__()) hwnd = dheng.str_toptr(widget.winId().__hex__()) if 'linux' in sys.platform: QtGui.QApplication.syncX() # important, must be called after winId() if is_init: if widget not in rts: if not dheng.app_add_rendertarget(name, hwnd, widget.width(), widget.height()): return False else: rts.append(widget) return True if not dheng.core_init(ctypes.c_uint32(dheng.CORE_INIT_ALL).value): print 'Engine core init failed' return False dheng.log_outputconsole(True) params = dheng.init_params() params.flags = dheng.ENG_FLAG_DEBUG | dheng.ENG_FLAG_DISABLEPHX | dheng.ENG_FLAG_DEV | \ dheng.ENG_FLAG_DISABLEBGLOAD params.gfx.flags = dheng.GFX_FLAG_DEBUG | dheng.GFX_FLAG_FXAA params.gfx.width = 128 params.gfx.height = 128 params.sct.mem_sz = 128 params.dev.buffsize_data = 256 params.data_dir = os.path.abspath( util.get_exec_dir(__file__) + '/../../data') if not dheng.app_init(name, params): dheng.err_sendtolog(False) dheng.core_release(False) return False if not dheng.eng_init(params): dheng.err_sendtolog(False) dheng.app_release() dheng.core_release(False) dheng.err_sendtolog(True) return False dheng.gfx_set_debug_renderfunc(dheng.gfx_render_grid) ## set path for our stuff dheng.fio_addvdir(assetdir, True) ## single scene with camera global scene scene = dheng.scn_create_scene('main') dheng.scn_setactive(scene) is_init = True rts.append(widget) return True
def initialize(assetdir, widget): global is_init, rts name = str(widget.winId().__hex__()) hwnd = dheng.str_toptr(widget.winId().__hex__()) if 'linux' in sys.platform: QtGui.QApplication.syncX() # important, must be called after winId() if is_init: if widget not in rts: if not dheng.app_add_rendertarget(name, hwnd, widget.width(), widget.height()): return False else: rts.append(widget) return True if not dheng.core_init(ctypes.c_uint32(dheng.CORE_INIT_ALL).value): print 'Engine core init failed' return False dheng.log_outputconsole(True) params = dheng.init_params() params.flags = dheng.ENG_FLAG_DEBUG | dheng.ENG_FLAG_DISABLEPHX | dheng.ENG_FLAG_DEV | \ dheng.ENG_FLAG_DISABLEBGLOAD params.gfx.flags = dheng.GFX_FLAG_DEBUG | dheng.GFX_FLAG_FXAA params.gfx.width = 128 params.gfx.height = 128 params.sct.mem_sz = 128 params.dev.buffsize_data = 256 params.data_dir = os.path.abspath(util.get_exec_dir(__file__) + '/../../data') if not dheng.app_init(name, params): dheng.err_sendtolog(False) dheng.core_release(False) return False if not dheng.eng_init(params): dheng.err_sendtolog(False) dheng.app_release() dheng.core_release(False) dheng.err_sendtolog(True) return False dheng.gfx_set_debug_renderfunc(dheng.gfx_render_grid) ## set path for our stuff dheng.fio_addvdir(assetdir, True) ## single scene with camera global scene scene = dheng.scn_create_scene('main') dheng.scn_setactive(scene) is_init = True rts.append(widget) return True
def save_config(self): # save config self.save_prefs(self.config) if not "ui" in self.config.sections(): self.config.add_section("ui") self.config.set("ui", "tab_idx", str(self.main_tab.currentIndex())) self.wnds["model"].save_config(self.config) self.wnds["anim"].save_config(self.config) self.wnds["phx"].save_config(self.config) self.config.write(open(os.path.normpath(util.get_exec_dir(__file__) + '/h3dimport-gui.ini'), 'w'))
def save_config(self): # save config self.save_prefs(self.config) if not "ui" in self.config.sections(): self.config.add_section("ui") self.config.set("ui", "tab_idx", str(self.main_tab.currentIndex())) self.wnds["model"].save_config(self.config) self.wnds["anim"].save_config(self.config) self.wnds["phx"].save_config(self.config) self.config.write( open( os.path.normpath( util.get_exec_dir(__file__) + '/h3dimport-gui.ini'), 'w'))
def __init__(self, parent): super(qClipEditDlg, self).__init__(parent) self.setMinimumSize(800, 600) self.setWindowTitle('Clip editor') self.setSizeGripEnabled(True) self.setWindowFlags(self.windowFlags() & (~Qt.WindowContextHelpButtonHint)) exedir = util.get_exec_dir(__file__) self.icn_play = QIcon( os.path.normcase(exedir + '/img/glyphicons_173_play.png')) self.icn_pause = QIcon( os.path.normcase(exedir + '/img/glyphicons_174_pause.png')) layout = QVBoxLayout() layout2 = QHBoxLayout() self.eng_view = eng_view.qEngineView(self) layout2.addWidget(self.eng_view) self.wnd_clips = qClipList(self) layout2.addWidget(self.wnd_clips) layout.addLayout(layout2) layout3 = QHBoxLayout() self.btn_play = QPushButton(self) self.btn_play.setIcon(self.icn_play) self.btn_play_state = False # keeps playing state of 'play/pause' button self.btn_play_state_prev = False self.clip_ctrl = qClipController(self) self.btn_play.setFixedSize(32, 32) layout3.addWidget(self.btn_play) layout3.addWidget(self.clip_ctrl) layout.addLayout(layout3) self.setLayout(layout) self.tm_play = QTimer(self) self.tm_play.setInterval(20) self.tm_preview = QTimer(self) self.tm_preview.setInterval(33) self.preview_clip = {} self.preview_frame = 0 self.camera = None # events self.btn_play.clicked.connect(self.btn_play_clicked) self.tm_play.timeout.connect(self.tm_play_timeout) self.tm_preview.timeout.connect(self.tm_preview_timeout)
def __init__(self, parent): super(qClipEditDlg, self).__init__(parent) self.setMinimumSize(800, 600) self.setWindowTitle('Clip editor') self.setSizeGripEnabled(True) self.setWindowFlags(self.windowFlags() & (~Qt.WindowContextHelpButtonHint)) exedir = util.get_exec_dir(__file__) self.icn_play = QIcon(os.path.normcase(exedir + '/img/glyphicons_173_play.png')) self.icn_pause = QIcon(os.path.normcase(exedir + '/img/glyphicons_174_pause.png')) layout = QVBoxLayout() layout2 = QHBoxLayout() self.eng_view = eng_view.qEngineView(self) layout2.addWidget(self.eng_view) self.wnd_clips = qClipList(self) layout2.addWidget(self.wnd_clips) layout.addLayout(layout2) layout3 = QHBoxLayout() self.btn_play = QPushButton(self) self.btn_play.setIcon(self.icn_play) self.btn_play_state = False # keeps playing state of 'play/pause' button self.btn_play_state_prev = False self.clip_ctrl = qClipController(self) self.btn_play.setFixedSize(32, 32) layout3.addWidget(self.btn_play) layout3.addWidget(self.clip_ctrl) layout.addLayout(layout3) self.setLayout(layout) self.tm_play = QTimer(self) self.tm_play.setInterval(20) self.tm_preview = QTimer(self) self.tm_preview.setInterval(33) self.preview_clip = {} self.preview_frame = 0 self.camera = None # events self.btn_play.clicked.connect(self.btn_play_clicked) self.tm_play.timeout.connect(self.tm_play_timeout) self.tm_preview.timeout.connect(self.tm_preview_timeout)
def init_ui(self): app_icon_path = os.path.normcase( util.get_exec_dir(__file__) + '/img/icon.ico') self.setMinimumWidth(600) self.setWindowTitle("darkHAMMER: h3dimport") self.setWindowFlags(self.windowFlags() & (~Qt.WindowMaximizeButtonHint)) self.setWindowIcon(QIcon(app_icon_path)) main_menu = QMenuBar(self) main_menu.addAction("Preferences", self.pref_clicked) mnu_help = QMenu("Help", self) mnu_help.addAction("About", self.mnu_help_click) main_menu.addMenu(mnu_help) self.setMenuBar(main_menu) self.main_tab = QTabWidget(self) self.setCentralWidget(self.main_tab) # child tabs self.wnds = dict() model_wnd = w_model(self) self.wnds["model"] = model_wnd self.main_tab.addTab(model_wnd, "Model") anim_wnd = w_anim(self) self.wnds["anim"] = anim_wnd self.main_tab.addTab(anim_wnd, "Anim") phx_wnd = w_phx(self) self.wnds["phx"] = phx_wnd self.main_tab.addTab(phx_wnd, "Physics") self.show() self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.main_tab.currentChanged.connect(self.tab_change) # load ui state self.load_config()
def init_ui(self): app_icon_path = os.path.normcase(util.get_exec_dir(__file__) + '/img/icon.ico') self.setMinimumWidth(600) self.setWindowTitle("darkHAMMER: h3dimport") self.setWindowFlags(self.windowFlags() & (~Qt.WindowMaximizeButtonHint)) self.setWindowIcon(QIcon(app_icon_path)) main_menu = QMenuBar(self) main_menu.addAction("Preferences", self.pref_clicked) mnu_help = QMenu("Help", self) mnu_help.addAction("About", self.mnu_help_click) main_menu.addMenu(mnu_help) self.setMenuBar(main_menu) self.main_tab = QTabWidget(self) self.setCentralWidget(self.main_tab) # child tabs self.wnds = dict() model_wnd = w_model(self) self.wnds["model"] = model_wnd self.main_tab.addTab(model_wnd, "Model") anim_wnd = w_anim(self) self.wnds["anim"] = anim_wnd self.main_tab.addTab(anim_wnd, "Anim") phx_wnd = w_phx(self) self.wnds["phx"] = phx_wnd self.main_tab.addTab(phx_wnd, "Physics") self.show() self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.main_tab.currentChanged.connect(self.tab_change) # load ui state self.load_config()
def load_config(self): try: self.config = ConfigParser.SafeConfigParser() f = self.config.read(os.path.normpath(util.get_exec_dir(__file__) + \ "/h3dimport-gui.ini")) if len(f) == 0: raise BaseException() except: print "Warning: could not load program config, reset to defaults" self.load_prefs(self.config) else: self.load_prefs(self.config) if "ui" in self.config.sections(): tab_idx = int(self.config.get("ui", "tab_idx")) else: tab_idx = 0 self.wnds["model"].load_config(self.config) self.wnds["anim"].load_config(self.config) self.wnds["phx"].load_config(self.config) self.main_tab.setCurrentIndex(tab_idx) self.tab_change(tab_idx)
def __init__(self, parent): super(qClipList, self).__init__(parent) self.clips = [] self.frame_cnt = 60 self.setFixedWidth(200) # layout and controls layout = QVBoxLayout() self.setLayout(layout) lbl_framecnt = QLabel('frame-cnt: ', self) layout.addWidget(lbl_framecnt) imgpath = os.path.normcase(util.get_exec_dir(__file__) + '/img/') layout2 = QHBoxLayout() layout2.setSpacing(1) ed_name = QLineEdit(self) ed_name.setMaxLength(30) layout2.addWidget(ed_name) btn_add = QPushButton(self) btn_remove = QPushButton(self) btn_add.setIcon(QIcon(imgpath + 'glyphicons_432_plus.png')) btn_remove.setIcon(QIcon(imgpath + 'glyphicons_207_remove_2.png')) btn_add.setFixedSize(24, 24) btn_remove.setFixedSize(24, 24) layout2.addWidget(btn_add) layout2.addWidget(btn_remove) layout.addLayout(layout2) self.lbl_framecnt = lbl_framecnt self.ed_name = ed_name self.btn_remove = btn_remove self.btn_add = btn_add lbl_clips = QLabel('Clips', self) self.lst_clips = QListWidget(self) self.lst_clips.setMaximumHeight(150) lst_palette = self.lst_clips.palette() lst_palette.setBrush(QPalette.Inactive, QPalette.Highlight, lst_palette.brush(QPalette.Active, QPalette.Highlight)) lst_palette.setBrush(QPalette.Inactive, QPalette.HighlightedText, lst_palette.brush(QPalette.Active, QPalette.HighlightedText)) self.lst_clips.setPalette(lst_palette) layout.addWidget(lbl_clips) layout.addWidget(self.lst_clips) layout3 = QFormLayout() self.ed_start = QLineEdit(self) self.ed_start.setValidator(QIntValidator()) self.ed_end = QLineEdit(self) self.ed_end.setValidator(QIntValidator()) self.chk_looped = QCheckBox(self) layout3.addRow('Start: ', self.ed_start) layout3.addRow('End: ', self.ed_end) layout3.addRow('Looped: ', self.chk_looped) self.edit_widgets = [self.ed_start, self.ed_end, self.chk_looped] layout.addLayout(layout3) layout.addStretch() ## events btn_add.clicked.connect(self.btn_add_clicked) self.ed_name.textChanged.connect(self.ed_name_changed) self.lst_clips.itemSelectionChanged.connect(self.lst_clips_selected) self.lst_clips.itemClicked.connect(self.lst_clips_clicked) btn_remove.clicked.connect(self.btn_remove_clicked) self.ed_start.textChanged.connect(self.ed_start_changed) self.ed_end.textChanged.connect(self.ed_end_changed) self.chk_looped.stateChanged.connect(self.chk_looped_changed) for widget in self.edit_widgets: widget.setEnabled(False) self.btn_remove.setEnabled(False) self.btn_add.setEnabled(False)
def __init__(self, parent): super(qClipList, self).__init__(parent) self.clips = [] self.frame_cnt = 60 self.setFixedWidth(200) # layout and controls layout = QVBoxLayout() self.setLayout(layout) lbl_framecnt = QLabel('frame-cnt: ', self) layout.addWidget(lbl_framecnt) imgpath = os.path.normcase(util.get_exec_dir(__file__) + '/img/') layout2 = QHBoxLayout() layout2.setSpacing(1) ed_name = QLineEdit(self) ed_name.setMaxLength(30) layout2.addWidget(ed_name) btn_add = QPushButton(self) btn_remove = QPushButton(self) btn_add.setIcon(QIcon(imgpath + 'glyphicons_432_plus.png')) btn_remove.setIcon(QIcon(imgpath + 'glyphicons_207_remove_2.png')) btn_add.setFixedSize(24, 24) btn_remove.setFixedSize(24, 24) layout2.addWidget(btn_add) layout2.addWidget(btn_remove) layout.addLayout(layout2) self.lbl_framecnt = lbl_framecnt self.ed_name = ed_name self.btn_remove = btn_remove self.btn_add = btn_add lbl_clips = QLabel('Clips', self) self.lst_clips = QListWidget(self) self.lst_clips.setMaximumHeight(150) lst_palette = self.lst_clips.palette() lst_palette.setBrush( QPalette.Inactive, QPalette.Highlight, lst_palette.brush(QPalette.Active, QPalette.Highlight)) lst_palette.setBrush( QPalette.Inactive, QPalette.HighlightedText, lst_palette.brush(QPalette.Active, QPalette.HighlightedText)) self.lst_clips.setPalette(lst_palette) layout.addWidget(lbl_clips) layout.addWidget(self.lst_clips) layout3 = QFormLayout() self.ed_start = QLineEdit(self) self.ed_start.setValidator(QIntValidator()) self.ed_end = QLineEdit(self) self.ed_end.setValidator(QIntValidator()) self.chk_looped = QCheckBox(self) layout3.addRow('Start: ', self.ed_start) layout3.addRow('End: ', self.ed_end) layout3.addRow('Looped: ', self.chk_looped) self.edit_widgets = [self.ed_start, self.ed_end, self.chk_looped] layout.addLayout(layout3) layout.addStretch() ## events btn_add.clicked.connect(self.btn_add_clicked) self.ed_name.textChanged.connect(self.ed_name_changed) self.lst_clips.itemSelectionChanged.connect(self.lst_clips_selected) self.lst_clips.itemClicked.connect(self.lst_clips_clicked) btn_remove.clicked.connect(self.btn_remove_clicked) self.ed_start.textChanged.connect(self.ed_start_changed) self.ed_end.textChanged.connect(self.ed_end_changed) self.chk_looped.stateChanged.connect(self.chk_looped_changed) for widget in self.edit_widgets: widget.setEnabled(False) self.btn_remove.setEnabled(False) self.btn_add.setEnabled(False)