Exemplo n.º 1
0
 def createCurveControl( self, inName, inShape ):
     '''
     Creates a nurbs curve control.
     
     @param inName: String. Name of the control curve to create.
     @param inShape: String. Type of shape to create.
     @return: MObject. Control curve.
     '''
     # Point locations for shapes. These are created on the XZ plane.
     square = ( [-1,0,-1], [1,0,-1], [1,0,1], [-1,0,1], [-1,0,-1] )
     
     triangle = ( [0,0,1], [1,0,-1], [-1,0,-1], [0,0,1] )
     
     arrow = ( [0,0,-2], [1,0,0], [0.5,0,0], [0.5,0,2], [-0.5,0,2], [-0.5,0,0], [-1,0,0], [0,0,-2] )
     
     plus = ( [-0.5,0,-2], [0.5,0,-2], [0.5,0,-0.5], [2,0,-0.5], [2,0,0.5], [0.5,0,0.5],
             [0.5,0,2], [-0.5,0,2], [-0.5,0,0.5], [-2,0,0.5], [-2,0,-0.5], [-0.5,0,-0.5], [-0.5,0,-2] )
     
     pyramid = ( [-1,0,-1], [1,0,-1], [1,0,1], [-1,0,1], [-1,0,-1], [0,2,0], [1,0,-1], [1,0,1], [0,2,0], [-1,0,1] )
     
     
     # Grab the points for the passed in shape.
     points = {'square':square,
               'triangle':triangle,
               'arrow':arrow,
               'plus':plus,
               'pyramid':pyramid}
     
     # Create the shape.
     if inShape == 'circle':
         control = NurbsCurveUtility.createCurveCircle( inName )
     elif inShape == 'ringDirection':
         rdCircle = NurbsCurveUtility.createCurveCircle( inName )
         rdTriangle = NurbsCurveUtility.createCurve( 'triangle', points['triangle'], 1, inForm=False, inOffset=[0,0,1.5], inScale=0.25 )
         cirName = OpenMaya.MDagPath.getAPathTo( rdCircle ).fullPathName()
         triName = OpenMaya.MDagPath.getAPathTo( rdTriangle ).fullPathName()
         control = NurbsCurveUtility.createCompoundCurve( [cirName, triName] )
     else:
         control = NurbsCurveUtility.createCurve( inName, points[inShape], inForm=False )
         
     return control