| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601 |
- from mantis.node_container_common import *
- from bpy.types import Node
- from .base_definitions import MantisNode, GraphError
- #TODO: get rid of this, it's unnecesary here, we always want to import
- # all classes in this file
- def TellClasses():
- return [
- # special
- LinkInherit,
- # copy
- LinkCopyLocation,
- LinkCopyRotation,
- LinkCopyScale,
- LinkCopyTransforms,
- LinkTransformation,
- # limit
- LinkLimitLocation,
- LinkLimitRotation,
- LinkLimitScale,
- LinkLimitDistance,
- # tracking
- LinkStretchTo,
- LinkDampedTrack,
- LinkLockedTrack,
- LinkTrackTo,
- #misc
- LinkInheritConstraint,
- LinkArmature,
- # IK
- LinkInverseKinematics,
- LinkSplineIK,
- # Drivers
- LinkDrivenParameter,
- ]
- def default_evaluate_input(nc, input_name):
- # should catch 'Target', 'Pole Target' and ArmatureConstraint targets, too
- if ('Target' in input_name) and input_name != "Target Space":
- socket = nc.inputs.get(input_name)
- if socket.is_linked:
- return socket.links[0].from_node
- return None
-
- else:
- return evaluate_input(nc, input_name)
- #*#-------------------------------#++#-------------------------------#*#
- # L I N K N O D E S
- #*#-------------------------------#++#-------------------------------#*#
- def GetxForm(nc):
- trace = trace_single_line_up(nc, "Output Relationship")
- for node in trace[0]:
- if (node.node_type == 'XFORM'):
- return node
- raise GraphError("%s is not connected to a downstream xForm" % nc)
- class LinkInherit:
- '''A node representing inheritance'''
-
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Parent" : NodeSocket(is_input = True, name = "Parent", node = self,),
- # bone only:
- "Inherit Rotation" : NodeSocket(is_input = True, name = "Inherit Rotation", node = self,),
- "Inherit Scale" : NodeSocket(is_input = True, name = "Inherit Scale", node = self,),
- "Connected" : NodeSocket(is_input = True, name = "Connected", node = self,),
- }
- self.outputs = { "Inheritance" : NodeSocket(name = "Inheritance", node = self) }
- self.parameters = {
- "Parent":None,
- # bone only:
- "Inherit Rotation":None,
- "Inherit Scale":None,
- "Connected":None,
- }
- self.links = {} # leave this empty for now!
- # now set up the traverse target...
- self.inputs["Parent"].set_traverse_target(self.outputs["Inheritance"])
- self.outputs["Inheritance"].set_traverse_target(self.inputs["Parent"])
- self.node_type = 'LINK'
-
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self): # DUPLICATED, TODO fix this
- trace = trace_single_line_up(self, "Inheritance")
- for node in trace[0]:
- if (node.node_type == 'XFORM'):
- return node
- raise GraphError("%s is not connected to a downstream xForm" % self)
-
- def bExecute(self, bContext = None,):
- # this is handled by the xForm objects, since it isn't really
- # a constraint.
- pass
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- class LinkCopyLocation:
- '''A node representing Copy Location'''
-
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Head/Tail" : NodeSocket(is_input = True, name = "Head/Tail", node = self,),
- "UseBBone" : NodeSocket(is_input = True, name = "UseBBone", node = self,),
- "Axes" : NodeSocket(is_input = True, name = "Axes", node = self,),
- "Invert" : NodeSocket(is_input = True, name = "Invert", node = self,),
- "Target Space" : NodeSocket(is_input = True, name = "Target Space", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Head/Tail":None,
- "UseBBone":None,
- "Axes":None,
- "Invert":None,
- "Target Space":None,
- "Owner Space":None,
- "Influence":None,
- "Target":None,
- "Enable":None, }
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
-
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('COPY_LOCATION')
- get_target_and_subtarget(self, c)
- print(wrapGreen("Creating ")+wrapWhite("Copy Location")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'head_tail' : ("Head/Tail", 0),
- 'use_bbone_shape' : ("UseBBone", False),
- 'invert_x' : ( ("Invert", 0), False),
- 'invert_y' : ( ("Invert", 1), False),
- 'invert_z' : ( ("Invert", 2), False),
- 'use_x' : ( ("Axes", 0), False),
- 'use_y' : ( ("Axes", 1), False),
- 'use_z' : ( ("Axes", 2), False),
- 'owner_space' : ("Owner Space", 'WORLD'),
- 'target_space' : ("Target Space", 'WORLD'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
-
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
-
- class LinkCopyRotation:
- '''A node representing Copy Rotation'''
-
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "RotationOrder" : NodeSocket(is_input = True, name = "RotationOrder", node = self,),
- "Rotation Mix" : NodeSocket(is_input = True, name = "Rotation Mix", node = self,),
- "Axes" : NodeSocket(is_input = True, name = "Axes", node = self,),
- "Invert" : NodeSocket(is_input = True, name = "Invert", node = self,),
- "Target Space" : NodeSocket(is_input = True, name = "Target Space", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "RotationOrder":None,
- "Rotation Mix":None,
- "Axes":None,
- "Invert":None,
- "Target Space":None,
- "Owner Space":None,
- "Influence":None,
- "Target":None,
- "Enable":None, }
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('COPY_ROTATION')
- get_target_and_subtarget(self, c)
- print(wrapGreen("Creating ")+wrapWhite("Copy Rotation")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- if self.parameters["Enable"]:
- c.enabled = True; c.mute = False
-
- rotation_order = self.evaluate_input("RotationOrder")
- if ((rotation_order == 'QUATERNION') or (rotation_order == 'AXIS_ANGLE')):
- c.euler_order = 'AUTO'
- else:
- try:
- c.euler_order = rotation_order
- except TypeError: # it's a driver or incorrect
- c.euler_order = 'AUTO'
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'euler_order' : ("RotationOrder", 'AUTO'),
- 'mix_mode' : ("Rotation Mix", 'REPLACE'),
- 'invert_x' : ( ("Invert", 0), False),
- 'invert_y' : ( ("Invert", 1), False),
- 'invert_z' : ( ("Invert", 2), False),
- 'use_x' : ( ("Axes", 0), False),
- 'use_y' : ( ("Axes", 1), False),
- 'use_z' : ( ("Axes", 2), False),
- 'owner_space' : ("Owner Space", 'WORLD'),
- 'target_space' : ("Target Space", 'WORLD'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
-
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
-
- class LinkCopyScale:
- '''A node representing Copy Scale'''
-
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Offset" : NodeSocket(is_input = True, name = "Offset", node = self,),
- "Average" : NodeSocket(is_input = True, name = "Average", node = self,),
- "Additive" : NodeSocket(is_input = True, name = "Additive", node = self,),
- "Axes" : NodeSocket(is_input = True, name = "Axes", node = self,),
- #"Invert" : NodeSocket(is_input = True, name = "Invert", node = self,),
- "Target Space" : NodeSocket(is_input = True, name = "Target Space", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Offset":None,
- "Average":None,
- "Axes":None,
- #"Invert":None,
- "Target Space":None,
- "Owner Space":None,
- "Influence":None,
- "Target":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('COPY_SCALE')
- get_target_and_subtarget(self, c)
- print(wrapGreen("Creating ")+wrapWhite("Copy Scale")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'use_offset' : ("Offset", False),
- 'use_make_uniform' : ("Average", False),
- 'owner_space' : ("Owner Space", 'WORLD'),
- 'target_space' : ("Target Space", 'WORLD'),
- 'use_x' : ( ("Axes", 0), False),
- 'use_y' : ( ("Axes", 1), False),
- 'use_z' : ( ("Axes", 2), False),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
-
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- class LinkCopyTransforms:
- '''A node representing Copy Transfoms'''
-
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Head/Tail" : NodeSocket(is_input = True, name = "Head/Tail", node = self,),
- "UseBBone" : NodeSocket(is_input = True, name = "UseBBone", node = self,),
- "Additive" : NodeSocket(is_input = True, name = "Additive", node = self,),
- "Mix" : NodeSocket(is_input = True, name = "Mix", node = self,),
- "Target Space" : NodeSocket(is_input = True, name = "Target Space", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Head/Tail":None,
- "UseBBone":None,
- "Mix":None,
- "Target Space":None,
- "Owner Space":None,
- "Influence":None,
- "Target":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('COPY_TRANSFORMS')
- get_target_and_subtarget(self, c)
- print(wrapGreen("Creating ")+wrapWhite("Copy Transforms")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'head_tail' : ("Head/Tail", 0),
- 'use_bbone_shape' : ("UseBBone", False),
- 'mix_mode' : ("Mix", 'REPLACE'),
- 'owner_space' : ("Owner Space", 'WORLD'),
- 'target_space' : ("Target Space", 'WORLD'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", False)
- }
- evaluate_sockets(self, c, props_sockets)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- transformation_props_sockets = {
- 'use_motion_extrapolate' : ("Extrapolate", False),
- 'map_from' : ("Map From", 'LOCATION'),
- 'from_rotation_mode' : ("Rotation Mode", 'AUTO'),
- 'from_min_x' : ("X Min From", 0.0),
- 'from_max_x' : ("X Max From", 0.0),
- 'from_min_y' : ("Y Min From", 0.0),
- 'from_max_y' : ("Y Max From", 0.0),
- 'from_min_z' : ("Z Min From", 0.0),
- 'from_max_z' : ("Z Max From", 0.0),
- 'from_min_x_rot' : ("X Min From", 0.0),
- 'from_max_x_rot' : ("X Max From", 0.0),
- 'from_min_y_rot' : ("Y Min From", 0.0),
- 'from_max_y_rot' : ("Y Max From", 0.0),
- 'from_min_z_rot' : ("Z Min From", 0.0),
- 'from_max_z_rot' : ("Z Max From", 0.0),
- 'from_min_x_scale' : ("X Min From", 0.0),
- 'from_max_x_scale' : ("X Max From", 0.0),
- 'from_min_y_scale' : ("Y Min From", 0.0),
- 'from_max_y_scale' : ("Y Max From", 0.0),
- 'from_min_z_scale' : ("Z Min From", 0.0),
- 'from_max_z_scale' : ("Z Max From", 0.0),
- 'map_to' : ("Map To", "LOCATION"),
- 'map_to_x_from' : ("X Source Axis", "X"),
- 'map_to_y_from' : ("Y Source Axis", "Y"),
- 'map_to_z_from' : ("Z Source Axis", "Z"),
- 'to_min_x' : ("X Min To", 0.0),
- 'to_max_x' : ("X Max To", 0.0),
- 'to_min_y' : ("Y Min To", 0.0),
- 'to_max_y' : ("Y Max To", 0.0),
- 'to_min_z' : ("Z Min To", 0.0),
- 'to_max_z' : ("Z Max To", 0.0),
- 'to_min_x_rot' : ("X Min To", 0.0),
- 'to_max_x_rot' : ("X Max To", 0.0),
- 'to_min_y_rot' : ("Y Min To", 0.0),
- 'to_max_y_rot' : ("Y Max To", 0.0),
- 'to_min_z_rot' : ("Z Min To", 0.0),
- 'to_max_z_rot' : ("Z Max To", 0.0),
- 'to_min_x_scale' : ("X Min To", 0.0),
- 'to_max_x_scale' : ("X Max To", 0.0),
- 'to_min_y_scale' : ("Y Min To", 0.0),
- 'to_max_y_scale' : ("Y Max To", 0.0),
- 'to_min_z_scale' : ("Z Min To", 0.0),
- 'to_max_z_scale' : ("Z Max To", 0.0),
- 'to_euler_order' : ("Rotation Mode", "AUTO"),
- 'mix_mode' : ("Mix Mode (Translation)", "ADD"),
- 'mix_mode_rot' : ("Mix Mode (Rotation)", "ADD"),
- 'mix_mode_scale' : ("Mix Mode (Scale)", "MULTIPLY"),
- 'owner_space' : ("Owner Space", 'WORLD'),
- 'target_space' : ("Target Space", 'WORLD'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", False),
- }
- class LinkTransformation:
- '''A node representing Copy Transfoms'''
-
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Target Space" : NodeSocket(is_input = True, name = "Target Space", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,),
- "Extrapolate" : NodeSocket(is_input = True, name = "Extrapolate", node = self,),
- "Map From" : NodeSocket(is_input = True, name = "Map From", node = self,),
- "Rotation Mode" : NodeSocket(is_input = True, name = "Rotation Mode", node = self,),
- "X Min From" : NodeSocket(is_input = True, name = "X Min From", node = self,),
- "X Max From" : NodeSocket(is_input = True, name = "X Max From", node = self,),
- "Y Min From" : NodeSocket(is_input = True, name = "Y Min From", node = self,),
- "Y Max From" : NodeSocket(is_input = True, name = "Y Max From", node = self,),
- "Z Min From" : NodeSocket(is_input = True, name = "Z Min From", node = self,),
- "Z Max From" : NodeSocket(is_input = True, name = "Z Max From", node = self,),
- "Map To" : NodeSocket(is_input = True, name = "Map To", node = self,),
- "X Source Axis" : NodeSocket(is_input = True, name = "X Source Axis", node = self,),
- "X Min To" : NodeSocket(is_input = True, name = "X Min To", node = self,),
- "X Max To" : NodeSocket(is_input = True, name = "X Max To", node = self,),
- "Y Source Axis" : NodeSocket(is_input = True, name = "Y Source Axis", node = self,),
- "Y Min To" : NodeSocket(is_input = True, name = "Y Min To", node = self,),
- "Y Max To" : NodeSocket(is_input = True, name = "Y Max To", node = self,),
- "Z Source Axis" : NodeSocket(is_input = True, name = "Z Source Axis", node = self,),
- "Z Min To" : NodeSocket(is_input = True, name = "Z Min To", node = self,),
- "Z Max To" : NodeSocket(is_input = True, name = "Z Max To", node = self,),
- "Rotation Mode" : NodeSocket(is_input = True, name = "Rotation Mode", node = self,),
- "Mix Mode (Translation)" : NodeSocket(is_input = True, name = "Mix Mode (Translation)", node = self,),
- "Mix Mode (Rotation)" : NodeSocket(is_input = True, name = "Mix Mode (Rotation)", node = self,),
- "Mix Mode (Scale)" : NodeSocket(is_input = True, name = "Mix Mode (Scale)", node = self,),
- }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name" : None,
- "Input Relationship" : None,
- "Target Space" : None,
- "Owner Space" : None,
- "Influence" : None,
- "Target" : None,
- "Enable" : None,
- "Extrapolate" : None,
- "Map From" : None,
- "Rotation Mode" : None,
- "X Min From" : None,
- "X Max From" : None,
- "Y Min From" : None,
- "Y Max From" : None,
- "Z Min From" : None,
- "Z Max From" : None,
- "Map To" : None,
- "X Source Axis" : None,
- "X Min To" : None,
- "X Max To" : None,
- "Y Source Axis" : None,
- "Y Min To" : None,
- "Y Max To" : None,
- "Z Source Axis" : None,
- "Z Min To" : None,
- "Z Max To" : None,
- "Rotation Order" : None,
- "Mix Mode (Translation)" : None,
- "Mix Mode (Rotation)" : None,
- "Mix Mode (Scale)" : None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('TRANSFORM')
- get_target_and_subtarget(self, c)
- print(wrapGreen("Creating ")+wrapWhite("Transformation")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = transformation_props_sockets
- evaluate_sockets(self, c, props_sockets)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- class LinkLimitLocation:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Use Max X" : NodeSocket(is_input = True, name = "Use Max X", node = self,),
- "Max X" : NodeSocket(is_input = True, name = "Max X", node = self,),
- "Use Max Y" : NodeSocket(is_input = True, name = "Use Max Y", node = self,),
- "Max Y" : NodeSocket(is_input = True, name = "Max Y", node = self,),
- "Use Max Z" : NodeSocket(is_input = True, name = "Use Max Z", node = self,),
- "Max Z" : NodeSocket(is_input = True, name = "Max Z", node = self,),
- "Use Min X" : NodeSocket(is_input = True, name = "Use Min X", node = self,),
- "Min X" : NodeSocket(is_input = True, name = "Min X", node = self,),
- "Use Min Y" : NodeSocket(is_input = True, name = "Use Min Y", node = self,),
- "Min Y" : NodeSocket(is_input = True, name = "Min Y", node = self,),
- "Use Min Z" : NodeSocket(is_input = True, name = "Use Min Z", node = self,),
- "Min Z" : NodeSocket(is_input = True, name = "Min Z", node = self,),
- "Affect Transform" : NodeSocket(is_input = True, name = "Affect Transform", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Use Max X":None,
- "Max X":None,
- "Use Max Y":None,
- "Max Y":None,
- "Use Max Z":None,
- "Max Z":None,
- "Use Min X":None,
- "Min X":None,
- "Use Min Y":None,
- "Min Y":None,
- "Use Min Z":None,
- "Min Z":None,
- "Affect Transform":None,
- "Owner Space":None,
- "Influence":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('LIMIT_LOCATION')
- #
- print(wrapGreen("Creating ")+wrapWhite("Limit Location")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
-
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'use_transform_limit' : ("Affect Transform", False),
- 'use_max_x' : ("Use Max X", False),
- 'use_max_y' : ("Use Max Y", False),
- 'use_max_z' : ("Use Max Z", False),
- 'use_min_x' : ("Use Min X", False),
- 'use_min_y' : ("Use Min Y", False),
- 'use_min_z' : ("Use Min Z", False),
- 'max_x' : ("Max X", 0),
- 'max_y' : ("Max Y", 0),
- 'max_z' : ("Max Z", 0),
- 'min_x' : ("Min X", 0),
- 'min_y' : ("Min Y", 0),
- 'min_z' : ("Min Z", 0),
- 'owner_space' : ("Owner Space", 'WORLD'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
-
- class LinkLimitRotation:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Use X" : NodeSocket(is_input = True, name = "Use X", node = self,),
- "Use Y" : NodeSocket(is_input = True, name = "Use Y", node = self,),
- "Use Z" : NodeSocket(is_input = True, name = "Use Z", node = self,),
- "Max X" : NodeSocket(is_input = True, name = "Max X", node = self,),
- "Max Y" : NodeSocket(is_input = True, name = "Max Y", node = self,),
- "Max Z" : NodeSocket(is_input = True, name = "Max Z", node = self,),
- "Min X" : NodeSocket(is_input = True, name = "Min X", node = self,),
- "Min Y" : NodeSocket(is_input = True, name = "Min Y", node = self,),
- "Min Z" : NodeSocket(is_input = True, name = "Min Z", node = self,),
- "Affect Transform" : NodeSocket(is_input = True, name = "Affect Transform", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Use X":None,
- "Use Y":None,
- "Use Z":None,
- "Max X":None,
- "Max Y":None,
- "Max Z":None,
- "Min X":None,
- "Min Y":None,
- "Min Z":None,
- "Affect Transform":None,
- "Owner Space":None,
- "Influence":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('LIMIT_ROTATION')
- print(wrapGreen("Creating ")+wrapWhite("Limit Rotation")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
-
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'use_transform_limit' : ("Affect Transform", False),
- 'use_limit_x' : ("Use X", False),
- 'use_limit_y' : ("Use Y", False),
- 'use_limit_z' : ("Use Z", False),
- 'max_x' : ("Max X", 0),
- 'max_y' : ("Max Y", 0),
- 'max_z' : ("Max Z", 0),
- 'min_x' : ("Min X", 0),
- 'min_y' : ("Min Y", 0),
- 'min_z' : ("Min Z", 0),
- 'owner_space' : ("Owner Space", 'WORLD'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
-
- class LinkLimitScale:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Use Max X" : NodeSocket(is_input = True, name = "Use Max X", node = self,),
- "Max X" : NodeSocket(is_input = True, name = "Max X", node = self,),
- "Use Max Y" : NodeSocket(is_input = True, name = "Use Max Y", node = self,),
- "Max Y" : NodeSocket(is_input = True, name = "Max Y", node = self,),
- "Use Max Z" : NodeSocket(is_input = True, name = "Use Max Z", node = self,),
- "Max Z" : NodeSocket(is_input = True, name = "Max Z", node = self,),
- "Use Min X" : NodeSocket(is_input = True, name = "Use Min X", node = self,),
- "Min X" : NodeSocket(is_input = True, name = "Min X", node = self,),
- "Use Min Y" : NodeSocket(is_input = True, name = "Use Min Y", node = self,),
- "Min Y" : NodeSocket(is_input = True, name = "Min Y", node = self,),
- "Use Min Z" : NodeSocket(is_input = True, name = "Use Min Z", node = self,),
- "Min Z" : NodeSocket(is_input = True, name = "Min Z", node = self,),
- "Affect Transform" : NodeSocket(is_input = True, name = "Affect Transform", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Use Max X":None,
- "Max X":None,
- "Use Max Y":None,
- "Max Y":None,
- "Use Max Z":None,
- "Max Z":None,
- "Use Min X":None,
- "Min X":None,
- "Use Min Y":None,
- "Min Y":None,
- "Use Min Z":None,
- "Min Z":None,
- "Affect Transform":None,
- "Owner Space":None,
- "Influence":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
-
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('LIMIT_SCALE')
- print(wrapGreen("Creating ")+wrapWhite("Limit Scale")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
-
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'use_transform_limit' : ("Affect Transform", False),
- 'use_max_x' : ("Use Max X", False),
- 'use_max_y' : ("Use Max Y", False),
- 'use_max_z' : ("Use Max Z", False),
- 'use_min_x' : ("Use Min X", False),
- 'use_min_y' : ("Use Min Y", False),
- 'use_min_z' : ("Use Min Z", False),
- 'max_x' : ("Max X", 0),
- 'max_y' : ("Max Y", 0),
- 'max_z' : ("Max Z", 0),
- 'min_x' : ("Min X", 0),
- 'min_y' : ("Min Y", 0),
- 'min_z' : ("Min Z", 0),
- 'owner_space' : ("Owner Space", 'WORLD'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
-
- class LinkLimitDistance:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Head/Tail" : NodeSocket(is_input = True, name = "Head/Tail", node = self,),
- "UseBBone" : NodeSocket(is_input = True, name = "UseBBone", node = self,),
- "Distance" : NodeSocket(is_input = True, name = "Distance", node = self,),
- "Clamp Region" : NodeSocket(is_input = True, name = "Clamp Region", node = self,),
- "Affect Transform" : NodeSocket(is_input = True, name = "Affect Transform", node = self,),
- "Owner Space" : NodeSocket(is_input = True, name = "Owner Space", node = self,),
- "Target Space" : NodeSocket(is_input = True, name = "Target Space", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Head/Tail":None,
- "UseBBone":None,
- "Distance":None,
- "Clamp Region":None,
- "Affect Transform":None,
- "Owner Space":None,
- "Target Space":None,
- "Influence":None,
- "Target":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- print(wrapGreen("Creating ")+wrapWhite("Limit Distance")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c = self.GetxForm().bGetObject().constraints.new('LIMIT_DISTANCE')
- get_target_and_subtarget(self, c)
- c.name = self.evaluate_input("Name")
- self.bObject = c
- #
- # TODO: set distance automagically
- # IMPORTANT TODO BUG
-
- props_sockets = {
- 'distance' : ("Distance", 0),
- 'head_tail' : ("Head/Tail", 0),
- 'limit_mode' : ("Clamp Region", "LIMITDIST_INSIDE"),
- 'use_bbone_shape' : ("UseBBone", False),
- 'use_transform_limit' : ("Affect Transform", 1),
- 'owner_space' : ("Owner Space", 1),
- 'target_space' : ("Target Space", 1),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- # Tracking
- class LinkStretchTo:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Head/Tail" : NodeSocket(is_input = True, name = "Head/Tail", node = self,),
- "UseBBone" : NodeSocket(is_input = True, name = "UseBBone", node = self,),
- "Original Length" : NodeSocket(is_input = True, name = "Original Length", node = self,),
- "Volume Variation" : NodeSocket(is_input = True, name = "Volume Variation", node = self,),
- "Use Volume Min" : NodeSocket(is_input = True, name = "Use Volume Min", node = self,),
- "Volume Min" : NodeSocket(is_input = True, name = "Volume Min", node = self,),
- "Use Volume Max" : NodeSocket(is_input = True, name = "Use Volume Max", node = self,),
- "Volume Max" : NodeSocket(is_input = True, name = "Volume Max", node = self,),
- "Smooth" : NodeSocket(is_input = True, name = "Smooth", node = self,),
- "Maintain Volume" : NodeSocket(is_input = True, name = "Maintain Volume", node = self,),
- "Rotation" : NodeSocket(is_input = True, name = "Rotation", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Head/Tail":None,
- "UseBBone":None,
- "Original Length":None,
- "Volume Variation":None,
- "Use Volume Min":None,
- "Volume Min":None,
- "Use Volume Max":None,
- "Volume Max":None,
- "Smooth":None,
- "Maintain Volume":None,
- "Rotation":None,
- "Influence":None,
- "Target":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- print(wrapGreen("Creating ")+wrapWhite("Stretch-To")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c = self.GetxForm().bGetObject().constraints.new('STRETCH_TO')
- get_target_and_subtarget(self, c)
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'head_tail' : ("Head/Tail", 0),
- 'use_bbone_shape' : ("UseBBone", False),
- 'bulge' : ("Volume Variation", 0),
- 'use_bulge_min' : ("Use Volume Min", False),
- 'bulge_min' : ("Volume Min", 0),
- 'use_bulge_max' : ("Use Volume Max", False),
- 'bulge_max' : ("Volume Max", 0),
- 'bulge_smooth' : ("Smooth", 0),
- 'volume' : ("Maintain Volume", 'VOLUME_XZX'),
- 'keep_axis' : ("Rotation", 'PLANE_X'),
- 'rest_length' : ("Original Length", self.GetxForm().bGetObject().bone.length),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
-
- if (self.evaluate_input("Original Length") == 0):
- # this is meant to be set automatically.
- c.rest_length = self.GetxForm().bGetObject().bone.length
-
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- class LinkDampedTrack:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Head/Tail" : NodeSocket(is_input = True, name = "Head/Tail", node = self,),
- "UseBBone" : NodeSocket(is_input = True, name = "UseBBone", node = self,),
- "Track Axis" : NodeSocket(is_input = True, name = "Track Axis", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Head/Tail":None,
- "UseBBone":None,
- "Track Axis":None,
- "Influence":None,
- "Target":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- print(wrapGreen("Creating ")+wrapWhite("Damped Track")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c = self.GetxForm().bGetObject().constraints.new('DAMPED_TRACK')
- get_target_and_subtarget(self, c)
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'head_tail' : ("Head/Tail", 0),
- 'use_bbone_shape' : ("UseBBone", False),
- 'track_axis' : ("Track Axis", 'TRACK_Y'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
-
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- class LinkLockedTrack:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Head/Tail" : NodeSocket(is_input = True, name = "Head/Tail", node = self,),
- "UseBBone" : NodeSocket(is_input = True, name = "UseBBone", node = self,),
- "Track Axis" : NodeSocket(is_input = True, name = "Track Axis", node = self,),
- "Lock Axis" : NodeSocket(is_input = True, name = "Lock Axis", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Head/Tail":None,
- "UseBBone":None,
- "Track Axis":None,
- "Lock Axis":None,
- "Influence":None,
- "Target":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- print(wrapGreen("Creating ")+wrapWhite("Locked Track")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c = self.GetxForm().bGetObject().constraints.new('LOCKED_TRACK')
- get_target_and_subtarget(self, c)
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'head_tail' : ("Head/Tail", 0),
- 'use_bbone_shape' : ("UseBBone", False),
- 'track_axis' : ("Track Axis", 'TRACK_Y'),
- 'lock_axis' : ("Lock Axis", 'UP_X'),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- class LinkTrackTo:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Head/Tail" : NodeSocket(is_input = True, name = "Head/Tail", node = self,),
- "UseBBone" : NodeSocket(is_input = True, name = "UseBBone", node = self,),
- "Track Axis" : NodeSocket(is_input = True, name = "Track Axis", node = self,),
- "Up Axis" : NodeSocket(is_input = True, name = "Up Axis", node = self,),
- "Use Target Z" : NodeSocket(is_input = True, name = "Use Target Z", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Head/Tail":None,
- "UseBBone":None,
- "Track Axis":None,
- "Up Axis":None,
- "Use Target Z":None,
- "Influence":None,
- "Target":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- print(wrapGreen("Creating ")+wrapWhite("Track-To")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c = self.GetxForm().bGetObject().constraints.new('TRACK_TO')
- get_target_and_subtarget(self, c)
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'head_tail' : ("Head/Tail", 0),
- 'use_bbone_shape' : ("UseBBone", False),
- 'track_axis' : ("Track Axis", "TRACK_Y"),
- 'up_axis' : ("Up Axis", "UP_Z"),
- 'use_target_z' : ("Use Target Z", False),
- 'influence' : ("Influence", 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
- # relationships & misc.
- class LinkInheritConstraint:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Location" : NodeSocket(is_input = True, name = "Location", node = self,),
- "Rotation" : NodeSocket(is_input = True, name = "Rotation", node = self,),
- "Scale" : NodeSocket(is_input = True, name = "Scale", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Location":None,
- "Rotation":None,
- "Scale":None,
- "Influence":None,
- "Target":None,
- "Enable":None,}
- self.drivers = {}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- print(wrapGreen("Creating ")+wrapWhite("Child-Of")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- c = self.GetxForm().bGetObject().constraints.new('CHILD_OF')
- get_target_and_subtarget(self, c)
- c.name = self.evaluate_input("Name")
- self.bObject = c
-
- props_sockets = {
- 'use_location_x' : (("Location", 0) , 1),
- 'use_location_y' : (("Location", 1) , 1),
- 'use_location_z' : (("Location", 2) , 1),
- 'use_rotation_x' : (("Rotation", 0) , 1),
- 'use_rotation_y' : (("Rotation", 1) , 1),
- 'use_rotation_z' : (("Rotation", 2) , 1),
- 'use_scale_x' : (("Scale" , 0) , 1),
- 'use_scale_y' : (("Scale" , 1) , 1),
- 'use_scale_z' : (("Scale" , 2) , 1),
- 'influence' : ( "Influence" , 1),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
-
-
- c.set_inverse_pending
-
-
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def fill_parameters(self):
- fill_parameters(self)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
- class LinkInverseKinematics:
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Chain Length" : NodeSocket(is_input = True, name = "Chain Length", node = self,),
- "Use Tail" : NodeSocket(is_input = True, name = "Use Tail", node = self,),
- "Stretch" : NodeSocket(is_input = True, name = "Stretch", node = self,),
- "Position" : NodeSocket(is_input = True, name = "Position", node = self,),
- "Rotation" : NodeSocket(is_input = True, name = "Rotation", node = self,),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self,),
- "Pole Target" : NodeSocket(is_input = True, name = "Pole Target", node = self,),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self,), }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self) }
- self.parameters = {
- "Name":None,
- "Connected":None,
- "Chain Length":None,
- "Use Tail":None,
- "Stretch":None,
- "Position":None,
- "Rotation":None,
- "Influence":None,
- "Target":None,
- "Pole Target":None,
- "Enable":None,}
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = 'LINK'
- self.bObject = None
- self.drivers = {}
-
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, context):
- prepare_parameters(self)
- print(wrapGreen("Creating ")+wrapOrange("Inverse Kinematics")+
- wrapGreen(" Constraint for bone: ") +
- wrapOrange(self.GetxForm().bGetObject().name))
- myOb = self.GetxForm().bGetObject()
- c = self.GetxForm().bGetObject().constraints.new('IK')
- get_target_and_subtarget(self, c)
- get_target_and_subtarget(self, c, input_name = 'Pole Target')
- c.name = self.evaluate_input("Name")
-
- self.bObject = c
- if (c.pole_target): # Calculate the pole angle, the user shouldn't have to.
- pole_object = c.pole_target
- pole_location = pole_object.matrix_world.decompose()[0]
- if (c.pole_subtarget):
- pole_object = c.pole_target.pose.bones[c.pole_subtarget]
- pole_location = pole_object.matrix.decompose()[0]
- #HACK HACK
- handle_location = myOb.bone.tail_local if (self.evaluate_input("Use Tail")) else myOb.bone.head_local
- counter = 0
- parent = myOb
- base_bone = myOb
- while (parent is not None):
- if ((self.evaluate_input("Chain Length") != 0) and (counter > self.evaluate_input("Chain Length"))):
- break
- base_bone = parent
- parent = parent.parent
- counter+=1
- head_location = base_bone.bone.head_local
- pole_normal = (handle_location - head_location).cross(pole_location - head_location)
- vector_u = myOb.bone.x_axis
- vector_v = pole_normal.cross(base_bone.bone.y_axis)
- angle = -1 * vector_u.angle(vector_v)
- # TODO: create warnings for edge cases that fail such as pole target in the same place as handle
- # if (vector_u.cross(vector_v).angle(base_bone.bone.y_axis) < 1):
- # angle = angle
-
- c.pole_angle = angle
-
- props_sockets = {
- 'chain_count' : ("Chain Length", 1),
- 'use_tail' : ("Use Tail", True),
- 'use_stretch' : ("Stretch", True),
- "weight" : ("Position", 1.0),
- "orient_weight" : ("Rotation", 0.0),
- "influence" : ("Influence", 1.0),
- 'mute' : ("Enable", True),
- }
- evaluate_sockets(self, c, props_sockets)
-
- # TODO: handle drivers
- # (it should be assumed we want it on if it's plugged
- # into a driver).
- c.use_location = self.evaluate_input("Position") > 0
- c.use_rotation = self.evaluate_input("Rotation") > 0
-
-
- def __repr__(self):
- return self.signature.__repr__()
-
- def bFinalize(self, bContext = None):
- finish_drivers(self)
-
-
- def fill_parameters(self):
- fill_parameters(self)
- # This is kinda a weird design decision?
- class LinkDrivenParameter:
- '''A node representing an armature object'''
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.executed = False
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Driver" : NodeSocket(is_input = True, name = "Driver", node = self),
- "Parameter" : NodeSocket(is_input = True, name = "Parameter", node = self),
- "Index" : NodeSocket(is_input = True, name = "Index", node = self),
- }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self), }
- self.parameters = {
- "Input Relationship":None,
- "Driver":None,
- "Parameter":None,
- "Index":None,
- }
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = "LINK"
- def GetxForm(self):
- return GetxForm(self)
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def bExecute(self, bContext = None,):
- prepare_parameters(self)
- prGreen("Executing Driven Parameter node")
-
- # example_ driver ={
- # "owner":None,
- # "prop":None, # will be filled out in the node that uses the driver
- # "ind":-1, # same here
- # "type": self.evaluate_input("Driver Type"),
- # "vars": my_vars,
- # "keys": self.evaluate_input("fCurve"),}
-
- driver = self.evaluate_input("Driver")
- driver["owner"] = self.GetxForm().bGetObject()
- driver["prop"] = self.evaluate_input("Parameter")
- driver["ind"] = self.evaluate_input("Index")
-
- self.parameters["Driver"] = driver
- def bFinalize(self, bContext = None):
- # TODO HACK BUG
- # This probably no longer works
- from mantis.drivers import CreateDrivers
- CreateDrivers( [ self.parameters["Driver"] ] )
-
- def __repr__(self):
- return self.signature.__repr__()
- def fill_parameters(self):
- fill_parameters(self)
-
- class LinkArmature:
- '''A node representing an armature object'''
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.executed = False
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Preserve Volume" : NodeSocket(is_input = True, name = "Preserve Volume", node = self),
- "Use Envelopes" : NodeSocket(is_input = True, name = "Use Envelopes", node = self),
- "Use Current Location" : NodeSocket(is_input = True, name = "Use Current Location", node = self),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self),
- "Enable" : NodeSocket(is_input = True, name = "Enable", node = self),
- }
- self.outputs = {
- "Output Relationship" : NodeSocket(name = "Output Relationship", node=self), }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Preserve Volume":None,
- "Use Envelopes":None,
- "Use Current Location":None,
- "Influence":None,
- "Enable":None,
- }
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = "LINK"
- setup_custom_props(self)
- def GetxForm(self):
- return GetxForm(self)
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def bExecute(self, bContext = None,):
- prGreen("Creating Armature Constraint for bone: \""+ self.GetxForm().bGetObject().name + "\"")
- prepare_parameters(self)
- c = self.GetxForm().bGetObject().constraints.new('ARMATURE')
- c.name = self.evaluate_input("Name")
- self.bObject = c
- # get number of targets
- num_targets = len( list(self.inputs.values())[6:] )//2
-
- props_sockets = {
- 'use_deform_preserve_volume' : ("Preserve Volume", 0),
- 'use_bone_envelopes' : ("Use Envelopes", 0),
- 'use_current_location' : ("Use Current Location", 0),
- 'influence' : ( "Influence" , 1),
- 'mute' : ("Enable", True),
- }
- targets_weights = {}
- for i in range(num_targets):
- target = c.targets.new()
- target_input_name = list(self.inputs.keys())[i*2+6 ]
- weight_input_name = list(self.inputs.keys())[i*2+6+1]
- get_target_and_subtarget(self, target, target_input_name)
- targets_weights[i]=self.evaluate_input(weight_input_name)
- # props_sockets["targets[%d].weight" % i] = (weight_input_name, 0)
- # targets_weights.append({"weight":(weight_input_name, 0)})
- evaluate_sockets(self, c, props_sockets)
- for target, value in targets_weights.items():
- c.targets[target].weight=value
- # for i, (target, weight) in enumerate(zip(c.targets, targets_weights)):
- # evaluate_sockets(self, target, weight)
- def bFinalize(self, bContext = None):
- finish_drivers(self)
- def __repr__(self):
- return self.signature.__repr__()
- def fill_parameters(self):
- fill_parameters(self)
- class LinkSplineIK:
- '''A node representing an armature object'''
- def __init__(self, signature, base_tree):
- self.base_tree=base_tree
- self.executed = False
- self.signature = signature
- self.inputs = {
- "Input Relationship" : NodeSocket(is_input = True, name = "Input Relationship", node = self,),
- "Target" : NodeSocket(is_input = True, name = "Target", node = self),
- "Chain Length" : NodeSocket(is_input = True, name = "Chain Length", node = self),
- "Even Divisions" : NodeSocket(is_input = True, name = "Even Divisions", node = self),
- "Chain Offset" : NodeSocket(is_input = True, name = "Chain Offset", node = self),
- "Use Curve Radius" : NodeSocket(is_input = True, name = "Use Curve Radius", node = self),
- "Y Scale Mode" : NodeSocket(is_input = True, name = "Y Scale Mode", node = self),
- "XZ Scale Mode" : NodeSocket(is_input = True, name = "XZ Scale Mode", node = self),
- "Use Original Scale" : NodeSocket(is_input = True, name = "Use Original Scale", node = self),
- "Influence" : NodeSocket(is_input = True, name = "Influence", node = self),
- }
- self.outputs = {
- "Output Relationship" : NodeSocket(is_input = False, name = "Output Relationship", node=self), }
- self.parameters = {
- "Name":None,
- "Input Relationship":None,
- "Target":None,
- "Chain Length":None,
- "Even Divisions":None,
- "Chain Offset":None,
- "Use Curve Radius":None,
- "Y Scale Mode":None,
- "XZ Scale Mode":None,
- "Use Original Scale":None,
- "Influence":None,
- }
- # now set up the traverse target...
- self.inputs["Input Relationship"].set_traverse_target(self.outputs["Output Relationship"])
- self.outputs["Output Relationship"].set_traverse_target(self.inputs["Input Relationship"])
- self.node_type = "LINK"
- def evaluate_input(self, input_name):
- return default_evaluate_input(self, input_name)
- def GetxForm(self):
- return GetxForm(self)
- def bExecute(self, bContext = None,):
- prepare_parameters(self)
- prGreen("Creating Spline-IK Constraint for bone: \""+ self.GetxForm().bGetObject().name + "\"")
- c = self.GetxForm().bGetObject().constraints.new('SPLINE_IK')
- get_target_and_subtarget(self, c)
- c.name = self.evaluate_input("Name")
- self.bObject = c
- props_sockets = {
- 'chain_count' : ("Chain Length", 0),
- 'use_even_divisions' : ("Even Divisions", False),
- 'use_chain_offset' : ("Chain Offset", False),
- 'use_curve_radius' : ("Use Curve Radius", False),
- 'y_scale_mode' : ("Y Scale Mode", "FIT_CURVE"),
- 'xz_scale_mode' : ("XZ Scale Mode", "NONE"),
- 'use_original_scale' : ("Use Original Scale", False),
- 'influence' : ("Influence", 1),
- }
- evaluate_sockets(self, c, props_sockets)
- def __repr__(self):
- return self.signature.__repr__()
- def fill_parameters(self):
- fill_parameters(self)
|