def getMaterialPaths(self, objType, proxy = None):
        if objType == 'skin':
            objType = 'skins'
        elif objType not in [t.lower() for t in SimpleProxyTypes]:
            objType = 'clothes'
        objType = objType.lower()

        if proxy and objType != 'skins':
            subPath = None
        else:
            subPath = objType

        # General paths
        if subPath:
            paths = [mh.getPath(os.path.join('data', subPath)), mh.getSysDataPath(subPath)]
            for p in paths:
                if getpath.isSubPath(p, mh.getPath()) and not os.path.exists(p):
                    os.makedirs(p)
        else:
            paths = []

        # Global material paths
        for p in [mh.getPath(os.path.join('data', objType, 'materials')), mh.getSysDataPath(os.path.join(objType, 'materials'))]:
            if os.path.isdir(p):
                paths.append(p)

        # Path where proxy file is located
        if proxy:
            paths = [os.path.dirname(proxy.file)] + paths

        return paths
Ejemplo n.º 2
0
    def buildTree(cls):
        cls._files = {}

        def add_file(dir, path):
            head, tail = path[0], path[1:]
            if not tail:
                dir[head] = None
            else:
                if head not in dir:
                    dir[head] = {}
                add_file(dir[head], tail)

        with zipfile.ZipFile(mh.getSysDataPath('targets.npz'), 'r') as npzfile:
            for file in npzfile.infolist():
                name = file.filename
                if not name.endswith('.index.npy'):
                    continue
                name = name[:-10] + '.target'
                path = name.split('/')
                add_file(cls._files, path)

        with open(mh.getSysDataPath('images.list'), 'r') as imgfile:
            for line in imgfile:
                name = line.rstrip()
                if not name.endswith('.png'):
                    continue
                path = name.split('/')
                add_file(cls._files, path)
Ejemplo n.º 3
0
 def getThemeResource(self, folder, id):
     if '/' in id:
         return id
     path = os.path.join(mh.getSysDataPath("themes/"), self.theme, folder, id)
     if os.path.exists(path):
         return path
     else:
         return os.path.join(mh.getSysDataPath("themes/default/"), folder, id)
Ejemplo n.º 4
0
def targetFileName(typ, name, gender, age):
    #if typ == "Expressions":
    #    return (mh.getSysDataPath('targets/expression/%s_%s/neutral_%s_%s_%s.target') % (gender, age, gender, age, name) )
    if typ == "ExpressionUnits":
        return (mh.getSysDataPath('targets/expression/units/caucasian/%s_%s/%s.target') %  (gender, age, name) )
    elif typ == "Corrective":
        (part, pose) = name
        return (mh.getSysDataPath("shared/mhx/targets/correctives/%s/caucasian/%s-%s/%s.target") % (part, gender, age, pose))
    else:
        raise NameError("Unknown type %s" % typ)
Ejemplo n.º 5
0
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)
        if gui3d.app.settings.get('cameraAutoZoom', True):
            gui3d.app.setGlobalCamera()

        # Disable smoothing in skeleton library
        self.oldSmoothValue = self.human.isSubdivided()
        self.human.setSubdivided(False)

        self.oldHumanMat = self.human.material.clone()
        self.oldPxyMats = dict()
        xray_mat = material.fromFile(mh.getSysDataPath('materials/xray.mhmat'))
        self.human.material = xray_mat
        for pxy in self.human.getProxies(includeHumanProxy=False):
            obj = pxy.object
            self.oldPxyMats[pxy.uuid] = obj.material.clone()
            obj.material = xray_mat

        if self.skelObj:
            self.skelObj.show()

        #if not self.jointsObj:
        #    self.drawJointHelpers()

        #self.filechooser.refresh()

        # Make sure skeleton is updated when human has changed
        self.human.getSkeleton()

        # Re-draw joints positions if human has changed
        if self.humanChanged:
            #self.drawJointHelpers()
            self.humanChanged = False
        mh.redraw()
Ejemplo n.º 6
0
    def __init__(self, category):

        gui3d.TaskView.__init__(self, category, 'Eyes')
        eyesDir = os.path.join(mh.getPath(''), 'data', 'eyes')
        if not os.path.exists(eyesDir):
            os.makedirs(eyesDir)
        self.paths = [eyesDir , mh.getSysDataPath('eyes')]
        #self.filechooser = self.addTopWidget(fc.FileChooser(self.paths, 'mhclo', 'thumb', mh.getSysDataPath('eyes/notfound.thumb')))
        self.filechooser = self.addRightWidget(fc.IconListFileChooser(self.paths, 'mhclo', 'thumb', mh.getSysDataPath('clothes/notfound.thumb'), 'Eyes'))
        self.filechooser.setIconSize(50,50)
        self.filechooser.enableAutoRefresh(False)
        self.addLeftWidget(self.filechooser.createSortBox())

        self.oHeadCentroid = [0.0, 7.436, 0.03 + 0.577]
        self.oHeadBBox = [[-0.84,6.409,-0.9862],[0.84,8.463,1.046]]

        self.human = gui3d.app.selectedHuman

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if self.human.eyesProxy:
                oldFile = self.human.eyesProxy.file
            else:
                oldFile = 'clear.mhclo'
            gui3d.app.do(EyesAction("Change eyes",
                self.human,
                self,
                oldFile,
                filename))
Ejemplo n.º 7
0
    def loadPreset(self, filename, selector, folder=mh.getSysDataPath("rigs/")):
        filepath = os.path.join(folder, filename + ".json")
        struct = io_json.loadJson(filepath)
        self.__init__()
        try:
            self.rigtype = struct["name"]
        except KeyError:
            pass
        try:
            self.description = struct["description"]
        except KeyError:
            pass
        try:
            self.merge = struct["merge"]
        except KeyError:
            pass
        try:
            settings = struct["settings"]
        except KeyError:
            settings = {}
        for key,value in list(settings.items()):
            expr = ("self.%s = %s" % (key, value))
            exec(expr)

        if selector is not None:
            selector.fromOptions(self)
        try:
            bones = struct["bones"]
        except KeyError:
            bones = None
        if bones:
            self.locale = Locale(bones=bones)
        return self.description
Ejemplo n.º 8
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Scene')
        self.scene = scene.Scene()

        leftTopBox = self.addLeftWidget(gui.GroupBox("Current scene"))
        filebox = leftTopBox.addWidget(gui.TextView("Default.mhscene"))
        
        sceneDir = mh.getPath('scenes')
        if not os.path.exists(sceneDir):
            os.makedirs(sceneDir)
        defscene = os.path.join(sceneDir, "Default.mhscene")
        if os.path.exists(defscene):
            self.scene.load(defscene)
        else:
            self.scene.save(defscene)
        if not os.path.exists(os.path.join(sceneDir, "notfound.thumb")):
            shutil.copy(os.path.normpath(mh.getSysDataPath("uvs/notfound.thumb")), sceneDir)
        self.filechooser = self.addRightWidget( \
        fc.IconListFileChooser(sceneDir , 'mhscene', ['thumb', 'png'], 'notfound.thumb', 'Scene'))
        self.addLeftWidget(self.filechooser.createSortBox())

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            self.scene.load(filename)
            filebox.setText(os.path.basename(filename))
    def __init__(self, category, proxyName, tabLabel = None, multiProxy = False, tagFilter = False, descriptionWidget = False):
        if not tabLabel:
            tabLabel = proxyName.capitalize()
        proxyName = proxyName.lower().replace(" ", "_")
        self.proxyName = proxyName
        gui3d.TaskView.__init__(self, category, tabLabel)
        filecache.MetadataCacher.__init__(self, self.getFileExtension(), self.proxyName + '_filecache.mhc')

        self.label = tabLabel
        self.multiProxy = multiProxy
        self.tagFilter = tagFilter
        self.descriptionWidget = descriptionWidget

        self.homeProxyDir = getpath.getPath(os.path.join('data', proxyName))
        self.sysProxyDir = mh.getSysDataPath(proxyName)

        if not os.path.exists(self.homeProxyDir):
            os.makedirs(self.homeProxyDir)

        self.paths = [self.homeProxyDir , self.sysProxyDir]

        self.human = gui3d.app.selectedHuman

        self._proxyFilePerUuid = None

        self.selectedProxies = []

        self.createFileChooser()
    def __init__(self, category):

        gui3d.TaskView.__init__(self, category, 'Proxies')
        self.installDir = mh.getSysDataPath('proxymeshes')
        self.userDir = os.path.join(mh.getPath(''), 'data', 'proxymeshes')
        if not os.path.exists(self.userDir):
            os.makedirs(self.userDir)
        self.paths = [self.userDir , self.installDir]
        #self.filechooser = self.addTopWidget(fc.FileChooser(self.paths, 'proxy', 'thumb', mh.getSysDataPath('proxymeshes/notfound.thumb'), sort=ProxyFileSort()))
        #self.filechooser = self.addRightWidget(fc.ListFileChooser(self.paths, 'proxy', 'Proxy', sort=ProxyFileSort()))
        self.filechooser = self.addRightWidget(fc.IconListFileChooser(self.paths, 'proxy', 'thumb', mh.getSysDataPath('proxymeshes/notfound.thumb'), 'Proxy'))
        self.filechooser.setIconSize(50,50)
        self.addLeftWidget(self.filechooser.createSortBox())

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            human = gui3d.app.selectedHuman
            if human.proxy:
                oldFile = human.proxy.file
            else:
                oldFile = "clear.proxy"
            gui3d.app.do(ProxyAction("Change proxy",
                human,
                self,
                oldFile,
                filename))
