示例#1
0
文件: view.py 项目: johndpope/CLOTH3D
def loadSampleFrame(sample, frame, info):
	""" SMPL """
	gender = 'm' if info['gender'] else 'f'
	p = info['poses'][:,frame].reshape((24,3))
	s = info['shape']
	t = info['trans'][:,frame]
	V, J = smpl[gender].set_params(pose=p, beta=s, trans=t)
	V -= J[0:1]
	ob = createBPYObj(V, smpl[gender].faces, name=sample)
	ob.rotation_euler[2] = info['zrot']		
	# Smooth
	bpy.ops.object.shade_smooth()
	# black object fix
	bpy.ops.object.editmode_toggle()
	bpy.ops.object.editmode_toggle()
	""" Garments """
	for garment in info['outfit']:
		# Read OBJ file and create BPY object
		_,F,Vt,Ft = readOBJ(os.path.join(PATH_SRC, sample, garment + '.obj'))
		V = readPC2Frame(os.path.join(PATH_SRC, sample, garment + '.pc16'), frame, True)
		V += info['trans'][:,frame][None]
		ob = createBPYObj(V, F, Vt, Ft, name=sample + '_' + garment)
		# z-rot
		ob.rotation_euler[2] = info['zrot']		
		# Material
		setMaterial(ob, sample, garment, info['outfit'][garment]['texture'])	
		# Smooth
		bpy.ops.object.shade_smooth()
		# black object fix
		bpy.ops.object.editmode_toggle()
		bpy.ops.object.editmode_toggle()
示例#2
0
文件: view.py 项目: johndpope/CLOTH3D
def loadGarment(sample, garment, info):
	texture = info['outfit'][garment]['texture']
	# Read OBJ file and create BPY object
	V,F,Vt,Ft = readOBJ(os.path.join(PATH_SRC, sample, garment + '.obj'))
	ob = createBPYObj(V, F, Vt, Ft, name=sample + '_' + garment)
	# z-rot
	ob.rotation_euler[2] = info['zrot']
	# Convert cache PC16 to PC2
	pc2_path = garmentCache(sample, garment, info['trans'])
	mesh_cache(ob, pc2_path)
	# Set material
	setMaterial(ob, sample, garment, texture)
	# Smooth
	bpy.ops.object.shade_smooth()
示例#3
0
import os
import sys

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
from values import *
from IO import readOBJ
"""
Creates TXT files with a list of garments of each samples and vertex count of each.
CLOTH3D has different files for different garments.
DeePSD is designed to work with whole outfits.
We use this metadata to move from garment-to-outfit and viceversa.
"""

samples = os.listdir(SRC)
for i, sample in enumerate(samples):
    print(str(i + 1) + '/' + str(len(samples)) + ' - ' + sample)
    src = SRC + sample + '/'
    dst = SRC_PREPROCESS + sample + '/'
    if os.path.isfile(dst + 'outfit_verts.txt'): continue
    # list garments
    garments = [
        f.replace('.obj', '') for f in os.listdir(src) if f.endswith('.obj')
    ]
    if not os.path.isdir(dst): os.mkdir(dst)
    with open(dst + 'outfit_verts.txt', 'w') as f:
        n = 0
        for i, g in enumerate(garments):
            n += readOBJ(src + g + '.obj')[0].shape[0]
            f.write(g + '\t' + str(n) + '\n')
示例#4
0
文件: read.py 项目: johndpope/CLOTH3D
 def read_garment_UVMap(self, sample, garment):
     # Read OBJ file
     obj_path = os.path.join(self.SRC, sample, garment + '.obj')
     return readOBJ(obj_path)[2:]
示例#5
0
文件: read.py 项目: johndpope/CLOTH3D
 def read_garment_topology(self, sample, garment):
     # Read OBJ file
     obj_path = os.path.join(self.SRC, sample, garment + '.obj')
     return readOBJ(obj_path)[1]
示例#6
0
	return np.array(out, np.int32)

samples = os.listdir(SRC)
N = len(samples)
for i,sample in enumerate(samples):
	print("Sample " + str(i+1) + '/' + str(N))
	src = SRC + sample + '/'
	dst = SRC_PREPROCESS + sample + '/'
	if os.path.isfile(dst + 'faces.bin'):
		assert os.path.isfile(dst + 'rest.pc16'), 'Faces but no Rest: ' + sample
		continue
	if not os.path.isdir(dst): os.mkdir(dst)
	# list garments
	with open(dst + '/outfit_verts.txt', 'r') as f:
		garments = [t.replace('\n','').split('\t')[0] for t in f.readlines()]
	# read sample
	zrot = loadInfo(src + 'info.mat')['zrot']
	V, F = None, None
	for g in garments:
		v, f = readOBJ(src + g + '.obj')[:2]
		f = quads2tris(f)
		if V is None:
			V = v
			F = f
		else:
			n = V.shape[0]
			V = np.concatenate((V, v), axis=0)
			F = np.concatenate((F, f + n), axis=0)
	V = (zRotMatrix(-zrot) @ V.T).T
	writePC2(dst + 'rest.pc16', V[None], True)
	writeFaceBIN(dst + 'faces.bin', F)