コード例 #1
0
ファイル: MccConverter.py プロジェクト: RoyLab/HairTraining
def mccPerFrameToAnim2(fileName, target):

    # import os, re
    # fileName = os.path.abspath(fileName)
    # dirName = os.path.dirname(fileName)
    #
    # baseName = os.path.basename(fileName).split('.')[0]
    # allFiles = os.listdir(dirName)
    # ids = []
    # matcher = re.compile(baseName)
    # nFrame = 0
    # for afile in allFiles:
    #     parts = os.path.splitext(afile)
    #     if (parts[1] == ".mcx" or parts[1] == ".mc") and matcher.match(afile) != None:
    #         id = eval(parts[0][len(baseName) + len('Frame'):])
    #         ids.append(id)
    #         nFrame += 1
    #
    # assert(nFrame == (max(ids)-min(ids)+1))
    #
    # defaultLogInfo("Found ncache %d files!" % nFrame)

    conv = ConverterHooker(target, True)
    conv.startLoop("Convert to anim file:")
    nCache.loop(fileName, conv)
    conv.endLoop()
コード例 #2
0
ファイル: pipeline.py プロジェクト: RoyLab/dxsimhair
    import cPickle as pkl
    import nCache
    import nCacheHooker as ch
    import GraphBuilder as gb
    import metis_graph as mg
    import os

    def setReadOnly(fileName):
        os.system('attrib +r \"'+fileName+'\"')

    if not needLoad:
        # step 1
        builder = ch.GraphBuildHooker(radius)
        builder.startLoop("Build InitGraph:")
        nCache.loop(fileName, builder, nFrame)
        builder.endLoop()

        nStrand, nParticle, edges, refFrame = builder.graph()
        factor = nParticle/nStrand

        thresh = nFrame * frameFilter
        gb.filterEdges(edges, thresh)

        refFrame.calcParticleDirections()
        ruler = ch.ConnectionCalcHooker(edges, refFrame, prefix[0])
        ruler.startLoop("Measure the deviation:")
        nCache.loop(fileName, ruler, nFrame)
        ruler.endLoop()

        pkl.dump(edges, file(prefix[0]+'-edges.dump', 'w'))
コード例 #3
0
        super(ConverterHooker, self).postFrame()

    def endLoop(self):
        # self.file.close()
        self.fileb.close()
        super(ConverterHooker, self).endLoop()

    def dataHooker(self, name, sz, arr):
        import re
        expr = re.compile(".*positions.*", re.I)
        if (expr.match(name)):
            self.data = arr
        super(ConverterHooker, self).dataHooker(name, sz, arr)

    def computeRigidMotionAndDirection(self):
        if self.i == 0:
            self.reference = self.frame

        self.frame.calcRigidMotionMatrix(self.reference)
        if self.needDirection:
            self.frame.calcParticleDirections()


if __name__ == "__main__":
    import sys

    conv = ConverterHooker(sys.argv[2], True)
    conv.startLoop("Convert to anim file:")
    nCache.loop(sys.argv[1], conv, 200)
    conv.endLoop()
コード例 #4
0
ファイル: MccConverter.py プロジェクト: RoyLab/HairTraining
def mccOneFileToAnim2(fileName, target, nFrame):
    conv = ConverterHooker(target, True)
    conv.startLoop("Convert to anim file:")
    nCache.loop(fileName, conv, nFrame)
    conv.endLoop()
コード例 #5
0
    nFrame = 200
    # fileName = "../../maya cache/03074/hair_nRigidShape1.xml"
    fileName = mxcFile

    nStrand, nParticle, factor, refFrame, radius, frameFilter = pkl.load(file(dumpFilePath+'\info.dump', 'r'))
    guide, weights = pkl.load(file(wFile, 'rb'))
    factor = 5

    n = len(weights)
    # print len(weights)
    # if n != 4245:
    #     nStrand = n/factor
    #     for i in range(n/factor):
    #         for j in range(1, factor):
    #             if weights[j*nStrand+i][0] != None:
    #                 weights[i] = weights[j*nStrand+i]
    #     weights = weights[:nStrand]
    # else:
    #     nStrand = n
    print len(weights)

    guideImporter = ch.GuideHairHooker(guide, refFrame)
    guideImporter.startLoop("Import guide hair data with %d frames:" % nFrame)
    nCache.loop(fileName, guideImporter, nFrame)
    guideImporter.endLoop()

    guideData = guideImporter.getResult()

    cache = HairInterpolation20(guideData, weights, refFrame, cacheFile)
    cache.interpolate()
コード例 #6
0
ファイル: nCacheConverter.py プロジェクト: RoyLab/dxsimhair
        if self.needDirection:
            array.array('f', self.frame.particle_direction.flatten()).tofile(self.fileb)
        super(ConverterHooker, self).postFrame()

    def endLoop(self):
        # self.file.close()
        self.fileb.close()
        super(ConverterHooker, self).endLoop()

    def dataHooker(self, name, sz, arr):
        import re
        expr = re.compile(".*positions.*", re.I)
        if (expr.match(name)):
            self.data = arr
        super(ConverterHooker, self).dataHooker(name, sz, arr)

    def computeRigidMotionAndDirection(self):
        if self.i == 0:
            self.reference = self.frame

        self.frame.calcRigidMotionMatrix(self.reference)
        if self.needDirection:
            self.frame.calcParticleDirections()


if __name__ == "__main__":
    conv = ConverterHooker("E:\\0418.anim2", True)
    conv.startLoop("Convert to anim file:")
    nCache.loop(file3, conv, 200)
    conv.endLoop()