Ejemplo n.º 11
0
 def applyTarget(self,targetName,power, assumeThreading = False):
     self.human.setDetail(mh.getSysDataPath("targets/" + targetName + ".target"), power)
     if assumeThreading:
         self._threadSafeApplyAllTargets()
     else:
         self.human.applyAllTargets()
     mh.redraw()
Ejemplo n.º 12
0
 def getItemPath(item):
     path = []
     while item is not None:
         path.append(item.text)
         item = item.parent
     path = mh.getSysDataPath(os.path.join(*reversed(path)))
     return path
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Material', label='Skin/Material')
        self.human = gui3d.app.selectedHuman

        # Paths, in order, in which relative material filepaths will be searched
        self.searchPaths = [mh.getPath(), mh.getSysDataPath()]
        self.searchPaths = [os.path.abspath(p) for p in self.searchPaths]

        self.materials = None

        self.filechooser = self.addRightWidget(fc.IconListFileChooser(self.materials, 'mhmat', ['thumb', 'png'], mh.getSysDataPath('skins/notfound.thumb'), name='Material'))
        self.filechooser.setIconSize(50,50)
        self.filechooser.enableAutoRefresh(False)
        #self.filechooser.setFileLoadHandler(fc.MhmatFileLoader())
        #self.addLeftWidget(self.filechooser.createSortBox())

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            mat = material.fromFile(filename)
            human = self.human

            obj = self.humanObjSelector.getSelectedObject()
            if obj:
                gui3d.app.do(MaterialAction(obj, mat))

        self.humanObjSelector = self.addLeftWidget(HumanObjectSelector(self.human))
        @self.humanObjSelector.mhEvent
        def onActivate(value):
            self.reloadMaterialChooser()
Ejemplo n.º 14
0
 def buildShader(self, shader):
     
     srcPath = os.path.join(mh.getSysDataPath('shaders/aqsis'), shader + '.sl')
     dstPath = os.path.join(self.sceneToRender.usrShaderPath, shader + '.slx')
     
     if not os.path.exists(dstPath) or os.stat(srcPath).st_mtime > os.stat(dstPath).st_mtime:
         subprocess.Popen('aqsl %s -o "%s"' % (srcPath, dstPath), shell=True)
Ejemplo n.º 15
0
    def __init__(self, category, proxyName, tabLabel = None, multiProxy = False, tagFilter = False):
        if not tabLabel:
            tabLabel = proxyName.capitalize()
        proxyName = proxyName.lower().replace(" ", "_")
        gui3d.TaskView.__init__(self, category, tabLabel)

        self.proxyName = proxyName
        self.label = tabLabel
        self.multiProxy = multiProxy
        self.tagFilter = tagFilter

        self.homeProxyDir = getpath.getPath(os.path.join('data', proxyName))
        self.sysProxyDir = mh.getSysDataPath(proxyName)

        if not os.path.exists(self.homeProxyDir):
            os.makedirs(self.homeProxyDir)

        self.paths = [self.homeProxyDir , self.sysProxyDir]

        self.human = gui3d.app.selectedHuman

        self._proxyCache = dict()
        self._proxyFileCache = None
        self._proxyFilePerUuid = None

        self.selectedProxies = []

        self.createFileChooser()
Ejemplo n.º 16
0
def readTarget(filepath):

    words = filepath.split("-")
    if (words[0] == mh.getSysDataPath("targets/macrodetails/universal") and
        words[-2] == "averagemuscle" and
        words[-1] == "averageweight.target"):
        return {}

    try:
        fp = open(filepath, "r")
    except:
        fp = None

    if fp is None:
        filepath1 = filepath.replace("-averagemuscle", "").replace("-averageweight", "")
        try:
            fp = open(filepath1, "r")
        except:
            fp = None

    if fp:
        target = {}
        for line in fp:
            words = line.split()
            if len(words) >= 4 and words[0][0] != '#':
                n = int(words[0])
                if n < meshstat.numberOfVertices:
                    target[n] = np.array([float(words[1]), float(words[2]), float(words[3])])
        fp.close()
        return target
    else:
        log.message("Found neither %s nor %s" % (filepath, filepath1))
        halt
        return None
Ejemplo n.º 17
0
 def onHumanChanged(self, event):
     super(EyesTaskView, self).onHumanChanged(event)
     if event.change == 'reset':
         # Load initial eyes
         self.selectProxy(mh.getSysDataPath("eyes/high-poly/high-poly.mhclo"))
         # Reset default material on eyes (in case it was changed)
         self.getObjects()[0].material = self.getSelection()[0].material
Ejemplo n.º 18
0
 def setValue(self, value):
     self._path = pathToUnicode(value)
     if value:
         self.imageView.setImage(value)
         if isinstance(value, basestring):
             self.browseBtn._path = pathToUnicode(value)
     else:
         self.imageView.setImage(mh.getSysDataPath('notfound.thumb'))
    def onSkinUpdateEvent(self, event):
        if "litsphereTexture" not in self.human.meshData.shaderParameters:
            return

        current = self.human.meshData.shaderParameters["litsphereTexture"]
        if current and (isinstance(current, image.Image) or \
           os.path.abspath(current) == os.path.abspath(mh.getSysDataPath("litspheres/adaptive_skin_tone.png"))):
            if event.change == "caucasian" or event.change == "african" or \
              event.change == "asian" or event.change == "material":
                self.updateAdaptiveSkin()
Ejemplo n.º 20
0
    def setTheme(self, theme):

        if self.theme == theme:
            return

        f = open(os.path.join(mh.getSysDataPath("themes/"), theme + ".mht"), 'r')

        for data in f.readlines():
            lineData = data.split()

            if len(lineData) > 0:
                if lineData[0] == "version":
                    log.message('Version %s', lineData[1])
                elif lineData[0] == "color":
                    if lineData[1] == "clear":
                        self.clearColor[:] = [float(val) for val in lineData[2:5]]
                        mh.setClearColor(float(lineData[2]), float(lineData[3]), float(lineData[4]), 1.0)
        log.debug("Loaded theme %s", mh.getSysDataPath('themes/'+theme+'.mht'))

        try:
            f = open(mh.getSysDataPath('themes/%s.qss' % theme), 'r')
            qStyle = "\n".join(f.readlines())
            self.setStyleSheet(qStyle)
            # Also set stylesheet on custom slider style
            for widget in self.allWidgets():
                if isinstance(widget, gui.Slider):
                    widget.setStyleSheet(qStyle)
            log.debug("Loaded Qt style %s", mh.getSysDataPath('themes/'+theme+'.qss'))
        except:
            self.setStyleSheet("")
            # Also set stylesheet on custom slider style
            for widget in self.allWidgets():
                if isinstance(widget, gui.Slider):
                    widget.setStyleSheet("")
            '''
            if theme != "default":
                log.warning('Could not open Qt style file %s.', mh.getSysDataPath('themes/'+theme+'.qss'))
            '''

        self.theme = theme
        self.reloadIcons()
        self.redraw()
Ejemplo n.º 21
0
 def getConverter(self):
     if self.basemesh in ["alpha_7", "alpha7"]:
         global _A7converter
         if _A7converter is None:
             _A7converter = readProxyFile(gui3d.app.selectedHuman.meshData, mh.getSysDataPath("3dobjs/a7_converter.proxy"), type="Converter")
         print(("Converting clothes with", _A7converter))
         return _A7converter
     elif self.basemesh == "hm08":
         return None
     else:
         raise NameError("Unknown basemesh for mhclo file: %s" % self.basemesh)
Ejemplo n.º 22
0
def testColor(self):
    """
    This method loads vertex colors on the base object.
    
    **Parameters:** This method has no parameters.

    """

    # TODO: move this in a test module

    algos3d.loadVertsColors(self.basemesh, mh.getSysDataPath('3dobjs/base.obj.colors'))
Ejemplo n.º 23
0
def load(app):
    category = app.getCategory('Geometries')
    taskview = EyesTaskView(category)
    taskview.sortOrder = 1
    category.addTask(taskview)

    app.addLoadHandler('eyes', taskview.loadHandler)
    app.addSaveHandler(taskview.saveHandler)

    # Load initial eyes
    taskview.setEyes(gui3d.app.selectedHuman, mh.getSysDataPath("eyes/low-poly/low-poly.mhclo"))
