<s> from kraken . core . maths import Vec3 <EOL> from kraken . core . maths . xfo import Xfo <EOL> from kraken . core . objects . components . base_example_component import BaseExampleComponent <EOL> from kraken . core . objects . attributes . attribute_group import AttributeGroup <EOL> from kraken . core . objects . attributes . bool_attribute import BoolAttribute <EOL> from kraken . core . objects . attributes . string_attribute import StringAttribute <EOL> from kraken . core . objects . constraints . pose_constraint import PoseConstraint <EOL> from kraken . core . objects . component_group import ComponentGroup <EOL> from kraken . core . objects . hierarchy_group import HierarchyGroup <EOL> from kraken . core . objects . locator import Locator <EOL> from kraken . core . objects . joint import Joint <EOL> from kraken . core . objects . ctrlSpace import CtrlSpace <EOL> from kraken . core . objects . control import Control <EOL> from kraken . core . objects . operators . kl_operator import KLOperator <EOL> from kraken . core . profiler import Profiler <EOL> from kraken . helpers . utility_methods import logHierarchy <EOL> class HeadComponent ( BaseExampleComponent ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name = '<STR_LIT>' , parent = None ) : <EOL> super ( HeadComponent , self ) . __init__ ( name , parent ) <EOL> self . headBaseInputTgt = self . createInput ( '<STR_LIT>' , dataType = '<STR_LIT>' , parent = self . inputHrcGrp ) . getTarget ( ) <EOL> self . headOutputTgt = self . createOutput ( '<STR_LIT>' , dataType = '<STR_LIT>' , parent = self . outputHrcGrp ) . getTarget ( ) <EOL> self . jawOutputTgt = self . createOutput ( '<STR_LIT>' , dataType = '<STR_LIT>' , parent = self . outputHrcGrp ) . getTarget ( ) <EOL> self . eyeLOutputTgt = self . createOutput ( '<STR_LIT>' , dataType = '<STR_LIT>' , parent = self . outputHrcGrp ) . getTarget ( ) <EOL> self . eyeROutputTgt = self . createOutput ( '<STR_LIT>' , dataType = '<STR_LIT>' , parent = self . outputHrcGrp ) . getTarget ( ) <EOL> self . drawDebugInputAttr = self . createInput ( '<STR_LIT>' , dataType = '<STR_LIT>' , value = False , parent = self . cmpInputAttrGrp ) . getTarget ( ) <EOL> self . rigScaleInputAttr = self . createInput ( '<STR_LIT>' , dataType = '<STR_LIT>' , value = <NUM_LIT:1.0> , parent = self . cmpInputAttrGrp ) . getTarget ( ) <EOL> class HeadComponentGuide ( HeadComponent ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name = '<STR_LIT>' , parent = None ) : <EOL> Profiler . getInstance ( ) . push ( "<STR_LIT>" + name ) <EOL> super ( HeadComponentGuide , self ) . __init__ ( name , parent ) <EOL> guideSettingsAttrGrp = AttributeGroup ( "<STR_LIT>" , parent = self ) <EOL> self . headCtrl = Control ( '<STR_LIT>' , parent = self . ctrlCmpGrp , shape = "<STR_LIT>" ) <EOL> self . headEndCtrl = Control ( '<STR_LIT>' , parent = self . ctrlCmpGrp , shape = "<STR_LIT>" ) <EOL> self . eyeLeftCtrl = Control ( '<STR_LIT>' , parent = self . ctrlCmpGrp , shape = "<STR_LIT>" ) <EOL> self . eyeRightCtrl = Control ( '<STR_LIT>' , parent = self . ctrlCmpGrp , shape = "<STR_LIT>" ) <EOL> self . jawCtrl = Control ( '<STR_LIT>' , parent = self . ctrlCmpGrp , shape = "<STR_LIT>" ) <EOL> data = { <EOL> "<STR_LIT:name>" : name , <EOL> "<STR_LIT:location>" : "<STR_LIT:M>" , <EOL> "<STR_LIT>" : Vec3 ( <NUM_LIT:0.0> , <NUM_LIT> , - <NUM_LIT> ) , <EOL> "<STR_LIT>" : Vec3 ( <NUM_LIT:0.0> , <NUM_LIT> , - <NUM_LIT> ) , <EOL> "<STR_LIT>" : Vec3 ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> "<STR_LIT>" : Vec3 ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> "<STR_LIT>" : Vec3 ( <NUM_LIT:0.0> , <NUM_LIT> , - <NUM_LIT> ) <EOL> } <EOL> self . loadData ( data ) <EOL> Profiler . getInstance ( ) . pop ( ) <EOL> def saveData ( self ) : <EOL> """<STR_LIT>""" <EOL> data = super ( HeadComponentGuide , self ) . saveData ( ) <EOL> data [ '<STR_LIT>' ] = self . headCtrl . xfo . tr <EOL> data [ '<STR_LIT>' ] = self . headEndCtrl . xfo . tr <EOL> data [ '<STR_LIT>' ] = self . eyeLeftCtrl . xfo . tr <EOL> data [ '<STR_LIT>' ] = self . eyeRightCtrl . xfo . tr <EOL> data [ '<STR_LIT>' ] = self . jawCtrl . xfo . tr <EOL> return data <EOL> def loadData ( self , data ) : <EOL> """<STR_LIT>""" <EOL> super ( HeadComponentGuide , self ) . loadData ( data ) <EOL> self . headCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . headEndCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . eyeLeftCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . eyeRightCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . jawCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> return True <EOL> def getRigBuildData ( self ) : <EOL> """<STR_LIT>""" <EOL> data = super ( HeadComponentGuide , self ) . getRigBuildData ( ) <EOL> data [ '<STR_LIT>' ] = self . headCtrl . xfo . tr <EOL> data [ '<STR_LIT>' ] = self . headEndCtrl . xfo . tr <EOL> data [ '<STR_LIT>' ] = self . eyeLeftCtrl . xfo . tr <EOL> data [ '<STR_LIT>' ] = self . eyeRightCtrl . xfo . tr <EOL> data [ '<STR_LIT>' ] = self . jawCtrl . xfo . tr <EOL> return data <EOL> @ classmethod <EOL> def getComponentType ( cls ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' <EOL> @ classmethod <EOL> def getRigComponentClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> return HeadComponentRig <EOL> class HeadComponentRig ( HeadComponent ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name = '<STR_LIT>' , parent = None ) : <EOL> Profiler . getInstance ( ) . push ( "<STR_LIT>" + name ) <EOL> super ( HeadComponentRig , self ) . __init__ ( name , parent ) <EOL> self . headCtrlSpace = CtrlSpace ( '<STR_LIT>' , parent = self . ctrlCmpGrp ) <EOL> self . headCtrl = Control ( '<STR_LIT>' , parent = self . headCtrlSpace , shape = "<STR_LIT>" ) <EOL> self . headCtrl . rotatePoints ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> ) <EOL> self . headCtrl . scalePoints ( Vec3 ( <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> ) ) <EOL> self . headCtrl . translatePoints ( Vec3 ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> self . eyeLeftCtrlSpace = CtrlSpace ( '<STR_LIT>' , parent = self . headCtrl ) <EOL> self . eyeLeftCtrl = Control ( '<STR_LIT>' , parent = self . eyeLeftCtrlSpace , shape = "<STR_LIT>" ) <EOL> self . eyeLeftCtrl . scalePoints ( Vec3 ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0.5> ) ) <EOL> self . eyeLeftCtrl . setColor ( "<STR_LIT>" ) <EOL> self . eyeRightCtrlSpace = CtrlSpace ( '<STR_LIT>' , parent = self . headCtrl ) <EOL> self . eyeRightCtrl = Control ( '<STR_LIT>' , parent = self . eyeRightCtrlSpace , shape = "<STR_LIT>" ) <EOL> self . eyeRightCtrl . scalePoints ( Vec3 ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0.5> ) ) <EOL> self . eyeRightCtrl . setColor ( "<STR_LIT>" ) <EOL> self . jawCtrlSpace = CtrlSpace ( '<STR_LIT>' , parent = self . headCtrl ) <EOL> self . jawCtrl = Control ( '<STR_LIT>' , parent = self . jawCtrlSpace , shape = "<STR_LIT>" ) <EOL> self . jawCtrl . alignOnYAxis ( negative = True ) <EOL> self . jawCtrl . alignOnZAxis ( ) <EOL> self . jawCtrl . scalePoints ( Vec3 ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . jawCtrl . translatePoints ( Vec3 ( <NUM_LIT:0> , - <NUM_LIT> , <NUM_LIT:0> ) ) <EOL> self . jawCtrl . setColor ( "<STR_LIT>" ) <EOL> deformersLayer = self . getOrCreateLayer ( '<STR_LIT>' ) <EOL> self . defCmpGrp = ComponentGroup ( self . getName ( ) , self , parent = deformersLayer ) <EOL> self . addItem ( '<STR_LIT>' , self . defCmpGrp ) <EOL> headDef = Joint ( '<STR_LIT>' , parent = self . defCmpGrp ) <EOL> headDef . setComponent ( self ) <EOL> jawDef = Joint ( '<STR_LIT>' , parent = self . defCmpGrp ) <EOL> jawDef . setComponent ( self ) <EOL> eyeLeftDef = Joint ( '<STR_LIT>' , parent = self . defCmpGrp ) <EOL> eyeLeftDef . setComponent ( self ) <EOL> eyeRightDef = Joint ( '<STR_LIT>' , parent = self . defCmpGrp ) <EOL> eyeRightDef . setComponent ( self ) <EOL> headInputConstraint = PoseConstraint ( '<STR_LIT:_>' . join ( [ self . headCtrlSpace . getName ( ) , '<STR_LIT>' , self . headBaseInputTgt . getName ( ) ] ) ) <EOL> headInputConstraint . setMaintainOffset ( True ) <EOL> headInputConstraint . addConstrainer ( self . headBaseInputTgt ) <EOL> self . headCtrlSpace . addConstraint ( headInputConstraint ) <EOL> headOutputConstraint = PoseConstraint ( '<STR_LIT:_>' . join ( [ self . headOutputTgt . getName ( ) , '<STR_LIT>' , self . headCtrl . getName ( ) ] ) ) <EOL> headOutputConstraint . addConstrainer ( self . headCtrl ) <EOL> self . headOutputTgt . addConstraint ( headOutputConstraint ) <EOL> jawOutputConstraint = PoseConstraint ( '<STR_LIT:_>' . join ( [ self . jawOutputTgt . getName ( ) , '<STR_LIT>' , self . jawCtrl . getName ( ) ] ) ) <EOL> jawOutputConstraint . addConstrainer ( self . jawCtrl ) <EOL> self . jawOutputTgt . addConstraint ( jawOutputConstraint ) <EOL> eyeLOutputConstraint = PoseConstraint ( '<STR_LIT:_>' . join ( [ self . eyeLOutputTgt . getName ( ) , '<STR_LIT>' , self . eyeLeftCtrl . getName ( ) ] ) ) <EOL> eyeLOutputConstraint . addConstrainer ( self . eyeLeftCtrl ) <EOL> self . eyeLOutputTgt . addConstraint ( eyeLOutputConstraint ) <EOL> eyeROutputConstraint = PoseConstraint ( '<STR_LIT:_>' . join ( [ self . eyeROutputTgt . getName ( ) , '<STR_LIT>' , self . eyeRightCtrl . getName ( ) ] ) ) <EOL> eyeROutputConstraint . addConstrainer ( self . eyeRightCtrl ) <EOL> self . eyeROutputTgt . addConstraint ( eyeROutputConstraint ) <EOL> self . outputsToDeformersKLOp = KLOperator ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . addOperator ( self . outputsToDeformersKLOp ) <EOL> self . outputsToDeformersKLOp . setInput ( '<STR_LIT>' , self . drawDebugInputAttr ) <EOL> self . outputsToDeformersKLOp . setInput ( '<STR_LIT>' , self . rigScaleInputAttr ) <EOL> self . outputsToDeformersKLOp . setInput ( '<STR_LIT>' , [ self . headOutputTgt , self . jawOutputTgt , self . eyeROutputTgt , self . eyeLOutputTgt ] ) <EOL> self . outputsToDeformersKLOp . setOutput ( '<STR_LIT>' , [ headDef , jawDef , eyeLeftDef , eyeRightDef ] ) <EOL> Profiler . getInstance ( ) . pop ( ) <EOL> def loadData ( self , data = None ) : <EOL> """<STR_LIT>""" <EOL> super ( HeadComponentRig , self ) . loadData ( data ) <EOL> self . headCtrlSpace . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . headCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . eyeLeftCtrlSpace . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . eyeLeftCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . eyeRightCtrlSpace . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . eyeRightCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . jawCtrlSpace . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . jawCtrl . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . headBaseInputTgt . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . headOutputTgt . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . jawOutputTgt . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . eyeLOutputTgt . xfo . tr = data [ '<STR_LIT>' ] <EOL> self . eyeROutputTgt . xfo . tr = data [ '<STR_LIT>' ] <EOL> from kraken . core . kraken_system import KrakenSystem <EOL> ks = KrakenSystem . getInstance ( ) <EOL> ks . registerComponent ( HeadComponentGuide ) <EOL> ks . registerComponent ( HeadComponentRig ) </s>
