def addCnsCurve( parent, name, centers, closed=False, degree=1 ): centers = list( centers ) points=[] if len(centers)<2: log('Select 2 or more object to create curve and clusters.', c.siError ) return if degree==3: if len(centers)==2: centers.insert( 0, centers[0] ) centers.append( centers[-1] ) elif len(centers)==3: centers.append( centers[-1] ) for center in centers: points.append( center.Kinematics.Global.Transform.PosX ) points.append( center.Kinematics.Global.Transform.PosY ) points.append( center.Kinematics.Global.Transform.PosZ ) points.append( 1.0 ) curve = parent.AddNurbsCurve( points, None , closed, degree, 0 , c.siSINurbs, name ) for i, center in enumerate(centers): cls = curve.ActivePrimitive.Geometry.AddCluster( c.siVertexCluster , 'center_%s'%str(i), [i] ) xsi.ApplyOp( 'ClusterCenter', cls.FullName+';'+center.FullName ) return curve
def addCnsCurve(parent, name, centers, closed=False, degree=1): centers = list(centers) points = [] if len(centers) < 2: log('Select 2 or more object to create curve and clusters.', c.siError) return if degree == 3: if len(centers) == 2: centers.insert(0, centers[0]) centers.append(centers[-1]) elif len(centers) == 3: centers.append(centers[-1]) for center in centers: points.append(center.Kinematics.Global.Transform.PosX) points.append(center.Kinematics.Global.Transform.PosY) points.append(center.Kinematics.Global.Transform.PosZ) points.append(1.0) curve = parent.AddNurbsCurve(points, None, closed, degree, 0, c.siSINurbs, name) for i, center in enumerate(centers): cls = curve.ActivePrimitive.Geometry.AddCluster( c.siVertexCluster, 'center_%s' % str(i), [i]) xsi.ApplyOp('ClusterCenter', cls.FullName + ';' + center.FullName) return curve
def buildInitialHierarchy( self ): log( 'BUILD - 1 ..................... builing initial hierarchy ') # model self.model = xsi.ActiveSceneRoot.AddModel( None, self.settings[ 'name' ] ) self.model.Properties('Visibility').Parameters('viewvis').Value = False # groups self.hidden_grp = self.model.AddGroup( None, 'hidden_grp' ) self.unselectable_grp = self.model.AddGroup( None, 'unselectable_grp') self.controllers_grp = self.model.AddGroup( None, 'controllers_grp') self.deformers_grp = self.model.AddGroup( None, 'deformers_grp') self.hidden_grp.Parameters( 'viewvis' ).Value = 0 self.unselectable_grp.Parameters( 'selectability' ).Value = 0 self.deformers_grp.Parameters( 'viewvis' ).Value = 0 # orgenizers self.deformers_org = self.model.AddNull( 'deformers_org') self.geometries_org = self.model.AddNull( 'geometries_org') self.hidden_grp.AddMember( self.deformers_org ) self.hidden_grp.AddMember( self.geometries_org )
def saveMarkerTransform( self, marker, markerName ): log( 'COMPONENT GUIDE - 1 .................................. saveMarkerTransform') tfm = marker.Kinematics.Global.Transform tfm.SetScalingFromValues(1,1,1) self.pos[ markerName ] = tfm.Translation self.tfm[ markerName ] = tfm self.apos.append( tfm.Translation ) self.atfm.append( tfm )
def __init__(self, property): ComponentGuide.__init__(self, property) log('---------------------------------poses---------------------------------' ) for poses in self.apos: log( str(self.name) + ' position: ' + str(poses.X) + ', ' + str(poses.Y) + ', ' + str(poses.Z))
def __init__( self, guide ): log( '' ) log( '' ) log( '------------ Builder class was instantiated ----------') log( '------------------------------------------------------' ) log( '' ) self.guide = guide self.settings = self.guide.settings self.components = {}
def __init__(self, guide): log('') log('') log('------------ Builder class was instantiated ----------') log('------------------------------------------------------') log('') self.guide = guide self.settings = self.guide.settings self.components = {}
def initComponents( self ): log( 'BUILD - 2 ..................... initializing Components ') for key, controlGuide in self.guide.components.items(): # ie: key = Arm_Left, controlGuide = components.ArmGuide() type_ = controlGuide.type_ log( 'init component builder: %s (%s)'%( key, type_ ) ) moduleName = type_.lower() module = __import__( 'Pythons.character_rigging_suit.components.' + moduleName, globals(), locals(), ['*'], -1 ) componentClass = getattr( module, type_ ) self.components[ key ] = componentClass( self, controlGuide ) # ie: components.Arm( )'''
def build( self ): startTime = datetime.datetime.now() #xsi.SetValue("preferences.scripting.msglog", False ) self.buildInitialHierarchy() self.initComponents() self.buildComponents() #xsi.SetValue("preferences.scripting.msglog", True ) endTime = datetime.datetime.now() log( endTime - startTime )
def build(self): startTime = datetime.datetime.now() #xsi.SetValue("preferences.scripting.msglog", False ) self.buildInitialHierarchy() self.initComponents() self.buildComponents() #xsi.SetValue("preferences.scripting.msglog", True ) endTime = datetime.datetime.now() log(endTime - startTime)
def __init__( self, model ): log( '' ) log( '' ) log( '------------ Guide class was instantiated ------------' ) log( '------------------------------------------------------' ) log( '' ) assert self.isValid( model ), 'Guide is not Valid.' self.settings = { 'name':'unknown' ,'color_R':'0,0,1' ,'color_M':'.75,.25,.75' ,'color_L':'1,0,0' } self.components = {} self.initFromModel()
def isValid( self, model ): log( 'GUIDE - 1 .................................. cheking model') self.model = model if not self.model.Type == "#model": return False self.settings_prop = model.Properties('Settings') if not self.settings_prop: return False self.components_org = model.FindChild( 'components_org') if not self.components_org: return False return True
def initComponents(self): log('BUILD - 2 ..................... initializing Components ') for key, controlGuide in self.guide.components.items( ): # ie: key = Arm_Left, controlGuide = components.ArmGuide() type_ = controlGuide.type_ log('init component builder: %s (%s)' % (key, type_)) moduleName = type_.lower() module = __import__( 'Pythons.character_rigging_suit.components.' + moduleName, globals(), locals(), ['*'], -1) componentClass = getattr(module, type_) self.components[key] = componentClass( self, controlGuide) # ie: components.Arm( )'''
def buildInitialHierarchy(self): log('BUILD - 1 ..................... builing initial hierarchy ') # model self.model = xsi.ActiveSceneRoot.AddModel(None, self.settings['name']) self.model.Properties('Visibility').Parameters('viewvis').Value = False # groups self.hidden_grp = self.model.AddGroup(None, 'hidden_grp') self.unselectable_grp = self.model.AddGroup(None, 'unselectable_grp') self.controllers_grp = self.model.AddGroup(None, 'controllers_grp') self.deformers_grp = self.model.AddGroup(None, 'deformers_grp') self.hidden_grp.Parameters('viewvis').Value = 0 self.unselectable_grp.Parameters('selectability').Value = 0 self.deformers_grp.Parameters('viewvis').Value = 0 # orgenizers self.deformers_org = self.model.AddNull('deformers_org') self.geometries_org = self.model.AddNull('geometries_org') self.hidden_grp.AddMember(self.deformers_org) self.hidden_grp.AddMember(self.geometries_org)
def __init__(self, builder, guide): log('===========================Creating Component==============================' ) self.builder = builder self.guide = guide self.settings = self.guide.settings self.model = self.builder.model self.hidden_grp = self.builder.hidden_grp self.unselectable_grp = self.builder.unselectable_grp self.controllers_grp = self.builder.controllers_grp self.deformers_grp = self.builder.deformers_grp self.deformers_org = self.builder.deformers_org self.name = self.guide.name self.location = self.guide.location self.build = [ self.createObjects, self.createParameters, self.createOperators, self.createSlots, self.createConnections ]
def __init__( self, builder, guide ): log( '===========================Creating Component==============================' ) self.builder = builder self.guide = guide self.settings = self.guide.settings self.model = self.builder.model self.hidden_grp = self.builder.hidden_grp self.unselectable_grp = self.builder.unselectable_grp self.controllers_grp = self.builder.controllers_grp self.deformers_grp = self.builder.deformers_grp self.deformers_org = self.builder.deformers_org self.name = self.guide.name self.location = self.guide.location self.build = [ self.createObjects , self.createParameters , self.createOperators , self.createSlots , self.createConnections ]
def initFromModel( self ): log( 'GUIDE - 2 .................................. get info From Model') for parameter in self.settings_prop.Parameters: self.settings[ parameter.ScriptName ] = parameter.Value self.settings[ 'color_R' ] = [ float(s) for s in self.settings[ 'color_R' ].split(',') ] self.settings[ 'color_M' ] = [ float(s) for s in self.settings[ 'color_M' ].split(',') ] self.settings[ 'color_L' ] = [ float(s) for s in self.settings[ 'color_L' ].split(',') ] for property in self.components_org.Properties: if not property.Name.startswith('settings_'): continue type_ = property.Type_.Value name = property.Name_.Value location = property.Location.Value log( 'Initializing........%s_%s (%s)'%(type_,name,location) ) moduleName = type_.lower() module = __import__( 'Pythons.character_rigging_suit.components.' + moduleName, globals(), locals(), ['*'], -1 ) guideClass = getattr( module, type_+'Guide' ) self.components[ name+'_'+location ] = guideClass( property ) # ie: components.ArmGuide( )
def createOperators(self): log(' creating Operators....................')
def createOperators( self ): log( ' creating Operators....................' )
def createSlots( self ): log( ' creating Slots....................' )
def buildComponents( self ): log( 'BUILD - 3 ..................... building Components' ) for i in xrange( 5 ): for key, component in self.components.items(): component.build[i]()
def createConnections( self ): log( ' creating Connections....................' )
def __init__( self, property ): ComponentGuide.__init__( self, property ) log( '---------------------------------poses---------------------------------' ) for poses in self.apos: log( str(self.name) + ' position: ' + str(poses.X) + ', ' + str(poses.Y) + ', ' + str(poses.Z) )
def createObjects(self): log(' creating Objects....................')
def createConnections(self): log(' creating Connections....................')
def createParameters( self ): log( ' creating Parameters....................' )
def buildComponents(self): log('BUILD - 3 ..................... building Components') for i in xrange(5): for key, component in self.components.items(): component.build[i]()
def createParameters(self): log(' creating Parameters....................')
def createSlots(self): log(' creating Slots....................')
def createObjects( self ): log( ' creating Objects....................' )