Ejemplo n.º 24
0
def load(app):
    global taskview

    category = app.getCategory('Geometries')
    taskview = EyesTaskView(category)
    taskview.sortOrder = 1
    category.addTask(taskview)

    taskview.registerLoadSaveHandlers()

    # Load initial eyes
    taskview.selectProxy(mh.getSysDataPath("eyes/high-poly/high-poly.mhclo"))
    def loadHandler(self, human, values):
        if values[0] == 'status':
            return

        if values[0] == 'skinMaterial':
            path = values[1]
            if os.path.isfile(path):
                mat = material.fromFile(path)
                human.material = mat
                return
            else:
                absP = getpath.findFile(path, [mh.getPath('data'), mh.getSysDataPath()])
                if not os.path.isfile(absP):
                    log.warning('Could not find material %s for skinMaterial parameter.', values[1])
                    return
                mat = material.fromFile(absP)
                human.material = mat
                return
        elif values[0] == 'material':
            if len(values) == 3:
                uuid = values[1]
                filepath = values[2]
                name = ""
            else:
                name = values[1]
                uuid = values[2]
                filepath = values[3]

            if human.hairProxy and human.hairProxy.getUuid() == uuid:
                proxy = human.hairProxy
                filepath = self.getMaterialPath(filepath, proxy.file)
                proxy.object.material = material.fromFile(filepath)
                return
            elif human.eyesProxy and human.eyesProxy.getUuid() == uuid:
                proxy = human.eyesProxy
                filepath = self.getMaterialPath(filepath, proxy.file)
                proxy.object.material = material.fromFile(filepath)
                return
            elif human.genitalsProxy and human.genitalsProxy.getUuid() == uuid:
                proxy = human.genitalsProxy
                filepath = self.getMaterialPath(filepath, proxy.file)
                proxy.object.material = material.fromFile(filepath)
                return
            elif not uuid in human.clothesProxies.keys():
                log.error("Could not load material for proxy with uuid %s (%s)! No such proxy." % (uuid, name))
                return

            proxy = human.clothesProxies[uuid]
            proxy = human.clothesProxies[uuid]
            filepath = self.getMaterialPath(filepath, proxy.file)
            self.applyClothesMaterial(uuid, filepath)
            return
Ejemplo n.º 26
0
 def _load_binary(self, name):
     if Target.npzfile is None:
         try:
             npzname = mh.getSysDataPath('targets.npz')
             Target.npzfile = np.load(npzname)
             Target.npztime = os.path.getmtime(npzname)
         except:
             log.message('no compressed targets found')
             Target.npzfile = False
     if Target.npzfile == False:
         self._load_binary_files(name)
     else:
         self._load_binary_archive(name)
Ejemplo n.º 27
0
    def __init__(self, category):
        guirender.RenderTaskView.__init__(self, category, 'Scene')

        self.filechooser = self.addRightWidget(
            fc.IconListFileChooser(
                [mh.getDataPath('scenes'), mh.getSysDataPath('scenes')],
                'mhscene', ['thumb', 'png'], 'notfound.thumb', 'Scene'))
        #self.addLeftWidget(self.filechooser.createSortBox())
        self.filechooser.enableAutoRefresh(False)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            G.app.setScene(scene.Scene(filename))
Ejemplo n.º 28
0
    def onHumanChanging(self, event):

        human = event.human
        if event.change == 'reset':
            log.message("resetting eyes")
            if human.eyesObj:
                gui3d.app.removeObject(human.eyesObj)
                human.eyesObj = None
                human.eyesProxy = None
            self.setEyes(human, mh.getSysDataPath("eyes/high-poly/high-poly.mhclo"))
            self.filechooser.deselectAll()
        else:
            if gui3d.app.settings.get('realtimeUpdates', False):
                self.adaptEyesToHuman(human)
Ejemplo n.º 29
0
    def reloadMaterial(self):
        obj = self.getSelectedObject()

        if shader.Shader.supported():
            self.listShaders(obj.material)
            self.listUniforms(obj.material)
        self.updateShaderConfig(obj.material)
        self.listMaterialSettings(obj)

        if obj.material.filepath:
            self.saveMaterialBtn.directory = obj.material.filepath
            self.loadMaterialBtn.directory = obj.material.filepath
        else:
            self.saveMaterialBtn.directory = mh.getPath('data')
            self.loadMaterialBtn.directory = mh.getSysDataPath()
Ejemplo n.º 30
0
def applyTexture(self):
    """
    This method applies the texture file to either the standard mesh or the
    subdivided mesh (epending upon which is currently active).

    **Parameters:** None.

    """

    if not self.basemesh.isSubdivided:
        self.basemesh.setTexture('data/textures/texture.tga')
    else:
        sob = self.scene.getObject(self.basemesh.name + '.sub')
        sob.setTexture(mh.getSysDataPath('textures/texture.tga'))
    self.scene.redraw()
Ejemplo n.º 31
0
    log = logDummy()

    class appDummy:
        def __init__(self, human):
            self.selectedHuman = human
            self.splash = splashDummy()
            self.log_window = log_windowDummy()
            self.statusBar = None
            self.progress = None

        def addLogMessage(self, arg1, arg2):
            "Noop"

    buddy = human.Human(
        files3d.loadMesh(mh.getSysDataPath("3dobjs/base.obj"), maxFaces=5))
    G.app = appDummy(buddy)
    base_skel = skeleton.load(mh.getSysDataPath('rigs/default.mhskel'),
                              buddy.meshData)
    buddy.setBaseSkeleton(base_skel)

    import humanmodifier
    humanmodifier.loadModifiers("data/modifiers/modeling_modifiers.json",
                                buddy)
    import proxy
    print os.getcwd()
    sys.stdout = stdout
    buddyProxy = proxy.loadProxy(
        buddy, os.path.join(os.getcwd(), 'data', 'eyes', 'low-poly',
                            'low-poly'), 'Eyes')
    print
Ejemplo n.º 32
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Skeleton')
        self.debugLib = None
        self.amtOptions = ArmatureOptions()
        self.optionsSelector = None

        self.systemRigs = mh.getSysDataPath('rigs')
        self.userRigs = os.path.join(mh.getPath(''), 'data', 'rigs')
        self.rigPaths = [self.userRigs, self.systemRigs]
        if not os.path.exists(self.userRigs):
            os.makedirs(self.userRigs)
        self.extension = "rig"

        self.human = gui3d.app.selectedHuman
        self.human._skeleton = None
        self.human.animated = None
        # Attach getter to human to access the skeleton, that takes care of deferred
        # updating when the skeleton should change
        import types
        self.human.getSkeleton = types.MethodType(_getSkeleton, self.human,
                                                  self.human.__class__)
        self.human.getVertexWeights = types.MethodType(_getVertexWeights,
                                                       self.human,
                                                       self.human.__class__)

        self.selectedRig = None
        self.selectedBone = None

        self.oldSmoothValue = False

        self.humanChanged = False  # Used for determining when joints need to be redrawn

        self.skelMesh = None
        self.skelObj = None

        self.jointsMesh = None
        self.jointsObj = None

        self.selectedJoint = None

        self.oldHumanTransp = self.human.material.transparent
        self.oldHumanShader = self.human.material.shader

        #
        #   Display box
        #
        '''
        self.displayBox = self.addLeftWidget(gui.GroupBox('Display'))
        self.showHumanTggl = self.displayBox.addWidget(gui.CheckBox("Show human"))
        @self.showHumanTggl.mhEvent
        def onClicked(event):
            if self.showHumanTggl.selected:
                self.human.show()
            else:
                self.human.hide()
        self.showHumanTggl.setSelected(True)

        self.showJointsTggl = self.displayBox.addWidget(gui.CheckBox("Show joints"))
        @self.showJointsTggl.mhEvent
        def onClicked(event):
            if not self.jointsObj:
                return
            if self.showJointsTggl.selected:
                self.jointsObj.show()
            else:
                self.jointsObj.hide()
        self.showJointsTggl.setSelected(True)
        '''

        self.sysDataPath = mh.getSysDataPath('rigs')
        self.homeDataPath = mh.getPath('data/rigs')
        if not os.path.exists(self.homeDataPath):
            os.makedirs(self.homeDataPath)
        self.paths = [self.homeDataPath, self.sysDataPath]

        #
        #   Preset box
        #

        self.presetChooser = self.addRightWidget(
            fc.IconListFileChooser(
                self.paths,
                'json',
                'thumb',
                name='Rig presets',
                notFoundImage=mh.getSysDataPath('notfound.thumb'),
                noneItem=True,
                doNotRecurse=True))
        self.presetChooser.setIconSize(50, 50)

        @self.presetChooser.mhEvent
        def onFileSelected(filename):
            self.rigPresetFileSelected(filename)

        self.infoBox = self.addLeftWidget(gui.GroupBox('Rig info'))
        self.boneCountLbl = self.infoBox.addWidget(gui.TextView('Bones: '))
        self.descrLbl = self.infoBox.addWidget(gui.TextView('Description: '))
        self.descrLbl.setSizePolicy(gui.QtGui.QSizePolicy.Ignored,
                                    gui.QtGui.QSizePolicy.Preferred)
        self.descrLbl.setWordWrap(True)
