socket_definitions.py 100 KB

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