#BPYCONSTRAINT ''' Rig-a-my-rule ''' # -------------------------------------------------------------------------- # ***** BEGIN GPL LICENSE BLOCK ***** # # Script copyright (C) Bassam Kurdali # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # ***** END GPL LICENCE BLOCK ***** # -------------------------------------------------------------------------- # copyright 2009 Bassam Kurdali # thanks to Martin Poirier for code reviews, fixes and advice import Blender from Blender import Draw ''' This variable specifies the number of targets that this constraint can use ''' NUM_TARGETS = 0 ''' This function is called to evaluate the constraint obmatrix: (Matrix) copy of owner's 'ownerspace' matrix targetmatrices: (List) list of copies of the 'targetspace' matrices of the targets (where applicable) idprop: (IDProperties) wrapped data referring to this constraint instance's idproperties ''' def doConstraint(obmatrix, targetmatrices, idprop): # we don't actually do anything here, sorry. return obmatrix ''' This function manipulates the matrix of a target prior to sending it to doConstraint() target_object: wrapped data, representing the target object subtarget_bone: wrapped data, representing the subtarget pose-bone/vertex-group (where applicable) target_matrix: (Matrix) the transformation matrix of the target id_properties_of_constraint: (IDProperties) wrapped idproperties ''' def doTarget(target_object, subtarget_bone, target_matrix, id_properties_of_constraint): return target_matrix ''' This function draws a pupblock that lets the user set the values of custom settings the constraint defines. This function is called when the user presses the settings button. idprop: (IDProperties) wrapped data referring to this constraint instance's idproperties ''' def getSettings(idprop): # Define user-settable parameters. # Must also be defined in getSettings(). if not idprop.has_key('eval'): idprop['eval'] = 1 if not idprop.has_key('method'): idprop['method'] = "" #valid functions defined in rules module if not idprop.has_key('mypart'): idprop['mypart'] = "" #valid parts are head, tail, roll or empty string if not idprop.has_key('target1'): idprop['target1'] = "" #target bone [.head/.tail] if not idprop.has_key('target2'): idprop['target2'] = "" #target bone [.head/.tail] if not idprop.has_key('target3'): idprop['target3'] = "" #target bone [.head/.tail] if not idprop.has_key('tarpart'): idprop['tarpart'] = "" #valid are head,tail,roll or empty string if not idprop.has_key('Xval'): idprop['Xval'] = 0.0 if not idprop.has_key('Yval'): idprop['Yval'] = 0.0 if not idprop.has_key('Zval'): idprop['Zval'] = 0.0 # create temporary vars for interface ueval = Draw.Create(idprop['eval']) umethod = Draw.Create(idprop['method']) umypart = Draw.Create(idprop['mypart']) utarget1 = Draw.Create(idprop['target1']) utarget2 = Draw.Create(idprop['target2']) utarget3 = Draw.Create(idprop['target3']) utarpart = Draw.Create(idprop['tarpart']) uXval = Draw.Create(idprop['Xval']) uYval = Draw.Create(idprop['Yval']) uZval = Draw.Create(idprop['Zval']) # define and draw pupblock block = [] block.append(("Priority: ",ueval,0,5, "Evaluation Priority")) block.append(("Rig Rule: ",umethod,0, 30, "The rule method")) block.append(("Bone Part: ", umypart, 0, 30, "head, tail, roll or blank")) block.append(("")) block.append(("Target 1: ", utarget1,0, 30, "First target (.head, or .tail allowed)")) block.append(("Target 2: ", utarget2,0, 30, "Second target (.head, or .tail allowed)")) block.append(("Target 3: ", utarget3,0, 30, "Third target (.head, or .tail allowed)")) block.append(("Target Part: ",utarpart,0,6, "head, tail, roll or blank")) block.append(("")) block.append(("X: ",uXval,-1000.0,1000.0, "X value")) block.append(("Y: ",uYval,-1000.0,1000.0, "Y value")) block.append(("Z: ",uZval,-1000.0,1000.0, "Z value")) retval = Draw.PupBlock("Rig-a-my-rule", block) # update id-property values after user changes settings if (retval): idprop['eval']=ueval.val idprop['method']= umethod.val idprop['mypart']= umypart.val idprop['target1']= utarget1.val idprop['target2']= utarget2.val idprop['target3']= utarget3.val idprop['tarpart']= utarpart.val idprop['Xval']= uXval.val idprop['Yval']= uYval.val idprop['Zval']= uZval.val