Esempio n. 1
0
def exportObj(filepath, config=None):
    progress = Progress(0, None)
    human = config.human
    config.setupTexFolder(filepath)
    filename = os.path.basename(filepath)
    name = config.goodName(os.path.splitext(filename)[0])

    progress(0, 0.3, "Collecting Objects")
    objects = human.getObjects(excludeZeroFaceObjs=not config.helperGeom)
    meshes = [o.mesh for o in objects]

    if config.helperGeom:
        # Disable the face masking on copies of the input meshes
        meshes = [m.clone(filterMaskedVerts=False) for m in meshes]
        for m in meshes:
            # Would be faster if we could tell clone() to do this, but it would 
            # make the interface more complex.
            # We could also let the wavefront module do this, but this would 
            # introduce unwanted "magic" behaviour into the export function.
            face_mask = np.ones(m.face_mask.shape, dtype=bool)
            m.changeFaceMask(face_mask)
            m.calcNormals()
            m.updateIndexBuffer()

    progress(0.3, 0.99, "Writing Objects")
    wavefront.writeObjFile(filepath, meshes, True, config, filterMaskedFaces=not config.helperGeom)

    progress(1.0, None, "OBJ Export finished. Output file: %s" % filepath)
Esempio n. 2
0
def exportObj(filepath, config=None):
    progress = Progress(0, None)
    human = config.human
    config.setupTexFolder(filepath)
    filename = os.path.basename(filepath)
    name = config.goodName(os.path.splitext(filename)[0])

    progress(0, 0.3, "Collecting Objects")
    objects = human.getObjects(excludeZeroFaceObjs=not config.hiddenGeom)
    meshes = [o.mesh for o in objects]

    if config.hiddenGeom:
        # Disable the face masking on copies of the input meshes
        meshes = [m.clone(filterMaskedVerts=False) for m in meshes]
        for m in meshes:
            # Would be faster if we could tell clone() to do this, but it would
            # make the interface more complex.
            # We could also let the wavefront module do this, but this would
            # introduce unwanted "magic" behaviour into the export function.
            face_mask = np.ones(m.face_mask.shape, dtype=bool)
            m.changeFaceMask(face_mask)
            m.calcNormals()
            m.updateIndexBuffer()

    progress(0.3, 0.99, "Writing Objects")
    wavefront.writeObjFile(filepath,
                           meshes,
                           True,
                           config,
                           filterMaskedFaces=not config.hiddenGeom)

    progress(1.0, None, "OBJ Export finished. Output file: %s" % filepath)
Esempio n. 3
0
def exportObj(filepath, config=None):
    progress = Progress(0, None)
    human = config.human
    config.setupTexFolder(filepath)
    filename = os.path.basename(filepath)
    name = config.goodName(os.path.splitext(filename)[0])

    progress(0, 0.3, "Collecting Objects")
    objects = human.getObjects(excludeZeroFaceObjs=True)

    progress(0.3, 0.99, "Writing Objects")
    wavefront.writeObjFile(filepath, objects, True, config)

    progress(1.0, None, "OBJ Export finished. Output file: %s" % filepath)
Esempio n. 4
0
def exportObj(filepath, config=None):
    progress = Progress(0, None)
    if config is None:
        config = exportutils.config.Config()
    human = config.human
    config.setupTexFolder(filepath)
    filename = os.path.basename(filepath)
    name = config.goodName(os.path.splitext(filename)[0])

    progress(0, 0.3, "Collecting Objects")
    objects = [
        m.object.mesh if isinstance(m, proxy.Proxy) else m.mesh
        for m in human.getMeshes()
    ]

    progress(0.3, 0.99, "Writing Objects")
    wavefront.writeObjFile(filepath, objects, True, config)

    progress(1.0, None, "OBJ Export finished. Output file: %s" % filepath)
