socket_definitions.py 88 KB

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