socket_definitions.py 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555
  1. import bpy
  2. from bpy.types import NodeSocket, NodeSocketStandard
  3. # Classes which do not have default_value
  4. # needed to detect when there is an error updating dynamic nodes
  5. no_default_value= [
  6. 'MantisSocket',
  7. 'RelationshipSocket',
  8. 'DeformerSocket',
  9. 'xFormSocket',
  10. 'GeometrySocket',
  11. 'GenericRotationSocket',
  12. 'FCurveSocket',
  13. 'DriverSocket',
  14. 'DriverVariableSocket',
  15. 'xFormParameterSocket',
  16. 'MorphTargetSocket',
  17. 'KeyframeSocket',
  18. 'WildcardSocket',
  19. ]
  20. # the sockets that do not have this field do not transfer data.
  21. # instead, it is the link itself which is meaningful.
  22. class MantisSocket(NodeSocket):
  23. is_valid_interface_type=False
  24. from .utilities import (prRed, prGreen, prPurple, prWhite,
  25. prOrange,
  26. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  27. wrapOrange,)
  28. transform_spaces_bone_to = (('WORLD', "World", "World Space"),
  29. ('LOCAL', "Local", "Local Space"),
  30. ('POSE', "Pose", "Pose Space"),
  31. ('CUSTOM', "Custom", "Custom Space"),
  32. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),
  33. ('LOCAL_OWNER_ORIENT', "Local (Owner Orientation)", "Local Space"),)
  34. transform_spaces_bone_from = (('WORLD', "World", "World Space"),
  35. ('LOCAL', "Local", "Local Space"),
  36. ('POSE', "Pose", "Pose Space"),
  37. ('CUSTOM', "Custom", "Custom Space"),
  38. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),)
  39. transform_spaces_bone_object = (('WORLD', "World", "World Space"),
  40. ('LOCAL', "Local", "Local Space"),
  41. ('POSE', "Pose", "Pose Space"),
  42. ('CUSTOM', "Custom", "Custom Space"),)
  43. transform_spaces_object = (('WORLD', "World", "World Space"),
  44. ('LOCAL', "Local", "Local Space"),
  45. ('CUSTOM', "Custom", "Custom Space"),)
  46. enumRotationOrder =(('AUTO', 'Auto', 'Auto'),
  47. ('XYZ', "XYZ", "XYZ"),
  48. ('XZY', "XZY", "XZY"),
  49. ('ZXY', "ZXY", "ZXY"),
  50. ('ZYX', "ZYX", "ZYX"),
  51. ('YXZ', "YXZ", "YXZ"),
  52. ('YZX', "YZX", "YZX"),
  53. ('QUATERNION', "Quaternion", "Quaternion"),
  54. ('AXIS_ANGLE', "Axis Angle", "Axis Angle"),)
  55. # node socket colors:
  56. cFloat = (0.631373, 0.631373, 0.631373, 1.000000)
  57. cColor = (0.780392, 0.780392, 0.160784, 1.000000)
  58. cVector = (0.388235, 0.388235, 0.780392, 1.000000)
  59. cShader = (0.388235, 0.780392, 0.388235, 1.000000)
  60. cInt = (0.058824, 0.521569, 0.149020, 1.000000)
  61. cString = (0.388235, 0.388235, 0.388235, 1.000000)
  62. # cBool = (0.698039, 0.650980, 0.188235, 1.000000)
  63. cParameter = (0.48, 0.24, 0.24, 1.0)
  64. cDriver = (0.88, 0.11, 0.88, 1.0)
  65. cDriverVariable = (0.66, 0.33, 0.04, 1.0)
  66. cFCurve = (0.77, 0.77, 0.11, 1.0)
  67. cKeyframe = (0.06, 0.22, 0.88, 1.0)
  68. cEnable = (0.92, 0.92, 0.92, 1.0)
  69. cBoneCollection = (0.82, 0.82, 0.82, 1.0)
  70. cDeformer = (0.05, 0.08, 0.45, 1.0)
  71. cShapeKey = (0.95, 0.32, 0.05, 1.0)
  72. # custom colors:
  73. cIK = (0.596078, 0.596078, 0.364706, 1.000000) #because it's yellow in Blender
  74. cRelationship = (0.352941, 0.584314, 0.431373, 1.000000) #constraint color
  75. cMatrix = (0.0, 1.0, 0.75, 1)
  76. cxForm = (0.843137, 0.592157, 0.388235, 1.000000) #could even fetch the theme colors...
  77. cTransformSpace = (1.0, 0.4, 0.216, 1.0)
  78. cBool = (0.1, 0.1, 0.1, 1.0)
  79. cBool3 = (0.35, 0.25, 0.18, 1.0)
  80. cRotationOrder = (0.0, 0.8, 0.0, 1.0)
  81. cQuaternion = (0.85, 0.25, 0.18, 1.0)
  82. #
  83. cGeometry = (0.000000, 0.672443, 0.366253, 1.000000)
  84. # think about making colors that are representative of the data's purpose:
  85. # location
  86. # rotation
  87. # scale
  88. # OR make all of it a reference to the type of data within?
  89. # Hybrid approach: Make same-data, similar purpose have similar colors.
  90. from typing import List
  91. def TellClasses() -> List[MantisSocket]:
  92. return [ #MantisSocket,
  93. #DefaultSocket,
  94. #InputSocket,
  95. MatrixSocket,
  96. xFormSocket,
  97. RelationshipSocket,
  98. DeformerSocket,
  99. GeometrySocket,
  100. GenericRotationSocket,
  101. EnableSocket,
  102. HideSocket,
  103. # InverseKinematicsSocket,
  104. DriverSocket,
  105. DriverVariableSocket,
  106. FCurveSocket,
  107. # LayerMaskSocket,
  108. # LayerMaskInputSocket,
  109. BoneCollectionSocket,
  110. EnumArrayGetOptions,
  111. xFormParameterSocket,
  112. ParameterBoolSocket,
  113. ParameterIntSocket,
  114. ParameterFloatSocket,
  115. ParameterVectorSocket,
  116. ParameterStringSocket,
  117. TransformSpaceSocket,
  118. BooleanSocket,
  119. InvertedBooleanSocket,
  120. BooleanThreeTupleSocket,
  121. RotationOrderSocket,
  122. QuaternionSocket,
  123. QuaternionSocketAA,
  124. UnsignedIntSocket,
  125. IntSocket,
  126. StringSocket,
  127. EnumMetaRigSocket,
  128. EnumMetaBoneSocket,
  129. EnumCurveSocket,
  130. BoolUpdateParentNode,
  131. # LabelSocket,
  132. IKChainLengthSocket,
  133. EnumInheritScale,
  134. EnumRotationMix,
  135. EnumRotationMixCopyTransforms,
  136. EnumMaintainVolumeStretchTo,
  137. EnumRotationStretchTo,
  138. EnumTrackAxis,
  139. EnumUpAxis,
  140. EnumFollowPathForwardAxis,
  141. EnumFloorAxis,
  142. EnumLockAxis,
  143. EnumLimitMode,
  144. EnumYScaleMode,
  145. EnumXZScaleMode,
  146. EnumTransformationMap,
  147. EnumTransformationRotationMode,
  148. EnumTransformationRotationOrder,
  149. EnumTransformationTranslationMixMode,
  150. EnumTransformationRotationMixMode,
  151. EnumTransformationScaleMixMode,
  152. EnumTransformationAxes,
  153. EnumBBoneHandleType,
  154. # Deformers
  155. EnumSkinning,
  156. MorphTargetSocket,
  157. #
  158. FloatSocket,
  159. FloatPositiveSocket,
  160. FloatFactorSocket,
  161. FloatAngleSocket,
  162. VectorSocket,
  163. VectorEulerSocket,
  164. VectorTranslationSocket,
  165. VectorScaleSocket,
  166. # Drivers
  167. EnumDriverVariableType,
  168. EnumDriverVariableEvaluationSpace,
  169. EnumDriverVariableTransformChannel,
  170. EnumDriverRotationMode,
  171. EnumDriverType,
  172. KeyframeSocket,
  173. EnumKeyframeInterpolationTypeSocket,
  174. EnumKeyframeBezierHandleTypeSocket,
  175. EnumLatticeInterpolationTypeSocket,
  176. eFCrvExtrapolationMode,
  177. # Math
  178. MathFloatOperation,
  179. MathVectorOperation,
  180. MatrixTransformOperation,
  181. #conditions
  182. EnumCompareOperation,
  183. # Schema
  184. WildcardSocket,
  185. # xFormArraySocket,
  186. # RelationshipArraySocket,
  187. # BooleanArraySocket,
  188. # IntArraySocket,
  189. # FloatArraySocket,
  190. # BooleanThreeTupleArraySocket,
  191. # VectorArraySocket,
  192. # QuaternionArraySocket,
  193. # MatrixArraySocket,
  194. # StringArraySocket,
  195. ]
  196. def Tell_bl_idnames(): # reroute nodes
  197. return [cls.bl_idname for cls in TellClasses()]#+["NodeSocketColor"]
  198. def tell_valid_bl_idnames():
  199. valid_classes = filter(lambda cls : cls.is_valid_interface_type, [cls for cls in TellClasses()])
  200. return (cls.bl_idname for cls in valid_classes)
  201. # Was setting color like this:
  202. # color : bpy.props.FloatVectorProperty(size = 4, default = cFCurve,)
  203. # but this didn't work when Blender automatically generated interface classes?
  204. # so changed it to color = cVariable
  205. # but for color-changing sockets, if I make them, this won' work? Maybe?
  206. #
  207. # I actually think I was wrong about all of that lol
  208. # TODO change it back, dingus
  209. ########################################################################
  210. # Update Callbacks
  211. ########################################################################
  212. def socket_update(mantis_node, ui_socket, socket_name=None):
  213. node_updated = mantis_node.ui_modify_socket(ui_socket, socket_name)
  214. if not node_updated: # so that we can tag its dependencies
  215. mantis_node.reset_execution_recursive()
  216. return node_updated
  217. def default_update(ui_socket, context, do_execute=True):
  218. context = bpy.context
  219. if not context.space_data:
  220. return
  221. if not hasattr(context.space_data, "path"):
  222. return
  223. try:
  224. node_tree = context.space_data.path[0].node_tree
  225. except IndexError: # not in the UI, for example, in a script instead.
  226. return
  227. if node_tree.is_executing or node_tree.is_exporting or not node_tree.do_live_update:
  228. return
  229. # if it is a Schema Node, it will fail the checks below -- but we need it to update the tree.
  230. from .base_definitions import SchemaUINode
  231. if isinstance(ui_socket.node, SchemaUINode):
  232. node_tree.update_tree(context, force = True)
  233. prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
  234. node_tree.execute_tree(context)
  235. return
  236. if hasattr(ui_socket.node, "initialized"):
  237. if not ui_socket.node.initialized: return
  238. elif hasattr(ui_socket.node, 'is_updating'):
  239. if ui_socket.node.is_updating: return
  240. else: return
  241. # if the socket has survived THAT ordeal, then the context is OK.
  242. # first, we try to update the Mantis tree in-situ.
  243. # Some nodes can update their b-objects, others will have to force-update the tree
  244. # because we just modified the data without modifying the topology of the graph.
  245. # finally, try and execute it if mantis couldn't update the b_objects itself.
  246. from .base_definitions import array_output_types
  247. mantis_updated=True
  248. if (ui_socket.node.bl_idname in ["MantisNodeGroup", "MantisSchemaGroup"]):
  249. mantis_updated=False # this kind of socket can't be updated here (yet)
  250. node_tree.update_tree(context, force=True)
  251. elif ui_socket.node.bl_idname in array_output_types:
  252. mantis_updated=False
  253. node_tree.update_tree(context, force=True)
  254. elif hasattr(ui_socket, 'default_value'):
  255. # we may not have to regenerate the tree; try and update the socket
  256. from .utilities import tree_from_nc
  257. for mantis_node in node_tree.parsed_tree.values():
  258. # check to see if the mantis node is in the same ui-tree as this ui_socket
  259. if mantis_node.ui_signature is None: continue # autogenerated nodes
  260. if mantis_node.ui_signature[-1] == ui_socket.node.name and \
  261. tree_from_nc(mantis_node.ui_signature, node_tree) == ui_socket.node.id_data:
  262. node_updated = True
  263. from .misc_nodes import SimpleInputNode
  264. if isinstance(mantis_node, SimpleInputNode):
  265. node_updated = socket_update(mantis_node, ui_socket)
  266. for l in mantis_node.outputs[ui_socket.name].links:
  267. node_updated = node_updated and socket_update(l.to_node, ui_socket, l.to_socket)
  268. else:
  269. node_updated = socket_update(mantis_node, ui_socket)
  270. # execute the tree if even one node didn't update
  271. mantis_updated = node_updated and mantis_updated
  272. # we want to force it if we have made an unhandled change inside of a schema.
  273. node_tree.update_tree(context, force = (mantis_updated == False))
  274. node_tree.display_update(context)
  275. if mantis_updated==False:
  276. try:
  277. prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
  278. node_tree.execute_tree(context)
  279. except Exception as e:
  280. prRed("Automatic Tree Execution failed because of %s" % e)
  281. def update_socket(self, context,):
  282. default_update(self,context)
  283. def driver_variable_socket_update(self, context):
  284. default_update(self,context)
  285. def driver_socket_update(self, context):
  286. default_update(self,context)
  287. def update_mute_socket(self, context):
  288. self.node.mute = not self.default_value
  289. default_update(self,context)
  290. def update_hide_socket(self, context):
  291. self.node.mute = self.default_value
  292. default_update(self,context)
  293. def ik_chain_length_update_socket(self, context):
  294. default_update(self,context)
  295. # self.node.update_chain_length(context)
  296. def update_parent_node(self, context):
  297. default_update(self,context)
  298. if hasattr(self.node, "display_update"):
  299. self.node.display_update(context)
  300. def update_metarig_armature(self, context,):
  301. if self.search_prop:
  302. self.node.armature = self.search_prop.name
  303. self.node.inputs["Meta-Bone"].search_prop = self.search_prop
  304. default_update(self,context)
  305. def update_metarig_posebone(self, context,):
  306. self.node.pose_bone = self.default_value
  307. default_update(self,context)
  308. ########################################################################
  309. # Sockets
  310. ########################################################################
  311. def ChooseDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  312. invert_checkbox = False
  313. if hasattr(self, "invert") and self.invert == True:
  314. invert_checkbox=True
  315. # TEXT ONLY
  316. if self.node.bl_idname in ["NodeGroupInput", "NodeGroupOutput"]:
  317. layout.label(text=text)
  318. elif hasattr(self, "display_text") and self.display_text and self.is_linked:
  319. layout.label(text=self.display_text)
  320. else:
  321. # ENUM VALUES (this is a HACK, fix it later)
  322. if ('Enum' in self.bl_idname) and (use_enum):
  323. if not (self.is_output or self.is_linked):
  324. layout.prop_tabs_enum(self, "default_value",)
  325. else:
  326. layout.label(text=text)
  327. # for OUTPUT sockets that take INPUT (confusing name!)
  328. elif ((hasattr(self, "default_value")) and hasattr(self, "input") and getattr(self, "input")):
  329. # for simple input nodes
  330. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True)
  331. # for INPUTS that are NOT CONNECTED
  332. elif (hasattr(self, "default_value")) and not (self.is_output or self.is_linked):
  333. # DO: expose these values as parameters for this function
  334. # and set them for each socket.
  335. if icon == 'NONE': icon_only = False
  336. elif icon_only == True : text = "" # "real" icon-only looks bad for strings, need to check other props types.
  337. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True, icon=icon,
  338. invert_checkbox=invert_checkbox)
  339. # CONNECTED sockets and outputs without input fields
  340. else:
  341. layout.label(text=text)
  342. class RelationshipSocket(MantisSocket):
  343. # Description string
  344. '''Relationship'''
  345. # Optional identifier string. If not explicitly defined, the python class name is used.
  346. bl_idname = 'RelationshipSocket'
  347. bl_label = "Relationship"
  348. color_simple = cRelationship
  349. color : bpy.props.FloatVectorProperty(default=cRelationship, size=4)
  350. input : bpy.props.BoolProperty(default =False,)
  351. is_valid_interface_type=True
  352. def draw(self, context, layout, node, text):
  353. ChooseDraw(self, context, layout, node, text)
  354. def draw_color(self, context, node):
  355. return self.color
  356. @classmethod
  357. def draw_color_simple(self):
  358. return self.color_simple
  359. class DeformerSocket(MantisSocket):
  360. # Description string
  361. '''Deformer'''
  362. # Optional identifier string. If not explicitly defined, the python class name is used.
  363. bl_idname = 'DeformerSocket'
  364. bl_label = "Deformer"
  365. is_valid_interface_type=True
  366. color_simple = cDeformer
  367. color : bpy.props.FloatVectorProperty(default=cDeformer, size=4)
  368. input : bpy.props.BoolProperty(default =False,)
  369. def draw(self, context, layout, node, text):
  370. ChooseDraw(self, context, layout, node, text)
  371. def draw_color(self, context, node):
  372. return self.color
  373. @classmethod
  374. def draw_color_simple(self):
  375. return self.color_simple
  376. class MatrixSocket(MantisSocket):
  377. '''Matrix Input Output'''
  378. bl_idname = 'MatrixSocket'
  379. bl_label = "Matrix"
  380. default_value : bpy.props.FloatVectorProperty(
  381. default = (1.0, 0.0, 0.0, 0.0,
  382. 0.0, 1.0, 0.0, 0.0,
  383. 0.0, 0.0, 1.0, 0.0,
  384. 0.0, 0.0, 0.0, 1.0),
  385. size=16,
  386. update = update_socket,)
  387. color_simple = cMatrix
  388. color : bpy.props.FloatVectorProperty(default=cMatrix, size=4)
  389. input : bpy.props.BoolProperty(default =False,)
  390. is_valid_interface_type=True
  391. # Optional function for drawing the socket input value
  392. def draw(self, context, layout, node, text):
  393. layout.label(text=text)
  394. def draw_color(self, context, node):
  395. return self.color
  396. @classmethod
  397. def draw_color_simple(self):
  398. return self.color_simple
  399. # Utility functions to make handling the 16 numbers more bearable
  400. def SetValue(self, mat):
  401. self.default_value = ( mat[0][0], mat[0][1], mat[0][2], mat[0][3],
  402. mat[1][0], mat[1][1], mat[1][2], mat[1][3],
  403. mat[2][0], mat[2][1], mat[2][2], mat[2][3],
  404. mat[3][0], mat[3][1], mat[3][2], mat[3][3], )
  405. def TellValue(self):
  406. from mathutils import Matrix
  407. v = self.default_value
  408. return Matrix( ( ( v[ 0], v[ 1], v[ 2], v[ 3],),
  409. ( v[ 4], v[ 5], v[ 6], v[ 7],),
  410. ( v[ 8], v[ 9], v[10], v[11],),
  411. ( v[12], v[13], v[14], v[15]), ) )
  412. #NOTE, we're not using the last row
  413. # so we're gonna use it to store data
  414. # unused, unused, unused, bone_length
  415. # but we're not going to make it
  416. # available except by accessor functions
  417. # would like to make this stuff easier to deal with tho
  418. def TellBoneLength(self):
  419. return self.default_value[15]
  420. class xFormSocket(MantisSocket):
  421. '''xFrom Input Output'''
  422. bl_idname = 'xFormSocket'
  423. bl_label = "xForm"
  424. color_simple = cxForm
  425. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  426. input : bpy.props.BoolProperty(default =False,)
  427. is_valid_interface_type=True
  428. def draw(self, context, layout, node, text):
  429. ChooseDraw(self, context, layout, node, text)
  430. def draw_color(self, context, node):
  431. return self.color
  432. @classmethod
  433. def draw_color_simple(self):
  434. return self.color_simple
  435. class GeometrySocket(MantisSocket):
  436. '''Geometry Input Output'''
  437. bl_idname = 'GeometrySocket'
  438. bl_label = "Geometry"
  439. color_simple = cGeometry
  440. color : bpy.props.FloatVectorProperty(default=cGeometry, size=4)
  441. input : bpy.props.BoolProperty(default =False,)
  442. is_valid_interface_type=True
  443. def draw(self, context, layout, node, text):
  444. ChooseDraw(self, context, layout, node, text)
  445. def draw_color(self, context, node):
  446. return self.color
  447. @classmethod
  448. def draw_color_simple(self):
  449. return self.color_simple
  450. class GenericRotationSocket(MantisSocket):
  451. '''Custom node socket type'''
  452. bl_idname = 'GenericRotationSocket'
  453. bl_label = "Rotation"
  454. color = (0.0,0.0,0.0,0.0)
  455. input : bpy.props.BoolProperty(default =False,)
  456. def draw(self, context, layout, node, text):
  457. ChooseDraw(self, context, layout, node, text)
  458. def draw_color(self, context, node):
  459. return self.color
  460. @classmethod
  461. def draw_color_simple(self):
  462. return self.color_simple
  463. ###############################
  464. class EnableSocket(MantisSocket):
  465. '''Custom node socket type'''
  466. bl_idname = 'EnableSocket'
  467. bl_label = "Enable"
  468. default_value: bpy.props.BoolProperty(default=True, update = update_mute_socket,)
  469. color_simple = cEnable
  470. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  471. input : bpy.props.BoolProperty(default =False,)
  472. def draw(self, context, layout, node, text):
  473. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  474. def draw_color(self, context, node):
  475. return self.color
  476. @classmethod
  477. def draw_color_simple(self):
  478. return self.color_simple
  479. class HideSocket(MantisSocket):
  480. '''Custom node socket type'''
  481. bl_idname = 'HideSocket'
  482. bl_label = "Hide"
  483. default_value: bpy.props.BoolProperty(default=False, update = update_hide_socket,)
  484. color_simple = cEnable
  485. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  486. input : bpy.props.BoolProperty(default =False,)
  487. def draw(self, context, layout, node, text):
  488. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  489. def draw_color(self, context, node):
  490. return self.color
  491. @classmethod
  492. def draw_color_simple(self):
  493. return self.color_simple
  494. class FCurveSocket(MantisSocket):
  495. '''fCurve'''
  496. bl_idname = 'FCurveSocket'
  497. bl_label = "fCurve"
  498. color_simple = cFCurve
  499. color : bpy.props.FloatVectorProperty(default=cFCurve, size=4)
  500. input : bpy.props.BoolProperty(default =False, update = update_socket)
  501. is_valid_interface_type=True
  502. def init(self):
  503. self.display_shape = 'CIRCLE_DOT'
  504. def draw(self, context, layout, node, text):
  505. ChooseDraw(self, context, layout, node, text)
  506. def draw_color(self, context, node):
  507. return self.color
  508. @classmethod
  509. def draw_color_simple(self):
  510. return self.color_simple
  511. class DriverSocket(MantisSocket):
  512. '''Driver'''
  513. bl_idname = 'DriverSocket'
  514. bl_label = "Driver"
  515. color_simple = cDriver
  516. color : bpy.props.FloatVectorProperty(default=cDriver, size=4)
  517. input : bpy.props.BoolProperty(default =False, update = update_socket)
  518. is_valid_interface_type=True
  519. def init(self):
  520. self.display_shape = 'CIRCLE_DOT'
  521. def draw(self, context, layout, node, text):
  522. ChooseDraw(self, context, layout, node, text)
  523. def draw_color(self, context, node):
  524. return self.color
  525. @classmethod
  526. def draw_color_simple(self):
  527. return self.color_simple
  528. class DriverVariableSocket(MantisSocket):
  529. '''Driver'''
  530. bl_idname = 'DriverVariableSocket'
  531. bl_label = "Driver Variable"
  532. color_simple = cDriverVariable
  533. color : bpy.props.FloatVectorProperty(default=cDriverVariable, size=4)
  534. input : bpy.props.BoolProperty(default =False, update = update_socket)
  535. is_valid_interface_type=True
  536. def init(self):
  537. self.display_shape = 'CIRCLE_DOT'
  538. def draw(self, context, layout, node, text):
  539. ChooseDraw(self, context, layout, node, text)
  540. def draw_color(self, context, node):
  541. return self.color
  542. @classmethod
  543. def draw_color_simple(self):
  544. return self.color_simple
  545. # transform_spaces
  546. # transform_spaces_bone_object
  547. # transform_spaces_object
  548. # def get_transform_space_enum(self, context):
  549. # pass
  550. def get_transform_space(self, context):
  551. if "Owner" in self.name:
  552. return transform_spaces_bone_from
  553. else:
  554. return transform_spaces_bone_to
  555. class TransformSpaceSocket(MantisSocket):
  556. '''Custom node socket type'''
  557. bl_idname = 'TransformSpaceSocket'
  558. bl_label = "Transform Space"
  559. default_value: bpy.props.EnumProperty(
  560. name="Space Transform",
  561. description="Space Transform",
  562. items=get_transform_space,
  563. default=0,
  564. update = update_socket,)
  565. color_simple = cTransformSpace
  566. color : bpy.props.FloatVectorProperty(default=cTransformSpace, size=4)
  567. input : bpy.props.BoolProperty(default =False,)
  568. def draw(self, context, layout, node, text):
  569. ChooseDraw(self, context, layout, node, text)
  570. def draw_color(self, context, node):
  571. return self.color
  572. @classmethod
  573. def draw_color_simple(self):
  574. return self.color_simple
  575. class BooleanSocket(MantisSocket):
  576. '''Custom node socket type'''
  577. bl_idname = 'BooleanSocket'
  578. bl_label = "Boolean"
  579. default_value: bpy.props.BoolProperty(update = update_socket,)
  580. color_simple = cBool
  581. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  582. input : bpy.props.BoolProperty(default =False,)
  583. is_valid_interface_type=True
  584. def draw(self, context, layout, node, text):
  585. ChooseDraw(self, context, layout, node, text)
  586. def draw_color(self, context, node):
  587. return self.color
  588. @classmethod
  589. def draw_color_simple(self):
  590. return self.color_simple
  591. class InvertedBooleanSocket(MantisSocket):
  592. '''Custom node socket type'''
  593. bl_idname = 'InvertedBooleanSocket'
  594. bl_label = "Inverted Boolean"
  595. default_value: bpy.props.BoolProperty(update = update_socket,)
  596. color_simple = cBool
  597. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  598. input : bpy.props.BoolProperty(default =False,)
  599. invert : bpy.props.BoolProperty(default=True,)
  600. is_valid_interface_type=False
  601. def draw(self, context, layout, node, text):
  602. ChooseDraw(self, context, layout, node, text)
  603. def draw_color(self, context, node):
  604. return self.color
  605. @classmethod
  606. def draw_color_simple(self):
  607. return self.color_simple
  608. class BooleanThreeTupleSocket(MantisSocket):
  609. # Description string
  610. '''Custom node socket type'''
  611. # Optional identifier string. If not explicitly defined, the python class name is used.
  612. bl_idname = 'BooleanThreeTupleSocket'
  613. bl_label = "Boolean Vector"
  614. default_value: bpy.props.BoolVectorProperty(subtype = "XYZ",update = update_socket,)
  615. color_simple = cBool3
  616. color : bpy.props.FloatVectorProperty(default=cBool3, size=4)
  617. input : bpy.props.BoolProperty(default =False,)
  618. is_valid_interface_type=True
  619. def draw(self, context, layout, node, text):
  620. ChooseDraw(self, context, layout, node, text)
  621. def draw_color(self, context, node):
  622. return self.color
  623. @classmethod
  624. def draw_color_simple(self):
  625. return self.color_simple
  626. def TellValue(self):
  627. return (self.default_value[0], self.default_value[1], self.default_value[2])
  628. class RotationOrderSocket(MantisSocket):
  629. '''Custom node socket type'''
  630. bl_idname = 'RotationOrderSocket'
  631. bl_label = "Rotation Order"
  632. default_value: bpy.props.EnumProperty(
  633. name="Rotation Order",
  634. description="Rotation Order",
  635. items=enumRotationOrder,
  636. default='AUTO',
  637. update = update_socket,)
  638. color_simple = cRotationOrder
  639. color : bpy.props.FloatVectorProperty(default=cRotationOrder, size=4)
  640. input : bpy.props.BoolProperty(default =False,)
  641. def draw(self, context, layout, node, text):
  642. ChooseDraw(self, context, layout, node, text)
  643. def draw_color(self, context, node):
  644. return self.color
  645. @classmethod
  646. def draw_color_simple(self):
  647. return self.color_simple
  648. class QuaternionSocket(MantisSocket):
  649. '''Custom node socket type'''
  650. bl_idname = 'QuaternionSocket'
  651. bl_label = "Quaternion"
  652. default_value: bpy.props.FloatVectorProperty(
  653. subtype = "QUATERNION",
  654. size = 4,
  655. default = (1.0, 0.0, 0.0, 0.0,),
  656. update = update_socket,)
  657. color_simple = cQuaternion
  658. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  659. input : bpy.props.BoolProperty(default =False,)
  660. def draw(self, context, layout, node, text):
  661. ChooseDraw(self, context, layout, node, text)
  662. def draw_color(self, context, node):
  663. return self.color
  664. @classmethod
  665. def draw_color_simple(self):
  666. return self.color_simple
  667. class QuaternionSocketAA(MantisSocket):
  668. '''Custom node socket type'''
  669. bl_idname = 'QuaternionSocketAA'
  670. bl_label = "Axis Angle Quaternion"
  671. color_simple = cQuaternion
  672. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  673. input : bpy.props.BoolProperty(default =False,)
  674. default_value: bpy.props.FloatVectorProperty(
  675. subtype = "AXISANGLE",
  676. size = 4,
  677. default = (1.0, 0.0, 0.0, 0.0,),
  678. update = update_socket,)
  679. def draw(self, context, layout, node, text):
  680. ChooseDraw(self, context, layout, node, text)
  681. def draw_color(self, context, node):
  682. return self.color
  683. @classmethod
  684. def draw_color_simple(self):
  685. return self.color_simple
  686. class IntSocket(MantisSocket):
  687. '''Custom node socket type'''
  688. bl_idname = 'IntSocket'
  689. bl_label = "Integer"
  690. default_value: bpy.props.IntProperty(default=0, update = update_socket, soft_min=-256, soft_max=256)
  691. color_simple = cInt
  692. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  693. input : bpy.props.BoolProperty(default =False,)
  694. is_valid_interface_type=True
  695. def draw(self, context, layout, node, text):
  696. ChooseDraw(self, context, layout, node, text)
  697. def draw_color(self, context, node):
  698. return self.color
  699. @classmethod
  700. def draw_color_simple(self):
  701. return self.color_simple
  702. class UnsignedIntSocket(MantisSocket):
  703. '''Unsigned Integer Socket'''
  704. bl_idname = 'UnsignedIntSocket'
  705. bl_label = "Unsigned Integer"
  706. default_value: bpy.props.IntProperty(default=0, update = update_socket, min=0, soft_max=256, max=2**13)
  707. color_simple = cInt
  708. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  709. input : bpy.props.BoolProperty(default =False,)
  710. is_valid_interface_type=True
  711. def draw(self, context, layout, node, text):
  712. ChooseDraw(self, context, layout, node, text)
  713. def draw_color(self, context, node):
  714. return self.color
  715. @classmethod
  716. def draw_color_simple(self):
  717. return self.color_simple
  718. class StringSocket(bpy.types.NodeSocketString, MantisSocket):
  719. """Float Input socket"""
  720. bl_idname = 'StringSocket'
  721. bl_label = "String"
  722. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  723. color_simple = cString
  724. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  725. icon : bpy.props.StringProperty(default = "NONE",)
  726. input : bpy.props.BoolProperty(default =False,)
  727. display_text : bpy.props.StringProperty(default="")
  728. is_valid_interface_type=True
  729. # def init(self):
  730. # if self.node.bl_idname == 'UtilityBoneProperties':
  731. # self.display_shape='CIRCLE_DOT'
  732. def draw(self, context, layout, node, text):
  733. ChooseDraw(self, context, layout, node, text, icon=self.icon, icon_only=True,)
  734. def draw_color(self, context, node):
  735. return self.color
  736. @classmethod
  737. def draw_color_simple(self):
  738. return self.color_simple
  739. class BoneCollectionSocket(MantisSocket):
  740. """Bone Collection socket"""
  741. bl_idname = 'BoneCollectionSocket'
  742. bl_label = "Bone Collection"
  743. default_value: bpy.props.StringProperty(default = "Collection", update = update_socket,)
  744. input : bpy.props.BoolProperty(default =False,)
  745. color_simple = cBoneCollection
  746. color : bpy.props.FloatVectorProperty(default=cBoneCollection, size=4)
  747. def draw(self, context, layout, node, text):
  748. ChooseDraw(self, context, layout, node, text)
  749. def draw_color(self, context, node):
  750. return self.color
  751. @classmethod
  752. def draw_color_simple(self):
  753. return self.color_simple
  754. eArrayGetOptions =(
  755. ('CAP', "Cap", "Fail if the index is out of bounds."),
  756. ('WRAP', "Wrap", "Wrap around to the beginning of the array once the idex goes out of bounds."),
  757. ('HOLD', "Hold", "Reuse the last element of the array if the index is out of bounds."),)
  758. class EnumArrayGetOptions(MantisSocket):
  759. '''Custom node socket type'''
  760. bl_idname = 'EnumArrayGetOptions'
  761. bl_label = "OoB Behaviour"
  762. default_value: bpy.props.EnumProperty(
  763. items=eArrayGetOptions,
  764. name="OoB Behaviour",
  765. description="Out-of-bounds behaviour.",
  766. default = 'HOLD',
  767. update = update_socket,)
  768. color_simple = cString
  769. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  770. input : bpy.props.BoolProperty(default =False,)
  771. def draw(self, context, layout, node, text):
  772. ChooseDraw(self, context, layout, node, text)
  773. def draw_color(self, context, node):
  774. return self.color
  775. @classmethod
  776. def draw_color_simple(self):
  777. return self.color_simple
  778. #####################################################################################
  779. # Parameters
  780. #####################################################################################
  781. class xFormParameterSocket(MantisSocket):
  782. '''xFrom Parameter'''
  783. bl_idname = 'xFormParameterSocket'
  784. bl_label = "sForm Parameter"
  785. color_simple = cxForm
  786. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  787. input : bpy.props.BoolProperty(default =False,)
  788. def init(self):
  789. self.display_shape = 'CIRCLE_DOT'
  790. def draw(self, context, layout, node, text):
  791. ChooseDraw(self, context, layout, node, text)
  792. def draw_color(self, context, node):
  793. return self.color
  794. @classmethod
  795. def draw_color_simple(self):
  796. return self.color_simple
  797. # what is this one again?
  798. class ParameterBoolSocket(MantisSocket):
  799. """Boolean Parameter Socket"""
  800. bl_idname = 'ParameterBoolSocket'
  801. bl_label = "Boolean Parameter"
  802. color_simple = cBool
  803. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  804. input : bpy.props.BoolProperty(default =False,)
  805. #custom properties:
  806. min:bpy.props.FloatProperty(default = 0)
  807. max:bpy.props.FloatProperty(default = 1)
  808. soft_min:bpy.props.FloatProperty(default = 0)
  809. soft_max:bpy.props.FloatProperty(default = 1)
  810. description:bpy.props.StringProperty(default = "")
  811. default_value : bpy.props.BoolProperty(default = False, update = update_socket,)
  812. def init(self):
  813. self.display_shape = 'CIRCLE_DOT'
  814. # if True:
  815. # print (self.is_property_set("default_value"))
  816. # ui_data = self.id_properties_ui("default_value")
  817. # ui_data.update(
  818. # description=self.description,
  819. # default=0,) # for now
  820. # ui_data.update(
  821. # min = self.min,
  822. # max = self.max,
  823. # soft_min = self.soft_min,
  824. # soft_max = self.soft_max,)
  825. def draw(self, context, layout, node, text):
  826. ChooseDraw(self, context, layout, node, text)
  827. def draw_color(self, context, node):
  828. return self.color
  829. @classmethod
  830. def draw_color_simple(self):
  831. return self.color_simple
  832. class ParameterIntSocket(MantisSocket):
  833. """Integer Parameter socket"""
  834. bl_idname = 'ParameterIntSocket'
  835. bl_label = "Integer Parameter"
  836. default_value : bpy.props.IntProperty(default = 0, update = update_socket,)
  837. color_simple = cInt
  838. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  839. input : bpy.props.BoolProperty(default =False,)
  840. #custom properties:
  841. min:bpy.props.FloatProperty(default = 0)
  842. max:bpy.props.FloatProperty(default = 1)
  843. soft_min:bpy.props.FloatProperty(default = 0)
  844. soft_max:bpy.props.FloatProperty(default = 1)
  845. description:bpy.props.StringProperty(default = "")
  846. def init(self):
  847. self.display_shape = 'CIRCLE_DOT'
  848. def draw(self, context, layout, node, text):
  849. ChooseDraw(self, context, layout, node, text)
  850. def draw_color(self, context, node):
  851. return self.color
  852. @classmethod
  853. def draw_color_simple(self):
  854. return self.color_simple
  855. class ParameterFloatSocket(MantisSocket):
  856. """Float Parameter socket"""
  857. bl_idname = 'ParameterFloatSocket'
  858. bl_label = "Float Parameter"
  859. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  860. color_simple = cFloat
  861. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  862. input : bpy.props.BoolProperty(default =False,)
  863. #custom properties:
  864. min:bpy.props.FloatProperty(default = 0)
  865. max:bpy.props.FloatProperty(default = 1)
  866. soft_min:bpy.props.FloatProperty(default = 0)
  867. soft_max:bpy.props.FloatProperty(default = 1)
  868. description:bpy.props.StringProperty(default = "")
  869. def init(self):
  870. self.display_shape = 'CIRCLE_DOT'
  871. def draw(self, context, layout, node, text):
  872. ChooseDraw(self, context, layout, node, text)
  873. def draw_color(self, context, node):
  874. return self.color
  875. @classmethod
  876. def draw_color_simple(self):
  877. return self.color_simple
  878. class ParameterVectorSocket(MantisSocket):
  879. """Vector Parameter socket"""
  880. bl_idname = 'ParameterVectorSocket'
  881. bl_label = "Vector Parameter"
  882. default_value : bpy.props.FloatVectorProperty(
  883. default = (0.0, 0.0, 0.0),
  884. update = update_socket,)
  885. color_simple = cVector
  886. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  887. input : bpy.props.BoolProperty(default =False,)
  888. #custom properties:
  889. description:bpy.props.StringProperty(default = "")
  890. def init(self):
  891. self.display_shape = 'CIRCLE_DOT'
  892. def draw(self, context, layout, node, text):
  893. ChooseDraw(self, context, layout, node, text)
  894. def draw_color(self, context, node):
  895. return self.color
  896. @classmethod
  897. def draw_color_simple(self):
  898. return self.color_simple
  899. class ParameterStringSocket(MantisSocket):
  900. """String Parameter socket"""
  901. bl_idname = 'ParameterStringSocket'
  902. bl_label = "String Parameter"
  903. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  904. color_simple = cString
  905. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  906. input : bpy.props.BoolProperty(default =False,)
  907. #custom properties:
  908. description:bpy.props.StringProperty(default = "")
  909. def init(self):
  910. self.display_shape = 'CIRCLE_DOT'
  911. def draw(self, context, layout, node, text):
  912. ChooseDraw(self, context, layout, node, text)
  913. def draw_color(self, context, node):
  914. return self.color
  915. @classmethod
  916. def draw_color_simple(self):
  917. return self.color_simple
  918. #####################################################################################
  919. # Additional socket types, for special cases
  920. #####################################################################################
  921. from bpy.props import PointerProperty, StringProperty
  922. def poll_is_armature(self, obj):
  923. return obj.type == "ARMATURE"
  924. # def poll_is_armature(self, obj):
  925. # return obj.type == "ARMATURE"
  926. class EnumMetaRigSocket(MantisSocket):
  927. '''Custom node socket type'''
  928. bl_idname = 'EnumMetaRigSocket'
  929. bl_label = "Meta Rig"
  930. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  931. def get_default_value(self):
  932. if self.search_prop:
  933. return self.search_prop.name
  934. return ""
  935. def set_default_value(self, value):
  936. if ob:= bpy.data.objects.get(value):
  937. if ob.type == 'ARMATURE':
  938. self.search_prop=ob
  939. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  940. color_simple = cString
  941. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  942. def draw(self, context, layout, node, text):
  943. if self.is_output:
  944. layout.label(text=self.name)
  945. elif not (self.is_linked):
  946. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="OUTLINER_OB_ARMATURE", results_are_suggestions=True)
  947. elif hasattr(self.node, "armature"):
  948. layout.label(text=self.node.armature)
  949. # TODO: we should actually use the parsed tree to query this info directly, since this socket may belong to a node group in/out
  950. # which doesn't have this parameter. whatever.
  951. else:
  952. layout.label(text=self.name)
  953. def draw_color(self, context, node):
  954. return self.color
  955. @classmethod
  956. def draw_color_simple(self):
  957. return self.color_simple
  958. def poll_is_curve(self, obj):
  959. return obj.type == "CURVE"
  960. class EnumCurveSocket(MantisSocket):
  961. '''Choose a curve'''
  962. bl_idname = 'EnumCurveSocket'
  963. bl_label = "Curve"
  964. is_valid_interface_type=True
  965. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_curve, update=update_socket)
  966. def get_default_value(self):
  967. if self.search_prop:
  968. return self.search_prop.name
  969. return ""
  970. def set_default_value(self, value):
  971. if ob:= bpy.data.objects.get(value):
  972. if ob.type == 'CURVE':
  973. self.search_prop=ob
  974. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  975. color_simple = cString
  976. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  977. def draw(self, context, layout, node, text):
  978. if not (self.is_linked) and not self.is_output:
  979. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="CURVE_DATA", results_are_suggestions=True)
  980. else:
  981. try:
  982. layout.label(text=self.search_prop.name)
  983. except AttributeError: # TODO make this show the graph's result
  984. layout.label(text=self.name)
  985. def draw_color(self, context, node):
  986. return self.color
  987. @classmethod
  988. def draw_color_simple(self):
  989. return self.color_simple
  990. def SearchPBDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  991. layout.prop_search(data=self, property="default_value", search_data=self.search_prop.data, search_property="bones", text=text, icon=icon, results_are_suggestions=True)
  992. class EnumMetaBoneSocket(MantisSocket):
  993. '''Custom node socket type'''
  994. bl_idname = 'EnumMetaBoneSocket'
  995. bl_label = "Meta Bone"
  996. search_prop:PointerProperty(type=bpy.types.Object)
  997. bone:StringProperty()
  998. def populate_bones_list(self, context):
  999. # just gonna hardcode the value
  1000. if (meta_rig := self.search_prop):
  1001. retList = []
  1002. armatures = []
  1003. i = -1
  1004. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  1005. for b in meta_rig.data.bones:
  1006. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  1007. return(retList)
  1008. return None
  1009. # default_value : bpy.props.EnumProperty(
  1010. # items = populate_bones_list,
  1011. # name = "Meta Rig")
  1012. # def get_default_value(self):
  1013. # return self.search_prop.name
  1014. default_value : StringProperty(name = "", update=update_metarig_posebone)
  1015. color_simple = cString
  1016. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1017. def draw(self, context, layout, node, text):
  1018. if not (self.is_linked):
  1019. if self.search_prop is None:
  1020. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  1021. else:
  1022. SearchPBDraw(self, context, layout, node, text="")
  1023. else:
  1024. layout.label(text=self.node.pose_bone)
  1025. def draw_color(self, context, node):
  1026. return self.color
  1027. @classmethod
  1028. def draw_color_simple(self):
  1029. return self.color_simple
  1030. class BoolUpdateParentNode(MantisSocket):
  1031. '''Custom node socket type'''
  1032. bl_idname = 'BoolUpdateParentNode'
  1033. bl_label = "Boolean"
  1034. default_value: bpy.props.BoolProperty(default=False, update = update_parent_node)
  1035. color_simple = cBool
  1036. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  1037. input : bpy.props.BoolProperty(default =False,)
  1038. def draw(self, context, layout, node, text):
  1039. ChooseDraw(self, context, layout, node, text)
  1040. def draw_color(self, context, node):
  1041. return self.color
  1042. @classmethod
  1043. def draw_color_simple(self):
  1044. return self.color_simple
  1045. class IKChainLengthSocket(MantisSocket):
  1046. '''Custom node socket type'''
  1047. bl_idname = 'IKChainLengthSocket'
  1048. bl_label = "IK Chain Length"
  1049. default_value: bpy.props.IntProperty(default=0, update = ik_chain_length_update_socket, min = 0, max = 255)
  1050. color_simple = cInt
  1051. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1052. input : bpy.props.BoolProperty(default =False,)
  1053. def draw(self, context, layout, node, text):
  1054. ChooseDraw(self, context, layout, node, text)
  1055. def draw_color(self, context, node):
  1056. return self.color
  1057. @classmethod
  1058. def draw_color_simple(self):
  1059. return self.color_simple
  1060. # Inherit
  1061. eInheritScale = (
  1062. ('FULL', "Full", "Fully inherit scale", 1),
  1063. ('AVERAGE', "Average", "todo", 2),
  1064. ('ALIGNED', "Aligned", "todo", 3),
  1065. ('FIX_SHEAR', "Fix Shear", "todo", 4),
  1066. ('NONE', "None", "todo", 5),
  1067. )
  1068. class EnumInheritScale(MantisSocket):
  1069. '''Custom node socket type'''
  1070. bl_idname = 'EnumInheritScale'
  1071. bl_label = "Inherit Scale"
  1072. default_value: bpy.props.EnumProperty(
  1073. items=eInheritScale,
  1074. name="Inherit Scale",
  1075. description="Inherit Scale",
  1076. default = 'FULL',
  1077. #options = set(),
  1078. update = update_socket,)
  1079. color_simple = cString
  1080. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1081. input : bpy.props.BoolProperty(default =False,)
  1082. def draw(self, context, layout, node, text):
  1083. ChooseDraw(self, context, layout, node, text)
  1084. def draw_color(self, context, node):
  1085. return self.color
  1086. @classmethod
  1087. def draw_color_simple(self):
  1088. return self.color_simple
  1089. # Copy Rotation
  1090. eRotationMix =(
  1091. ('REPLACE', "Replace", "Fully inherit scale", 0),
  1092. ('BEFORE', "Before", "Fully inherit scale", 1),
  1093. ('AFTER', "After", "Fully inherit scale", 2),
  1094. ('ADD', "Add", "Fully inherit scale", 3),
  1095. #todo, but i don't care much
  1096. )
  1097. # TODO HACK
  1098. # I am trying to figure out how to do enum_flag as
  1099. # mutually exclusive options
  1100. # but! I don't think it's possible
  1101. # I just like the UI for it :P
  1102. class EnumRotationMix(MantisSocket):
  1103. '''Custom node socket type'''
  1104. bl_idname = 'EnumRotationMix'
  1105. bl_label = "Rotation Mix"
  1106. default_value: bpy.props.EnumProperty(
  1107. items=eRotationMix,
  1108. name="Rotation Mix",
  1109. description="Rotation Mix",
  1110. default = 'REPLACE',#{'REPLACE'},
  1111. options = set(), # this has to be a set lol
  1112. update = update_socket,)
  1113. color_simple = cString
  1114. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1115. input : bpy.props.BoolProperty(default =False,)
  1116. def draw(self, context, layout, node, text):
  1117. ChooseDraw(self, context, layout, node, text)
  1118. def draw_color(self, context, node):
  1119. return self.color
  1120. @classmethod
  1121. def draw_color_simple(self):
  1122. return self.color_simple
  1123. eRotationMix_copytransforms =(
  1124. ('REPLACE', "Replace (Aligned)", "Fully inherit scale"),
  1125. ('BEFORE', "Before (Aligned)", "Fully inherit scale"),
  1126. ('AFTER', "After (Aligned)", "Fully inherit scale"),
  1127. ('REPLACE_SPLIT', "Replace (Split Channels)", "Fully inherit scale"),
  1128. ('BEFORE_SPLIT', "Before (Split Channels)", "Fully inherit scale"),
  1129. ('AFTER_SPLIT', "After (Split Channels)", "Fully inherit scale"),
  1130. ('REPLACE_FULL', "Replace (Full)", "Fully inherit scale"),
  1131. ('BEFORE_FULL', "Before (Full)", "Fully inherit scale"),
  1132. ('AFTER_FULL', "After (Full)", "Fully inherit scale"),)
  1133. class EnumRotationMixCopyTransforms(MantisSocket):
  1134. '''Custom node socket type'''
  1135. bl_idname = 'EnumRotationMixCopyTransforms'
  1136. bl_label = "Rotation Mix"
  1137. default_value: bpy.props.EnumProperty(
  1138. items=eRotationMix_copytransforms,
  1139. name="Rotation Mix",
  1140. description="Rotation Mix",
  1141. default = 'REPLACE', #{'REPLACE'},
  1142. #options = {'ENUM_FLAG'}, # this sux
  1143. update = update_socket,)
  1144. color_simple = cString
  1145. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1146. input : bpy.props.BoolProperty(default =False,)
  1147. def draw(self, context, layout, node, text):
  1148. ChooseDraw(self, context, layout, node, text)
  1149. def draw_color(self, context, node):
  1150. return self.color
  1151. @classmethod
  1152. def draw_color_simple(self):
  1153. return self.color_simple
  1154. # STRETCH TO
  1155. eMaintainVolumeStretchTo = (('VOLUME_XZX', "XZ", "XZ", 1),
  1156. ('VOLUME_X', "X", "X", 2),
  1157. ('VOLUME_Z', "Z", "Z", 4),
  1158. ('NO_VOLUME', "None", "None", 8),)
  1159. class EnumMaintainVolumeStretchTo(MantisSocket):
  1160. '''Custom node socket type'''
  1161. bl_idname = 'EnumMaintainVolumeStretchToSocket'
  1162. bl_label = "Maintain Volume"
  1163. default_value: bpy.props.EnumProperty(
  1164. items=eMaintainVolumeStretchTo,
  1165. name="Maintain Volume",
  1166. description="Maintain Volume",
  1167. default = 'VOLUME_XZX',
  1168. #options = {'ENUM_FLAG'},
  1169. update = update_socket,)
  1170. color_simple = cString
  1171. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1172. input : bpy.props.BoolProperty(default =False,)
  1173. def draw(self, context, layout, node, text):
  1174. ChooseDraw(self, context, layout, node, text)
  1175. def draw_color(self, context, node):
  1176. return self.color
  1177. @classmethod
  1178. def draw_color_simple(self):
  1179. return self.color_simple
  1180. eRotationStretchTo = (('PLANE_X', "XZ", "XZ", 1),
  1181. ('PLANE_Z', "ZX", "ZX", 2),
  1182. ('SWING_Y', "Swing", "Swing", 4),)
  1183. class EnumRotationStretchTo(MantisSocket):
  1184. '''Custom node socket type'''
  1185. bl_idname = 'EnumRotationStretchTo'
  1186. bl_label = "Rotation"
  1187. default_value: bpy.props.EnumProperty(
  1188. items=eRotationStretchTo,
  1189. name="Rotation",
  1190. description="Rotation",
  1191. default = 'PLANE_X',
  1192. #options = {'ENUM_FLAG'},
  1193. update = update_socket,)
  1194. color_simple = cString
  1195. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1196. input : bpy.props.BoolProperty(default =False,)
  1197. def draw(self, context, layout, node, text):
  1198. ChooseDraw(self, context, layout, node, text)
  1199. def draw_color(self, context, node):
  1200. return self.color
  1201. @classmethod
  1202. def draw_color_simple(self):
  1203. return self.color_simple
  1204. # Track-To
  1205. eTrackAxis = (('TRACK_X', "X", "X", 1),
  1206. ('TRACK_Y', "Y", "Y", 2),
  1207. ('TRACK_Z', "Z", "Z", 4),
  1208. ('TRACK_NEGATIVE_X', "-X", "-X", 8),
  1209. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 16),
  1210. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 32,))
  1211. eUpAxis = (('UP_X', "X", "X", 1),
  1212. ('UP_Y', "Y", "Y", 2),
  1213. ('UP_Z', "Z", "Z", 4),)
  1214. # ugly but I can't change it easily without messing up versioning
  1215. class EnumTrackAxis(MantisSocket):
  1216. '''Custom node socket type'''
  1217. bl_idname = 'EnumTrackAxis'
  1218. bl_label = "Track Axis"
  1219. default_value: bpy.props.EnumProperty(
  1220. items=eTrackAxis,
  1221. name="Track Axis",
  1222. description="Track Axis",
  1223. default = 'TRACK_X',
  1224. #options = {'ENUM_FLAG'},
  1225. update = update_socket,)
  1226. color_simple = cString
  1227. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1228. input : bpy.props.BoolProperty(default =False,)
  1229. def draw(self, context, layout, node, text):
  1230. ChooseDraw(self, context, layout, node, text)
  1231. def draw_color(self, context, node):
  1232. return self.color
  1233. @classmethod
  1234. def draw_color_simple(self):
  1235. return self.color_simple
  1236. class EnumUpAxis(MantisSocket):
  1237. '''Custom node socket type'''
  1238. bl_idname = 'EnumUpAxis'
  1239. bl_label = "Up Axis"
  1240. default_value: bpy.props.EnumProperty(
  1241. items=eUpAxis,
  1242. name="Up Axis",
  1243. description="Up Axis",
  1244. default = 'UP_X',
  1245. #options = {'ENUM_FLAG'},
  1246. update = update_socket,)
  1247. color_simple = cString
  1248. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1249. input : bpy.props.BoolProperty(default =False,)
  1250. def draw(self, context, layout, node, text):
  1251. ChooseDraw(self, context, layout, node, text)
  1252. def draw_color(self, context, node):
  1253. return self.color
  1254. @classmethod
  1255. def draw_color_simple(self):
  1256. return self.color_simple
  1257. # Follow Track Forward axis
  1258. eForwardAxis = (('FORWARD_X', "X", "X", 0),
  1259. ('FORWARD_Y', "Y", "Y", 1),
  1260. ('FORWARD_Z', "Z", "Z", 2),
  1261. ('TRACK_NEGATIVE_X', "-X", "-X", 3),
  1262. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 4),
  1263. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 5),)
  1264. class EnumFollowPathForwardAxis(MantisSocket):
  1265. '''Custom node socket type'''
  1266. bl_idname = 'EnumFollowPathForwardAxis'
  1267. bl_label = "Forward Axis"
  1268. default_value: bpy.props.EnumProperty(
  1269. items=eForwardAxis,
  1270. name="Forward Axis",
  1271. description="Forward Axis",
  1272. default = 'FORWARD_X',
  1273. update = update_socket,)
  1274. color_simple = cString
  1275. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1276. input : bpy.props.BoolProperty(default =False,)
  1277. def draw(self, context, layout, node, text):
  1278. ChooseDraw(self, context, layout, node, text)
  1279. def draw_color(self, context, node):
  1280. return self.color
  1281. @classmethod
  1282. def draw_color_simple(self):
  1283. return self.color_simple
  1284. # Follow Track Forward axis
  1285. eFloorAxis = (('FLOOR_X', "X", "X", 0),
  1286. ('FLOOR_Y', "Y", "Y", 1),
  1287. ('FLOOR_Z', "Z", "Z", 2),
  1288. ('FLOOR_NEGATIVE_X', "-X", "-X", 3),
  1289. ('FLOOR_NEGATIVE_Y', "-Y", "-Y", 4),
  1290. ('FLOOR_NEGATIVE_Z', "-Z", "-Z", 5),)
  1291. class EnumFloorAxis(MantisSocket):
  1292. '''Floor Constraint Axis'''
  1293. bl_idname = 'EnumFloorAxis'
  1294. bl_label = "Floor Axis"
  1295. default_value: bpy.props.EnumProperty(
  1296. items=eFloorAxis,
  1297. name="Floor Axis",
  1298. description="Floor Axis",
  1299. default = 'FLOOR_X',
  1300. update = update_socket,)
  1301. color_simple = cString
  1302. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1303. input : bpy.props.BoolProperty(default =False,)
  1304. def draw(self, context, layout, node, text):
  1305. ChooseDraw(self, context, layout, node, text)
  1306. def draw_color(self, context, node):
  1307. return self.color
  1308. @classmethod
  1309. def draw_color_simple(self):
  1310. return self.color_simple
  1311. # Locked Track
  1312. eLockAxis = (('LOCK_X', "X", "X", 1),
  1313. ('LOCK_Y', "Y", "Y", 2),
  1314. ('LOCK_Z', "Z", "Z", 4),)
  1315. class EnumLockAxis(MantisSocket):
  1316. '''Custom node socket type'''
  1317. bl_idname = 'EnumLockAxis'
  1318. bl_label = "Lock Axis"
  1319. default_value: bpy.props.EnumProperty(
  1320. items=eLockAxis,
  1321. name="Lock Axis",
  1322. description="Lock Axis",
  1323. default = 'LOCK_X',
  1324. #options = {'ENUM_FLAG'},
  1325. update = update_socket,)
  1326. color_simple = cString
  1327. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1328. input : bpy.props.BoolProperty(default =False,)
  1329. def draw(self, context, layout, node, text):
  1330. ChooseDraw(self, context, layout, node, text)
  1331. def draw_color(self, context, node):
  1332. return self.color
  1333. @classmethod
  1334. def draw_color_simple(self):
  1335. return self.color_simple
  1336. # Limit Distance:
  1337. eLimitMode = (('LIMITDIST_INSIDE', "Inside", "Inside",),
  1338. ('LIMITDIST_OUTSIDE', "Outside", "Outside",),
  1339. ('LIMITDIST_ONSURFACE', "On Surface", "On Surface",),)
  1340. class EnumLimitMode(MantisSocket):
  1341. '''Custom node socket type'''
  1342. bl_idname = 'EnumLimitMode'
  1343. bl_label = "Clamp Region"
  1344. default_value: bpy.props.EnumProperty(
  1345. items=eLimitMode,
  1346. name="Clamp Region",
  1347. description="Clamp Region",
  1348. default = 'LIMITDIST_INSIDE',
  1349. update = update_socket,)
  1350. color_simple = cString
  1351. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1352. input : bpy.props.BoolProperty(default =False,)
  1353. def draw(self, context, layout, node, text):
  1354. ChooseDraw(self, context, layout, node, text)
  1355. def draw_color(self, context, node):
  1356. return self.color
  1357. @classmethod
  1358. def draw_color_simple(self):
  1359. return self.color_simple
  1360. # Spline IK
  1361. eYScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1362. ('FIT_CURVE', "Fit Curve", "Scale the bones to fit the entire length of the curve.",),
  1363. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),)
  1364. eXZScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1365. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),
  1366. ('INVERSE_PRESERVE', "Inverse Scale", "Scale of the X and Z axes is the inverse of the Y-Scale.",),
  1367. ('VOLUME_PRESERVE', "Volume Preservation", "Scale of the X and Z axes are adjusted to preserve the volume of the bones.",),)
  1368. class EnumYScaleMode(MantisSocket):
  1369. '''Custom node socket type'''
  1370. bl_idname = 'EnumYScaleMode'
  1371. bl_label = "Y Scale Mode"
  1372. default_value: bpy.props.EnumProperty(
  1373. items=eYScaleMode,
  1374. name="Y Scale Mode",
  1375. description="Y Scale Mode",
  1376. default = 'FIT_CURVE',
  1377. update = update_socket,)
  1378. color_simple = cString
  1379. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1380. input : bpy.props.BoolProperty(default =False,)
  1381. def draw(self, context, layout, node, text):
  1382. ChooseDraw(self, context, layout, node, text)
  1383. def draw_color(self, context, node):
  1384. return self.color
  1385. @classmethod
  1386. def draw_color_simple(self):
  1387. return self.color_simple
  1388. class EnumXZScaleMode(MantisSocket):
  1389. '''Custom node socket type'''
  1390. bl_idname = 'EnumXZScaleMode'
  1391. bl_label = "XZ Scale Mode"
  1392. default_value: bpy.props.EnumProperty(
  1393. items=eXZScaleMode,
  1394. name="XZ Scale Mode",
  1395. description="XZ Scale Mode",
  1396. default = 'NONE',
  1397. update = update_socket,)
  1398. color_simple = cString
  1399. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1400. input : bpy.props.BoolProperty(default =False,)
  1401. def draw(self, context, layout, node, text):
  1402. ChooseDraw(self, context, layout, node, text)
  1403. def draw_color(self, context, node):
  1404. return self.color
  1405. @classmethod
  1406. def draw_color_simple(self):
  1407. return self.color_simple
  1408. eMapxForm = (('LOCATION', "Location", "Location",),
  1409. ('ROTATION', "Rotation", "Rotation",),
  1410. ('SCALE', "Scale", "Scale",),)
  1411. eRotationMode = (('AUTO', 'Auto', 'Automattically Selected.', 0),
  1412. ('XYZ', "XYZ", "Euler using the XYZ rotation order", 1),
  1413. ('XZY', "XZY", "Euler using the XZY rotation order", 2),
  1414. ('ZXY', "ZXY", "Euler using the ZXY rotation order", 3),
  1415. ('ZYX', "ZYX", "Euler using the ZYX rotation order", 4),
  1416. ('YXZ', "YXZ", "Euler using the YXZ rotation order", 5),
  1417. ('YZX', "YZX", "Euler using the YZX rotation order", 6),
  1418. ('QUATERNION', "Quaternion", "Quaternion", 7),
  1419. ('SWING_TWIST_X', 'Swing and X Twist.', 'Decompose into a swing rotation to aim the X axis, followed by twist around it.', 8),
  1420. ('SWING_TWIST_Y', 'Swing and Y Twist.', 'Decompose into a swing rotation to aim the Y axis, followed by twist around it.', 9),
  1421. ('SWING_TWIST_Z', 'Swing and Z Twist.', 'Decompose into a swing rotation to aim the Z axis, followed by twist around it.', 10),)
  1422. enumTransformationRotationOrder = enumRotationOrder[:6]
  1423. eTranslationMix =(
  1424. ('ADD', "Add", "", 0),
  1425. ('REPLACE', "Replace", "", 1),
  1426. )
  1427. eScaleMix =(
  1428. ('MULTIPLY', "Multiply", "", 0),
  1429. ('REPLACE', "Replace", "", 1),
  1430. )
  1431. class EnumTransformationMap(MantisSocket):
  1432. '''Custom node socket type'''
  1433. bl_idname = 'EnumTransformationMap'
  1434. bl_label = "Map To/From"
  1435. default_value: bpy.props.EnumProperty(
  1436. items=eMapxForm,
  1437. name="Map To/From",
  1438. description="Map To/From",
  1439. default = 'LOCATION',
  1440. update = update_socket,)
  1441. color_simple = cString
  1442. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1443. input : bpy.props.BoolProperty(default =False,)
  1444. def draw(self, context, layout, node, text):
  1445. ChooseDraw(self, context, layout, node, text)
  1446. def draw_color(self, context, node):
  1447. return self.color
  1448. @classmethod
  1449. def draw_color_simple(self):
  1450. return self.color_simple
  1451. class EnumTransformationRotationMode(MantisSocket):
  1452. '''Custom node socket type'''
  1453. bl_idname = 'EnumTransformationRotationMode'
  1454. bl_label = "Map To/From"
  1455. default_value: bpy.props.EnumProperty(
  1456. items=eRotationMode,
  1457. name="Rotation Mode",
  1458. description="Rotation Mode",
  1459. default = 'AUTO',
  1460. update = update_socket,)
  1461. color_simple = cString
  1462. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1463. input : bpy.props.BoolProperty(default =False,)
  1464. def draw(self, context, layout, node, text):
  1465. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1466. def draw_color(self, context, node):
  1467. return self.color
  1468. @classmethod
  1469. def draw_color_simple(self):
  1470. return self.color_simple
  1471. class EnumTransformationRotationOrder(MantisSocket):
  1472. '''Custom node socket type'''
  1473. bl_idname = 'EnumTransformationRotationOrder'
  1474. bl_label = "Map To/From"
  1475. default_value: bpy.props.EnumProperty(
  1476. items=enumTransformationRotationOrder,
  1477. name="Rotation Order",
  1478. description="Rotation Order",
  1479. default = 'AUTO',
  1480. update = update_socket,)
  1481. color_simple = cString
  1482. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1483. input : bpy.props.BoolProperty(default =False,)
  1484. def draw(self, context, layout, node, text):
  1485. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1486. def draw_color(self, context, node):
  1487. return self.color
  1488. @classmethod
  1489. def draw_color_simple(self):
  1490. return self.color_simple
  1491. class EnumTransformationTranslationMixMode(MantisSocket):
  1492. '''Custom node socket type'''
  1493. bl_idname = 'EnumTransformationTranslationMixMode'
  1494. bl_label = "Mix Mode"
  1495. default_value: bpy.props.EnumProperty(
  1496. items=eTranslationMix,
  1497. name="Mix Translation",
  1498. description="Mix Translation",
  1499. default = 'ADD',
  1500. update = update_socket,)
  1501. color_simple = cString
  1502. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1503. input : bpy.props.BoolProperty(default =False,)
  1504. def draw(self, context, layout, node, text):
  1505. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1506. def draw_color(self, context, node):
  1507. return self.color
  1508. @classmethod
  1509. def draw_color_simple(self):
  1510. return self.color_simple
  1511. class EnumTransformationRotationMixMode(MantisSocket):
  1512. '''Custom node socket type'''
  1513. bl_idname = 'EnumTransformationRotationMixMode'
  1514. bl_label = "Mix Mode"
  1515. default_value: bpy.props.EnumProperty(
  1516. items=eRotationMix,
  1517. name="Mix Rotation",
  1518. description="Mix Rotation",
  1519. default = 'ADD',
  1520. update = update_socket,)
  1521. color_simple = cString
  1522. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1523. input : bpy.props.BoolProperty(default =False,)
  1524. def draw(self, context, layout, node, text):
  1525. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1526. def draw_color(self, context, node):
  1527. return self.color
  1528. @classmethod
  1529. def draw_color_simple(self):
  1530. return self.color_simple
  1531. class EnumTransformationScaleMixMode(MantisSocket):
  1532. '''Custom node socket type'''
  1533. bl_idname = 'EnumTransformationScaleMixMode'
  1534. bl_label = "Mix Mode"
  1535. default_value: bpy.props.EnumProperty(
  1536. items=eScaleMix,
  1537. name="Mix Scale",
  1538. description="Mix Scale",
  1539. default = 'REPLACE',
  1540. update = update_socket,)
  1541. color_simple = cString
  1542. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1543. input : bpy.props.BoolProperty(default =False,)
  1544. def draw(self, context, layout, node, text):
  1545. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1546. def draw_color(self, context, node):
  1547. return self.color
  1548. @classmethod
  1549. def draw_color_simple(self):
  1550. return self.color_simple
  1551. eAxes = (
  1552. ('X', "X", "X", 0),
  1553. ('Y', "Y", "Y", 1),
  1554. ('Z', "Z", "Z", 2),
  1555. )
  1556. class EnumTransformationAxes(MantisSocket):
  1557. '''Custom node socket type'''
  1558. bl_idname = 'EnumTransformationAxes'
  1559. bl_label = "Axes"
  1560. default_value: bpy.props.EnumProperty(
  1561. items=eAxes,
  1562. # name="",
  1563. # description="",
  1564. default = 'X',
  1565. update = update_socket,)
  1566. color_simple = cString
  1567. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1568. input : bpy.props.BoolProperty(default =False,)
  1569. def draw(self, context, layout, node, text):
  1570. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1571. def draw_color(self, context, node):
  1572. return self.color
  1573. @classmethod
  1574. def draw_color_simple(self):
  1575. return self.color_simple
  1576. #
  1577. eBBoneHandleType = (
  1578. ('AUTO', "Automatic", "", 0),
  1579. ('ABSOLUTE', "Absolute", "", 1),
  1580. ('RELATIVE', "Relative", "", 2),
  1581. ('TANGENT', "Tangent", "", 3),
  1582. )
  1583. class EnumBBoneHandleType(MantisSocket):
  1584. '''Custom node socket type'''
  1585. bl_idname = 'EnumBBoneHandleType'
  1586. bl_label = "Axes"
  1587. default_value: bpy.props.EnumProperty(
  1588. items=eBBoneHandleType,
  1589. # name="",
  1590. # description="",
  1591. default = 'AUTO',
  1592. update = update_socket,)
  1593. color_simple = cString
  1594. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1595. input : bpy.props.BoolProperty(default =False,)
  1596. def draw(self, context, layout, node, text):
  1597. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1598. def draw_color(self, context, node):
  1599. return self.color
  1600. @classmethod
  1601. def draw_color_simple(self):
  1602. return self.color_simple
  1603. eSkinningMethod = (('EXISTING_GROUPS', "Use Existing Groups", "Use the existing vertex groups, or create empty groups if not found.",),
  1604. ('AUTOMATIC_HEAT', "Automatic (Heat)", "Use Blender's heatmap automatic skinning",),
  1605. ('COPY_FROM_OBJECT', "Copy from object", "Copy skin weights from the selected object"),)
  1606. class EnumSkinning(MantisSocket):
  1607. '''Custom node socket type'''
  1608. bl_idname = 'EnumSkinning'
  1609. bl_label = "Skinning Method"
  1610. default_value: bpy.props.EnumProperty(
  1611. items=eSkinningMethod,
  1612. name="Skinning Method",
  1613. description="Skinning Method",
  1614. default = 'AUTOMATIC_HEAT',
  1615. update = update_socket,)
  1616. color_simple = cString
  1617. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1618. input : bpy.props.BoolProperty(default =False,)
  1619. def draw(self, context, layout, node, text):
  1620. ChooseDraw(self, context, layout, node, text)
  1621. def draw_color(self, context, node):
  1622. return self.color
  1623. @classmethod
  1624. def draw_color_simple(self):
  1625. return self.color_simple
  1626. class MorphTargetSocket(MantisSocket):
  1627. """Morph Target"""
  1628. bl_idname = 'MorphTargetSocket'
  1629. bl_label = "Morph Target"
  1630. color_simple = cShapeKey
  1631. color : bpy.props.FloatVectorProperty(default=cShapeKey, size=4)
  1632. input : bpy.props.BoolProperty(default =False,)
  1633. is_valid_interface_type=True
  1634. def draw(self, context, layout, node, text):
  1635. ChooseDraw(self, context, layout, node, text)
  1636. def draw_color(self, context, node):
  1637. return self.color
  1638. @classmethod
  1639. def draw_color_simple(self):
  1640. return self.color_simple
  1641. eDriverVariableType = (
  1642. ( 'SINGLE_PROP',
  1643. "Property",
  1644. "Property",
  1645. 1),
  1646. ( 'LOC_DIFF',
  1647. "Distance",
  1648. "Distance",
  1649. 2),
  1650. ( 'ROTATION_DIFF',
  1651. "Rotational Difference",
  1652. "Rotational Difference",
  1653. 3),
  1654. # ( 'TRANSFORMS',
  1655. # "Transform Channel",
  1656. # "Transform Channel",
  1657. # 4),
  1658. )
  1659. class EnumDriverVariableType(MantisSocket):
  1660. '''Custom node socket type'''
  1661. bl_idname = 'EnumDriverVariableType'
  1662. bl_label = "Variable Type"
  1663. default_value: bpy.props.EnumProperty(
  1664. items = eDriverVariableType,
  1665. name = "Variable Type",
  1666. description = "Variable Type",
  1667. default = 'SINGLE_PROP',
  1668. update = driver_variable_socket_update,)
  1669. color_simple = cString
  1670. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1671. input : bpy.props.BoolProperty(default =False,)
  1672. def draw(self, context, layout, node, text):
  1673. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1674. def draw_color(self, context, node):
  1675. return self.color
  1676. @classmethod
  1677. def draw_color_simple(self):
  1678. return self.color_simple
  1679. eDriverVariableEvaluationSpace = (
  1680. ( 'WORLD_SPACE',
  1681. "World",
  1682. "World",
  1683. 1),
  1684. ( 'TRANSFORM_SPACE',
  1685. "Transform",
  1686. "Transform",
  1687. 2),
  1688. ( 'LOCAL_SPACE',
  1689. "Local",
  1690. "Local",
  1691. 3),
  1692. )
  1693. class EnumDriverVariableEvaluationSpace(MantisSocket):
  1694. '''Custom node socket type'''
  1695. bl_idname = 'EnumDriverVariableEvaluationSpace'
  1696. bl_label = "Evaluation Space"
  1697. default_value: bpy.props.EnumProperty(
  1698. items = eDriverVariableEvaluationSpace,
  1699. name = "Evaluation Space",
  1700. description = "Evaluation Space",
  1701. default = 'WORLD_SPACE',
  1702. update = driver_variable_socket_update,)
  1703. color_simple = cString
  1704. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1705. input : bpy.props.BoolProperty(default =False,)
  1706. def draw(self, context, layout, node, text):
  1707. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1708. def draw_color(self, context, node):
  1709. return self.color
  1710. @classmethod
  1711. def draw_color_simple(self):
  1712. return self.color_simple
  1713. eDriverVariableTransformChannel = (
  1714. ("LOC_X", "X Location", "The X-coordinate of an object's location.", 1),
  1715. ("LOC_Y", "Y Location", "The Y-coordinate of an object's location.", 2),
  1716. ("LOC_Z", "Z Location", "The Z-coordinate of an object's location.", 3),
  1717. ("ROT_X", "X Rotation", "Rotation X-axis.", 4),
  1718. ("ROT_Y", "Y Rotation", "Rotation Y-axis.", 5),
  1719. ("ROT_Z", "Z Rotation", "Rotation Z-axis.", 6),
  1720. ("ROT_W", "W Rotation", "Rotation W-axis.", 7),
  1721. ("SCALE_X", "X Scale", "The X-scale of an object's scale.", 8),
  1722. ("SCALE_Y", "Y Scale", "The Y-scale of an object's scale.", 9),
  1723. ("SCALE_Z", "Z Scale", "The Z-scale of an object's scale.", 10),
  1724. ("SCALE_AVG", "Average Scale", "The scale factor of an object's scale.", 11),
  1725. )
  1726. class EnumDriverVariableTransformChannel(MantisSocket):
  1727. '''Custom node socket type'''
  1728. bl_idname = 'EnumDriverVariableTransformChannel'
  1729. bl_label = "Transform Channel"
  1730. default_value: bpy.props.EnumProperty(
  1731. items = eDriverVariableTransformChannel,
  1732. name = "Transform Channel",
  1733. description = "Transform Channel",
  1734. default = 'LOC_X',
  1735. update = driver_variable_socket_update,)
  1736. color_simple = cString
  1737. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1738. input : bpy.props.BoolProperty(default =False,)
  1739. def draw(self, context, layout, node, text):
  1740. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1741. def draw_color(self, context, node):
  1742. return self.color
  1743. @classmethod
  1744. def draw_color_simple(self):
  1745. return self.color_simple
  1746. class EnumDriverRotationMode(MantisSocket):
  1747. '''Custom node socket type'''
  1748. bl_idname = 'EnumDriverRotationMode'
  1749. bl_label = "Rotaton Mode"
  1750. default_value: bpy.props.EnumProperty(
  1751. items = eRotationMode,
  1752. name = "Rotation Mode",
  1753. description = "Rotation Mode",
  1754. default = 'AUTO',
  1755. update = driver_variable_socket_update,)
  1756. color_simple = cString
  1757. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1758. input : bpy.props.BoolProperty(default =False,)
  1759. def draw(self, context, layout, node, text):
  1760. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1761. def draw_color(self, context, node):
  1762. return self.color
  1763. @classmethod
  1764. def draw_color_simple(self):
  1765. return self.color_simple
  1766. #
  1767. eDriverType = (('AVERAGE', 'Average', 'Average', 0),
  1768. ('SUM', "Sum", "Sum", 1),
  1769. ('SCRIPTED', "Scripted", "Scripted Expression", 2),
  1770. ('MIN', "Min", "Minimum", 3),
  1771. ('MAX', "Max", "Maximum", 4),)
  1772. class EnumDriverType(MantisSocket):
  1773. '''Custom node socket type'''
  1774. bl_idname = 'EnumDriverType'
  1775. bl_label = "Driver Type"
  1776. default_value: bpy.props.EnumProperty(
  1777. items = eDriverType,
  1778. name = "Driver Type",
  1779. description = "Driver Type",
  1780. default = 'AVERAGE',
  1781. update = driver_socket_update,)
  1782. color_simple = cString
  1783. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1784. input : bpy.props.BoolProperty(default =False,)
  1785. def draw(self, context, layout, node, text):
  1786. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1787. def draw_color(self, context, node):
  1788. return self.color
  1789. @classmethod
  1790. def draw_color_simple(self):
  1791. return self.color_simple
  1792. # Keyframe
  1793. # Enum for kf handle type
  1794. # enum for interpolation type
  1795. # eventually gonna make it to the fancy stuff
  1796. class FloatSocket(bpy.types.NodeSocketFloat, MantisSocket):
  1797. """Float Input socket"""
  1798. bl_idname = 'FloatSocket'
  1799. bl_label = "Float"
  1800. is_valid_interface_type=True
  1801. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  1802. color_simple = cFloat
  1803. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1804. input : bpy.props.BoolProperty(default =False,)
  1805. def draw(self, context, layout, node, text):
  1806. ChooseDraw(self, context, layout, node, text)
  1807. def draw_color(self, context, node):
  1808. return self.color
  1809. @classmethod
  1810. def draw_color_simple(self):
  1811. return self.color_simple
  1812. class FloatPositiveSocket(bpy.types.NodeSocketFloat, MantisSocket):
  1813. """Float Input socket"""
  1814. bl_idname = 'FloatPositiveSocket'
  1815. bl_label = "Float (Positive)"
  1816. is_valid_interface_type=True
  1817. default_value : bpy.props.FloatProperty(default = 0.0, min=0, update = update_socket,)
  1818. color_simple = cFloat
  1819. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1820. input : bpy.props.BoolProperty(default =False,)
  1821. def draw(self, context, layout, node, text):
  1822. ChooseDraw(self, context, layout, node, text)
  1823. def draw_color(self, context, node):
  1824. return self.color
  1825. @classmethod
  1826. def draw_color_simple(self):
  1827. return self.color_simple
  1828. class FloatFactorSocket(bpy.types.NodeSocketFloatFactor, MantisSocket):
  1829. '''xFrom Input Output'''
  1830. bl_idname = 'FloatFactorSocket'
  1831. bl_label = "Float (Factor)"
  1832. is_valid_interface_type=True
  1833. default_value : bpy.props.FloatProperty(
  1834. default = 0.0,
  1835. min = 0.0,
  1836. max=1.0,
  1837. update = update_socket,
  1838. subtype='FACTOR',)
  1839. color_simple = cFloat
  1840. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1841. input : bpy.props.BoolProperty(default =False,)
  1842. def draw(self, context, layout, node, text):
  1843. ChooseDraw(self, context, layout, node, text)
  1844. def draw_color(self, context, node):
  1845. return self.color
  1846. @classmethod
  1847. def draw_color_simple(self):
  1848. return self.color_simple
  1849. class FloatAngleSocket(bpy.types.NodeSocketFloatAngle, MantisSocket):
  1850. '''xFrom Input Output'''
  1851. bl_idname = 'FloatAngleSocket'
  1852. bl_label = "Float (Angle)"
  1853. is_valid_interface_type=True
  1854. default_value : bpy.props.FloatProperty(
  1855. default = 0.0,
  1856. min = -180,
  1857. max=180,
  1858. update = update_socket,
  1859. subtype='ANGLE',)
  1860. color_simple = cFloat
  1861. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1862. input : bpy.props.BoolProperty(default =False,)
  1863. def draw(self, context, layout, node, text):
  1864. ChooseDraw(self, context, layout, node, text)
  1865. def draw_color(self, context, node):
  1866. return self.color
  1867. @classmethod
  1868. def draw_color_simple(self):
  1869. return self.color_simple
  1870. class VectorSocket(bpy.types.NodeSocketVectorEuler, MantisSocket):
  1871. """Vector Input socket"""
  1872. bl_idname = 'VectorSocket'
  1873. bl_label = "Vector"
  1874. is_valid_interface_type=True
  1875. default_value : bpy.props.FloatVectorProperty(
  1876. default = (0.0, 0.0, 0.0),
  1877. update = update_socket,)
  1878. color_simple = cVector
  1879. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1880. input : bpy.props.BoolProperty(default =False,)
  1881. def draw(self, context, layout, node, text):
  1882. ChooseDraw(self, context, layout, node, text)
  1883. def draw_color(self, context, node):
  1884. return self.color
  1885. @classmethod
  1886. def draw_color_simple(self):
  1887. return self.color_simple
  1888. class VectorEulerSocket(bpy.types.NodeSocketVectorEuler, MantisSocket):
  1889. """Vector Input socket"""
  1890. bl_idname = 'VectorEulerSocket'
  1891. bl_label = "Euler"
  1892. is_valid_interface_type=True
  1893. default_value : bpy.props.FloatVectorProperty(
  1894. default = (0.0, 0.0, 0.0),
  1895. update = update_socket,
  1896. subtype='EULER',)
  1897. color_simple = cVector
  1898. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1899. input : bpy.props.BoolProperty(default =False,)
  1900. def draw(self, context, layout, node, text):
  1901. ChooseDraw(self, context, layout, node, text)
  1902. def draw_color(self, context, node):
  1903. return self.color
  1904. @classmethod
  1905. def draw_color_simple(self):
  1906. return self.color_simple
  1907. class VectorTranslationSocket(bpy.types.NodeSocketVectorTranslation, MantisSocket):
  1908. """Vector Input socket"""
  1909. bl_idname = 'VectorTranslationSocket'
  1910. bl_label = "Vector (Translation)"
  1911. default_value : bpy.props.FloatVectorProperty(
  1912. default = (0.0, 0.0, 0.0),
  1913. update = update_socket,
  1914. subtype='TRANSLATION',)
  1915. color_simple = cVector
  1916. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1917. input : bpy.props.BoolProperty(default =False,)
  1918. def draw(self, context, layout, node, text):
  1919. ChooseDraw(self, context, layout, node, text)
  1920. def draw_color(self, context, node):
  1921. return self.color
  1922. @classmethod
  1923. def draw_color_simple(self):
  1924. return self.color_simple
  1925. class VectorScaleSocket(bpy.types.NodeSocketVectorXYZ, MantisSocket):
  1926. """Vector Input socket"""
  1927. bl_idname = 'VectorScaleSocket'
  1928. bl_label = "Vector (Scale)"
  1929. default_value : bpy.props.FloatVectorProperty(
  1930. default = (1.0, 1.0, 1.0),
  1931. update = update_socket,
  1932. subtype='XYZ',)
  1933. color_simple = cVector
  1934. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1935. input : bpy.props.BoolProperty(default =False,)
  1936. def draw(self, context, layout, node, text):
  1937. ChooseDraw(self, context, layout, node, text)
  1938. def draw_color(self, context, node):
  1939. return self.color
  1940. @classmethod
  1941. def draw_color_simple(self):
  1942. return self.color_simple
  1943. class KeyframeSocket(MantisSocket):
  1944. '''Keyframe'''
  1945. bl_idname = 'KeyframeSocket'
  1946. bl_label = "Keyframe"
  1947. is_valid_interface_type=True
  1948. color_simple = cKeyframe
  1949. color : bpy.props.FloatVectorProperty(default=cKeyframe, size=4)
  1950. input : bpy.props.BoolProperty(default =False, update = update_socket)
  1951. def init(self):
  1952. self.display_shape = 'CIRCLE_DOT'
  1953. def draw(self, context, layout, node, text):
  1954. ChooseDraw(self, context, layout, node, text)
  1955. def draw_color(self, context, node):
  1956. return self.color
  1957. @classmethod
  1958. def draw_color_simple(self):
  1959. return self.color_simple
  1960. EnumKeyframeInterpolationType = (('CONSTANT', 'Stepped', 'Stepped'),
  1961. ('LINEAR', "Linear", "Linear"),
  1962. ('BEZIER', "Bezier", "Bezier"),)
  1963. class EnumKeyframeInterpolationTypeSocket(MantisSocket):
  1964. '''Keyframe Interpolation Type'''
  1965. bl_idname = 'EnumKeyframeInterpolationTypeSocket'
  1966. bl_label = "Keyframe Interpolation Type"
  1967. default_value :bpy.props.EnumProperty(
  1968. name="",
  1969. description="Interpolation",
  1970. items=EnumKeyframeInterpolationType,
  1971. default='LINEAR',
  1972. update = update_socket,)
  1973. color_simple = cString
  1974. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1975. input : bpy.props.BoolProperty(default =False, update = update_socket)
  1976. def draw(self, context, layout, node, text):
  1977. ChooseDraw(self, context, layout, node, text)
  1978. def draw_color(self, context, node):
  1979. return self.color
  1980. @classmethod
  1981. def draw_color_simple(self):
  1982. return self.color_simple
  1983. EnumKeyframeBezierHandleType = (('FREE', 'Free', 'Completely independent manually set handle.'),
  1984. ('ALIGNED', "Aligned", "Manually set handle with rotation locked together with its pair."),
  1985. ('VECTOR', "Vector", "Automatic handles that create straight lines."),
  1986. ('AUTO', "Automatic", "Automatic handles that create smooth curves."),
  1987. ('AUTO_CLAMPED', "Auto Clamped", "Automatic handles that create smooth curves which only change direction at keyframes."),)
  1988. class EnumKeyframeBezierHandleTypeSocket(MantisSocket):
  1989. '''Keyframe Bezier Handle Type'''
  1990. bl_idname = 'EnumKeyframeBezierHandleTypeSocket'
  1991. bl_label = "Keyframe Bezier Handle Type"
  1992. default_value :bpy.props.EnumProperty(
  1993. name="",
  1994. description="Handle Type",
  1995. items=EnumKeyframeBezierHandleType,
  1996. default='AUTO_CLAMPED',
  1997. update = update_socket,)
  1998. color_simple = cString
  1999. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2000. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2001. def draw(self, context, layout, node, text):
  2002. ChooseDraw(self, context, layout, node, text)
  2003. def draw_color(self, context, node):
  2004. return self.color
  2005. @classmethod
  2006. def draw_color_simple(self):
  2007. return self.color_simple
  2008. enumExtrapolationMode = (('CONSTANT', 'Constant', 'Constant'),
  2009. ('LINEAR', "Linear", "Linear"),)
  2010. class eFCrvExtrapolationMode(MantisSocket):
  2011. '''FCurve Extrapolation Mode'''
  2012. bl_idname = 'eFCrvExtrapolationMode'
  2013. bl_label = "Extrapolation Mode"
  2014. default_value :bpy.props.EnumProperty(
  2015. name="",
  2016. description="Handle Type",
  2017. items=enumExtrapolationMode,
  2018. default='CONSTANT',
  2019. update = update_socket,)
  2020. color_simple = cString
  2021. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2022. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2023. def draw(self, context, layout, node, text):
  2024. ChooseDraw(self, context, layout, node, text)
  2025. def draw_color(self, context, node):
  2026. return self.color
  2027. @classmethod
  2028. def draw_color_simple(self):
  2029. return self.color_simple
  2030. EnumLatticeInterpolationType = (('KEY_LINEAR', 'Linear', 'Linear Interpolation.'),
  2031. ('KEY_CARDINAL', "Cardinal", "Cardinal Interpolation."),
  2032. ('KEY_CATMULL_ROM', "Catmull Rom", "Catmull Rom Interpolation."),
  2033. ('KEY_BSPLINE', "B-Spline", "B Spline Interpolation."),)
  2034. class EnumLatticeInterpolationTypeSocket(MantisSocket):
  2035. '''Lattice Interpolation Type'''
  2036. bl_idname = 'EnumLatticeInterpolationTypeSocket'
  2037. bl_label = "Lattice Interpolation Type"
  2038. default_value :bpy.props.EnumProperty(
  2039. name="",
  2040. description="Interpolation Type",
  2041. items=EnumLatticeInterpolationType,
  2042. default='KEY_BSPLINE',
  2043. update = update_socket,)
  2044. color_simple = cString
  2045. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2046. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2047. def draw(self, context, layout, node, text):
  2048. ChooseDraw(self, context, layout, node, text)
  2049. def draw_color(self, context, node):
  2050. return self.color
  2051. @classmethod
  2052. def draw_color_simple(self):
  2053. return self.color_simple
  2054. enumFloatOperations = (('ADD', 'Add', 'Add'),
  2055. ('SUBTRACT', "Subtract", "Subtract"),
  2056. ('MULTIPLY', "Multiply", "Multiply"),
  2057. ('DIVIDE', "Divide", "Divide"),
  2058. ('POWER', "Power", "Power"),
  2059. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2060. ('MODULUS', "Modulus", "Modulus"),
  2061. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2062. ('MAXIMUM', "Maximum", "Maximum"),
  2063. ('MINIMUM', "Minimum", "Minimum"),
  2064. ('GREATER THAN', "Greater Than", "Greater Than"),
  2065. ('LESS THAN', "Less Than", "Less Than"),
  2066. ('ARCTAN2', "atan2", "2-argument arctan function"),
  2067. ('FLOOR', "Floor", "the nearest integer lower than input A"),
  2068. ('CEIL', "Ceiling", "the next integer higher than input A"),
  2069. ('ROUND', "Round", "Round to the nearest integer"),)
  2070. class MathFloatOperation(MantisSocket):
  2071. """Float Math Operation"""
  2072. bl_idname = 'MathFloatOperation'
  2073. bl_label = "Operation"
  2074. default_value :bpy.props.EnumProperty(
  2075. name="",
  2076. description="Operation",
  2077. items=enumFloatOperations,
  2078. default='MULTIPLY',
  2079. update = update_socket,)
  2080. color_simple = cString
  2081. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2082. input : bpy.props.BoolProperty(default =False,)
  2083. def draw(self, context, layout, node, text):
  2084. ChooseDraw(self, context, layout, node, text)
  2085. def draw_color(self, context, node):
  2086. return self.color
  2087. @classmethod
  2088. def draw_color_simple(self):
  2089. return self.color_simple
  2090. enumVectorOperations = (('ADD', 'Add', 'Add (Component-wise)'),
  2091. ('SUBTRACT', "Subtract", "Subtract (Component-wise)"),
  2092. ('MULTIPLY', "Multiply", "Multiply (Component-wise)"),
  2093. ('SCALE', "Scale", "Scales vector by input float or average magnitude of input vector's components."),
  2094. ('DIVIDE', "Divide", "Divide (Component-wise)"),
  2095. ('POWER', "Power", "Power (Component-wise)"),
  2096. ('LENGTH', "Length", "Length"),
  2097. ('CROSS', "Cross Product", "Cross product of A X B"),
  2098. ('NORMALIZE', "Normalize", "Returns a normalized vector."),
  2099. ('DOT', "Dot Product", "Dot product of A . B"),
  2100. ('LINEAR_INTERP', "Linear Interpolation", "Linear Interpolation between vectors A and B by factor"))
  2101. class MathVectorOperation(MantisSocket):
  2102. """Vector Math Operation"""
  2103. bl_idname = 'MathVectorOperation'
  2104. bl_label = "Operation"
  2105. default_value :bpy.props.EnumProperty(
  2106. name="",
  2107. description="Operation",
  2108. items=enumVectorOperations,
  2109. default='MULTIPLY',
  2110. update = update_socket,)
  2111. color_simple = cString
  2112. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2113. input : bpy.props.BoolProperty(default =False,)
  2114. def draw(self, context, layout, node, text):
  2115. ChooseDraw(self, context, layout, node, text)
  2116. def draw_color(self, context, node):
  2117. return self.color
  2118. @classmethod
  2119. def draw_color_simple(self):
  2120. return self.color_simple
  2121. enumMatrixTransform = (('TRANSLATE', 'Translate', 'Translate'),
  2122. ('ROTATE_AXIS_ANGLE', "Rotate (Axis-angle)", "Rotates a number of radians around an axis"),
  2123. # ('ROTATE_EULER', "Rotate (Euler)", "Euler Rotation"),
  2124. # ('ROTATE_QUATERNION', "Rotate (Quaternion)", "Quaternion Rotation"),
  2125. ('SCALE', "Scale", "Scale"),)
  2126. class MatrixTransformOperation(MantisSocket):
  2127. """Matrix Transform Operation"""
  2128. bl_idname = 'MatrixTransformOperation'
  2129. bl_label = "Operation"
  2130. default_value :bpy.props.EnumProperty(
  2131. name="",
  2132. description="Operation",
  2133. items=enumMatrixTransform,
  2134. default='TRANSLATE',
  2135. update = update_socket,)
  2136. color_simple = cString
  2137. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2138. input : bpy.props.BoolProperty(default =False,)
  2139. def draw(self, context, layout, node, text):
  2140. ChooseDraw(self, context, layout, node, text)
  2141. def draw_color(self, context, node):
  2142. return self.color
  2143. @classmethod
  2144. def draw_color_simple(self):
  2145. return self.color_simple
  2146. enumIntOperations = (('ADD', 'Add', 'Add'),
  2147. ('SUBTRACT', "Subtract", "Subtract"),
  2148. ('MULTIPLY', "Multiply", "Multiply"),
  2149. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2150. ('POWER', "Power", "Power"),
  2151. ('MODULUS', "Modulus", "Modulus"),
  2152. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2153. ('MAXIMUM', "Maximum", "Maximum"),
  2154. ('MINIMUM', "Minimum", "Minimum"),
  2155. ('GREATER THAN', "Greater Than", "Greater Than"),
  2156. ('LESS THAN', "Less Than", "Less Than"),)
  2157. class MathIntOperation(MantisSocket):
  2158. """Int Math Operation"""
  2159. bl_idname = 'MathIntOperation'
  2160. bl_label = "Operation"
  2161. default_value :bpy.props.EnumProperty(
  2162. name="",
  2163. description="Operation",
  2164. items=enumIntOperations,
  2165. default='MULTIPLY',
  2166. update = update_socket,)
  2167. color_simple = cString
  2168. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2169. input : bpy.props.BoolProperty(default =False,)
  2170. def draw(self, context, layout, node, text):
  2171. ChooseDraw(self, context, layout, node, text)
  2172. def draw_color(self, context, node):
  2173. return self.color
  2174. @classmethod
  2175. def draw_color_simple(self):
  2176. return self.color_simple
  2177. enumCompareOperations = (('EQUAL', "Equal", "Equal"),
  2178. ('NOT_EQUAL', "Not Equal", "Not Equal"),
  2179. ('GREATER_THAN', "Greater Than", "Greater Than"),
  2180. ('GREATER_THAN_EQUAL', "Greater Than or Equal", "Greater Than or Equal"),
  2181. ('LESS_THAN', "Less Than", "Less Than"),
  2182. ('LESS_THAN_EQUAL', "Equal or Less Than", "Equal or Less Than"),)
  2183. class EnumCompareOperation(MantisSocket):
  2184. """Compare Operation"""
  2185. bl_idname = 'EnumCompareOperation'
  2186. bl_label = "Comparison"
  2187. default_value :bpy.props.EnumProperty(
  2188. name="",
  2189. description="Comparison",
  2190. items=enumCompareOperations,
  2191. default='EQUAL',
  2192. update = update_socket,)
  2193. color_simple = cString
  2194. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2195. input : bpy.props.BoolProperty(default =False,)
  2196. def draw(self, context, layout, node, text):
  2197. ChooseDraw(self, context, layout, node, text)
  2198. def draw_color(self, context, node):
  2199. return self.color
  2200. @classmethod
  2201. def draw_color_simple(self):
  2202. return self.color_simple
  2203. class WildcardSocket(MantisSocket):
  2204. """Some kind of node socket lol I donno"""
  2205. bl_idname = 'WildcardSocket'
  2206. bl_label = ""
  2207. color_simple = (0.0,0.0,0.0,0.0)
  2208. color : bpy.props.FloatVectorProperty(default=(0.0,0.0,0.0,0.0), size=4)
  2209. input : bpy.props.BoolProperty(default =False,)
  2210. def draw(self, context, layout, node, text):
  2211. ChooseDraw(self, context, layout, node, text)
  2212. def draw_color(self, context, node):
  2213. return self.color
  2214. @classmethod
  2215. def draw_color_simple(self):
  2216. return self.color_simple