Esempio n. 5
0
def exportObj(human, filepath, config=None):
    progress = Progress(0, None)
    if config is None:
        config = exportutils.config.Config()
    config.setHuman(human)
    config.setupTexFolder(filepath)
    filename = os.path.basename(filepath)
    name = config.goodName(os.path.splitext(filename)[0])

    progress(0, 0.3, "Collecting Objects")
    rmeshes = exportutils.collect.setupMeshes(
        name,
        human,
        config=config,
        subdivide=config.subdivide)

    progress(0.3, 0.99, "Writing Objects")
    objects = [rmesh.object for rmesh in rmeshes]
    wavefront.writeObjFile(filepath, objects, True, config)

    progress(1.0, None, "OBJ Export finished. Output file: %s" % filepath)
Esempio n. 6
0
def exportObj(human, filepath, config=None):
    if config is None:
        config = exportutils.config.Config()
    obj = human.meshData
    config.setHuman(human)
    config.setupTexFolder(filepath)
    filename = os.path.basename(filepath)
    name = config.goodName(os.path.splitext(filename)[0])

    rmeshes,_amt = exportutils.collect.setupObjects(
        name,
        human,
        config=config,
        helpers=config.helpers,
        eyebrows=config.eyebrows,
        lashes=config.lashes,
        subdivide=config.subdivide)

    objects = [rmesh.richMesh.object for rmesh in rmeshes]
    wavefront.writeObjFile(filepath, objects, True, config)

    return
Esempio n. 7
0
    def exportOBJ(self, path):
        h = self._mhmain.selectedHuman
        # here i'm importing wavefront and exportutils dynamicly forcing it to
        # execute after global initialisation. Causes errors otherwise.
        # Still i didn't want to import these modules everytime the method was
        # called so I stores them in the class instance of the app.
        # normal save process from here..
        config = exportutils.config.Config()
        config.setHuman(h)
        config.setupTexFolder(path)
        filename = os.path.basename(path)
        name = config.goodName(os.path.splitext(filename)[0])
        tmp = config.subdivide
        rmeshes = exportutils.collect.setupMeshes(name,
                                                  h,
                                                  config=config,
                                                  subdivide=tmp)
        objects = [rmesh.object for rmesh in rmeshes]

        # seting False as last parameter on writeObjFile will write
        # the OBJ file,
        # setting True will write the NML file
        wavefront.writeObjFile('%s.obj' % path, objects, False, config)
        wavefront.writeObjFile('%s.mtl' % path, objects, True, config)
 def saveObj(self, name, path=mh.getPath('exports')):
     log.message("SCRIPT: saveObj(" + name + "," + path + ")")
     filename = os.path.join(path, name + ".obj")
     import wavefront
     wavefront.writeObjFile(filename, self.human.mesh)
Esempio n. 9
0
 def saveObj(self, name, path = mh.getPath('exports')):
     log.message("SCRIPT: saveObj(" + name + "," + path + ")")
     filename = os.path.join(path,name + ".obj")
     import wavefront
     wavefront.writeObjFile(filename, self.human.mesh)
