def startPlayback(self): self.playPauseBtn.setText('Pause') if self.timer: mh.removeTimer(self.timer) self.timer = None if self.perFramePlayback: self.timer = mh.addTimer(max(30, int(1.0/self.animTrack.frameRate * 1000)), self.onFrameChanged) else: # 30 FPS fixed self.timer = mh.addTimer(30, self.onFrameChanged)
def startPlayback(self): self.playPauseBtn.setText('Pause') if self.timer: mh.removeTimer(self.timer) self.timer = None if self.perFramePlayback: self.timer = mh.addTimer( max(30, int(1.0 / self.animTrack.frameRate * 1000)), self.onFrameChanged) else: # 30 FPS fixed self.timer = mh.addTimer(30, self.onFrameChanged)
def onClicked(value): if self.playPause.label.getText() == 'Play': self.playPause.label.setText('Pause') self.timer = mh.addTimer(max(30, int(self.__skeleton.frameTime * 1000)), self.onFrameChanged) else: self.playPause.label.setText('Play') mh.removeTimer(self.timer)
def startPlayback(self): self.playPause.setText('Pause') if self.timer: mh.removeTimer(self.timer) self.timer = None self.timer = mh.addTimer( max(30, int(1.0 / self.anim.frameRate * 1000)), self.onFrameChanged)
def startPlayback(self): self.playPause.setText('Pause') if self.timer: mh.removeTimer(self.timer) self.timer = None self.timer = mh.addTimer(max(30, int(1.0/self.anim.frameRate * 1000)), self.onFrameChanged)
def povrayExport(settings): """ This function exports data in a format that can be used to reconstruct all renderable MakeHuman objects in POV-Ray. Parameters ---------- settings: *Dictionary*. Options passed from the Povray exporter GUI. """ settings['name'] = string.replace(getHumanName(), " ", "_") log.message('POV-Ray Export of object: %s', settings['name']) camera = gui3d.app.modelCamera settings['resw'] = gui3d.app.settings.get('rendering_width', 800) settings['resh'] = gui3d.app.settings.get('rendering_height', 600) path = os.path.join( mh.getPath('render'), gui3d.app.settings.get('povray_render_dir', 'pov_output'), "%s.inc" % settings['name']) # The format option defines whether a simple mesh2 object is to be generated # or the more flexible but slower array and macro combo is to be generated. if settings['format'] == 'array': povrayExportArray(gui3d.app.selectedHuman.mesh, camera, path, settings) if settings['format'] == 'mesh2': povrayExportMesh2(gui3d.app.selectedHuman.mesh, camera, path, settings) outputDirectory = os.path.dirname(path) log.debug('out folder: %s', outputDirectory) povray_bin = (gui3d.app.settings.get('povray_bin', '')) # try to use the appropriate binary if os.path.exists(povray_bin): exetype = settings['bintype'] if exetype == 'win64': povray_bin += '/pvengine64.exe' elif exetype == 'win32sse2': povray_bin += '/pvengine-sse2.exe' elif exetype == 'win32': povray_bin += '/pvengine.exe' elif exetype == 'linux': povray_bin += '/povray' log.debug('Povray path: %s', povray_bin) povwatchApp = None povwatchPath = "" povwatchTimer = 0 def povwatch(): if povwatchApp.poll() is not None: gui3d.app.getCategory('Rendering').getTaskByName( 'Viewer').setImage(povwatchPath) mh.changeTask('Rendering', 'Viewer') gui3d.app.statusPersist('Rendering complete') mh.removeTimer(povwatchTimer) if settings['action'] == 'render': if os.path.isfile(povray_bin): # Prepare command line. if os.name == 'nt': cmdLine = (povray_bin, 'MHRENDER', '/EXIT') else: cmdLine = (povray_bin, 'MHRENDER') # Pass parameters by writing an .ini file. iniFD = open(os.path.join(outputDirectory, 'MHRENDER.ini'), 'w') iniFD.write('Input_File_Name="%s.pov"\n' % settings['name'] + '+W%d +H%d +a%s +am2\n' % (settings['resw'], settings['resh'], settings['AA'])) iniFD.close() povwatchApp = subprocess.Popen(cmdLine, cwd=os.path.dirname(path)) gui3d.app.statusPersist('POV - Ray is rendering.') povwatchPath = path.replace('.inc', '.png') povwatchTimer = mh.addTimer(1000, lambda: povwatch()) else: gui3d.app.prompt( 'POV-Ray not found', 'You don\'t seem to have POV-Ray installed or the path is incorrect.', 'Download', 'Cancel', downloadPovRay)
def povrayExport(settings): """ This function exports data in a format that can be used to reconstruct all renderable MakeHuman objects in POV-Ray. After that, POV-Ray is run and the rendering begins. Parameters ---------- settings: *Dictionary*. Options passed from the Povray exporter GUI. """ povwatchApp = None povwatchPath = "" povwatchTimer = 0 def povwatch(): if povwatchApp.poll() is not None: gui3d.app.getCategory('Rendering').getTaskByName('Viewer').setImage(povwatchPath) mh.changeTask('Rendering', 'Viewer') gui3d.app.statusPersist('Rendering complete') mh.removeTimer(povwatchTimer) settings['name'] = str.replace(getHumanName(), " ", "_") log.message('POV-Ray Export of object: %s', settings['name']) camera = gui3d.app.modelCamera settings['resw'] = gui3d.app.settings.get('rendering_width', 800) settings['resh'] = gui3d.app.settings.get('rendering_height', 600) path = os.path.join(mh.getPath('render'), gui3d.app.settings.get('povray_render_dir', 'pov_output'), "%s.inc" % settings['name']) povray_bin = (gui3d.app.settings.get('povray_bin', '')) # try to use the appropriate binary if os.path.exists(povray_bin): exetype = settings['bintype'] if exetype == 'win64': povray_bin += '/pvengine64.exe' elif exetype == 'win32sse2': povray_bin += '/pvengine-sse2.exe' elif exetype == 'win32': povray_bin += '/pvengine.exe' elif exetype == 'linux': povray_bin += '/povray' log.debug('Povray path: %s', povray_bin) if settings['action'] == 'render': if os.path.isfile(povray_bin): # Export the files. # The format option defines whether a simple mesh2 object is to be generated # or the more flexible but slower array and macro combo is to be generated. if settings['format'] == 'array': povrayExportArray(gui3d.app.selectedHuman.mesh, camera, path, settings) if settings['format'] == 'mesh2': povrayExportMesh2(gui3d.app.selectedHuman.mesh, camera, path, settings) outputDirectory = os.path.dirname(path) log.debug('out folder: %s', outputDirectory) # Prepare command line. if os.name == 'nt': cmdLine = (povray_bin, 'MHRENDER', '/EXIT') else: cmdLine = (povray_bin, 'MHRENDER') # Pass parameters by writing an .ini file. iniFD = open(os.path.join(outputDirectory, 'MHRENDER.ini'), 'w') iniFD.write('Input_File_Name="%s.pov"\n' % settings['name'] + '+W%d +H%d +a%s +am2\n' % (settings['resw'], settings['resh'], settings['AA'])) iniFD.close() # Run POV-Ray, and observe it while it renders. povwatchApp = subprocess.Popen(cmdLine, cwd = os.path.dirname(path)) gui3d.app.statusPersist('POV - Ray is rendering.') povwatchPath = path.replace('.inc','.png') povwatchTimer = mh.addTimer(1000, lambda: povwatch()) else: gui3d.app.prompt( 'POV-Ray not found', 'You don\'t seem to have POV-Ray installed or the path is incorrect.', 'Download', 'Cancel', downloadPovRay)
def povrayExport(settings): """ This function exports data in a format that can be used to reconstruct all renderable MakeHuman objects in POV-Ray. After that, POV-Ray is run and the rendering begins. Parameters ---------- settings: *Dictionary*. Options passed from the Povray exporter GUI. """ settings['name'] = re.sub('[^0-9a-zA-Z]+', '_', getHumanName()) log.message('POV-Ray Export of object: %s', settings['name']) settings['resw'] = gui3d.app.settings.get('rendering_width', 800) settings['resh'] = gui3d.app.settings.get('rendering_height', 600) path = os.path.join( mh.getPath('render'), gui3d.app.settings.get('povray_render_dir', 'pov_output')) povwatchApp = None povwatchPath = "" povwatchTimer = 0 def povwatch(): if povwatchApp.poll() is not None: if os.path.exists(povwatchPath): imgpath = os.path.join(path, settings['name'] + '.png') shutil.move(povwatchPath, imgpath) gui3d.app.getCategory('Rendering').getTaskByName( 'Viewer').setImage(imgpath) mh.changeTask('Rendering', 'Viewer') gui3d.app.statusPersist('Rendering complete. Output path: %s' % imgpath) else: log.notice("POV - Ray did not produce an output file!") gui3d.app.statusPersist('Rendering failed!') mh.removeTimer(povwatchTimer) povray_bin = (gui3d.app.settings.get('povray_bin', '')) if os.path.exists(povray_bin): # Try to guess povray version. povdirname = os.path.basename( os.path.normpath(os.path.join(povray_bin, '../'))) if povdirname == 'v3.7': settings['povver'] = (3, 7, 0) if povdirname == 'v3.7 RC6': settings['povver'] = (3, 7, 6) # Try to use the appropriate binary. exetype = settings['bintype'] if exetype == 'win64': povray_bin += '/pvengine64.exe' elif exetype == 'win32sse2': if settings['povver'] == (3, 7, 0): povray_bin += '/pvengine32-sse2.exe' else: povray_bin += '/pvengine-sse2.exe' elif exetype == 'win32': povray_bin += '/pvengine.exe' elif exetype == 'linux': povray_bin += '/povray' log.debug('Povray path: %s', povray_bin) if os.path.isfile(povray_bin): # Export the files. povrayExportMesh2(path, settings) # Prepare command line. if os.name == 'nt': cmdLine = (povray_bin, '/RENDER', 'MHRENDER.ini', '/EXIT') else: cmdLine = (povray_bin, 'MHRENDER') # Pass parameters by writing an .ini file. iniFD = open(os.path.join(path, 'source/', 'MHRENDER.ini'), 'w') iniFD.write('Input_File_Name="%s.pov"\n' % settings['name'] + '+W%d +H%d +a%s +am2\n' % (settings['resw'], settings['resh'], settings['AA'])) iniFD.close() # Run POV-Ray, and observe it while it renders. povwatchApp = subprocess.Popen(cmdLine, cwd=os.path.join(path, 'source/')) gui3d.app.statusPersist('POV - Ray is rendering.') povwatchPath = os.path.join(path, 'source/', settings['name'] + '.png') povwatchTimer = mh.addTimer(1000, lambda: povwatch()) else: gui3d.app.prompt( 'POV-Ray not found', 'You don\'t seem to have POV-Ray installed or the path is incorrect.', 'Download', 'Cancel', downloadPovRay)