socket_definitions.py 88 KB

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