#-------------------------------------------------------------------------------
# Name:        YJ_Shoulder_Rig
# Purpose:
#
# Author:      YangJie
#
# Created:     12/07/2014
# Copyright:   (c) YangJie 2014
# Email:        691633493@
#-------------------------------------------------------------------------------
from YJ_Rig_Pub import*
from YJ_IK_Rig import*
from YJ_CreateRCIK_Rig_P import*

L_Shloud_Jnt_List = YJ_Load_List('L_Shloud_Jnt_List.pkl')
R_Shloud_Jnt_List = YJ_GetMir_List(L_Shloud_Jnt_List)

def YJ_Shoulder_Rig(NamePre):
    L_Shoulder_Ctrl_Lis = YJ_Shoulder_Jud_Rig("L",L_Shloud_Jnt_List)
    R_Shoulder_Ctrl_Lis = YJ_Shoulder_Jud_Rig("R",R_Shloud_Jnt_List)

#NamePre,Shloud_Jnt_List = "R",R_Shloud_Jnt_List
def YJ_Shoulder_Jud_Rig(NamePre,Shloud_Jnt_List):
    ZeroCreate = YJRigZeroGrp([Shloud_Jnt_List[0]])
    parent(ZeroCreate,w=True )
    Shoulder_Grp = rename(ZeroCreate[0],NamePre + '_Shoulder_Grp' )
    Shoulder_List = YJ_DuplicateJnt(Shloud_Jnt_List,'jnt','RCIK')
    ConstrnList = YJ_SetParentConstraint(Shoulder_List,Shloud_Jnt_List)
    Shoulder_Ro,Shoulder_Tran,IK_LocEnd,RC_Grp = YJ_Create_Shoulder_IK(Shoulder_List,Shloud_Jnt_List,NamePre)
    Shoulder_anim_Lis = [Shoulder_Ro] + [Shoulder_Tran]
    YJ_Clean_Shoulder_Layer(RC_Grp,Shoulder_Ro,Shoulder_Tran,IK_LocEnd)
    YJ_Scale_Shape(Shoulder_anim_Lis,0.1)
    return Shoulder_anim_Lis

#JntLis = Shoulder_List

def YJ_Create_Shoulder_IK(JntLis,Shloud_Jnt_List,NamePre):
    RC_Grp,IK_LocEnd = YJ_CreateRC_IK_Rig(JntLis)
    Shoulder_Ctrl_Lis = YJ_DuplicateJnt(Shloud_Jnt_List,'jnt','anim')
    Shoulder_Ro = rename(Shoulder_Ctrl_Lis[0],NamePre + '_Shoulder_Ro_anim' )
    Shoulder_Tran = rename(Shoulder_Ctrl_Lis[-1],NamePre + '_Shoulder_T_anim' )
    Zero_Shoulder_Ro = YJRigZeroGrp([Shoulder_Ro])
    Zero_Shoulder_Tran = YJRigZeroGrp([Shoulder_Tran])
    YJ_Shlouder_Shape(Shoulder_Ro,Shoulder_Tran)

    return Shoulder_Ro,Shoulder_Tran,IK_LocEnd,RC_Grp


def YJ_Shlouder_Shape(Shoulder_Ro,Shoulder_Tran):
    YJ_Creat_Ctrl("Cur10","CruveRo")
    YJ_Parent_Shape("CruveRo",Shoulder_Ro,0,0)
    setAttr (Shoulder_Ro + ".drawStyle",2)

    YJ_Creat_Ctrl("Cur13","CruveTran")
    YJ_Parent_Shape("CruveTran",Shoulder_Tran,0,0)
    setAttr (Shoulder_Tran + ".drawStyle",2)

def YJ_Clean_Shoulder_Layer(RC_Grp,Shoulder_Ro,Shoulder_Tran,IK_LocEnd):
    YJ_Try_Parent(RC_Grp,Shoulder_Ro)
    YJ_Try_Parent(IK_LocEnd,Shoulder_Tran)