Esempio n. 10
0
def saviour(age, gendere, weighte, body_proportion, heighte, name, key_string, image_path, chest_cm, waist_cm, skin_color):

	if(skin_color == '1'):
		humanoid.setCaucasian(1)
	elif(skin_color == '2'):
		humanoid.setCaucasian(0.7)
	elif(skin_color == '4'):
		humanoid.setAsian(0.5)
	elif(skin_color == '5'):
		humanoid.setAfrican(0.6)
	elif(skin_color == '6'):
		humanoid.setAfrican(0.7)
	
	if (gendere == 1):
		humanoid.setHeight(mcmtofr(heighte, age))
	else:
		humanoid.setHeight(fcmtofr(heighte, age))

	humanoid.setAgeYears(age)
	humanoid.setGender(gendere)

	# setting muscle to zero is the only way after which we can add fat to the body (by increasing weight, through calculating BMI)
	humanoid.setMuscle(0)

	BMI = weighte / ((heighte/100) * (heighte/100))

	if (BMI > 30):
		humanoid.setWeight(0.9)
	elif (BMI > 26):
		humanoid.setWeight(0.7)
	elif (BMI > 18.5):
		humanoid.setWeight(0.5)
	else:
		humanoid.setWeight(0.3)

	## Modelling the face using BetaFaceAPI
	if(len(image_path) > 1):

		print "Inside facial modelling"
		photo_instance = api.BetaFaceAPI()
		photo_info = photo_instance.upload_face(image_path, 'modestreet@internet')

		for info in photo_info:
			prop = info['name'].encode('utf-8')
			value = info['value'].encode('utf-8')
			
			if(float(info['confidence'].encode('utf-8')) < 0.5):
				continue

			### eyes
			if(prop == 'eyes distance'):
				if(value == 'extra far'):
					humanoid.setDetail(dpa + 'eyes/l-eye-trans-out.target', 0.6)
					humanoid.setDetail(dpa + 'eyes/r-eye-trans-out.target', 0.6)
				elif(value == 'far'):
					humanoid.setDetail(dpa + 'eyes/l-eye-trans-out.target', 0.3)
					humanoid.setDetail(dpa + 'eyes/r-eye-trans-out.target', 0.3)
				elif(value == 'close'):
					humanoid.setDetail(dpa + 'eyes/l-eye-trans-in.target', 0.3)
					humanoid.setDetail(dpa + 'eyes/r-eye-trans-in.target', 0.3)
				elif(value == 'extra close'):
					humanoid.setDetail(dpa + 'eyes/l-eye-trans-in.target', 0.6)
					humanoid.setDetail(dpa + 'eyes/r-eye-trans-in.target', 0.6)

			elif(prop == 'eyes position'):
				if(value == 'extra low'):
					humanoid.setDetail(dpa + 'eyes/l-eye-trans-down.target', 0.6)
					humanoid.setDetail(dpa + 'eyes/r-eye-trans-down.target', 0.6)
				elif(value == 'low'):
					humanoid.setDetail(dpa + 'eyes/l-eye-trans-down.target', 0.3)
					humanoid.setDetail(dpa + 'eyes/r-eye-trans-down.target', 0.3)
				elif(value == 'high'):
					humanoid.setDetail(dpa + 'eyes/l-eye-trans-up.target', 0.3)
					humanoid.setDetail(dpa + 'eyes/r-eye-trans-up.target', 0.3)
				elif(value == 'extra high'):
					humanoid.setDetail(dpa + 'eyes/l-eye-trans-up.target', 0.6)
					humanoid.setDetail(dpa + 'eyes/r-eye-trans-up.target', 0.6)
			
			elif(prop == 'eyes shape'):
				if(value == 'extra round'):
					humanoid.setDetail(dpa + 'eyes/l-eye-height2-incr.target', 0.6)
					humanoid.setDetail(dpa + 'eyes/r-eye-height2-incr.target', 0.6)
				elif(value == 'round'):
					humanoid.setDetail(dpa + 'eyes/l-eye-height2-incr.target', 0.3)
					humanoid.setDetail(dpa + 'eyes/r-eye-height2-incr.target', 0.3)
				elif(value == 'thin'):
					humanoid.setDetail(dpa + 'eyes/l-eye-height2-decr.target', 0.3)
					humanoid.setDetail(dpa + 'eyes/r-eye-height2-decr.target', 0.3)
				elif(value == 'extra thin'):
					humanoid.setDetail(dpa + 'eyes/l-eye-height2-decr.target', 0.6)
					humanoid.setDetail(dpa + 'eyes/r-eye-height2-decr.target', 0.6)

			### mouth
			elif(prop == 'mouth corners'):
				if(value == 'extra low'):
					humanoid.setDetail(dpa + 'mouth/mouth-angles-down.target', 0.6)
				elif(value == 'low'):
					humanoid.setDetail(dpa + 'mouth/mouth-angles-down.target', 0.3)
				elif(value == 'raised'):
					humanoid.setDetail(dpa + 'mouth/mouth-angles-up.target', 0.3)
				elif(value == 'extra raised'):
					humanoid.setDetail(dpa + 'mouth/mouth-angles-up.target', 0.6)

			elif(prop == 'mouth height'):
				if(value == 'extra thick'):
					humanoid.setDetail(dpa + 'mouth/mouth-scale-vert-incr.target', 0.6)
				elif(value == 'thick'):
					humanoid.setDetail(dpa + 'mouth/mouth-scale-vert-incr.target', 0.3)
				elif(value == 'thin'):
					humanoid.setDetail(dpa + 'mouth/mouth-scale-vert-decr.target', 0.3)
				elif(value == 'extra thin'):
					humanoid.setDetail(dpa + 'mouth/mouth-scale-vert-decr.target', 0.6)

			elif(prop == 'mouth width'):
				if(value == 'extra wide'):
					humanoid.setDetail(dpa + 'mouth/mouth-scale-horiz-incr.target', 0.6)
				elif(value == 'wide'):
					humanoid.setDetail(dpa + 'mouth/mouth-scale-horiz-incr.target', 0.3)
				elif(value == 'small'):
					humanoid.setDetail(dpa + 'mouth/mouth-scale-horiz-decr.target', 0.3)
				elif(value == 'extra small'):
					humanoid.setDetail(dpa + 'mouth/mouth-scale-horiz-decr.target', 0.6)


			### nose
			elif(prop == 'nose width'):
				if(value == 'extra wide'):
					humanoid.setDetail(dpa + 'nose/nose-scale-horiz-incr.target', 0.6)
				elif(value == 'wide'):
					humanoid.setDetail(dpa + 'nose/nose-scale-horiz-incr.target', 0.3)
				elif(value == 'narrow'):
					humanoid.setDetail(dpa + 'nose/nose-scale-horiz-decr.target', 0.3)
				elif(value == 'extra narrow'):
					humanoid.setDetail(dpa + 'nose/nose-scale-horiz-decr.target', 0.6)
			
			elif(prop == 'nose shape'):
				if(value == 'extra straight'):
					humanoid.setDetail(dpa + 'nose/nose-width1-incr.target', 0.6)
				elif(value == 'straight'):
					humanoid.setDetail(dpa + 'nose/nose-width1-incr.target', 0.3)
				elif(value == 'triangle'):
					humanoid.setDetail(dpa + 'nose/nose-width1-decr.target', 0.3)
				elif(value == 'extra triangle'):
					humanoid.setDetail(dpa + 'nose/nose-width1-decr.target', 0.6)
				
			## head
			elif(prop == 'chin size'):
				if(value == 'extra large'):
					humanoid.setDetail(dpa + 'chin/chin-width-incr.target', 0.6)
				elif(value == 'large'):
					humanoid.setDetail(dpa + 'chin/chin-width-incr.target', 0.3)
				elif(value == 'small'):
					humanoid.setDetail(dpa + 'chin/chin-width-decr.target', 0.3)
				elif(value == 'extra small'):
					humanoid.setDetail(dpa + 'chin/chin-width-decr.target', 0.6)

			elif(prop == 'head shape'):
				if(value == 'extra heart'):
					humanoid.setDetail(dpa + 'head/head-invertedtriangular.target', 0.5)
				elif(value == 'heart'):
					humanoid.setDetail(dpa + 'head/head-invertedtriangular.target', 0.3)
				elif(value == 'rect'):
					humanoid.setDetail(dpa + 'head/head-rectangular.target', 0.3)
				elif(value == 'extra rect'):
					humanoid.setDetail(dpa + 'head/head-rectangular.target', 0.5)
	
	## move ear wings inwards, looks better with ears adjusted
	humanoid.setDetail(dpa + 'ears/l-ear-wing-decr.target', 0.5)
	humanoid.setDetail(dpa + 'ears/r-ear-wing-decr.target', 0.5)

	humanoid.applyAllTargets()

	print humanoid.targetsDetailStack
	wavefront.writeObjFile(fpa +  name + '.obj', humanoid.mesh)