Beispiel #1
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Censor')

        self.mouseBox = self.addLeftWidget(gui.GroupBox('Censor'))
        self.enableCensor = self.mouseBox.addWidget(
            gui.CheckBox("Enable", gui3d.app.settings.get('censor', False)))

        human = gui3d.app.selectedHuman

        self.breastVertices = human.mesh.getVerticesForGroups(
            ['l-torso-nipple', 'r-torso-nipple'])
        mesh = geometry3d.RectangleMesh(100, 100)
        self.breastCensorship = gui3d.app.addObject(
            gui3d.Object([0, 0, 9], mesh))
        mesh.setColor([0, 0, 0, 255])
        mesh.setPickable(False)
        mesh.setShadeless(True)
        mesh.setDepthless(True)
        mesh.priority = 80

        self.genitalVertices = human.mesh.getVerticesForGroups(
            ['pelvis-genital-area'])
        mesh = geometry3d.RectangleMesh(100, 100)
        self.genitalCensorship = gui3d.app.addObject(
            gui3d.Object([0, 0, 9], mesh))
        mesh.setColor([0, 0, 0, 255])
        mesh.setPickable(False)
        mesh.setShadeless(True)
        mesh.setDepthless(True)
        mesh.priority = 80

        if gui3d.app.settings.get('censor', False):
            self.updateCensor()
        else:
            self.breastCensorship.hide()
            self.genitalCensorship.hide()

        @self.enableCensor.mhEvent
        def onClicked(event):
            gui3d.app.settings['censor'] = self.enableCensor.selected
            if self.enableCensor.selected:
                self.updateCensor()
                self.breastCensorship.show()
                self.genitalCensorship.show()
            else:
                self.breastCensorship.hide()
                self.genitalCensorship.hide()
