Demo Reel for Graduation

import pymel.core as pm
import maya.mel as mel
import re
'''
Radio button for point lock activation
'''
def button_base( *args ) :
intFieldData_seq = pm.intField( intFieldEntry_seq, editable = True, query = True, value = True)
global radioButton_follicle
radioButton_follicle=0
def button_tip( *args ) :
intFieldData_seq = pm.intField( intFieldEntry_seq, editable = True, query = True, value = True)
global radioButton_follicle
radioButton_follicle=1
def button_both_end( *args ) :
intFieldData_seq = pm.intField( intFieldEntry_seq, editable = True, query = True, value = True)
global radioButton_follicle
radioButton_follicle=2
'''
Radio button for Self Collision activation
'''
def self_col_on( *args ) :
global checkBox_self_col
checkBox_self_col = 1
def self_col_off( *args ) :
global checkBox_self_col
checkBox_self_col = 0
'''
Radio button for Self Collision activation
'''
def col_on( *args ) :
global checkBox_col
checkBox_col = 1
def col_off( *args ) :
global checkBox_col
checkBox_col = 0
'''
Create dynamic hair with multi curve
'''
def hair_joint_multi( *args ) :
'''
Collect Data
'''
intFieldData_num_joint = pm.intField( intFieldEntry_num_joint, editable = True, query = True, value = True)
intFieldData_seq = pm.intField( intFieldEntry_seq, editable = True, query = True, value = True)
if intFieldData_seq == 0 :
seq_curve = intFieldData_seq
elif intFieldData_seq > 0 :
seq_curve = intFieldData_seq 1
if pm.objExists( 'hair_{0}_01_bind'.format( seq_curve + 1 ) ) :
print 'Error on naming sequence'
else :
list_curve = pm.ls( sl= True )
for item in list_curve :
seq_curve = seq_curve + 1
'''
Collect Data
'''
intFieldData_num_joint = pm.intField( intFieldEntry_num_joint, editable = True, query = True, value = True)
'''
Method on reconstruct curve and rename
'''
pm.rebuildCurve( item , ch=1, rpo=1 , rt=0 , end=1 , kr=0 , kcp=0 , kep=1 , kt=0 , s=intFieldData_num_joint, d=3 , tol=0.0001 )
name_curve = pm.rename( item , 'hair_{0}_curve'.format( seq_curve ) )
'''
Method on create joint along curve
'''
pre_joint = ''
root_joint = ''
for i in range( 0 , intFieldData_num_joint ) :
user_default_unit = pm.currentUnit( query=True, linear=True )
pm.currentUnit( linear = 'cm' )
pm.select( cl = True )
new_joint = pm.joint()
mot_path = pm.pathAnimation( new_joint , c = item , fm = True )
pm.cutKey( mot_path + '.u' )
pm.setAttr( mot_path + '.u', i * ( 1.0 / ( intFieldData_num_joint 1 )) )
pm.delete( '{0}.{1}'.format( new_joint , 'tx' ) , icn = True )
pm.delete( '{0}.{1}'.format( new_joint , 'ty' ) , icn = True )
pm.delete( '{0}.{1}'.format( new_joint , 'tz' ) , icn = True )
pm.currentUnit( linear = '{0}'.format(user_default_unit) )
renaming_item = pm.ls( sl = True )
if i == 0 :
pre_joint = new_joint
root_joint = new_joint
pm.rename( renaming_item , 'hair_{0}_{1:02d}_bind'.format( seq_curve ,i+1 ) )
continue
elif i < intFieldData_num_joint 1 :
pm.rename( renaming_item , 'hair_{0}_{1:02d}_bind'.format( seq_curve ,i+1 ) )
else :
pm.rename( renaming_item , 'hair_{0}_{1:02d}_waste'.format( seq_curve ,i+1 ) )
pm.parent( new_joint , pre_joint )
pre_joint = new_joint
pm.joint( root_joint, e = True , zso = True, oj = 'xyz' , ch = True , sao = 'yup' )
'''
Method on create dynamic curve
'''
pm.select( name_curve )
mel.eval('makeCurvesDynamic 2 { "0", "0", "1", "1", "0"}')
pm.hide(item)
pm.parent( 'hairSystem{0}Follicles'.format(seq_curve) , 'hair_{0}_01_bind'.format(seq_curve) )
output_curve_selected = pm.listRelatives( 'hairSystem{0}OutputCurves'.format(seq_curve) , c=1 )
output_curve = pm.rename( output_curve_selected , 'hair_{0}_output_curve'.format( seq_curve ) )
'''
Method on IK Spline
'''
pm.ikHandle(sj='hair_{0}_02_bind'.format(seq_curve), ee='hair_{0}_{1:02d}_waste'.format(seq_curve , intFieldData_num_joint ),c=output_curve, n = 'hair_{0}_ik'.format( seq_curve ), sol= 'ikSplineSolver' , createCurve = False, simplifyCurve = False, rootOnCurve = False , twistType = 'linear' , createRootAxis = False , parentCurve= False, snapCurve = False , rootTwistMode = False)
'''
Method on changing pointLock of dynamic curve
'''
if radioButton_follicle == 0 :
curve_follicle = 'follicleShape{0}'.format(seq_curve)
pm.setAttr(curve_follicle + ".pointLock", 1)
elif radioButton_follicle == 1 :
curve_follicle = 'follicleShape{0}'.format(seq_curve)
pm.setAttr(curve_follicle + ".pointLock", 2)
else :
curve_follicle = 'follicleShape{0}'.format(seq_curve)
pm.setAttr(curve_follicle + ".pointLock", 3)
print '-'*100
print 'dynamic hair created, proceed to attritube'
print '-'*100
'''
Create group if not exist
'''
if pm.objExists('hair_system_group'):
print 'group already exist'
else :
pm.group(em = True, n='hair_system_group' , w = True)
if pm.objExists('hair_ik_group'):
print 'group already exist'
else :
pm.group(em = True, n='hair_ik_group' , w = True)
if pm.objExists('hair_output_group'):
print 'group already exist'
else :
pm.group(em = True, n='hair_output_group' , w = True)
if pm.objExists('hair_joint_group'):
print 'group already exist'
else :
pm.group(em = True, n='hair_joint_group' , w = True)
'''
Parent object to existing group
'''
if pm.objExists('hair_system_group') :
pm.parent( 'hairSystem{0}'.format(seq_curve) , 'hair_system_group')
else :
print 'group not exist'
if pm.objExists('hair_ik_group'):
pm.parent( 'hair_{0}_ik'.format(seq_curve) , 'hair_ik_group' )
else :
print 'group not exist'
if pm.objExists('hair_output_group'):
pm.parent( 'hairSystem{0}OutputCurves'.format(seq_curve) , 'hair_output_group' )
else :
print 'group not exist'
if pm.objExists('hair_joint_group'):
pm.parent( 'hair_{0}_01_bind'.format( seq_curve ) , 'hair_joint_group' )
else :
print 'group not exist'
def dyn_curve_attr ( *args ) :
list_hair_curve = pm.ls(sl=True)
for item_hair_curve in list_hair_curve :
'''
Collect Data
'''
str_item_hair_curve = str(item_hair_curve)
allNum_curve = re.findall(r'\d+',str_item_hair_curve)
num_seq_curve = allNum_curve[0]
hair_joint_rel = pm.select( 'hair_{0}_01_bind'.format(num_seq_curve) )
last_jnt = pm.listRelatives( allDescendents=True , type = 'joint' )[0]
str_last_jnt = str(last_jnt)
allNum_joint = re.findall(r'\d+',str_last_jnt)
int_allNum_joint = int(allNum_joint[1])
floatFieldData_joint_size = pm.floatSliderGrp ( floatFieldEntry_joint_size , query = True, value = True)
floatFieldData_stretch_res = pm.floatSliderGrp ( floatFieldEntry_stretch_res , query = True, value = True)
floatFieldData_compress_res = pm.floatSliderGrp ( floatFieldEntry_compress_res , query = True, value = True)
floatFieldData_bend_res = pm.floatSliderGrp ( floatFieldEntry_bend_res , query = True, value = True)
floatFieldData_twist_res = pm.floatSliderGrp ( floatFieldEntry_twist_res , query = True, value = True)
floatFieldData_curve_att = pm.floatSliderGrp ( floatFieldEntry_curve_att , query = True, value = True)
floatFieldData_curve_att_damp = pm.floatSliderGrp ( floatFieldEntry_curve_att_damp , query = True, value = True)
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
'''
Method on changing SelfCollision of dynamic curve
'''
if checkBox_self_col == 0 :
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
pm.setAttr( curve_hair_sys + ".selfCollide", 0 )
elif checkBox_self_col == 1 :
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
pm.setAttr( curve_hair_sys + ".selfCollide", 1 )
'''
Method on changing Collision of dynamic curve
'''
if checkBox_col == 0 :
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
pm.setAttr( curve_hair_sys + ".collide", 0 )
elif checkBox_col == 1 :
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
pm.setAttr( curve_hair_sys + ".collide", 1 )
'''
Method on changing size of joint
'''
for i in range( 1 , int_allNum_joint + 1 ) :
if i < int_allNum_joint :
hair_joint_edit = 'hair_{0}_{1:02d}_bind'.format( num_seq_curve ,i )
elif i == int_allNum_joint :
hair_joint_edit = 'hair_{0}_{1:02d}_waste'.format( num_seq_curve ,i )
pm.setAttr( hair_joint_edit + '.radius' , floatFieldData_joint_size )
'''
Method on changing attribute of dynamic curve
'''
pm.setAttr( curve_hair_sys + '.stretchResistance' , floatFieldData_stretch_res )
pm.setAttr( curve_hair_sys + '.compressionResistance' , floatFieldData_compress_res )
pm.setAttr( curve_hair_sys + '.bendResistance' , floatFieldData_bend_res )
pm.setAttr( curve_hair_sys + '.twistResistance' , floatFieldData_twist_res )
pm.setAttr( curve_hair_sys + '.startCurveAttract' , floatFieldData_curve_att )
pm.setAttr( curve_hair_sys + '.attractionDamp' , floatFieldData_curve_att_damp )
def nucleus_name_changed ( *args ) :
print 'Nucleus name had changed to ' + nucleus_located
'''
locate nucleus
'''
global nucleus_located
nucleus_located = 'nucleus1'
if pm.objExists(nucleus_located) :
nucleus_located = pm.rename ( nucleus_located , 'nucleus1' )
else :
print 'nucleus1 not in the scene'
print 'Create nucleus1 or rename nucleus name back to nucleus1 and run again'
pm.scriptJob( killAll = True )
pm.scriptJob( e = [ 'NameChanged' , nucleus_name_changed ] , cu = True )
def dyn_nucleus_attr ( *args ) :
'''
Collect Data
'''
floatFieldData_gravity = pm.floatSliderGrp ( floatFieldEntry_gravity , query = True, value = True )
floatFieldData_gravityDirectionX = pm.floatSliderGrp ( floatFieldEntry_gravityDirectionX , query = True, value = True )
floatFieldData_gravityDirectionY = pm.floatSliderGrp ( floatFieldEntry_gravityDirectionY , query = True, value = True )
floatFieldData_gravityDirectionZ = pm.floatSliderGrp ( floatFieldEntry_gravityDirectionZ , query = True, value = True )
floatFieldData_airDensity = pm.floatSliderGrp ( floatFieldEntry_airDensity , query = True, value = True )
floatFieldData_windSpeed = pm.floatSliderGrp ( floatFieldEntry_windSpeed , query = True, value = True )
floatFieldData_windDirectionX = pm.floatSliderGrp ( floatFieldEntry_windDirectionX , query = True, value = True )
floatFieldData_windDirectionY = pm.floatSliderGrp ( floatFieldEntry_windDirectionY , query = True, value = True )
floatFieldData_windDirectionZ = pm.floatSliderGrp ( floatFieldEntry_windDirectionZ , query = True, value = True )
floatFieldData_windNoise = pm.floatSliderGrp ( floatFieldEntry_windNoise , query = True, value = True )
floatFieldData_maxCollisionIterations = pm.floatSliderGrp ( floatFieldEntry_maxCollisionIterations , query = True, value = True )
'''
Method on changing attribute of nucleus
'''
pm.setAttr( '{0}.gravity'.format(nucleus_located) , floatFieldData_gravity )
pm.setAttr( '{0}.gravityDirectionX'.format(nucleus_located) , floatFieldData_gravityDirectionX )
pm.setAttr( '{0}.gravityDirectionY'.format(nucleus_located) , floatFieldData_gravityDirectionY )
pm.setAttr( '{0}.gravityDirectionZ'.format(nucleus_located) , floatFieldData_gravityDirectionZ )
pm.setAttr( '{0}.airDensity'.format(nucleus_located) , floatFieldData_airDensity )
pm.setAttr( '{0}.windSpeed'.format(nucleus_located) , floatFieldData_windSpeed )
pm.setAttr( '{0}.windDirectionX'.format(nucleus_located) , floatFieldData_windDirectionX )
pm.setAttr( '{0}.windDirectionY'.format(nucleus_located) , floatFieldData_windDirectionY )
pm.setAttr( '{0}.windDirectionZ'.format(nucleus_located) , floatFieldData_windDirectionZ )
pm.setAttr( '{0}.windNoise'.format(nucleus_located) , floatFieldData_windNoise )
pm.setAttr( '{0}.maxCollisionIterations'.format(nucleus_located) , floatFieldData_maxCollisionIterations )
def dyn_nucleus_attr_default ( *args ) :
'''
Method on changing attribute of nucleus back to default
'''
pm.setAttr( '{0}.gravity'.format(nucleus_located) , 9.8 )
pm.setAttr( '{0}.gravityDirectionX'.format(nucleus_located) , 0 )
pm.setAttr( '{0}.gravityDirectionY'.format(nucleus_located) , 1 )
pm.setAttr( '{0}.gravityDirectionZ'.format(nucleus_located) , 0 )
pm.setAttr( '{0}.airDensity'.format(nucleus_located) , 1 )
pm.setAttr( '{0}.windSpeed'.format(nucleus_located) , 0 )
pm.setAttr( '{0}.windDirectionX'.format(nucleus_located) , 1 )
pm.setAttr( '{0}.windDirectionY'.format(nucleus_located) , 0 )
pm.setAttr( '{0}.windDirectionZ'.format(nucleus_located) , 0 )
pm.setAttr( '{0}.windNoise'.format(nucleus_located) , 0 )
pm.setAttr( '{0}.maxCollisionIterations'.format(nucleus_located) , 4 )
floatFieldEntry_gravity.setValue( 9.8 )
floatFieldEntry_gravityDirectionX.setValue( 0 )
floatFieldEntry_gravityDirectionY.setValue( 1 )
floatFieldEntry_gravityDirectionZ.setValue( 0 )
floatFieldEntry_airDensity.setValue( 1 )
floatFieldEntry_windSpeed.setValue( 0 )
floatFieldEntry_windDirectionX.setValue( 1 )
floatFieldEntry_windDirectionY.setValue( 0 )
floatFieldEntry_windDirectionZ.setValue( 0 )
floatFieldEntry_windNoise.setValue( 0 )
floatFieldEntry_maxCollisionIterations.setValue( 4 )
def dyn_curve_attr_rough_low (*args) :
list_hair_curve = pm.ls(sl=True)
for item_hair_curve in list_hair_curve :
'''
Collect Data
'''
str_item_hair_curve = str(item_hair_curve)
allNum_curve = re.findall(r'\d+',str_item_hair_curve)
num_seq_curve = allNum_curve[0]
hair_joint_rel = pm.select( 'hair_{0}_01_bind'.format(num_seq_curve) )
last_jnt = pm.listRelatives( allDescendents=True , type = 'joint' )[0]
str_last_jnt = str(last_jnt)
allNum_joint = re.findall(r'\d+',str_last_jnt)
int_allNum_joint = int(allNum_joint[1])
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
pm.setAttr( curve_hair_sys + ".selfCollide", 1 )
pm.setAttr( curve_hair_sys + ".collide", 1 )
pm.setAttr( curve_hair_sys + '.stretchResistance' , 100 )
pm.setAttr( curve_hair_sys + '.compressionResistance' , 70 )
pm.setAttr( curve_hair_sys + '.bendResistance' , 50 )
pm.setAttr( curve_hair_sys + '.twistResistance' , 80 )
pm.setAttr( curve_hair_sys + '.startCurveAttract' , 0.1 )
pm.setAttr( curve_hair_sys + '.attractionDamp' , 0.05 )
floatFieldEntry_stretch_res.setValue( 100 )
floatFieldEntry_compress_res.setValue( 70 )
floatFieldEntry_bend_res.setValue( 50 )
floatFieldEntry_twist_res.setValue( 80 )
floatFieldEntry_curve_att.setValue( 0.1 )
floatFieldEntry_curve_att_damp.setValue( 0.05 )
collision_dyn.setValue( 1 )
selfCollision_dyn.setValue( 1 )
def dyn_curve_attr_rough_medium (*args) :
list_hair_curve = pm.ls(sl=True)
for item_hair_curve in list_hair_curve :
'''
Collect Data
'''
str_item_hair_curve = str(item_hair_curve)
allNum_curve = re.findall(r'\d+',str_item_hair_curve)
num_seq_curve = allNum_curve[0]
hair_joint_rel = pm.select( 'hair_{0}_01_bind'.format(num_seq_curve) )
last_jnt = pm.listRelatives( allDescendents=True , type = 'joint' )[0]
str_last_jnt = str(last_jnt)
allNum_joint = re.findall(r'\d+',str_last_jnt)
int_allNum_joint = int(allNum_joint[1])
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
pm.setAttr( curve_hair_sys + ".selfCollide", 1 )
pm.setAttr( curve_hair_sys + ".collide", 1 )
pm.setAttr( curve_hair_sys + '.stretchResistance' , 120 )
pm.setAttr( curve_hair_sys + '.compressionResistance' , 100 )
pm.setAttr( curve_hair_sys + '.bendResistance' , 70 )
pm.setAttr( curve_hair_sys + '.twistResistance' , 120 )
pm.setAttr( curve_hair_sys + '.startCurveAttract' , 0.3 )
pm.setAttr( curve_hair_sys + '.attractionDamp' , 0.1 )
floatFieldEntry_stretch_res.setValue( 120 )
floatFieldEntry_compress_res.setValue( 100 )
floatFieldEntry_bend_res.setValue( 70 )
floatFieldEntry_twist_res.setValue( 120 )
floatFieldEntry_curve_att.setValue( 0.3 )
floatFieldEntry_curve_att_damp.setValue( 0.1 )
collision_dyn.setValue( 1 )
selfCollision_dyn.setValue( 1 )
def dyn_curve_attr_rough_high (*args) :
list_hair_curve = pm.ls(sl=True)
print list_hair_curve
for item_hair_curve in list_hair_curve :
'''
Collect Data
'''
str_item_hair_curve = str(item_hair_curve)
allNum_curve = re.findall(r'\d+',str_item_hair_curve)
num_seq_curve = allNum_curve[0]
hair_joint_rel = pm.select( 'hair_{0}_01_bind'.format(num_seq_curve) )
last_jnt = pm.listRelatives( allDescendents=True , type = 'joint' )[0]
str_last_jnt = str(last_jnt)
allNum_joint = re.findall(r'\d+',str_last_jnt)
int_allNum_joint = int(allNum_joint[1])
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
pm.setAttr( curve_hair_sys + ".selfCollide", 1 )
pm.setAttr( curve_hair_sys + ".collide", 1 )
dyn_curve_prop_stretch_res = pm.setAttr( curve_hair_sys + '.stretchResistance' , 145 )
dyn_curve_prop_compress_res = pm.setAttr( curve_hair_sys + '.compressionResistance' , 125 )
dyn_curve_prop_bend_res = pm.setAttr( curve_hair_sys + '.bendResistance' , 100 )
dyn_curve_prop_twist_res = pm.setAttr( curve_hair_sys + '.twistResistance' , 150 )
dyn_curve_prop_curve_att = pm.setAttr( curve_hair_sys + '.startCurveAttract' , 0.5 )
dyn_curve_prop_curve_att_damp = pm.setAttr( curve_hair_sys + '.attractionDamp' , 0.15 )
floatFieldEntry_stretch_res.setValue( 145 )
floatFieldEntry_compress_res.setValue( 125 )
floatFieldEntry_bend_res.setValue( 100 )
floatFieldEntry_twist_res.setValue( 150 )
floatFieldEntry_curve_att.setValue( 0.5 )
floatFieldEntry_curve_att_damp.setValue( 0.15 )
collision_dyn.setValue( 1 )
selfCollision_dyn.setValue( 1 )
'''
Window creation
'''
class window_creation :
def changing_properties( self , *args ) :
dyn_nucleus_prop_gravity = pm.getAttr('{0}.gravity'.format(nucleus_located))
dyn_nucleus_prop_gravityDirectionX = pm.getAttr('{0}.gravityDirectionX'.format(nucleus_located))
dyn_nucleus_prop_gravityDirectionY = pm.getAttr('{0}.gravityDirectionY'.format(nucleus_located))
dyn_nucleus_prop_gravityDirectionZ = pm.getAttr('{0}.gravityDirectionZ'.format(nucleus_located))
dyn_nucleus_prop_airDensity = pm.getAttr('{0}.airDensity'.format(nucleus_located))
dyn_nucleus_prop_windSpeed = pm.getAttr('{0}.windSpeed'.format(nucleus_located))
dyn_nucleus_prop_windDirectionX = pm.getAttr('{0}.windDirectionX'.format(nucleus_located))
dyn_nucleus_prop_windDirectionY = pm.getAttr('{0}.windDirectionY'.format(nucleus_located))
dyn_nucleus_prop_windDirectionZ = pm.getAttr('{0}.windDirectionZ'.format(nucleus_located))
dyn_nucleus_prop_windNoise = pm.getAttr('{0}.windNoise'.format(nucleus_located))
dyn_nucleus_prop_maxCollisionIterations = pm.getAttr('{0}.maxCollisionIterations'.format(nucleus_located))
self.floatFieldEntry_gravity.setValue( dyn_nucleus_prop_gravity )
self.floatFieldEntry_gravityDirectionX.setValue( dyn_nucleus_prop_gravityDirectionX )
self.floatFieldEntry_gravityDirectionY.setValue( dyn_nucleus_prop_gravityDirectionY )
self.floatFieldEntry_gravityDirectionZ.setValue( dyn_nucleus_prop_gravityDirectionZ )
self.floatFieldEntry_airDensity.setValue( dyn_nucleus_prop_airDensity )
self.floatFieldEntry_windSpeed.setValue( dyn_nucleus_prop_windSpeed )
self.floatFieldEntry_windDirectionX.setValue( dyn_nucleus_prop_windDirectionX )
self.floatFieldEntry_windDirectionY.setValue( dyn_nucleus_prop_windDirectionY )
self.floatFieldEntry_windDirectionZ.setValue( dyn_nucleus_prop_windDirectionZ )
self.floatFieldEntry_windNoise.setValue( dyn_nucleus_prop_windNoise )
self.floatFieldEntry_maxCollisionIterations.setValue( dyn_nucleus_prop_maxCollisionIterations )
'''
Collect data
'''
list_hair_curve = pm.ls(sl=True)
for item_hair_curve in list_hair_curve :
if len(list_hair_curve) > 0 :
first_item_hair_curve = list_hair_curve[0]
str_item_hair_curve = str(first_item_hair_curve)
allNum_curve = re.findall(r'\d+',str_item_hair_curve)
num_seq_curve = allNum_curve[0]
curve_hair_sys = 'hairSystemShape{0}'.format(num_seq_curve)
'''
set value for ui based on selection
'''
if item_hair_curve == 'hair_{0}_output_curve'.format(num_seq_curve) :
print ' '
print '-'*100
print first_item_hair_curve + ' is the first hair curve to show properties'
dyn_curve_prop_collision = pm.getAttr (curve_hair_sys + '.collide')
dyn_curve_prop_self_collision = pm.getAttr (curve_hair_sys + '.selfCollide')
dyn_curve_prop_stretch_res = pm.getAttr( curve_hair_sys + '.stretchResistance' )
dyn_curve_prop_compress_res = pm.getAttr( curve_hair_sys + '.compressionResistance' )
dyn_curve_prop_bend_res = pm.getAttr( curve_hair_sys + '.bendResistance' )
dyn_curve_prop_twist_res = pm.getAttr( curve_hair_sys + '.twistResistance' )
dyn_curve_prop_curve_att = pm.getAttr( curve_hair_sys + '.startCurveAttract' )
dyn_curve_prop_curve_att_damp = pm.getAttr( curve_hair_sys + '.attractionDamp' )
if dyn_curve_prop_collision == True :
collision_on_off = 1
else :
collision_on_off = 0
if dyn_curve_prop_self_collision == True :
selfCollision_on_off = 1
else :
selfCollision_on_off = 0
'''
show the value of properties
'''
print' '
print'-'*100
if collision_on_off == 1 :
print 'Collision is On'
else :
print 'Collision is Off'
if selfCollision_on_off == 1 :
print 'Self Collision is On'
else :
print 'Self Collision is Off'
print 'stretch resistance = {0} '.format(dyn_curve_prop_stretch_res)
print 'compress resistance = {0} '.format(dyn_curve_prop_compress_res)
print 'bend resistance = {0} '.format(dyn_curve_prop_bend_res)
print 'twist resistance = {0} '.format(dyn_curve_prop_twist_res)
print 'curve attraction = {0} '.format(dyn_curve_prop_curve_att)
print 'curve attraction damp = {0} '.format(dyn_curve_prop_curve_att_damp)
print'-'*100
print' '
self.floatFieldEntry_stretch_res.setValue( dyn_curve_prop_stretch_res )
self.floatFieldEntry_compress_res.setValue( dyn_curve_prop_compress_res )
self.floatFieldEntry_bend_res.setValue( dyn_curve_prop_bend_res )
self.floatFieldEntry_twist_res.setValue( dyn_curve_prop_twist_res )
self.floatFieldEntry_curve_att.setValue( dyn_curve_prop_curve_att )
self.floatFieldEntry_curve_att_damp.setValue( dyn_curve_prop_curve_att_damp )
self.collision_dyn.setValue( collision_on_off )
self.selfCollision_dyn.setValue( selfCollision_on_off )
else :
dyn_curve_prop_stretch_res = 0
dyn_curve_prop_compress_res = 0
dyn_curve_prop_bend_res = 0
dyn_curve_prop_twist_res = 0
dyn_curve_prop_curve_att = 0
dyn_curve_prop_curve_att_damp = 0
else :
print 'nothing selected or not output curve'
def __init__(self) :
self.ui_creation()
def ui_creation(self) :
if pm.window('hair_window' , exists = True ) :
pm.deleteUI('hair_window')
window = pm.window( 'hair_window' , title="HairRigging", iconName="SpeedHairRig", widthHeight=( 450,900 ) )
pm.columnLayout( )
pm.text(' ')
pm.text( 'Create Dynamic Hair Based on Curve' )
pm.text(' ')
pm.rowColumnLayout( nc=7, cw = [ (1,50),(2,40),(3,80),(4,70),(5,50),(6,60),(7,50) ] )
pm.radioCollection()
pm.radioButton(label = 'Base', editable = True, onCommand = button_base)
pm.radioButton(label = 'Tip', editable = True, onCommand = button_tip)
pm.radioButton(label = 'Both_End', editable = True, onCommand = button_both_end)
global intFieldName_num_joint
global intFieldEntry_num_joint
global intFieldName_seq
global intFieldEntry_seq
intFieldName_num_joint = pm.text( label= 'No_Joint :')
intFieldEntry_num_joint = pm.intField(intFieldName_num_joint, editable = True, value=0)
intFieldName_seq = pm.text( label= 'Sequence :')
intFieldEntry_seq = pm.intField(intFieldName_seq, editable = True, value=0)
pm.setParent('..')
pm.button( label="Create Hair Joint", width=400, command= hair_joint_multi )
pm.text(' ')
pm.setParent('..')
pm.columnLayout( )
pm.text('-'*100)
pm.text( 'Dynamic Curve Properties' )
pm.text(' ')
pm.rowColumnLayout( nc=3, cw = [ (1,50),(2,150),(3,150) ] )
pm.text(' ')
self.collision_dyn = pm.checkBox( label = 'Collision' , ofc = col_off , onc = col_on )
self.selfCollision_dyn = pm.checkBox( label = 'selfCollision' , ofc = self_col_off , onc = self_col_on )
global collision_dyn
global selfCollision_dyn
collision_dyn = self.collision_dyn
selfCollision_dyn = self.selfCollision_dyn
pm.setParent('..')
self.floatFieldEntry_joint_size = pm.floatSliderGrp ( label= 'Joint Size' , field= True , minValue = 0 , maxValue =200.0 , fieldMinValue =0 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_stretch_res = pm.floatSliderGrp ( label= 'Stretch Resistance' , field= True , minValue = 0 , maxValue =200.0 , fieldMinValue =0 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_compress_res = pm.floatSliderGrp ( label= 'Compression Resistance' , field= True , minValue = 0 , maxValue =200.0 , fieldMinValue =0 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_bend_res = pm.floatSliderGrp ( label= 'Bend Resistance' , field= True , minValue = 0 , maxValue =200.0 , fieldMinValue =0 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_twist_res = pm.floatSliderGrp ( label= 'Twist Resistance' , field= True , minValue = 0 , maxValue =200.0 , fieldMinValue =0 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_curve_att = pm.floatSliderGrp ( label= 'Start Curve Attraction' , field= True , minValue = 0 , maxValue =200.0 , fieldMinValue =0 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_curve_att_damp = pm.floatSliderGrp ( label= 'Atrraction Damp' , field= True , minValue = 0 , maxValue =200.0 , fieldMinValue =0 , fieldMaxValue = 200.0 , value= 0 , precision = 3 , step = 0.01 )
global floatFieldEntry_joint_size
global floatFieldEntry_stretch_res
global floatFieldEntry_compress_res
global floatFieldEntry_bend_res
global floatFieldEntry_twist_res
global floatFieldEntry_curve_att
global floatFieldEntry_curve_att_damp
floatFieldEntry_joint_size = self.floatFieldEntry_joint_size
floatFieldEntry_stretch_res = self.floatFieldEntry_stretch_res
floatFieldEntry_compress_res = self.floatFieldEntry_compress_res
floatFieldEntry_bend_res = self.floatFieldEntry_bend_res
floatFieldEntry_twist_res = self.floatFieldEntry_twist_res
floatFieldEntry_curve_att = self.floatFieldEntry_curve_att
floatFieldEntry_curve_att_damp = self.floatFieldEntry_curve_att_damp
pm.button( label="Change Attritbute", width=400, command = dyn_curve_attr )
pm.separator( h=5, style='none')
pm.button( label="Low Resistance", width=400, command = dyn_curve_attr_rough_low )
pm.button( label="Medium Resistance", width=400, command = dyn_curve_attr_rough_medium )
pm.button( label="High Resistance", width=400, command = dyn_curve_attr_rough_high )
pm.separator( h=10, style='none')
pm.text('-'*100)
pm.text( 'Nucleus Properties' )
pm.text(' ')
self.floatFieldEntry_gravity = pm.floatSliderGrp ( label= 'Gravity' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 9.8 )
self.floatFieldEntry_gravityDirectionX = pm.floatSliderGrp ( label= 'Gravity DirectionX' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_gravityDirectionY = pm.floatSliderGrp ( label= 'Gravity DirectionY' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 1 )
self.floatFieldEntry_gravityDirectionZ = pm.floatSliderGrp ( label= 'Gravity DirectionZ' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_airDensity = pm.floatSliderGrp ( label= 'Air Density' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 1 )
self.floatFieldEntry_windSpeed = pm.floatSliderGrp ( label= 'Wind Speed' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_windDirectionX = pm.floatSliderGrp ( label= 'Wind Direction X' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 1 )
self.floatFieldEntry_windDirectionY = pm.floatSliderGrp ( label= 'Wind Direction Y' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_windDirectionZ = pm.floatSliderGrp ( label= 'Wind Direction Z' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_windNoise = pm.floatSliderGrp ( label= 'Wind Noise' , field= True , minValue = 200 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 0 )
self.floatFieldEntry_maxCollisionIterations = pm.floatSliderGrp ( label= 'Max Collision Iterations' , field= True , minValue = 0 , maxValue =200.0 , fieldMinValue =200 , fieldMaxValue = 200.0 , value= 4 )
global floatFieldEntry_gravity
global floatFieldEntry_gravityDirectionX
global floatFieldEntry_gravityDirectionY
global floatFieldEntry_gravityDirectionZ
global floatFieldEntry_airDensity
global floatFieldEntry_windSpeed
global floatFieldEntry_windDirectionX
global floatFieldEntry_windDirectionY
global floatFieldEntry_windDirectionZ
global floatFieldEntry_windNoise
global floatFieldEntry_maxCollisionIterations
floatFieldEntry_gravity = self.floatFieldEntry_gravity
floatFieldEntry_gravityDirectionX = self.floatFieldEntry_gravityDirectionX
floatFieldEntry_gravityDirectionY = self.floatFieldEntry_gravityDirectionY
floatFieldEntry_gravityDirectionZ = self.floatFieldEntry_gravityDirectionZ
floatFieldEntry_airDensity = self.floatFieldEntry_airDensity
floatFieldEntry_windSpeed = self.floatFieldEntry_windSpeed
floatFieldEntry_windDirectionX = self.floatFieldEntry_windDirectionX
floatFieldEntry_windDirectionY = self.floatFieldEntry_windDirectionY
floatFieldEntry_windDirectionZ = self.floatFieldEntry_windDirectionZ
floatFieldEntry_windNoise = self.floatFieldEntry_windNoise
floatFieldEntry_maxCollisionIterations = self.floatFieldEntry_maxCollisionIterations
pm.button( label="Change Attritbute", width=400, command= dyn_nucleus_attr )
pm.button( label="Default", width=400, command= dyn_nucleus_attr_default )
pm.scriptJob(e = [ 'SelectionChanged' , self.changing_properties ], cu = True, parent= 'hair_window')
window.show()
window_creation()
Github web address for hair rig script
https://gist.github.com/williamyap912/9b770550c2eca58a4b877ba8abe0191f

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s