2011년 12월 6일 화요일

Python Rif Layer - 1

import prman
import sys

class myRif(prman.Rif):
    def __init__(self, ri):
        prman.Rif.__init__(self, ri)
        self.m_nsubdivs = 0
    def HierarchicalSubdivisionMesh(self, mask, nverts, verts, tags, nargs, intargs, floatargs, stringargs, plist):
        nloops = [1 for i in range(len(nverts))]
        self.m_ri.PointsGeneralPolygons(nloops, nverts, verts, plist)
        self.m_nsubdivs += 1

if len(sys.argv) == 3:
    infile = sys.argv[1]
    outfile = sys.argv[2]
    prman.Init(["-catrib", outfile, "-progress"])
    ri = prman.Ri()
    rif1 = myRif(ri)
    prman.RifInit([rif1])
    ri.Begin(ri.RENDER)
    prman.ParseFile(infile)
    ri.End()
    print ("Converted %d subdivs to polys from %s into %s" % (rif1.m_nsubdivs, infile, outfile))
else:
    print ("usage: %s infile.rib outfile.rib" % sys.argv[0])

댓글 없음: