socket_definitions.py 88 KB

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