# Adds a linear RiCurves to each vertex aligned to the average normal.
# Execute this mel command on the polymesh geometries that should be
# effected by this rif.
# addFloatPrimVar("normals_mode", 1);
import prman
from rif_utilities import VertexDB
class Rif(prman.Rif):
def __init__(self, ri, length, width):
self.length = float(length)
self.width = float(width)
prman.Rif.__init__(self, ri)
def PointsGeneralPolygons(self, nloops, nverts, verts, params):
if not params.has_key('constant float normals_mode'):
self.m_ri.PointsGeneralPolygons(nloops, nverts, verts, params)
return
mode = int(params['constant float normals_mode'][0])
if mode == 1:
verts_per_curve = []
xyz_curve = []
vertDB = VertexDB(nloops, nverts, verts, params)
vertices = vertDB.getVertices()
for vert in vertices:
vx,vy,vz = vert
nx,ny,nz = vertDB.getAveNormal(vert)
xyz_curve.extend( vert )
xyz_curve.extend( [vx + nx * self.length,
vy + ny * self.length,
vz + nz * self.length] )
verts_per_curve.append(2)
parms = { 'vertex point P' : xyz_curve, prman.Ri.CONSTANTWIDTH : self.width }
self.m_ri.Curves(prman.Ri.LINEAR, verts_per_curve, prman.Ri.NONPERIODIC, parms)
self.m_ri.PointsGeneralPolygons(nloops, nverts, verts, params)