示例#1
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)
示例#2
0
 def toggleProfiling(self):
     import profiler
     if self.actions.profiling.isChecked():
         profiler.start()
         log.notice('profiling started')
     else:
         profiler.stop()
         log.notice('profiling stopped')
         mh.changeTask('Develop', 'Profile')
 def setBackgroundEnabled(self, enable):
     if enable:
         if self.isBackgroundSet():
             self.setBackgroundImage(self.getCurrentSide())
             self.backgroundImageToggle.setChecked(True)
             mh.redraw()
         else:
             mh.changeTask('Textures', 'Background')
     else:  # Disable
         self.backgroundImage.hide()
         self.backgroundImageToggle.setChecked(False)
         mh.redraw()
示例#4
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)
示例#5
0
 def onClicked(event):
     mh.changeTask('Settings', 'Background')
示例#6
0
 def gotoshell():
     mh.changeTask('Utilities', 'Shell')
示例#7
0
 def gotodefaultshell(self):
     mh.changeTask('Utilities', 'Shell')
 def onClicked(event):
     mh.changeTask('Textures', 'Background')
示例#9
0
def Render(settings):
    progress = Progress.begin()

    if not mh.hasRenderToRenderbuffer():
        settings['dimensions'] = (G.windowWidth, G.windowHeight)

    if settings['lightmapSSS']:
        progress(0, 0.05, "Storing data")
        import material
        human = G.app.selectedHuman
        materialBackup = material.Material(human.material)

        progress(0.05, 0.1, "Projecting lightmaps")
        diffuse = imgop.Image(data=human.material.diffuseTexture)
        lmap = projection.mapSceneLighting(settings['scene'],
                                           border=human.material.sssRScale)
        progress(0.1, 0.4, "Applying medium scattering")
        lmapG = imgop.blurred(lmap, human.material.sssGScale, 13)
        progress(0.4, 0.7, "Applying high scattering")
        lmapR = imgop.blurred(lmap, human.material.sssRScale, 13)
        lmap = imgop.compose([lmapR, lmapG, lmap])
        if not diffuse.isEmpty:
            progress(0.7, 0.8, "Combining textures")
            lmap = imgop.resized(lmap,
                                 diffuse.width,
                                 diffuse.height,
                                 filter=image.FILTER_BILINEAR)
            progress(0.8, 0.9)
            lmap = imgop.multiply(lmap, diffuse)
        lmap.sourcePath = "Internal_Renderer_Lightmap_SSS_Texture"

        progress(0.9, 0.95, "Setting up renderer")
        human.material.diffuseTexture = lmap
        human.configureShading(diffuse=True)
        human.shadeless = True
        progress(0.95, 0.98, None)
    else:
        progress(0, 0.99, None)

    if not mh.hasRenderToRenderbuffer():
        # Limited fallback mode, read from screen buffer
        log.message("Fallback render: grab screen")
        img = mh.grabScreen(0, 0, G.windowWidth, G.windowHeight)
        alphaImg = None
    else:
        # Render to framebuffer object
        renderprog = Progress()
        renderprog(0, 0.99 - 0.59 * settings['AA'], "Rendering")
        width, height = settings['dimensions']
        log.message("Rendering at %sx%s", width, height)
        if settings['AA']:
            width = width * 2
            height = height * 2
        img = mh.renderToBuffer(width, height)
        alphaImg = mh.renderAlphaMask(width, height)
        img = imgop.addAlpha(img, imgop.getChannel(alphaImg, 0))

        if settings['AA']:
            renderprog(0.4, 0.99, "AntiAliasing")
            # Resize to 50% using bi-linear filtering
            img = img.resized(width / 2,
                              height / 2,
                              filter=image.FILTER_BILINEAR)
            # TODO still haven't figured out where components get swapped, but this hack appears to be necessary
            img.data[:, :, :] = img.data[:, :, (2, 1, 0, 3)]
        renderprog.finish()

    if settings['lightmapSSS']:
        progress(0.98, 0.99, "Restoring data")
        human.material = materialBackup

    progress(1, None, 'Rendering complete')

    gui3d.app.getCategory('Rendering').getTaskByName('Viewer').setImage(img)
    mh.changeTask('Rendering', 'Viewer')
    gui3d.app.statusPersist('Rendering complete')
示例#10
0
    def __init__(self, category):
        super(ShellTaskView, self).__init__(category, 'Shell')
        self.globals = {'G': G}
        self.history = []
        self.histitem = None

        #Register shortcut Shift S for the shell tab
        action = gui.Action('shell', language.getLanguageString('Python Shell'),
                            lambda: mh.changeTask('Utilities', 'Shell'))
        G.app.mainwin.addAction(action)
        mh.setShortcut(mh.Modifiers.SHIFT, mh.Keys.s, action)

        if hasIpython:
            # Use the more advanced Ipython console
            self.console = self.addTopWidget(ipythonconsole.IPythonConsoleWidget())

        else:

            # Fall back to old console
            self.console = None
            self.main = self.addTopWidget(QtWidgets.QWidget())
            self.layout = QtWidgets.QGridLayout(self.main)
            self.layout.setRowStretch(0, 0)
            self.layout.setRowStretch(1, 0)
            self.layout.setColumnStretch(0, 1)
            self.layout.setColumnStretch(1, 0)

            self.text = gui.DocumentEdit()
            self.text.setSizePolicy(
                QtWidgets.QSizePolicy.Expanding,
                QtWidgets.QSizePolicy.Expanding)
            self.layout.addWidget(self.text, 0, 0, 1, 2)

            self.line = ShellTextEdit()
            self.line.setFocusPolicy(QtCore.Qt.StrongFocus)
            self.layout.addWidget(self.line, 1, 0, 1, 1)
            self.globals = {'G': G}

            self.clear = gui.Button("Clear")
            self.layout.addWidget(self.clear, 1, 1, 1, 1)

            @self.line.mhEvent
            def onActivate(text):
                self.execute(text)
                self.history.append(text)
                self.histitem = None
                self.line.setText('')

            @self.line.mhEvent
            def onTabPressed(edit):
                def _longest_common_substring(s1, s2):
                    """
                    This is simply the O(n) left-aligned version
                    """
                    limit = min(len(s1), len(s2))
                    i = 0
                    while i < limit and s1[i] == s2[i]:
                        i += 1
                    return s1[:i]

                def _largest_common(strings):
                    strings = list(strings)
                    try:
                        strings.remove('...')
                    except:
                        pass

                    if len(strings) == 0:
                        return ""
                    elif len(strings) == 1:
                        return strings[0]
                    else:
                        result = strings[0]
                        for s in strings[1:]:
                            result = _longest_common_substring(result, s)
                        return result

                line = edit.getText()
                suggestions = self.getSuggestions(line)

                if len(suggestions) == 0:
                    return
                if len(suggestions) > 1:
                    self.write('\n'.join(suggestions)+"\n")
                    scrollbar = self.text.verticalScrollBar()
                    scrollbar.setSliderPosition(scrollbar.maximum())
                    edit.setText(_largest_common(suggestions))
                elif len(suggestions) == 1:
                    edit.setText(suggestions[0])

            @self.clear.mhEvent
            def onClicked(event):
                self.clearText()

            @self.line.mhEvent
            def onUpArrow(_dummy):
                self.upArrow()

            @self.line.mhEvent
            def onDownArrow(_dummy):
                self.downArrow()
示例#11
0
 def goToExport(self):
     mh.changeTask("Files", "Export")
     self.redraw()
示例#12
0
 def goToLoad(self):
     mh.changeTask("Files", "Load")
     self.redraw()
示例#13
0
 def goToSave(self):
     mh.changeTask("Files", "Save")
     self.redraw()
示例#14
0
def Render(settings):
    progress = Progress.begin()

    if not mh.hasRenderToRenderbuffer():
        settings['dimensions'] = (G.windowWidth, G.windowHeight)

    if settings['lightmapSSS']:
        progress(0, 0.05, "Storing data")
        import material
        human = G.app.selectedHuman
        materialBackup = material.Material(human.material)

        progress(0.05, 0.1, "Projecting lightmaps")
        diffuse = imgop.Image(data=human.material.diffuseTexture)
        lmap = projection.mapSceneLighting(settings['scene'],
                                           border=human.material.sssRScale)
        progress(0.1, 0.4, "Applying medium scattering")
        lmapG = imgop.blurred(lmap, human.material.sssGScale, 13)
        progress(0.4, 0.7, "Applying high scattering")
        lmapR = imgop.blurred(lmap, human.material.sssRScale, 13)
        lmap = imgop.compose([lmapR, lmapG, lmap])
        if not diffuse.isEmpty:
            progress(0.7, 0.8, "Combining textures")
            lmap = imgop.resized(lmap, diffuse.width, diffuse.height)
            progress(0.8, 0.9)
            lmap = imgop.multiply(lmap, diffuse)
        lmap.sourcePath = "Internal_Renderer_Lightmap_SSS_Texture"

        progress(0.9, 0.95, "Setting up renderer")
        human.material.diffuseTexture = lmap
        human.mesh.configureShading(diffuse=True)
        human.mesh.shadeless = True
        progress(0.95, 0.98, None)
    else:
        progress(0, 0.99, None)

    if not mh.hasRenderToRenderbuffer():
        # Limited fallback mode, read from screen buffer
        log.message("Fallback render: grab screen")
        img = mh.grabScreen(0, 0, G.windowWidth, G.windowHeight)
        alphaImg = None
    else:
        # Render to framebuffer object
        renderprog = Progress()
        renderprog(0, 0.99 - 0.59 * settings['AA'], "Rendering")
        width, height = settings['dimensions']
        log.message("Rendering at %sx%s", width, height)
        if settings['AA']:
            width = width * 2
            height = height * 2
        img = mh.renderToBuffer(width, height)
        alphaImg = mh.renderAlphaMask(width, height)
        img = imgop.addAlpha(img, imgop.getChannel(alphaImg, 0))

        if settings['AA']:
            renderprog(0.4, 0.99, "AntiAliasing")
            # Resize to 50% using Qt image class
            qtImg = img.toQImage()
            del img
            # Bilinear filtered resize for anti-aliasing
            scaledImg = qtImg.scaled(
                width / 2,
                height / 2,
                transformMode=gui.QtCore.Qt.SmoothTransformation)
            del qtImg
            img = scaledImg
            #img = image.Image(scaledImg)    # Convert back to MH image
            #del scaledImg
        renderprog.finish()

    if settings['lightmapSSS']:
        progress(0.98, 0.99, "Restoring data")
        human.material = materialBackup

    progress(1, None, 'Rendering complete')

    gui3d.app.getCategory('Rendering').getTaskByName('Viewer').setImage(img)
    mh.changeTask('Rendering', 'Viewer')
    gui3d.app.statusPersist('Rendering complete.')