コード例 #1
0
ファイル: simplexSplitter.py プロジェクト: iVerb/Simplex
    def loadSMPX(cls, smpx):
        iarch = IArchive(str(smpx))  # because alembic hates unicode
        try:
            top = iarch.getTop()
            par = top.children[0]
            par = IXform(top, par.getName())

            abcMesh = par.children[0]
            abcMesh = IPolyMesh(par, abcMesh.getName())

            systemSchema = par.getSchema()
            props = systemSchema.getUserProperties()
            prop = props.getProperty('simplex')
            jsString = prop.getValue()
            js = json.loads(jsString)
            system = cls.loadJSON(js)
            system._smpx = smpx
            meshSchema = abcMesh.getSchema()
            rawFaces = meshSchema.getFaceIndicesProperty().samples[0]
            rawCounts = meshSchema.getFaceCountsProperty().samples[0]

            system._faces = [i for i in rawFaces]
            system._counts = [i for i in rawCounts]

            for shape, sample in zip(
                    system.shapes,
                    meshSchema.getPositionsProperty().samples):
                shape.loadSMPX(sample)

        finally:
            del iarch

        return system
コード例 #2
0
def getMesh(iarch):
    '''Load the static mesh data from an alembic archive

	Parameters
	----------
	iarch : IArchive
		The input alembic archive

	Returns
	-------
	: imath.IntArray
		The Faces array
	: imath.IntArray
		The Counts array

	'''
    top = iarch.getTop()
    par = top.children[0]
    par = IXform(top, par.getName())

    abcMesh = par.children[0]
    abcMesh = IPolyMesh(par, abcMesh.getName())

    sch = abcMesh.getSchema()
    faces = sch.getFaceIndicesProperty().samples[0]
    counts = sch.getFaceCountsProperty().samples[0]

    return faces, counts
コード例 #3
0
ファイル: hdf5Convert.py プロジェクト: rusn07/Simplex
def loadMesh(iarch):
    top = iarch.getTop()
    par = top.children[0]
    par = IXform(top, par.getName())

    abcMesh = par.children[0]
    abcMesh = IPolyMesh(par, abcMesh.getName())

    sch = abcMesh.getSchema()
    faces = sch.getFaceIndicesProperty().samples[0]
    counts = sch.getFaceCountsProperty().samples[0]

    return faces, counts
コード例 #4
0
def getMesh(iarch):
    ''' Load the static mesh data from an alembic archive '''
    top = iarch.getTop()
    par = top.children[0]
    par = IXform(top, par.getName())

    abcMesh = par.children[0]
    abcMesh = IPolyMesh(par, abcMesh.getName())

    sch = abcMesh.getSchema()
    faces = sch.getFaceIndicesProperty().samples[0]
    counts = sch.getFaceCountsProperty().samples[0]

    return faces, counts
コード例 #5
0
ファイル: applyCorrectives.py プロジェクト: tfart/Simplex
def loadSmpx(iarch):
    ''' Load the json and shape data from a .smpx file '''
    top = iarch.getTop()
    par = top.children[0]
    par = IXform(top, par.getName())

    abcMesh = par.children[0]
    abcMesh = IPolyMesh(par, abcMesh.getName())

    meshSchema = abcMesh.getSchema()
    posProp = meshSchema.getPositionsProperty()
    shapes = getSampleArray(abcMesh)

    print "Done Loading"

    return shapes
コード例 #6
0
ファイル: hdf5Convert.py プロジェクト: rusn07/Simplex
def loadSmpx(iarch):
    top = iarch.getTop()
    par = top.children[0]
    par = IXform(top, par.getName())

    abcMesh = par.children[0]
    abcMesh = IPolyMesh(par, abcMesh.getName())

    meshSchema = abcMesh.getSchema()
    posProp = meshSchema.getPositionsProperty()

    shapes = []
    lpps = len(posProp.samples)
    for i, s in enumerate(posProp.samples):
        print "Reading {0: 3d} of {1}\r".format(i, lpps),
        shapes.append(s)
    print "Reading {0: 3d} of {1}".format(lpps, lpps)
    return shapes
コード例 #7
0
def loadSmpx(iarch):
    ''' Load the json and shape data from a .smpx file '''
    top = iarch.getTop()
    par = top.children[0]
    par = IXform(top, par.getName())

    abcMesh = par.children[0]
    abcMesh = IPolyMesh(par, abcMesh.getName())

    meshSchema = abcMesh.getSchema()
    posProp = meshSchema.getPositionsProperty()

    print "Loading Verts"
    shapes = np.empty((len(posProp.samples), len(posProp.samples[0]), 3))
    for i, s in enumerate(posProp.samples):
        shapes[i] = arrayToNumpy(s)

    print "Done Loading"

    return shapes
コード例 #8
0
def parseAbc(path):
	""" Read an .abc file and produce a Mesh object

	Args:
		path: The path to the .abc formatted file

	Returns:
		A list of vertices and the face connectivity

	Raises:
		IOError: If the file cannot be opened
	"""

	iarch = IArchive(str(path)) # because alembic hates unicode
	top = iarch.getTop()
	ixfo = IXform(top, top.children[0].getName())
	mesh = IPolyMesh(ixfo, ixfo.children[0].getName())

	sch = mesh.getSchema()
	rawVerts = sch.getPositionsProperty().samples[0]
	rawFaces = sch.getFaceIndicesProperty().samples[0]
	rawCounts = sch.getFaceCountsProperty().samples[0]

	faces = []
	faceCounter = 0
	for count in rawCounts:
		f = list(rawFaces[faceCounter: faceCounter+count])
		# Ignoring UV/Normal data for now
		faces.append(f)
		faceCounter += count

	verts = []
	for v in rawVerts:
		verts.append(list(v))

	return verts, faces