socket_definitions.py 89 KB

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