def create_component_base(self): """Creates common groups for all components These groups are provided as a mean to organize the different elements of every component. Each component's base hierarchy: CONTROLS_GRP [name]_ctrls_GRP SETUP_GRP [name]_setup_GRP [name]_driver_GRP [name]_output_GRP [name]_skeleton_GRP """ self.ctrls_grp = trans.Transform(name='%s_ctrls_GRP' % self.name, parent='CTRLS_GRP') self.setup_grp = trans.Transform(name='%s_setup_GRP' % self.name, parent='SETUP_GRP') self.driver_grp = trans.Transform(name='%s_driver_GRP' % self.name, parent=self.setup_grp) self.output_grp = trans.Transform(name='%s_output_GRP' % self.name, parent=self.setup_grp) self.skeleton_grp = trans.Transform(name='%s_skeleton_GRP' % self.name, parent=self.setup_grp)
def build_base_grps(self): """ Creates top groups for the rig parent groups are hard coded as they should be the same for every rig """ #Top most group self.top_grp = trans.Transform(name='_%s' % self.asset_name.upper()) #Create all the other base groups and parent them under top group for grp_name in self.base_grps: grp_attr = '%s_grp' % grp_name grp = trans.Transform(name=grp_attr.upper(), parent=self.top_grp) setattr(self, grp_attr, grp) self.geo_grp.attr_set('overrideEnabled', 1) self.geo_grp.attr_set('overrideDisplayType', 2)
def build_template(self, template_data=None): """ """ self.create_component_base() if template_data: self.template_data = template_data self.template_grp = trans.Transform(name='%s_template_GRP' % self.name, parent='TEMPLATE_GRP') self.build_controls(self._hierarchy_graph.root_node, template=True) self.solve(template=True)
def setup_driver(self): """ Connects each of the component's drivers to their respective master Each individual component is then responsible for connecting their own driver (or drivers) to all the elements that need to be driven TODO: Decide on whether or not to support the Dictionary option No? Just one driver per component and special components have an special component_arg for extra drivers? Only one driver seems to be the most common scenario NOTE: Only the String option is supported for now self.driver_target can be a String or a Dictionary: In the first case, a single transform is created using the name "[name]_main_driver_GRP". In the second case, each key in the dictionary must be a string that will be used as a name for a new transform, which will then be connected to it's respective value in the dictionary """ if self.driver_target: self.main_driver = trans.Transform(name='%s_main_driver_XFORM' % self.name, parent=self.driver_grp) self.main_driver.constrain_to(self.driver_target, 'parent', mo=False) if self.scale_driver_target: if self.scale_driver_target == self.driver_target: self.main_driver.constrain_to(self.driver_target, 'scale', mo=True) self.main_scale_driver = self.main_driver else: self.main_scale_driver = trans.Transform( name='%s_main_scale_driver_XFORM' % self.name, parent=self.driver_grp) self.main_scale_driver.constrain_to(self.scale_driver_target, 'parent', mo=False)
def solve(self, template=False): """ Connects the lowest controls in the hierarchy to the output transform """ out_driver = self.ctrls[self.ctr_full_name].last_ctr self.output_xform = trans.Transform(name=self._output_name, side=self.side, parent=self.output_grp, match_object=out_driver) out_driver.constrain(self.output_xform, 'parent') if self.scale_constrained: out_driver.constrain(self.output_xform, 'scale')
def solve(self): """ Will constraint the root jnt to the last ctrl """ last_ctr_obj = self.M_local_CTR.last_ctr # Constrain skeleton last_ctr_obj.constrain(self.M_root_JNT, 'parent') last_ctr_obj.constrain(self.M_root_JNT, 'scale') # Create and constrain transforms output self.output_xform = trans.Transform( name = self._output_name, side = self.side, parent = self.output_grp ) last_ctr_obj.constrain(self.output_xform, 'parent', mo = False) last_ctr_obj.constrain(self.output_xform, 'scale', mo = False)
def build_template(self): '''Builds each component's template ''' self.template_grp = trans.Transform(name='TEMPLATE_GRP') for comp_name in self.components.keys(): self.components[comp_name].build_template()