本文整理汇总了Python中mh.getPath函数的典型用法代码示例。如果您正苦于以下问题:Python getPath函数的具体用法?Python getPath怎么用?Python getPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getPath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveSettings
def saveSettings(self, promptOnFail=False):
try:
if not os.path.exists(mh.getPath('')):
os.makedirs(mh.getPath(''))
with outFile("settings.ini") as f:
f.write(mh.formatINI(self.settings))
with outFile("shortcuts.ini") as f:
for action, shortcut in self.shortcuts.iteritems():
f.write('%d %d %s\n' % (shortcut[0], shortcut[1], action))
with outFile("mouse.ini") as f:
for mouseAction, method in self.mouseActions.iteritems():
f.write('%d %d %s\n' % (mouseAction[0], mouseAction[1], method.__name__))
if self.dialog is not None:
self.helpIds.update(self.dialog.helpIds)
with outFile("help.ini") as f:
for helpId in self.helpIds:
f.write('%s\n' % helpId)
except:
log.error('Failed to save settings file', exc_info=True)
if promptOnFail:
self.prompt('Error', 'Could not save settings file.', 'OK')
示例2: projectLighting
def projectLighting(self):
mesh = gui3d.app.selectedHuman.mesh
mesh.setShadeless(1)
dstImg = mh.Image(width=1024, height=1024, bitsPerPixel=24)
dstW = dstImg.width
dstH = dstImg.height
for v in mesh.verts:
ld = vnorm(vsub((-10.99, 20.0, 20.0,), v.co))
s = vdot(v.no, ld)
s = max(0, min(255, int(s*255)))
v.setColor([s, s, s, 255])
for g in mesh.faceGroups:
if g.name.startswith("joint") or g.name.startswith("helper"):
continue
for f in g.faces:
co = [(mesh.uvValues[i][0]*dstW, dstH-(mesh.uvValues[i][1]*dstH)) for i in f.uv]
c = [v.color for v in f.verts]
RasterizeTriangle(dstImg, co[0], co[1], co[2], ColorShader(c[:3]))
RasterizeTriangle(dstImg, co[2], co[3], co[0], ColorShader((c[2], c[3], c[0])))
#dstImg.resize(128, 128);
dstImg.save(os.path.join(mh.getPath(''), 'data', 'skins', 'lighting.png'))
gui3d.app.selectedHuman.setTexture(os.path.join(mh.getPath(''), 'data', 'skins', 'lighting.png'))
mesh.setColor([255, 255, 255, 255])
示例3: getMaterialPaths
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
示例4: __init__
def __init__(self, category):
self.systemSkins = os.path.join('data', 'skins')
self.userSkins = os.path.join(mh.getPath(''), 'data', 'skins')
gui3d.TaskView.__init__(self, category, 'Human texture', label='Skin')
if not os.path.exists(os.path.join(mh.getPath(''), 'data', 'skins')):
os.makedirs(os.path.join(mh.getPath(''), 'data', 'skins'))
self.filechooser = self.addView(gui3d.FileChooser([self.systemSkins, self.userSkins], 'png', 'thumb'))
self.update = self.filechooser.sortBox.addView(gui3d.Button('Check for updates'))
self.mediaSync = None
@self.filechooser.event
def onFileSelected(filename):
gui3d.app.do(Action(gui3d.app.selectedHuman,
gui3d.app.selectedHuman.getTexture(),
os.path.join(mh.getPath(''), 'data', 'skins', filename)))
gui3d.app.switchCategory('Modelling')
@self.update.event
def onClicked(event):
self.syncMedia()
gui3d.app.addLoadHandler('skinTexture', self.loadHandler)
gui3d.app.addSaveHandler(self.saveHandler)
示例5: projectUV
def projectUV(self):
dstImg = projection.mapUV()
# dstImg.resize(128, 128)
dstImg.save(os.path.join(mh.getPath(""), "data", "skins", "uvtopo.png"))
gui3d.app.selectedHuman.setTexture(os.path.join(mh.getPath(""), "data", "skins", "uvtopo.png"))
log.debug("Enabling shadeless rendering on body")
gui3d.app.selectedHuman.mesh.setShadeless(1) # Remember to reset this when lighting projection is done.
示例6: onClicked
def onClicked(event):
if not self.path:
if not os.path.exists(mh.getPath('render')):
os.makedirs(mh.getPath('render'))
self.path = mh.getPath('render')
filename = mh.getSaveFileName(os.path.splitext(self.path)[0],
'PNG Image (*.png);;JPEG Image (*.jpg);;All files (*.*)')
if filename:
self.path = os.path.dirname(filename)
self.image.save(filename)
示例7: __init__
def __init__(self, category):
gui3d.TaskView.__init__(self, category, 'Save')
modelPath = mh.getPath('models')
self.fileentry = self.addTopWidget(gui.FileEntryView('Save', mode='save'))
self.fileentry.setDirectory(mh.getPath('models'))
self.fileentry.setFilter('MakeHuman Models (*.mhm)')
self.selection_width = 1.2
self.selection_height = 1.3
mesh = geometry3d.FrameMesh(self.selection_width, self.selection_height)
mesh.move(-self.selection_width/2, -self.selection_height/2)
self.selection = 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 = 90
self.selection.hide()
@self.fileentry.mhEvent
def onFileSelected(filename):
if not filename.lower().endswith('.mhm'):
filename += '.mhm'
path = os.path.normpath(os.path.join(modelPath, filename))
dir, name = os.path.split(path)
name, ext = os.path.splitext(name)
if not os.path.exists(dir):
os.makedirs(dir)
# Save the thumbnail
((x0,y0,z0),(x1,y1,z1)) = self.selection.mesh.calcBBox()
x0,y0,z0 = gui3d.app.guiCamera.convertToScreen(x0, y0, 0)
x1,y1,z1 = gui3d.app.guiCamera.convertToScreen(x1, y1, 0)
log.debug('grab rectangle: %d %d %d %d', x0, y0, x1, y1)
mh.grabScreen(int(x0+1), int(y1+1), int(x1-x0-1), int(y0-y1-1), os.path.join(dir, name + '.thumb'))
# Save the model
human = gui3d.app.selectedHuman
human.save(path, name)
gui3d.app.modified = False
#gui3d.app.clearUndoRedo()
gui3d.app.setFilenameCaption(filename)
gui3d.app.setFileModified(False)
mh.changeCategory('Modelling')
示例8: __init__
def __init__(self, template, bodypart, fallback):
string = template.replace("$", "").replace("{", "").replace("}", "")
warppath = os.path.join(mh.getPath(""), "warp", string)
if not os.path.exists(os.path.dirname(warppath)):
os.makedirs(os.path.dirname(warppath))
if not os.path.exists(warppath):
fp = open(warppath, "w")
fp.close()
humanmodifier.SimpleModifier.__init__(self, warppath)
self.fallback = eval("humanmodifier.%s('%s')" % (fallback, template))
self.warppath = warppath
self.template = template
paths = self.fallback.expandTemplate([(self.template, [])])
self.bases = {}
if len(paths) == 1:
path = paths[0]
char, key = getBaseCharacter(path[0])
self.bases[key] = (path[0], char, -1)
else:
for path in paths:
char, key = getBaseCharacter(path[1])
self.bases[key] = (path[0], char, -1)
self.isWarp = True
self.bodypart = bodypart
self.slider = None
self.refTargets = {}
self.refTargetVerts = {}
示例9: __init__
def __init__(self, category):
modelPath = mh.getPath('models')
gui3d.TaskView.__init__(self, category, 'Load', )
self.filechooser = self.addTopWidget(fc.FileChooser(modelPath, 'mhm', 'thumb', 'data/notfound.thumb', sort=HumanFileSort()))
self.addLeftWidget(self.filechooser.sortBox)
@self.filechooser.mhEvent
def onFileSelected(filename):
human = gui3d.app.selectedHuman
human.load(filename, True, gui3d.app.progress)
del gui3d.app.undoStack[:]
del gui3d.app.redoStack[:]
gui3d.app.modified = False
name = os.path.basename(filename).replace('.mhm', '')
self.parent.tasksByName['Save'].fileentry.text = name
self.parent.tasksByName['Save'].fileentry.edit.setText(name)
gui3d.app.setFilenameCaption(filename)
gui3d.app.setFileModified(False)
mh.changeCategory('Modelling')
示例10: __init__
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))
示例11: __init__
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))
示例12: onFileSelected
def onFileSelected(filename):
gui3d.app.do(Action(gui3d.app.selectedHuman,
gui3d.app.selectedHuman.getTexture(),
os.path.join(mh.getPath(''), 'data', 'skins', filename)))
gui3d.app.switchCategory('Modelling')
示例13: __init__
def __init__(self, category):
gui3d.TaskView.__init__(self, category, 'Load')
self.modelPath = None
self.fileentry = self.addTopWidget(gui.FileEntryView('Browse', mode='dir'))
self.fileentry.filter = 'MakeHuman Models (*.mhm)'
@self.fileentry.mhEvent
def onFileSelected(event):
self.filechooser.setPaths([event.path])
self.filechooser.refresh()
self.filechooser = fc.IconListFileChooser(mh.getPath("models"), 'mhm', 'thumb', mh.getSysDataPath('notfound.thumb'), sort=HumanFileSort())
self.addRightWidget(self.filechooser)
self.addLeftWidget(self.filechooser.createSortBox())
@self.filechooser.mhEvent
def onFileSelected(filename):
if gui3d.app.currentFile.modified:
gui3d.app.prompt("Load", "You have unsaved changes. Are you sure you want to close the current file?",
"Yes", "No", lambda: gui3d.app.loadHumanMHM(filename))
else:
gui3d.app.loadHumanMHM(filename)
示例14: __init__
def __init__(self, template, bodypart, modtype):
global theModifierTypes, theBaseCharacterParts
string = template.replace('$','').replace('{','').replace('}','')
warppath = os.path.join(mh.getPath(""), "warp", string)
if not os.path.exists(os.path.dirname(warppath)):
os.makedirs(os.path.dirname(warppath))
if not os.path.exists(warppath):
fp = open(warppath, "w")
fp.close()
humanmodifier.SimpleModifier.__init__(self, warppath)
self.eventType = 'warp'
self.warppath = warppath
self.template = template
self.isWarp = True
self.bodypart = bodypart
self.slider = None
self.refTargets = {}
self.refTargetVerts = {}
self.modtype = modtype
self.fallback = None
for (tlabel, tname, tvar) in theModifierTypes[modtype]:
self.fallback = humanmodifier.MacroModifier(tlabel, tname, tvar)
break
self.bases = {}
self.targetSpecs = {}
if modtype == "GenderAge":
self.setupBaseCharacters("Gender", "Age", "NoEthnic", "NoUniv", "NoUniv")
elif modtype == "GenderAgeEthnic":
self.setupBaseCharacters("Gender", "Age", "Ethnic", "NoUniv", "NoUniv")
elif modtype == "GenderAgeToneWeight":
self.setupBaseCharacters("Gender", "Age", "NoEthnic", "Tone", "Weight")
示例15: onShow
def onShow(self, event):
# When the task gets shown, set the focus to the file chooser
gui3d.TaskView.onShow(self, event)
human = gui3d.app.selectedHuman
self.skinRadio.setChecked(True)
self.reloadMaterialChooser()
if human.hairObj:
self.hairRadio.setEnabled(True)
else:
self.hairRadio.setEnabled(False)
if human.eyesObj:
self.eyesRadio.setEnabled(True)
else:
self.eyesRadio.setEnabled(False)
self.populateClothesSelector()
# Offer to download skins if none are found
self.numSkin = len([filename for filename in os.listdir(os.path.join(mh.getPath(''), 'data', 'skins')) if filename.lower().endswith('png')])
if self.numSkin < 1:
gui3d.app.prompt('No skins found', 'You don\'t seem to have any skins, download them from the makehuman media repository?\nNote: this can take some time depending on your connection speed.', 'Yes', 'No', self.syncMedia)