Código para crear atributos y conexiones

Moderadores: David, Tutores

Responder
ikerJ
Miembro Vip
Miembro Vip
Mensajes: 212
Registrado: Mar Jun 15, 2010 9:21 pm

Código para crear atributos y conexiones

Mensaje por ikerJ »

Ahí va el código que uso para crear 'custom attributes' en la huella del pie y conectarlos a las rotaciones y comportamientos de los huesos. Necesitaréis adaptarlo a vuestras nomenclaturas, y a pesar de que no es super elegante, funciona.

Código: Seleccionar todo

/*
__MXSDOC__
[TITLE]
kg_Leg_IK_ca

[DESCRIPTION]
Adds CA's to the IK system and ties everything up.

[USAGE]
Run script

[CREATION INFO]
Author:Iker J. de los Mozos
E-mail:iker@kandor.int
Company:Kandor Graphics
Last Updated: MArch 19, 2009

[Category]
Rigging

[KEYWORDS]
Rigging

[VERSION HISTORY]
V1.0 -- First commented version. Added 'charName' for the namings. No object names used, only variables.
V1.1 -- Added Layer Distribution.
V1.2 -- Added Snap FK/IK.
V1.3 -- New Naming Convention.

[SEE ALSO]
kg_Leg_IK

__END__
*/


addModifier lFootIK (EmptyModifier())
	
 iklegCTRL_CA = attributes L_ik_leg_xtra
