socket_definitions.py 86 KB

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