Ejemplo n.º 33
0
    def listMaterialSettings(self, obj):
        for child in self.materialBox.children[:]:
            self.materialBox.removeWidget(child)

        mat = obj.material
        sh = self.getSelectedShader()
        if sh:
            uniforms = [u.name for u in sh.getUniforms()] + sh.glUniforms

        # TODO reduce code replication by using a more generic approach

        # Diffuse color and texture
        w1 = self.materialBox.addWidget(ColorValue("Diffuse",
                                                   mat.diffuseColor))
        if sh:
            w1.setEnabled(('diffuse' in uniforms
                           or 'gl_FrontMaterial.diffuse' in uniforms)
                          and not mat.autoBlendSkin)
        else:
            w1.setEnabled(not mat.autoBlendSkin)

        @w1.mhEvent
        def onActivate(event):
            mat.diffuseColor = w1.value

        diffuseMapAvailable = (not sh) or ('diffuseTexture'
                                           in uniforms) or ('DIFFUSE'
                                                            in sh.defineables)
        w3 = self.materialBox.addWidget(
            ImageValue("Diffuse texture", mat.diffuseTexture,
                       mh.getSysDataPath('textures')))
        w3.setEnabled(diffuseMapAvailable)

        @w3.mhEvent
        def onActivate(event):
            mat.diffuseTexture = w3.value
            self.updateShaderConfig()

        # Phong shading color parameters
        w4 = self.materialBox.addWidget(ColorValue("Ambient",
                                                   mat.ambientColor))
        if sh:
            w4.setEnabled('ambient' in uniforms
                          or 'gl_FrontMaterial.ambient' in uniforms)

        @w4.mhEvent
        def onActivate(event):
            mat.ambientColor = w4.value

        w5 = self.materialBox.addWidget(
            ColorValue("Specular", mat.specularColor))
        if sh:
            w5.setEnabled('specular' in uniforms
                          or 'gl_FrontMaterial.specular' in uniforms)

        @w5.mhEvent
        def onActivate(event):
            mat.specularColor = w5.value

        w7 = self.materialBox.addWidget(
            ScalarValue("Specular shininess", mat.shininess))
        if sh:
            w7.setEnabled('specular' in uniforms
                          or 'gl_FrontMaterial' in uniforms)

        @w7.mhEvent
        def onActivate(event):
            mat.shininess = w7.value

        w8 = self.materialBox.addWidget(
            ColorValue("Emissive", mat.emissiveColor))
        if sh:
            w8.setEnabled('emissive' in uniforms
                          or 'gl_FrontMaterial' in uniforms)

        @w8.mhEvent
        def onActivate(event):
            mat.emissiveColor = w8.value

        w9 = self.materialBox.addWidget(ScalarValue("Opacity", mat.opacity))
        if sh:
            w9.setEnabled('diffuse' in uniforms
                          or 'gl_FrontMaterial' in uniforms)

        @w9.mhEvent
        def onActivate(event):
            mat.opacity = w9.value

        w10 = self.materialBox.addWidget(
            ScalarValue("Translucency", mat.translucency))

        @w10.mhEvent
        def onActivate(event):
            mat.translucency = w10.value

        # Config toggles
        w10a = self.materialBox.addWidget(
            TruthValue("Shadeless", mat.shadeless))

        @w10a.mhEvent
        def onActivate(event):
            mat.shadeless = w10a.value

        w10b = self.materialBox.addWidget(
            TruthValue("Wireframe", mat.wireframe))

        @w10b.mhEvent
        def onActivate(event):
            mat.wireframe = w10b.value

        w10c = self.materialBox.addWidget(
            TruthValue("Transparent", mat.transparent))

        @w10c.mhEvent
        def onActivate(event):
            mat.transparent = w10c.value

        w10c2 = self.materialBox.addWidget(
            TruthValue("Alpha to Coverage", mat.alphaToCoverage))

        @w10c2.mhEvent
        def onActivate(event):
            mat.alphaToCoverage = w10c2.value

        w10d = self.materialBox.addWidget(
            TruthValue("Backface culling", mat.backfaceCull))

        @w10d.mhEvent
        def onActivate(event):
            mat.backfaceCull = w10d.value

        w10e = self.materialBox.addWidget(
            TruthValue("Depthless", mat.depthless))

        @w10e.mhEvent
        def onActivate(event):
            mat.depthless = w10e.value

        w10f = self.materialBox.addWidget(
            TruthValue("Auto ethnic skin", mat.autoBlendSkin))

        @w10f.mhEvent
        def onActivate(event):
            mat.autoBlendSkin = w10f.value
            self.listMaterialSettings(self.getSelectedObject()
                                      )  # Update diffuse color property state
            self.listUniforms(mat)  # Update litsphere texture enabled state

        # Transparency mapping
        transparencyMapAvailable = sh and \
                                   (('transparencymapTexture' in uniforms) or \
                                   ('TRANSPARENCYMAP' in sh.defineables))
        w11 = self.materialBox.addWidget(
            ImageValue("Transparency map texture", mat.transparencyMapTexture,
                       mh.getSysDataPath('textures')))
        if sh:
            w11.setEnabled(transparencyMapAvailable)

        @w11.mhEvent
        def onActivate(event):
            mat.transparencyMapTexture = w11.value
            self.updateShaderConfig()

        w12 = self.materialBox.addWidget(
            ScalarValue("Transparency (map) intensity",
                        mat.transparencyMapIntensity))
        if sh:
            w12.setEnabled(transparencyMapAvailable)

        @w12.mhEvent
        def onActivate(event):
            mat.transparencyMapIntensity = w12.value

        # Bump mapping
        bumpMapAvailable = sh and \
                           (('bumpmapTexture' in uniforms) or \
                           ('BUMPMAP' in sh.defineables))
        w13 = self.materialBox.addWidget(
            ImageValue("Bump map texture", mat.bumpMapTexture,
                       mh.getSysDataPath('textures')))
        if sh:
            w13.setEnabled(bumpMapAvailable)

        @w13.mhEvent
        def onActivate(event):
            mat.bumpMapTexture = w13.value
            self.updateShaderConfig()

        w14 = self.materialBox.addWidget(
            ScalarValue("Bump map intensity", mat.bumpMapIntensity))
        if sh:
            w14.setEnabled(bumpMapAvailable)

        @w14.mhEvent
        def onActivate(event):
            mat.bumpMapIntensity = w14.value

        # Normal mapping
        normalMapAvailable = sh and \
                             (('normalmapTexture' in uniforms) or \
                             ('NORMALMAP' in sh.defineables))
        w15 = self.materialBox.addWidget(
            ImageValue("Normal map texture", mat.normalMapTexture,
                       mh.getSysDataPath('textures')))
        if sh:
            w15.setEnabled(normalMapAvailable)

        @w15.mhEvent
        def onActivate(event):
            mat.normalMapTexture = w15.value
            self.updateShaderConfig()

        w16 = self.materialBox.addWidget(
            ScalarValue("Normal map intensity", mat.normalMapIntensity))
        if sh:
            w16.setEnabled(normalMapAvailable)

        @w16.mhEvent
        def onActivate(event):
            mat.normalMapIntensity = w16.value

        # Displacement mapping
        displacementMapAvailable = sh and \
                                   (('displacementmapTexture' in uniforms) or \
                                   ('DISPLACEMENT' in sh.defineables))
        w17 = self.materialBox.addWidget(
            ImageValue("Displacement map texture", mat.displacementMapTexture,
                       mh.getSysDataPath('textures')))
        if sh:
            w17.setEnabled(displacementMapAvailable)

        @w17.mhEvent
        def onActivate(event):
            mat.displacementMapTexture = w17.value
            self.updateShaderConfig()

        w18 = self.materialBox.addWidget(
            ScalarValue("Displacement map intensity",
                        mat.displacementMapIntensity))
        if sh:
            w18.setEnabled(displacementMapAvailable)

        @w18.mhEvent
        def onActivate(event):
            mat.displacementMapIntensity = w18.value

        # Specular mapping
        specularMapAvailable = sh and \
                               (('specularmapTexture' in uniforms) or \
                               ('SPECULARMAP' in sh.defineables))
        w19 = self.materialBox.addWidget(
            ImageValue("Specular map texture", mat.specularMapTexture,
                       mh.getSysDataPath('textures')))
        if sh:
            w19.setEnabled(specularMapAvailable)

        @w19.mhEvent
        def onActivate(event):
            mat.specularMapTexture = w19.value
            self.updateShaderConfig()

        w20 = self.materialBox.addWidget(
            ScalarValue("Specular map intensity", mat.specularMapIntensity))
        if sh:
            w20.setEnabled(specularMapAvailable)

        @w20.mhEvent
        def onActivate(event):
            mat.specularMapIntensity = w20.value

        # Ambient occlusion
        aoMapAvailable = sh and \
                         (('aomapTexture' in uniforms) or \
                          ('AOMAP' in sh.defineables))
        w20b = self.materialBox.addWidget(
            ImageValue("Ambient Occlusion texture", mat.aoMapTexture,
                       mh.getSysDataPath('textures')))
        if sh:
            w20b.setEnabled(aoMapAvailable)

        @w20b.mhEvent
        def onActivate(event):
            mat.aoMapTexture = w20b.value
            self.updateShaderConfig()

        w20c = self.materialBox.addWidget(
            ScalarValue("AO map intensity", mat.aoMapIntensity))
        if sh:
            w20c.setEnabled(aoMapAvailable)

        @w20c.mhEvent
        def onActivate(event):
            mat.aoMapIntensity = w20c.value

        w21 = self.materialBox.addWidget(
            FileValue("UV map", mat.uvMap, mh.getSysDataPath('uvs')))
        w21.browseBtn.setFilter("UV Set (*.obj)")

        @w21.mhEvent
        def onActivate(event):
            if os.path.basename(w21.value) == "default.obj":
                w21.value = None
                obj.setUVMap(None)
            else:
                obj.setUVMap(w21.value)

        w22 = self.materialBox.addWidget(TextValue("Material name", mat.name))

        @w22.mhEvent
        def onActivate(event):
            mat.name = w22.value