(
	parameters main rollout:params
	(
		blending type:#float ui:blending default:1.0
		autostretch type:#float ui:autostretch default:1.0		
		stretchFactor 	type:#float ui:stretchFactor default:0.0	
		knee type:#float ui:knee default:0.0
	)
	
	rollout params "Leg Controls"
	(
		
		spinner blending "FK :: IK " type:#float Range:[0.0,1.0,1.0] Width:90 align:#right
		spinner autostretch "autoStretch " type:#float Range:[0.0,1.0,1.0] Width:107 align:#right
		spinner stretchFactor "stretchFactor " type:#float Range:[-3.0,3.0,0.0] Width:107 align:#right
		spinner knee "knee angle " type:#float Range:[-360.0, 360.0, 0.0] Width: 105 align:#right
		button snapFK "snap"		
		
		on snapFK pressed do with undo on
		(
			local charName = (filterstring selection[1].name "_")[2]
			local rUppArm = getNodebyName ("C_" + charName + "_Bone_LMM_Leg-Thigh_BA")
			local rForArm = getNodebyName ("C_" + charName + "_Bone_LMM_Leg-Calf_BA")
			local rHand = getNodebyName ("C_" + charName + "_Bone_LMM_Leg-Foot_BA")
			local rHandIK = getNodebyName ("C_" + charName + "_Ctrl_LMM_Leg-FootIK_SA")
			local rElbowIK = getNodebyName ("C_" + charName + "_Ctrl_LMM_Leg-KneeIK_SA")
			local elbowMatch = getNodebyName ("C_" + charName + "_Rig_LMM_Leg-KneeMatch_DH")
			local shoulder_ik = getNodebyName ("C_" + charName + "_Rig_LMM_Leg-ThighIK_DH")
			local elbow_ik = getNodebyName ("C_" + charName + "_Rig_LMM_Leg-CalfIK_DH")
			local theSnap = getNodebyName ("C_" + charName + "_Rig_LMM_Leg-FootSnap_DH")
			local theOrient = getNodebyName ("C_" + charName + "_Rig_LMM_Leg-FootBallOrient_DH")
			
			case rHandIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#blending].value of
			(
				0.0:	
					(
						rHandIK.pos = theSnap.pos
						 in coordsys theSnap rHandIK.rotation = eulerangles 0 0 0
						rElbowIK.position = elbowMatch.position
						
						rUppArm.modifiers[#Attribute_Holder].ca_xtra[#scaling].value = 0
						rForArm.modifiers[#Attribute_Holder].ca_xtra[#scaling].value = 0							
						
						rHandIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#blending].value = 1
						rHandIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#autoStretch].value = 1
					)
					
				1.0:	
					(
						upperFactor = (distance rForArm rUppArm)
						lowerFactor = (distance rHand rForArm)
				
						rHandIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#blending].value = 0							
				
						in coordsys shoulder_ik rUppArm.rotation = eulerangles 0 0 0
						in coordsys elbow_ik rForArm.rotation = eulerangles 0 0 0 
						in coordsys theOrient rHand.rotation = eulerangles 0 0 0 
							
						rHandIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#autoStretch].value = 0

						newUpperFactor = (distance rForArm rUppArm)
						newlowerFactor = (distance rHand rForArm)
				
						rUppArm.modifiers[#Attribute_Holder].ca_xtra[#scaling].value = (upperfactor/newUpperFactor) - 1
						rForArm.modifiers[#Attribute_Holder].ca_xtra[#scaling].value = (lowerfactor/newLowerFactor)	- 1				
					)
			)			
		)	
	)
	
	parameters footCTRL rollout:footCtrl
	(
		footRoll type:#float ui:footRoll default:0.0
		tilt type:#float ui:tilt default:0.0
		toeRoll type:#float ui:toeRoll default:0.0
		toeSlide type:#float ui:toeSlide default:0.0
		ballRoll type:#float ui:ballRoll default:0.0
		heelRoll type:#float ui:heelRoll default:0.0
		toesV type:#float ui:toesV default:0.0
		toesH type:#float ui:toesH default:0.0
	)

	rollout footCtrl "Foot Controls"
	(
		spinner footRoll "foot :: Roll " type:#float Range:[-90.0,180.0,0.0] Width:90 align:#right
		spinner tilt "foot :: Tilt " type:#float Range:[-90.0,90,0.0] Width:107 align:#right
		spinner toeSlide "foot :: Slide " type:#float Range:[-180.0,180.0,0.0] Width: 105 align:#right
		spinner heelRoll "heel :: Roll " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
		spinner ballRoll "ball ::Roll " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
		spinner toeRoll "toe :: Roll " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
		spinner toesV "toes:: Vert " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
		spinner toesH "toes :: Horz " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
	)
)

custAttributes.add lFootIK.attribute_holder iklegCTRL_CA

/* foot controls*/

paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#tilt]  lFootTiltIn.rotation.controller[#X_Rotation] "if tilt<0 then (degToRad tilt) else 0"
paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#tilt] lFootTiltOut.rotation.controller[#X_Rotation] "if tilt>0 then (degToRad tilt) else 0"
paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#toeRoll] footToes.rotation.controller.animation.controller[#Z_Rotation] "degToRad toeRoll"
paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#toeSlide] lFootSlide.rotation.controller.animation.controller[#Y_Rotation] "degToRad toeSlide"
paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#ballRoll] footBall.rotation.controller.animation.controller[#Z_Rotation] "degToRad ballRoll"
paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#heelRoll] footSole.rotation.controller.animation.controller[#Z_Rotation] "degToRad heelRoll"
paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#toesV] IKBall.rotation.controller.animation.controller[#Z_Rotation] "degToRad toesV"
paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#toesH] IKBall.rotation.controller.animation.controller[#Y_Rotation] "degToRad toesH"

/* foot Roll */

footRoll = lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#footRoll]
footRoll.controller = Bezier_Float()

 --local ballLimit = charConfig[#ballLimit]  

ballLimit = 60 -- muerte -- 20 enfermera -- 34 vieja
ballMult = 1
toeMult = 1
ballMult2 = 1

Expressions = #("if footRoll < 0 then (degToRad footRoll) else 0","if footRoll < 0 then 0 else (if (footRoll*ballMult) < limit then (degToRad footRoll*ballMult) else (degToRad (limit-(footRoll*ballMult-limit)*ballMult2)))", "if footRoll > (limit/ballMult) then degToRad((footRoll-limit/ballMult)*toeMult) else 0")

theBones = #(
         footSole,
         footBall,
		footToes
      )

      theSubs = for o in theBones collect o[3][2][#Wire][#Z_Rotation]

      for i=1 to theBones.count do
      (
         theSubs[i].controller = float_script()
      )

      theCnts = for s in theSubs collect s.controller

      theCnts[1].addTarget "footRoll" footRoll
      theCnts[1].setExpression expressions[1]

      theCnts[2].addTarget "footRoll" footRoll
      theCnts[2].addConstant "limit" ballLimit
      theCnts[2].addConstant "ballMult" ballMult
      theCnts[2].addConstant "ballMult2" ballMult2
      theCnts[2].setExpression expressions[2]

      theCnts[3].addTarget "footRoll" footRoll
      theCnts[3].addConstant "limit" ballLimit
      theCnts[3].addConstant "ballMult" ballMult
      theCnts[3].addConstant "toeMult" toeMult
      theCnts[3].setExpression expressions[3]

/********************************/
-- AUTOSTRETCH

paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#autostretch] knee_ik.transform.controller.FK_Sub_Control.controller.Position.controller[4][2] "autostretch"
paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#autostretch] foot_ik.transform.controller.FK_Sub_Control.controller.Position.controller[4][2] "autostretch"

-- StretchFactor
lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#stretchFactor].controller = Bezier_Float()

-- in FK points

	-- creates Orientation Constraints

	lThigh.rotation.controller.Available.controller = Orientation_Constraint ()
	lThigh.rotation.controller[5].controller.appendTarget thigh_ik 100

	lCalf.rotation.controller.Available.controller = Orientation_Constraint ()
	lCalf.rotation.controller[5].controller.appendTarget knee_ik 100

	lFoot.rotation.controller.Available.controller = Orientation_Constraint ()
	lFoot.rotation.controller[5].controller.appendTarget IKHeel 100

	lToes.rotation.controller.Available.controller = Orientation_Constraint ()
	lToes.rotation.controller[5].controller.appendTarget IKBall 100

-- BLENDING

	paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#blending] lThigh.rotation.controller[7][5] "blending"
	paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#blending] lCalf.rotation.controller[7][5] "blending"
	paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#blending] lFoot.rotation.controller[7][5] "blending"
	paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#blending] lToes.rotation.controller[7][5] "blending"

	-- create scaling tracks for autoSstretch in the bones

	lCalf.pos.controller.Zero.controller.X_Position.controller = float_list ()
	lCalf.pos.controller.Zero.controller.X_Position.controller.Available.controller = float_script ()

	lCalf.pos.controller.Zero.controller.X_Position.controller[2].controller.addConstant "ab" (distance thigh_ik knee_ik)
	lCalf.pos.controller.Zero.controller.X_Position.controller[2].controller.addConstant "bc" (distance foot_ik knee_ik)
	lCalf.pos.controller.Zero.controller.X_Position.controller[2].controller.addTarget "d" leg_expose_ik.distance.controller
	lCalf.pos.controller.Zero.controller.X_Position.controller[2].controller.script = "if d > (ab + bc) then (d - (ab + bc))/2 else 0"

	lFoot.pos.controller.Zero.controller.X_Position.controller = float_list ()
	lFoot.pos.controller.Zero.controller.X_Position.controller.Available.controller = float_script ()

	lFoot.pos.controller.Zero.controller.X_Position.controller[2].controller.addConstant "ab" (distance thigh_ik knee_ik)
	lFoot.pos.controller.Zero.controller.X_Position.controller[2].controller.addConstant "bc" (distance foot_ik knee_ik)
	lFoot.pos.controller.Zero.controller.X_Position.controller[2].controller.addTarget "d" leg_expose_ik.distance.controller
	lFoot.pos.controller.Zero.controller.X_Position.controller[2].controller.script = "if d > (ab + bc) then (d - (ab + bc))/2 else 0"

	-- connects autoScale in bones

	paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#autostretch] lCalf.position.controller[1][1][4][2] "autostretch"
	paramWire.connect lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#autostretch] lFoot.position.controller[1][1][4][2] "autostretch"
	
-- KNEE

	lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#knee].controller = Bezier_Float()
	lLegSolver.transform.controller.swivelAngle.controller = lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra[#knee].controller = Linear_Float()
	lFootIK.modifiers[#Attribute_Holder].L_ik_leg_xtra.knee.controller = l_ankle.rotation.controller[2].controller[1].controller
	
-- Toes offset 

	

-- $R_Arm_Wrist__SA.parent = $R_Arm_HandIK__SA
-- poslist $R_Arm_Wrist__SA
-- rotlist  $R_Arm_Wrist__SA

-- $R_Arm_Wrist__SA.rotation.controller[2].rotation.controller[1].controller = r_wrist.rotation.controller[2].controller[1].controller

-- posList $R_Arm_ElbowIK__SA
-- rotList $R_Arm_ElbowIK__SA

-- elbowMatch = point pos:$R_Arm_ElbowIK__SA.pos box:on cross:off axistripod:off size:2.0 name:"R_Arm_ElbowMatch__DH"
-- elbowMatch.parent = $R_Arm_Upperarm__BA

/********************* RIGHT SIDE ***************************/

addModifier rFootIK (EmptyModifier())
	
 r_iklegCTRL_CA = attributes R_ik_leg_xtra
(
	parameters main rollout:params
	(
		blending type:#float ui:blending default:1.0
		autostretch type:#float ui:autostretch default:1.0		
		stretchFactor type:#float ui:stretchFactor default:0.0		
		knee type:#float ui:knee default:0.0
	)
	
	rollout params "Leg Controls"
	(
		
		spinner blending "FK :: IK " type:#float Range:[0.0,1.0,1.0] Width:90 align:#right
		spinner autostretch "autoStretch " type:#float Range:[0.0,1.0,1.0] Width:107 align:#right
		spinner stretchFactor "stretchFactor " type:#float Range:[-3.0,3.0,0.0] Width:107 align:#right
		spinner knee "knee angle " type:#float Range:[-360.0, 360.0, 0.0] Width: 105 align:#right
		button snapFK "snap"		
		
		on snapFK pressed do with undo on
		(
			local charName = (filterstring selection[1].name "_")[2]
			local rUppArm = getNodebyName ("C_" + charName + "_Bone_RMM_Leg-Thigh_BA")
			local rForArm = getNodebyName ("C_" + charName + "_Bone_RMM_Leg-Calf_BA")
			local rHand = getNodebyName ("C_" + charName + "_Bone_RMM_Leg-Foot_BA")
			local rHandIK = getNodebyName ("C_" + charName + "_Ctrl_RMM_Leg-FootIK_SA")
			local rElbowIK = getNodebyName ("C_" + charName + "_Ctrl_RMM_Leg-KneeIK_SA")
			local elbowMatch = getNodebyName ("C_" + charName + "_Rig_RMM_Leg-KneeMatch_DH")
			local shoulder_ik = getNodebyName ("C_" + charName + "_Rig_RMM_Leg-ThighIK_DH")
			local elbow_ik = getNodebyName ("C_" + charName + "_Rig_RMM_Leg-CalfIK_DH")
			local theSnap = getNodebyName ("C_" + charName + "_Rig_RMM_Leg-FootSnap_DH")
			local theOrient = getNodebyName ("C_" + charName + "_Rig_RMM_Leg-FootBallOrient_DH")

			case rHandIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#blending].value of
			(
				0.0:	(
							rHandIK.pos = theSnap.pos
							 in coordsys theSnap rHandIK.rotation = eulerangles 0 0 0
							rElbowIK.position = elbowMatch.position
							
							rUppArm.modifiers[#Attribute_Holder].ca_xtra[#scaling].value = 0
							rForArm.modifiers[#Attribute_Holder].ca_xtra[#scaling].value = 0							
							
							rHandIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#blending].value = 1
							rHandIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#autoStretch].value = 1
						)
					
				1.0:	(
							upperFactor = (distance rForArm rUppArm)
							lowerFactor = (distance rHand rForArm)
					
							rHandIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#blending].value = 0							
					
							in coordsys shoulder_ik rUppArm.rotation = eulerangles 0 0 0
							in coordsys elbow_ik rForArm.rotation = eulerangles 0 0 0 
							in coordsys theOrient rHand.rotation = eulerangles 0 0 0 
								
							rHandIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#autoStretch].value = 0

							newUpperFactor = (distance rForArm rUppArm)
							newlowerFactor = (distance rHand rForArm)
					
							rUppArm.modifiers[#Attribute_Holder].ca_xtra[#scaling].value = (upperfactor/newUpperFactor) - 1
							rForArm.modifiers[#Attribute_Holder].ca_xtra[#scaling].value = (lowerfactor/newLowerFactor)	- 1				
						)
			)			
		)					

	)	
	
	parameters footCTRL rollout:footCtrl
	(
		footRoll type:#float ui:footRoll default:0.0
		tilt type:#float ui:tilt default:0.0
		toeRoll type:#float ui:toeRoll default:0.0
		toeSlide type:#float ui:toeSlide default:0.0
		ballRoll type:#float ui:ballRoll default:0.0
		heelRoll type:#float ui:heelRoll default:0.0
		toesV type:#float ui:toesV default:0.0
		toesH type:#float ui:toesH default:0.0
	)

	rollout footCtrl "Foot Controls"
	(
		spinner footRoll "foot :: Roll " type:#float Range:[-90.0,180.0,0.0] Width:90 align:#right
		spinner tilt "foot :: Tilt " type:#float Range:[-90.0,90,0.0] Width:107 align:#right
		spinner toeSlide "foot :: Slide " type:#float Range:[-180.0,180,0.0] Width: 105 align:#right
		spinner heelRoll "heel :: Roll " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
		spinner ballRoll "ball ::Roll " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
		spinner toeRoll "toe :: Roll " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
		spinner toesV "toes:: Vert " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
		spinner toesH "toes :: Horz " type:#float Range:[-90.0,90,0.0] Width: 105 align:#right
	)
)

custAttributes.add rFootIK.attribute_holder r_iklegCTRL_CA

/* foot controls*/

paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#tilt]  rFootTiltIn.rotation.controller[#X_Rotation] "if tilt<0 then -(degToRad tilt) else 0"
paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#tilt] rFootTiltOut.rotation.controller[#X_Rotation] "if tilt>0 then -(degToRad tilt) else 0"
paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#toeRoll] r_footToes.rotation.controller.animation.controller[#Z_Rotation] "degToRad toeRoll"
paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#toeSlide] rFootSlide.rotation.controller.animation.controller[#Y_Rotation] "degToRad toeSlide"
paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#ballRoll] r_footBall.rotation.controller.animation.controller[#Z_Rotation] "degToRad ballRoll"
paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#heelRoll] r_footSole.rotation.controller.animation.controller[#Z_Rotation] "degToRad heelRoll"
paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#toesV] r_IKBall.rotation.controller.animation.controller[#Z_Rotation] "degToRad toesV"
paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#toesH] r_IKBall.rotation.controller.animation.controller[#Y_Rotation] "degToRad toesH"

/* foot Roll */

footRoll = rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#footRoll]
footRoll.controller = Bezier_Float()

 --local ballLimit = charConfig[#ballLimit]  

ballLimit = 60
ballMult = 1
toeMult = 1
ballMult2 = 1

Expressions = #("if footRoll < 0 then (degToRad footRoll) else 0","if footRoll < 0 then 0 else (if (footRoll*ballMult) < limit then (degToRad footRoll*ballMult) else (degToRad (limit-(footRoll*ballMult-limit)*ballMult2)))", "if footRoll > (limit/ballMult) then degToRad((footRoll-limit/ballMult)*toeMult) else 0")

theBones = #(
         r_footSole,
         r_footBall,
		r_footToes
      )

      theSubs = for o in theBones collect o[3][2][#Wire][#Z_Rotation]

      for i=1 to theBones.count do
      (
         theSubs[i].controller = float_script()
      )

      theCnts = for s in theSubs collect s.controller

      theCnts[1].addTarget "footRoll" footRoll
      theCnts[1].setExpression expressions[1]

      theCnts[2].addTarget "footRoll" footRoll
      theCnts[2].addConstant "limit" ballLimit
      theCnts[2].addConstant "ballMult" ballMult
      theCnts[2].addConstant "ballMult2" ballMult2
      theCnts[2].setExpression expressions[2]

      theCnts[3].addTarget "footRoll" footRoll
      theCnts[3].addConstant "limit" ballLimit
      theCnts[3].addConstant "ballMult" ballMult
      theCnts[3].addConstant "toeMult" toeMult
      theCnts[3].setExpression expressions[3]

/********************************/
-- AUTOSTRETCH

paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#autostretch] r_Knee_ik.transform.controller.FK_Sub_Control.controller.Position.controller[4][2] "autostretch"
paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#autostretch] r_Foot_ik.transform.controller.FK_Sub_Control.controller.Position.controller[4][2] "autostretch"

-- StretchFactor
rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#stretchFactor].controller = Bezier_Float()

-- in FK points

	-- creates Orientation Constraints

	rThigh.rotation.controller.Available.controller = Orientation_Constraint ()
	rThigh.rotation.controller[3].controller.appendTarget r_thigh_ik 100

	rCalf.rotation.controller.Available.controller = Orientation_Constraint ()
	rCalf.rotation.controller[3].controller.appendTarget r_knee_ik 100

	rFoot.rotation.controller.Available.controller = Orientation_Constraint ()
	rFoot.rotation.controller[3].controller.appendTarget r_IKHeel 100

	rToes.rotation.controller.Available.controller = Orientation_Constraint ()
	rToes.rotation.controller[3].controller.appendTarget r_IKBall 100

-- BLENDING

	paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#blending] rThigh.rotation.controller[5][3] "blending"
	paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#blending] rCalf.rotation.controller[5][3] "blending"
	paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#blending] rFoot.rotation.controller[5][3] "blending"
	paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#blending] rToes.rotation.controller[5][3] "blending"

	-- create scaling tracks for autoSstretch in the bones

	rCalf.pos.controller.Zero.controller.X_Position.controller = float_list ()
	rCalf.pos.controller.Zero.controller.X_Position.controller.Available.controller = float_script ()

	rCalf.pos.controller.Zero.controller.X_Position.controller[2].controller.addConstant "ab" (distance thigh_ik knee_ik)
	rCalf.pos.controller.Zero.controller.X_Position.controller[2].controller.addConstant "bc" (distance foot_ik knee_ik)
	rCalf.pos.controller.Zero.controller.X_Position.controller[2].controller.addTarget "d" r_leg_expose_ik.distance.controller
	rCalf.pos.controller.Zero.controller.X_Position.controller[2].controller.script = "if d > (ab + bc) then (d - (ab + bc))/2 else 0"

	rFoot.pos.controller.Zero.controller.X_Position.controller = float_list ()
	rFoot.pos.controller.Zero.controller.X_Position.controller.Available.controller = float_script ()

	rFoot.pos.controller.Zero.controller.X_Position.controller[2].controller.addConstant "ab" (distance thigh_ik knee_ik)
	rFoot.pos.controller.Zero.controller.X_Position.controller[2].controller.addConstant "bc" (distance foot_ik knee_ik)
	rFoot.pos.controller.Zero.controller.X_Position.controller[2].controller.addTarget "d" r_leg_expose_ik.distance.controller
	rFoot.pos.controller.Zero.controller.X_Position.controller[2].controller.script = "if d > (ab + bc) then (d - (ab + bc))/2 else 0"

	-- connects autoScale in bones

	paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#autostretch] rCalf.position.controller[1][1][4][2] "autostretch"
	paramWire.connect rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#autostretch] rFoot.position.controller[1][1][4][2] "autostretch"

-- knee

	rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#knee].controller = Bezier_Float()
	rLegSolver.transform.controller.swivelAngle.controller = rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra[#knee].controller = Linear_Float()
	rFootIK.modifiers[#Attribute_Holder].R_ik_leg_xtra.knee.controller = r_ankle.rotation.controller[2].controller[1].controller

-- Current Layer Zero -----------------------------------------------
	layerZero = layerManager.getLayerFromName "0"
	layerZero.current = true
-------------------------------------------------------------------------

-- this is a temporary solution for matching FK and IK before manipulating the snaps, so there is no offseting when matching :-D

kneeMatch.position = lkneeIK.position
r_kneeMatch.position = rKneeIK.position




Responder

Volver a “Convocatoria Abril 2012”