socket_definitions.py 89 KB

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