Ejemplo n.º 34
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Skeleton')
        filecache.MetadataCacher.__init__(self, 'mhskel',
                                          'skeleton_filecache.mhc')

        self.human = gui3d.app.selectedHuman

        self.referenceRig = None

        self.selectedRig = None

        self.skelMesh = None
        self.skelObj = None

        self.jointsMesh = None
        self.jointsObj = None

        self.selectedJoint = None

        self.oldHumanMat = self.human.material
        self.oldPxyMats = dict()

        self.sysDataPath = getpath.getSysDataPath('rigs')
        self.userDataPath = getpath.getDataPath('rigs')
        if not os.path.exists(self.userDataPath):
            os.makedirs(self.userDataPath)
        self.paths = [self.userDataPath, self.sysDataPath]

        self.filechooser = self.addRightWidget(fc.IconListFileChooser( \
                                                    self.paths,
                                                    'mhskel',
                                                    'thumb',
                                                    name='Rig presets',
                                                    notFoundImage = mh.getSysDataPath('notfound.thumb'),
                                                    noneItem = True,
                                                    doNotRecurse = True))
        self.filechooser.setIconSize(50, 50)
        self.filechooser.enableAutoRefresh(False)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if filename:
                msg = "Change skeleton"
            else:
                msg = "Clear skeleton"
            gui3d.app.do(SkeletonAction(msg, self, self.selectedRig, filename))

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())

        self.infoBox = self.addLeftWidget(gui.GroupBox('Rig info'))
        self.boneCountLbl = self.infoBox.addWidget(gui.TextView('Bones: '))
        self.infoBox.setSizePolicy(gui.QtGui.QSizePolicy.Preferred,
                                   gui.QtGui.QSizePolicy.Maximum)

        descBox = self.addLeftWidget(gui.GroupBox('Description'))
        self.descrLbl = descBox.addWidget(gui.TextView(''))
        self.descrLbl.setSizePolicy(gui.QtGui.QSizePolicy.Ignored,
                                    gui.QtGui.QSizePolicy.Preferred)
        self.descrLbl.setWordWrap(True)

        self.xray_mat = None

        # the reference skeleton
        self.referenceRig = self.human.getBaseSkeleton()