Beispiel #2
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Background')

        self.human = gui3d.app.selectedHuman

        self.backgroundsFolder = mh.getPath('backgrounds')
        if not os.path.exists(self.backgroundsFolder):
            os.makedirs(self.backgroundsFolder)

        self.backgroundsFolders = [ mh.getSysDataPath('backgrounds'),
                                    self.backgroundsFolder ]
        self.extensions = ['bmp', 'png', 'tif', 'tiff', 'jpg', 'jpeg']

        self.texture = mh.Texture()

        self.sides = { 'front': [0,0,0],
                       'back': [0,180,0],
                       'left': [0,-90,0],
                       'right': [0,90,0],
                       'top': [90,0,0],
                       'bottom': [-90,0,0],
                       'other': None }

        self.filenames = {}    # Stores (filename, aspect)
        self.transformations = {} # Stores ((posX,posY), scaleY)
        for side in self.sides.keys():
            self.filenames[side] = None
            self.transformations[side] = [(0.0, 0.0), 1.0]

        self.planeMeshes = dict()

        self.opacity = 40

        for viewName, rot in self.sides.items():
            if rot is not None:
                rv = [0, 0, 0]
                angle = 0.0
                for r_idx, r in enumerate(rot):
                    if r != 0:
                        rv[r_idx] = 1
                        angle = math.radians(r)
                if angle == 0:
                    m = None
                else:
                    m = tm.rotation_matrix(-angle, rv)
            else:
                m = None

            mesh = geometry3d.RectangleMesh(20, 20, centered=True, rotation=m)
            mesh.name = "Background_%s" % viewName
            obj = gui3d.app.addObject(gui3d.Object(mesh, [0, 0, 0], visible=False))
            obj.setShadeless(True)
            obj.setDepthless(True)
            #obj.placeAtFeet = True
            mesh.setCameraProjection(0)
            mesh.setColor([255, 255, 255, self.opacity*2.55])
            mesh.setPickable(False)
            mesh.priority = -90
            self.planeMeshes[viewName] = obj

            if viewName == 'other':
                obj.lockRotation = True

            @obj.mhEvent
            def onMouseDragged(event):
                if event.button in [mh.Buttons.LEFT_MASK, mh.Buttons.MIDDLE_MASK]:
                    if mh.getKeyModifiers() & (mh.Modifiers.SHIFT):
                        delta = 150.0
                    else:
                        delta = 30.0

                    dx = float(event.dx)/delta
                    dy = float(-event.dy)/delta
                    self.moveBackground(dx, dy)
                elif event.button == mh.Buttons.RIGHT_MASK:
                    if mh.getKeyModifiers() & (mh.Modifiers.SHIFT):
                        delta = 500.0
                    else:
                        delta = 100.0
                    scale = self.getBackgroundScale()
                    scale += float(event.dy)/delta

                    self.setBackgroundScale(scale)

        # Add icon to action toolbar
        self.backgroundImageToggle = gui.Action('background', 'Background', self.toggleBackground, toggle=True)
        gui3d.app.view_toolbar.addAction(self.backgroundImageToggle)
        gui3d.app.actions.background = self.backgroundImageToggle

        #self.filechooser = self.addTopWidget(fc.FileChooser(self.backgroundsFolders, self.extensions, None))
        #self.addLeftWidget(self.filechooser.sortBox)
        self.filechooser = self.addRightWidget(fc.IconListFileChooser(self.backgroundsFolders, self.extensions, None, None, 'Background', noneItem=True))
        self.filechooser.setIconSize(50,50)
        self.filechooser.enableAutoRefresh(False)
        #self.addLeftWidget(self.filechooser.createSortBox())

        self.backgroundBox = self.addLeftWidget(gui.GroupBox('Side'))
        self.bgSettingsBox = self.addLeftWidget(gui.GroupBox('Background settings'))

        self.radioButtonGroup = []
        for side in ['front', 'back', 'left', 'right', 'top', 'bottom', 'other']:
            radioBtn = self.backgroundBox.addWidget(gui.RadioButton(self.radioButtonGroup, label=side.capitalize(), selected=len(self.radioButtonGroup)==0))
            radioBtn.side = side
            @radioBtn.mhEvent
            def onClicked(value):
                side = self.sides[self.getSelectedSideCheckbox()]
                if side:
                    gui3d.app.axisView(side)
                self.refreshFileChooser()

        self.opacitySlider = self.bgSettingsBox.addWidget(gui.Slider(value=self.opacity, min=0,max=100, label = ["Opacity",": %d%%"]))
        self.dragButton = self.bgSettingsBox.addWidget(gui.CheckBox('Move && Resize'))
        self.foregroundTggl = self.bgSettingsBox.addWidget(gui.CheckBox("Show in foreground"))

        @self.opacitySlider.mhEvent
        def onChanging(value):
            for obj in self.planeMeshes.values():
                obj.mesh.setColor([255, 255, 255, 2.55*value])
        @self.opacitySlider.mhEvent
        def onChange(value):
            self.opacity = value
            for obj in self.planeMeshes.values():
                obj.mesh.setColor([255, 255, 255, 2.55*value])
        @self.foregroundTggl.mhEvent
        def onClicked(value):
            self.setShowBgInFront(self.foregroundTggl.selected)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            side = self.getSelectedSideCheckbox()

            if self.filenames[side]:
                oldBg = self.filenames[side][0]
            else:
                oldBg = None
            gui3d.app.do(BackgroundAction("Change background",
                self,
                side,
                oldBg,
                filename))

            mh.redraw()


        @self.dragButton.mhEvent
        def onClicked(event):
            for obj in self.planeMeshes.values():
                obj.mesh.setPickable(self.dragButton.selected)
            gui3d.app.selectedHuman.mesh.setPickable(not self.dragButton.selected)
            mh.redraw()
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Background')

        self.backgroundsFolder = os.path.join(mh.getPath(''), 'backgrounds')
        if not os.path.exists(self.backgroundsFolder):
            os.makedirs(self.backgroundsFolder)

        self.backgroundsFolders = [
            os.path.join('data', 'backgrounds'), self.backgroundsFolder
        ]
        self.extensions = ['bmp', 'png', 'tif', 'tiff', 'jpg', 'jpeg', 'clear']

        self.texture = mh.Texture()

        self.sides = {
            'front': [0, 0, 0],
            'back': [0, 180, 0],
            'left': [0, 90, 0],
            'right': [0, -90, 0],
            'top': [90, 0, 0],
            'bottom': [-90, 0, 0],
            'other': None
        }

        self.filenames = {}  # Stores (filename, aspect)
        self.transformations = {}  # Stores ((posX,posY), scaleY)
        for side in self.sides.keys():
            self.filenames[side] = None
            self.transformations[side] = [(0.0, 0.0), 1.0]

        mesh = geometry3d.RectangleMesh(20, 20, centered=True)
        self.backgroundImage = gui3d.app.addObject(
            gui3d.Object([0, 0, 1], mesh, visible=False))
        self.backgroundImage.mesh.setCameraProjection(0)  # Set to model camera
        self.opacity = 100
        mesh.setColor([255, 255, 255, self.opacity])
        mesh.setPickable(False)
        mesh.setShadeless(True)
        mesh.setDepthless(True)
        mesh.priority = -90

        self.backgroundImageToggle = gui.Action('background',
                                                'Background',
                                                self.toggleBackground,
                                                toggle=True)
        gui3d.app.main_toolbar.addAction(self.backgroundImageToggle)
        gui3d.app.actions.background = self.backgroundImageToggle

        #self.filechooser = self.addTopWidget(fc.FileChooser(self.backgroundsFolders, self.extensions, None))
        #self.addLeftWidget(self.filechooser.sortBox)
        self.filechooser = self.addRightWidget(
            fc.IconListFileChooser(self.backgroundsFolders, self.extensions,
                                   None, None, 'Background'))
        self.filechooser.setIconSize(50, 50)
        self.addLeftWidget(self.filechooser.createSortBox())

        self.backgroundBox = self.addLeftWidget(gui.GroupBox('Side'))
        self.bgSettingsBox = self.addLeftWidget(
            gui.GroupBox('Background settings'))

        self.radioButtonGroup = []
        for side in [
                'front', 'back', 'left', 'right', 'top', 'bottom', 'other'
        ]:
            radioBtn = self.backgroundBox.addWidget(
                gui.RadioButton(self.radioButtonGroup,
                                label=side.capitalize(),
                                selected=len(self.radioButtonGroup) == 0))
            radioBtn.side = side

        self.opacitySlider = self.bgSettingsBox.addWidget(
            gui.Slider(value=self.opacity, min=0, max=255,
                       label="Opacity: %d"))
        self.foregroundTggl = self.bgSettingsBox.addWidget(
            gui.ToggleButton("Show in foreground"))

        @self.opacitySlider.mhEvent
        def onChanging(value):
            self.backgroundImage.mesh.setColor([255, 255, 255, value])

        @self.opacitySlider.mhEvent
        def onChange(value):
            self.opacity = value
            self.backgroundImage.mesh.setColor([255, 255, 255, value])

        @self.foregroundTggl.mhEvent
        def onClicked(value):
            self.setShowBgInFront(self.foregroundTggl.selected)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            side = self.getSelectedSideCheckbox()

            if os.path.splitext(filename)[1] == ".clear":
                filename = None

            if self.filenames[side]:
                oldBg = self.filenames[side][0]
            else:
                oldBg = None
            gui3d.app.do(
                BackgroundAction("Change background", self, side, oldBg,
                                 filename))

            if self.sides[side]:
                gui3d.app.selectedHuman.setRotation(self.sides[side])
            mh.redraw()