Ejemplo n.º 35
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'AutoPose')
        # super(PoseLibraryAotu1TaskView, self).__init__(category, 'clothes', multiProxy = True, tagFilter = True)
        filecache.MetadataCacher.__init__(self, ['bvh'], 'pose_filecache.mhc')
        self.cache_format_version = '1c'  # Bump cacher version for updated format of pose metadata
        box1 = self.addLeftWidget(gui.GroupBox('ImageMatch'))
        self.aButtonC1 = box1.addWidget(gui.Button('L.UpArm'))
        self.aButtonC2 = box1.addWidget(gui.Button('L.LowArm'))
        self.aButtonC3 = box1.addWidget(gui.Button('R.UpArm'))
        self.aButtonC4 = box1.addWidget(gui.Button('R.LowArm'))
        self.aButtonC5 = box1.addWidget(gui.Button('L.UpLeg'))
        self.aButtonC6 = box1.addWidget(gui.Button('L.LowLeg'))
        self.aButtonC7 = box1.addWidget(gui.Button('R.UpLeg'))
        self.aButtonC8 = box1.addWidget(gui.Button('R.LowLeg'))
        box = self.addLeftWidget(gui.GroupBox('AngleRotate'))
        self.aSliderLabel = box.addWidget(gui.TextView('Value is initialize=0.5'))
        self.InitButton = box.addWidget(gui.Button('Init Pose'))

        @self.InitButton.mhEvent
        def onClicked(event):
            chushihua()
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            # gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepath1))
            # anim = self.loadBvh(fileout, convertFromZUp="auto")
            log.message("Init Pose.")

        self.aButton = box.addWidget(gui.Button('BVH'))
        #  self.aButton1 = box.addWidget(gui.Button('Save RGBImage'))
        self.aButton2 = box.addWidget(gui.Button('Save Image'))
        # self.aButton3 = box.addWidget(gui.Button('AotuPoseImage'))
        self.aSliderLabel = box.addWidget(gui.TextView('****************************'))
        a1 = [0]
        a2 = [0]
        a3 = [0]
        a4 = [0]
        a5 = [0]
        a6 = [0]
        a7 = [0]
        a8 = [0]
        deltvalue1 = [100]
        deltvalue2 = [100]
        deltvalue3 = [100]
        deltvalue4 = [100]
        deltvalue5 = [100]
        deltvalue6 = [100]
        deltvalue7 = [100]
        deltvalue8 = [100]
        deltva1 = [0]
        deltva2 = [0]
        deltva3 = [0]
        deltva4 = [0]
        deltva5 = [0]
        deltva6 = [0]
        deltva7 = [0]
        deltva8 = [0]
        self.aSlider = box.addWidget(gui.Slider(value=0.5, label=['upperarm01.L', ' %.3f']))

        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('AngleRotate is %.1f', (value - 0.5) * 100)
            a1[0] = (value - 0.5) * 100
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            anim = self.loadBvh(fileout, convertFromZUp="auto")

        log.message(str(a1[0]))
        self.aSlider = box.addWidget(gui.Slider(value=0.5, label=['lowerarm01.L', ' %.3f']))

        # self.aSliderLabel = box.addWidget(gui.TextView('Value is initialize=0.5'))
        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('AngleRotate is %.1f', (value - 0.5) * 100)
            # global a2
            a2[0] = (value - 0.5) * 100
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            anim = self.loadBvh(fileout, convertFromZUp="auto")
            # return a2

            # laL=onChange()

        self.aSlider = box.addWidget(gui.Slider(value=0.5, label=['upperarm01.R', ' %.3f']))

        #  self.aSliderLabel = box.addWidget(gui.TextView('Value is initialize=0.5'))
        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('AngleRotate is %.1f', (value - 0.5) * 100)
            # global a3
            a3[0] = (value - 0.5) * 100
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            anim = self.loadBvh(fileout, convertFromZUp="auto")
            # return a3

            # ulL=onChange(value)

        self.aSlider = box.addWidget(gui.Slider(value=0.5, label=['lowerarm01.R', ' %.3f']))

        # self.aSliderLabel = box.addWidget(gui.TextView('Value is initialize=0.5'))
        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('AngleRotate is %.1f', (value - 0.5) * 100)
            # global a4
            a4[0] = (value - 0.5) * 100
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            anim = self.loadBvh(fileout, convertFromZUp="auto")
            # return a4

            # llL=onChange(value)

        self.aSlider = box.addWidget(gui.Slider(value=0.5, label=['upperleg01.L', ' %.3f']))

        # self.aSliderLabel = box.addWidget(gui.TextView('Value is initialize=0.5'))
        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('AngleRotate is %.1f', (value - 0.5) * 100)
            # global a5
            a5[0] = (value - 0.5) * 100
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            anim = self.loadBvh(fileout, convertFromZUp="auto")
            # return a5

        # uaR=onChange(value)
        self.aSlider = box.addWidget(gui.Slider(value=0.0, label=['lowerleg01.L', ' %.3f']))

        # self.aSliderLabel = box.addWidget(gui.TextView('Value is initialize=0.5'))
        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('AngleRotate is %.1f', (value - 0.0) * 100)
            # global a6
            a6[0] = (value - 0.0) * 100
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            anim = self.loadBvh(fileout, convertFromZUp="auto")
            # return a6

        # laR=onChange(value)
        self.aSlider = box.addWidget(gui.Slider(value=0.5, label=['upperleg01.R', ' %.3f']))

        #  self.aSliderLabel = box.addWidget(gui.TextView('Value is initialize=0.5'))
        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('AngleRotate is %.1f', (value - 0.5) * 100)
            # global a7
            a7[0] = (value - 0.5) * 100
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            anim = self.loadBvh(fileout, convertFromZUp="auto")
            # return a7;

        # ulR=onChange(value)
        self.aSlider = box.addWidget(gui.Slider(value=0.0, label=['lowerleg01.R', ' %.3f']))

        # self.aSliderLabel = box.addWidget(gui.TextView('Value is initialize=0.5'))
        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('AngleRotate is %.1f', (value - 0.0) * 100)
            # global a8
            a8[0] = (value - 0.0) * 100
            bvhanniu()
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
            anim = self.loadBvh(fileout, convertFromZUp="auto")
            # return a8

        # llR=onChange(value)
        # We make the first one selected
        self.human = G.app.selectedHuman
        self.currentPose = None

        self.paths = [mh.getDataPath('Mydata'), mh.getSysDataPath('Mydata')]

        self.filechooser = self.addRightWidget(
            fc.IconListFileChooser(self.paths, ['bvh'], 'thumb', mh.getSysDataPath('poses/notfound.thumb'), name='Pose',
                                   noneItem=True))
        self.filechooser.setIconSize(50, 50)
        self.filechooser.enableAutoRefresh(False)

        # filepath0=[str(0)]
        @self.filechooser.mhEvent
        def onFileSelected(filename):
            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filename))
            if not filename:
                self.human.resetToRestPose()

            else:
                anim = self.loadBvh(filename, convertFromZUp="auto")

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())
        log.message(self.paths)
        self.skelObj = None
        # filepath1=self.paths+'\\ORIGINAL_MODEL.bvh'
        # filepath1=filepath0[0]
        fp = open(filepath1, "rU")
        bvh1 = bvh.BVH()
        bvh2 = bvh1._BVH__expectKeyword('HIERARCHY', fp)
        words = bvh1._BVH__expectKeyword('ROOT', fp)
        rootJoint = bvh1.addRootJoint(words[1])
        bvh1._BVH__readJoint(bvh1.rootJoint, fp)
        self.convertFromZUp = bvh1._autoGuessCoordinateSystem()
        log.message("Automatically guessed coordinate system for BVH file %s (%s)" % (
        filepath1, "Z-up" if self.convertFromZUp else "Y-up"))
        if self.convertFromZUp:
            # Conversion needed: convert from Z-up to Y-up
            bvh1._BVH__cacheGetJoints()
            for joint in bvh1.jointslist:
                bvh1._BVH__calcPosition(joint, joint.offset)

        # Read motion
        bvh1._BVH__expectKeyword('MOTION', fp)
        words = bvh1._BVH__expectKeyword('Frames:', fp)
        self.frameCount = int(words[1])
        words = bvh1._BVH__expectKeyword('Frame', fp)  # Time:
        self.frameTime = float(words[2])

        for i in range(self.frameCount):
            line = fp.readline()
            words = line.split()
            data = [float(word) for word in words]
            if i != 43:
                for joint in bvh1.getJointsBVHOrder():
                    data = bvh1._BVH__processChannelData(joint, data)

            else:
                data = int(90)

        bvh1._BVH__cacheGetJoints()
        bvh1.frameCount = self.frameCount
        # Transform frame data into transformation matrices for all joints
        for joint in bvh1.getJoints():
            joint.calculateFrames()

        @self.aButtonC1.mhEvent
        def onClicked(event):
            chushihua()
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(str(width))
            log.message(str(height))

            OrigalIm = cv2.imread(filepicture)  # 先读目标图像
            for value in range(0, 101, 20):
                a1[0] = value - 50
                bvhanniu()
                gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
                anim = self.loadBvh(fileout, convertFromZUp="auto")
                # cv2.waitKey(10)
                # filenameImage=fileResult+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
                filenameImage = fileResult + str(a1[0]) + 'DegreeLarm.png'
                # filenameIma=fileResult+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
                filenameIma = fileResult + str(a1[0]) + 'DegreeLarm.png'
                width = G.windowWidth;
                height = G.windowHeight;

                Xdel = 600  # 原图为800x600  减除后为200x150
                Ydel = 450
                width = width - Xdel;
                height = height - Ydel;
                # log.message(filenameImage)
                # mh.grabScreen(300,225,width,height,filenameImage)  #存盘

                mh.grabScreen(Xdel / 2, Ydel / 2, width, height, filenameImage)  # 不存盘,全在内在操作,提高速度
                log.message("Saved screengrab to %s", filenameImage)

                img = cv2.imread(filenameImage)  # 存盘
                height1, width1 = img.shape[:2]
                # print height,width
                for i in range(height1):
                    for j in range(width1):
                        r, b, g = img[i][j]
                        rb = abs(r - b)
                        rg = abs(r - g)
                        bg = abs(b - g)
                        if rb < 10 and rg < 10 and bg < 10:
                            img[i][j] = [0, 0, 0]
                        else:
                            img[i][j] = [255, 255, 255]

                imsave = normalize.Normalize(img)
                cv2.imwrite(filenameIma, imsave)
                # cv2.imshow("img",imsave)
                # cv2.waitKey(10)
                # delt1=findcontours.GetDeltValue(imsave,OrigalIm)  #onpicture()
                delt1 = findcontours.CalDiff(imsave, OrigalIm)
                log.debug('delt1 (%d Degree): = %f', a1[0], delt1)
                if delt1 <= deltvalue1[0]:
                    deltvalue1[0] = delt1
                    deltva1[0] = value - 50
                    filenameImaFit = filenameIma
                    bvhanniu(filepicbvh)
                    # gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepicbvh))
                    # anim = self.loadBvh(filepicbvh, convertFromZUp="auto")
                    imsavefit = imsave

            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepicbvh))
            # anim = self.loadBvh(filepicbvh, convertFromZUp="auto")
            a1[0] = deltva1[0]  # 需要更新,不然后面姿态重置了
            bvhanniu()
            num1 = (deltva1[0] + 50) / 5
            # result=cv2.imread(fileResult+str(num1)+'.png')
            # result=cv2.imread(filenameImaFit)
            result = imsavefit
            result2 = cv2.imread(filepicture)
            # cv2.imshow("Result", result)
            # cv2.imshow("Original", result2)
            # cv2.waitKey(10)
            log.message(deltvalue1)
            log.message(num1)
            imsavefit = None

        @self.aButtonC2.mhEvent
        def onClicked(event):
            chushihua()
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(str(width))
            log.message(str(height))
            for value in range(5, 100, 5):
                a2[0] = value - 50
                bvhanniu()
                gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
                # anim = self.loadBvh(fileout, convertFromZUp="auto")
                filenameImage = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
                filenameIma = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
                width = G.windowWidth;
                height = G.windowHeight;
                width = width - 3;
                height = height - 3;
                # log.message(filenameImage)
                mh.grabScreen(0, 0, width, height, filenameImage)
                img = cv2.imread(filenameImage)
                height1, width1 = img.shape[:2]
                # print height,width
                for i in range(height1):
                    for j in range(width1):
                        r, b, g = img[i][j]
                        rb = abs(r - b)
                        rg = abs(r - g)
                        bg = abs(b - g)
                        if rb < 10 and rg < 10 and bg < 10:
                            img[i][j] = [0, 0, 0]
                        else:
                            img[i][j] = [255, 255, 255]

                imsave = normalize.Normalize(img)
                cv2.imwrite(filenameIma, imsave)
                #cv2.imshow("img", imsave)
                #cv2.waitKey(10)
                #delt2 = onpicture()
                imnew = cv2.imread(filepicture)
                delt2=findcontours.GetDeltValue(imsave, imnew)
                if delt2 <= deltvalue2[0]:
                    deltvalue2[0] = delt2
                    deltva2[0] = value - 50

            num2 = (deltva2[0] + 50) / 5
            result = cv2.imread(fileResult + str(num2) + '.png')
            # cv2.imshow("Result", result)
            # cv2.waitKey(0)
            log.message(deltvalue2)
            log.message(num2)

        @self.aButtonC3.mhEvent
        def onClicked(event):
            chushihua()
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(str(width))
            log.message(str(height))
            for value in range(5, 100, 5):
                a3[0] = value - 50
                bvhanniu()
                gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
                # anim = self.loadBvh(fileout, convertFromZUp="auto")
                filenameImage = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
                filenameIma = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
                width = G.windowWidth;
                height = G.windowHeight;
                width = width - 3;
                height = height - 3;
                # log.message(filenameImage)
                mh.grabScreen(0, 0, width, height, filenameImage)
                img = cv2.imread(filenameImage)
                height1, width1 = img.shape[:2]
                # print height,width
                for i in range(height1):
                    for j in range(width1):
                        r, b, g = img[i][j]
                        rb = abs(r - b)
                        rg = abs(r - g)
                        bg = abs(b - g)
                        if rb < 10 and rg < 10 and bg < 10:
                            img[i][j] = [0, 0, 0]
                        else:
                            img[i][j] = [255, 255, 255]

                imsave = normalize.Normalize(img)
                cv2.imwrite(filenameIma, imsave)
                # cv2.imshow("img", imsave)
                # cv2.waitKey(10)
                # delt3 = onpicture()
                imnew = cv2.imread(filepicture)
                delt2 = findcontours.GetDeltValue(imsave, imnew)
                if delt3 <= deltvalue3[0]:
                    deltvalue3[0] = delt3
                    deltva3[0] = value - 50

            num3 = (deltva3[0] + 50) / 5
            result = cv2.imread(fileResult + str(num3) + '.png')
            cv2.imshow("Result", result)
            cv2.waitKey(0)
            log.message(deltvalue3)
            log.message(num3)

        @self.aButtonC4.mhEvent
        def onClicked(event):
            chushihua()
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(str(width))
            log.message(str(height))
            for value in range(5, 100, 5):
                a4[0] = value - 50
                bvhanniu()
                gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
                # anim = self.loadBvh(fileout, convertFromZUp="auto")
                filenameImage = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
                filenameIma = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
                width = G.windowWidth;
                height = G.windowHeight;
                width = width - 3;
                height = height - 3;
                # log.message(filenameImage)
                mh.grabScreen(0, 0, width, height, filenameImage)
                img = cv2.imread(filenameImage)
                height1, width1 = img.shape[:2]
                # print height,width
                for i in range(height1):
                    for j in range(width1):
                        r, b, g = img[i][j]
                        rb = abs(r - b)
                        rg = abs(r - g)
                        bg = abs(b - g)
                        if rb < 10 and rg < 10 and bg < 10:
                            img[i][j] = [0, 0, 0]
                        else:
                            img[i][j] = [255, 255, 255]

                imsave = normalize.Normalize(img)
                cv2.imwrite(filenameIma, imsave)
                #cv2.imshow("img", imsave)
                #cv2.waitKey(10)
                #delt4 = onpicture()
                imnew = cv2.imread(filepicture)
                delt4 = findcontours.GetDeltValue(imsave, imnew)
                if delt4 <= deltvalue4[0]:
                    deltvalue4[0] = delt4
                    deltva4[0] = value - 50

            num4 = (deltva4[0] + 50) / 5
            result = cv2.imread(fileResult + str(num4) + '.png')
            cv2.imshow("Result", result)
            cv2.waitKey(0)
            log.message(deltvalue4)
            log.message(num4)

        @self.aButtonC5.mhEvent
        def onClicked(event):
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(str(width))
            log.message(str(height))
            for value in range(5, 100, 5):
                chushihua()
                a5[0] = value - 50
                bvhanniu()
                gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
                # anim = self.loadBvh(fileout, convertFromZUp="auto")
                filenameImage = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
                filenameIma = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
                width = G.windowWidth;
                height = G.windowHeight;
                width = width - 3;
                height = height - 3;
                # log.message(filenameImage)
                mh.grabScreen(0, 0, width, height, filenameImage)
                img = cv2.imread(filenameImage)
                height1, width1 = img.shape[:2]
                # print height,width
                for i in range(height1):
                    for j in range(width1):
                        r, b, g = img[i][j]
                        rb = abs(r - b)
                        rg = abs(r - g)
                        bg = abs(b - g)
                        if rb < 10 and rg < 10 and bg < 10:
                            img[i][j] = [0, 0, 0]
                        else:
                            img[i][j] = [255, 255, 255]

                imsave = normalize.Normalize(img)
                cv2.imwrite(filenameIma, imsave)
                #cv2.imshow("img", imsave)
                #cv2.waitKey(10)
                #delt5 = onpicture()
                imnew = cv2.imread(filepicture)
                delt5 = findcontours.GetDeltValue(imsave, imnew)
                if delt5 <= deltvalue5[0]:
                    deltvalue5[0] = delt5
                    deltva5[0] = value - 50

            num5 = (deltva5[0] + 50) / 5
            result = cv2.imread(fileResult + str(num5) + '.png')
            cv2.imshow("Result", result)
            cv2.waitKey(0)
            log.message(deltvalue5)
            log.message(num5)

        @self.aButtonC6.mhEvent
        def onClicked(event):
            # chushihua()
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(str(width))
            log.message(str(height))

            OrigalIm = cv2.imread(filepicture)  # 先读目标图像
            for value in range(49, 101, 10):
                a6[0] = value - 50
                bvhanniu()
                gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
                # anim = self.loadBvh(fileout, convertFromZUp="auto")
                # cv2.waitKey(10)
                # filenameImage=fileResult+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
                filenameImage = fileResult + str(a6[0]) + 'DegreeLLeg.png'
                # filenameIma=fileResult+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
                filenameIma = fileResult + str(a6[0]) + 'DegreeLLeg.png'
                width = G.windowWidth;
                height = G.windowHeight;

                Xdel = 600  # 原图为800x600  减除后为200x150
                Ydel = 450
                width = width - Xdel;
                height = height - Ydel;
                # log.message(filenameImage)
                # mh.grabScreen(300,225,width,height,filenameImage)  #存盘

                mh.grabScreen(Xdel / 2, Ydel / 2, width, height, filenameImage)  # 不存盘,全在内在操作,提高速度
                log.message("Saved screengrab to %s", filenameImage)

                img = cv2.imread(filenameImage)  # 存盘
                height1, width1 = img.shape[:2]
                # print height,width
                for i in range(height1):
                    for j in range(width1):
                        r, b, g = img[i][j]
                        rb = abs(r - b)
                        rg = abs(r - g)
                        bg = abs(b - g)
                        if rb < 10 and rg < 10 and bg < 10:
                            img[i][j] = [0, 0, 0]
                        else:
                            img[i][j] = [255, 255, 255]

                imsave = normalize.Normalize(img)
                cv2.imwrite(filenameIma, imsave)
                # cv2.imshow("img",imsave)
                # cv2.waitKey(10)
                # delt6=findcontours.GetDeltValue(imsave,OrigalIm)  #onpicture()
                delt6 = findcontours.CalDiff(imsave, OrigalIm)
                log.debug('delt6 (%d Degree): = %f', a6[0], delt6)
                if delt6 <= deltvalue6[0]:
                    deltvalue6[0] = delt6
                    deltva6[0] = value - 50
                    filenameImaFit = filenameIma
                    bvhanniu(filepicbvh)
                    # gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepicbvh))
                    # anim = self.loadBvh(filepicbvh, convertFromZUp="auto")
                    imsavefit = imsave

            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepicbvh))
            anim = self.loadBvh(filepicbvh, convertFromZUp="auto")
            a6[0] = deltva6[0]  # 需要更新,不然后面姿态重置了
            bvhanniu()
            num1 = (deltva6[0] + 50) / 5
            # result=cv2.imread(fileResult+str(num1)+'.png')
            # result=cv2.imread(filenameImaFit)
            result = imsavefit
            result2 = cv2.imread(filepicture)
            #cv2.imshow("Result", result)
            #cv2.imshow("Original", result2)
            # cv2.waitKey(10)
            log.message(deltvalue6)
            log.message(num1)
            imsavefit = None

        @self.aButtonC7.mhEvent
        def onClicked(event):
            # chushihua()
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(str(width))
            log.message(str(height))

            OrigalIm = cv2.imread(filepicture)  # 先读目标图像
            for value in range(0, 60, 10):
                a7[0] = value - 50
                bvhanniu()
                gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
                anim = self.loadBvh(fileout, convertFromZUp="auto")
                # cv2.waitKey(10)
                # filenameImage=fileResult+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
                filenameImage = fileResult + str(a7[0]) + 'DegreeLLeg.png'
                # filenameIma=fileResult+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
                filenameIma = fileResult + str(a7[0]) + 'DegreeLLeg.png'
                width = G.windowWidth;
                height = G.windowHeight;

                Xdel = 600  # 原图为800x600  减除后为200x150
                Ydel = 450
                width = width - Xdel;
                height = height - Ydel;
                # log.message(filenameImage)
                # mh.grabScreen(300,225,width,height,filenameImage)  #存盘

                mh.grabScreen(Xdel / 2, Ydel / 2, width, height, filenameImage)  # 不存盘,全在内在操作,提高速度
                log.message("Saved screengrab to %s", filenameImage)

                img = cv2.imread(filenameImage)  # 存盘
                height1, width1 = img.shape[:2]
                # print height,width
                for i in range(height1):
                    for j in range(width1):
                        r, b, g = img[i][j]
                        rb = abs(r - b)
                        rg = abs(r - g)
                        bg = abs(b - g)
                        if rb < 10 and rg < 10 and bg < 10:
                            img[i][j] = [0, 0, 0]
                        else:
                            img[i][j] = [255, 255, 255]

                imsave = normalize.Normalize(img)
                cv2.imwrite(filenameIma, imsave)
                # cv2.imshow("img",imsave)
                # cv2.waitKey(10)
                # delt7=findcontours.GetDeltValue(imsave,OrigalIm)  #onpicture()
                delt7 = findcontours.CalDiff(imsave, OrigalIm)
                log.debug('delt7 (%d Degree): = %f', a7[0], delt7)
                if delt7 <= deltvalue7[0]:
                    deltvalue7[0] = delt7
                    deltva7[0] = value - 50
                    filenameImaFit = filenameIma
                    bvhanniu(filepicbvh)
                    # gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepicbvh))
                    anim = self.loadBvh(filepicbvh, convertFromZUp="auto")
                    imsavefit = imsave

            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepicbvh))
            anim = self.loadBvh(filepicbvh, convertFromZUp="auto")
            a7[0] = deltva7[0]  # 需要更新,不然后面姿态重置了
            bvhanniu()
            num1 = (deltva7[0] + 50) / 5
            # result=cv2.imread(fileResult+str(num1)+'.png')
            # result=cv2.imread(filenameImaFit)
            #result = imsavefit
            #result2 = cv2.imread(filepicture)
            #cv2.imshow("Result", result)
            #cv2.imshow("Original", result2)
            # cv2.waitKey(10)
            log.message(deltvalue7)
            log.message(num1)
            imsavefit = None

        @self.aButtonC8.mhEvent
        def onClicked(event):
            # chushihua()
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(str(width))
            log.message(str(height))

            OrigalIm = cv2.imread(filepicture)  # 先读目标图像
            for value in range(61, 71, 10):
                a8[0] = value - 50
                bvhanniu()
                gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, fileout))
                anim = self.loadBvh(fileout, convertFromZUp="auto")
                # cv2.waitKey(10)
                # filenameImage=fileResult+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
                filenameImage = fileResult + str(a8[0]) + 'DegreeLLeg.png'
                # filenameIma=fileResult+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
                filenameIma = fileResult + str(a8[0]) + 'DegreeLLeg.png'
                width = G.windowWidth;
                height = G.windowHeight;

                Xdel = 600  # 原图为800x600  减除后为200x150
                Ydel = 450
                width = width - Xdel;
                height = height - Ydel;
                # log.message(filenameImage)
                # mh.grabScreen(300,225,width,height,filenameImage)  #存盘

                mh.grabScreen(Xdel / 2, Ydel / 2, width, height, filenameImage)  # 不存盘,全在内在操作,提高速度
                log.message("Saved screengrab to %s", filenameImage)

                img = cv2.imread(filenameImage)  # 存盘
                height1, width1 = img.shape[:2]
                # print height,width
                for i in range(height1):
                    for j in range(width1):
                        r, b, g = img[i][j]
                        rb = abs(r - b)
                        rg = abs(r - g)
                        bg = abs(b - g)
                        if rb < 10 and rg < 10 and bg < 10:
                            img[i][j] = [0, 0, 0]
                        else:
                            img[i][j] = [255, 255, 255]

                imsave = normalize.Normalize(img)
                cv2.imwrite(filenameIma, imsave)
                # cv2.imshow("img",imsave)
                # cv2.waitKey(10)
                # delt8=findcontours.GetDeltValue(imsave,OrigalIm)  #onpicture()
                delt8 = findcontours.CalDiff(imsave, OrigalIm)
                log.debug('delt8 (%d Degree): = %f', a8[0], delt8)
                if delt8 <= deltvalue8[0]:
                    deltvalue8[0] = delt8
                    deltva8[0] = value - 50
                    filenameImaFit = filenameIma
                    bvhanniu(filepicbvh)
                    gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepicbvh))
                    anim = self.loadBvh(filepicbvh, convertFromZUp="auto")
                    imsavefit = imsave

            gui3d.app.do(AotuPose1("Change pose", self, self.currentPose, filepicbvh))
            anim = self.loadBvh(filepicbvh, convertFromZUp="auto")
            a8[0] = deltva8[0]  # 需要更新,不然后面姿态重置了
            bvhanniu()
            num1 = (deltva8[0] + 50) / 5
            # result=cv2.imread(fileResult+str(num1)+'.png')
            # result=cv2.imread(filenameImaFit)
            #result = imsavefit
            #result2 = cv2.imread(filepicture)
            #cv2.imshow("Result", result)
            #cv2.imshow("Original", result2)
            # cv2.waitKey(10)
            log.message(deltvalue8)
            log.message(num1)
            imsavefit = None

        def chushihua():
            a1 = [0]
            a2 = [0]
            a3 = [0]
            a4 = [0]
            a5 = [0]
            a6 = [0]
            a7 = [0]
            a8 = [0]
            deltvalue1 = [100]
            deltvalue2 = [100]
            deltvalue3 = [100]
            deltvalue4 = [100]
            deltvalue5 = [100]
            deltvalue6 = [100]
            deltvalue7 = [100]
            deltvalue8 = [100]
            deltva1 = [0]
            deltva2 = [0]
            deltva3 = [0]
            deltva4 = [0]
            deltva5 = [0]
            deltva6 = [0]
            deltva7 = [0]
            deltva8 = [0]

        def bvhanniu(filename=None):
            if filename is None:
                filename = fileout
            log.debug('FileName is %s', filename)
            f = open(filename, 'w')
            # Write structure
            f.write('HIERARCHY\n')
            bvh1._writeJoint(f, bvh1.rootJoint, 0)
            # Write animation
            f.write('MOTION\n')
            f.write('Frames: %s\n' % bvh1.frameCount)
            f.write('Frame Time: %f\n' % bvh1.frameTime)
            allJoints = [joint for joint in bvh1.getJointsBVHOrder() if not joint.isEndConnector()]
            jointsData = [joint.matrixPoses for joint in allJoints]
            nJoints = len(jointsData)
            nFrames = len(jointsData[0])
            totalChannels = sum([len(joint.channels) for joint in allJoints])

            frameData = []
            for fIdx in xrange(bvh1.frameCount):
                for joint in allJoints:
                    offset = fIdx * len(joint.channels)
                    frameData.extend(joint.frames[offset:offset + len(joint.channels)])
                frameData = [str(fl) for fl in frameData]

            frameData[37] = str(a1[0])
            frameData[43] = str(a2[0] + 35)
            frameData[127] = str(a3[0])
            frameData[133] = str(a4[0] + 35)
            frameData[433] = str(a5[0])
            frameData[439] = str(a6[0])
            frameData[508] = str(a7[0])
            frameData[514] = str(a8[0])
            for fIdx in xrange(bvh1.frameCount):
                frameData = [str(fl) for fl in frameData]
                f.write('%s\n' % " ".join(frameData))

            f.close()

            # @self.aButton1.mhEvent
            # def onClicked(event):
            #  filenameImage='F:/'+str(time.strftime("%Y-%m-%d_%H.%M.%S"))+'.png'
            # width = G.windowWidth;
            #   height = G.windowHeight;
            #  width = width - 3;
            #  height = height - 3;
            #  log.message(filenameImage)
            #  mh.grabScreen(0,0,width,height,filenameImage)

        def dayinpicture():
            filenameImage = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
            filenameIma = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            # log.message(filenameImage)
            # mh.grabScreen(0,0,width,height,filenameImage)
            # img=cv2.imread(filenameImage)
            img = grabMyScreen(0, 0, width, height)
            height1, width1 = img.shape[:2]
            # print height,width
            for i in range(height1):
                for j in range(width1):
                    r, b, g = img[i][j]
                    rb = abs(r - b)
                    rg = abs(r - g)
                    bg = abs(b - g)
                    if rb < 10 and rg < 10 and bg < 10:
                        img[i][j] = [0, 0, 0]
                    else:
                        img[i][j] = [255, 255, 255]

            imsave = normalize.Normalize(img)
            cv2.imwrite(filenameIma, imsave)

        @self.aButton2.mhEvent
        def onClicked(event):
            filenameImage = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
            filenameIma = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(filenameImage)
            mh.grabScreen(0, 0, width, height, filenameImage)
            img = cv2.imread(filenameImage)
            height1, width1 = img.shape[:2]
            # print height,width
            for i in range(height1):
                for j in range(width1):
                    r, b, g = img[i][j]
                    rb = abs(r - b)
                    rg = abs(r - g)
                    bg = abs(b - g)
                    if rb < 10 and rg < 10 and bg < 10:
                        img[i][j] = [0, 0, 0]
                    else:
                        img[i][j] = [255, 255, 255]

            cv2.imwrite(filenameIma, img)
            # getcontourspoint.MainGetContourPoint(filenameImage,"F:/w1/lunkuo.txt")

        def onpicture():
            filenameImage = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
            filenameIma = fileStartDir + '/data/Auto3DImage/' + str(time.strftime("%Y-%m-%d_%H.%M.%S")) + '.png'
            width = G.windowWidth;
            height = G.windowHeight;
            width = width - 3;
            height = height - 3;
            log.message(filenameImage)
            # mh.grabScreen(0,0,width,height,filenameImage)
            img = grabMyScreen(0, 0, width, height)
            # log.message(str(imgs))
            # img=cv2.imread(filenameImage)
            height1, width1 = img.shape[:2]
            # print height,width
            for i in range(height1):
                for j in range(width1):
                    r, b, g = img[i][j]
                    rb = abs(r - b)
                    rg = abs(r - g)
                    bg = abs(b - g)
                    if rb < 10 and rg < 10 and bg < 10:
                        img[i][j] = [0, 0, 0]
                    else:
                        img[i][j] = [255, 255, 255]




                        # cv2.imwrite(filenameIma,img)
            imsave = normalize.Normalize(img)
            delt = findcontours.GetDeltValue(imsave, filepicture)
            return delt

        def grabMyScreen(x, y, width, height, filename=None, productionRender=False):
            if width <= 0 or height <= 0:
                raise RuntimeError("width or height is 0")

            log.debug('grabScreen: %d %d %d %d', x, y, width, height)

            # Draw before grabbing, to make sure we grab a rendering and not a picking buffer
            glmodule.draw(productionRender)

            sx0 = x
            sy0 = G.windowHeight - y - height
            sx1 = sx0 + width
            sy1 = sy0 + height

            sx0 = max(sx0, 0)
            sx1 = min(sx1, G.windowWidth)
            sy0 = max(sy0, 0)
            sy1 = min(sy1, G.windowHeight)

            rwidth = sx1 - sx0
            rwidth -= rwidth % 4
            sx1 = sx0 + rwidth
            rheight = sy1 - sy0

            surface = np.empty((rheight, rwidth, 3), dtype=np.uint8)

            log.debug('glReadPixels: %d %d %d %d', sx0, sy0, rwidth, rheight)

            glmodule.glReadPixels(sx0, sy0, rwidth, rheight, GL_RGB, GL_UNSIGNED_BYTE, surface)

            if width != rwidth or height != rheight:
                surf = np.zeros((height, width, 3), dtype=np.uint8) + 127
                surf[...] = surface[:1, :1, :]
                dx0 = (width - rwidth) / 2
                dy0 = (height - rheight) / 2
                dx1 = dx0 + rwidth
                dy1 = dy0 + rheight
                surf[dy0:dy1, dx0:dx1] = surface
                surface = surf

            surface = np.ascontiguousarray(surface[::-1, :, :])
            # surface = Image(data = surface)
            return surface

        @self.aButton.mhEvent
        def onClicked(event):
            f = open(filepath1, 'w')
            # Write structure
            f.write('HIERARCHY\n')
            bvh1._writeJoint(f, bvh1.rootJoint, 0)
            # Write animation
            f.write('MOTION\n')
            f.write('Frames: %s\n' % bvh1.frameCount)
            f.write('Frame Time: %f\n' % bvh1.frameTime)
            allJoints = [joint for joint in bvh1.getJointsBVHOrder() if not joint.isEndConnector()]
            jointsData = [joint.matrixPoses for joint in allJoints]
            nJoints = len(jointsData)
            nFrames = len(jointsData[0])
            totalChannels = sum([len(joint.channels) for joint in allJoints])
            frameData = []
            for fIdx in xrange(bvh1.frameCount):
                for joint in allJoints:
                    offset = fIdx * len(joint.channels)
                    frameData.extend(joint.frames[offset:offset + len(joint.channels)])
                frameData = [str(fl) for fl in frameData]

            for fIdx in xrange(bvh1.frameCount):
                frameData = [str(fl) for fl in frameData]
                f.write('%s\n' % " ".join(frameData))

            f.close()