socket_definitions.py 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196
  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. 'EnumCustomPropTypeSocket',
  13. 'CustomPropSocket',
  14. 'FCurveSocket',
  15. 'DriverSocket',
  16. 'DriverVariableSocket',
  17. 'xFormParameterSocket',
  18. 'MorphTargetSocket',
  19. 'KeyframeSocket',
  20. 'WildcardSocket',
  21. ]
  22. # the sockets that do not have this field do not transfer data.
  23. # instead, it is the link itself which is meaningful.
  24. from bpy.app import version as bpy_version
  25. if bpy_version == (4,5,0): # THere is a bug that requires the socket type to inherit from a Blender class
  26. from bpy.types import NodeSocketGeometry # so we will just inherit from NodeSocketGeometry
  27. class MantisSocket(NodeSocketGeometry, NodeSocket): # even though that is kinda silly
  28. is_valid_interface_type=False
  29. category : bpy.props.StringProperty()
  30. @property # making this a classmethod is apparently not gonna work
  31. def interface_type(self):
  32. return NodeSocketGeometry.bl_idname
  33. else:
  34. class MantisSocket(NodeSocket):
  35. is_valid_interface_type=False
  36. category : bpy.props.StringProperty()
  37. @property
  38. def interface_type(self):
  39. # this is stupid but it is the fastest way to implement this
  40. # TODO: refactor this, it should be a class property
  41. if hasattr(self, "color"):
  42. return map_color_to_socket_type(self.color)
  43. return map_color_to_socket_type(self.color_simple)
  44. from .utilities import (prRed, prGreen, prPurple, prWhite,
  45. prOrange,
  46. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  47. wrapOrange,)
  48. transform_spaces_bone_to = (('WORLD', "World", "World Space"),
  49. ('LOCAL', "Local", "Local Space"),
  50. ('POSE', "Pose", "Pose Space"),
  51. ('CUSTOM', "Custom", "Custom Space"),
  52. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),
  53. ('LOCAL_OWNER_ORIENT', "Local (Owner Orientation)", "Local Space"),)
  54. transform_spaces_bone_from = (('WORLD', "World", "World Space"),
  55. ('LOCAL', "Local", "Local Space"),
  56. ('POSE', "Pose", "Pose Space"),
  57. ('CUSTOM', "Custom", "Custom Space"),
  58. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),)
  59. transform_spaces_bone_object = (('WORLD', "World", "World Space"),
  60. ('LOCAL', "Local", "Local Space"),
  61. ('POSE', "Pose", "Pose Space"),
  62. ('CUSTOM', "Custom", "Custom Space"),)
  63. transform_spaces_object = (('WORLD', "World", "World Space"),
  64. ('LOCAL', "Local", "Local Space"),
  65. ('CUSTOM', "Custom", "Custom Space"),)
  66. enumRotationOrder =(('AUTO', 'Auto', 'Auto'),
  67. ('XYZ', "XYZ", "XYZ"),
  68. ('XZY', "XZY", "XZY"),
  69. ('ZXY', "ZXY", "ZXY"),
  70. ('ZYX', "ZYX", "ZYX"),
  71. ('YXZ', "YXZ", "YXZ"),
  72. ('YZX', "YZX", "YZX"),
  73. ('QUATERNION', "Quaternion", "Quaternion"),
  74. ('AXIS_ANGLE', "Axis Angle", "Axis Angle"),)
  75. # node socket colors:
  76. cFloat = (0.631373, 0.631373, 0.631373, 1.000000)
  77. cColor = (0.780392, 0.780392, 0.160784, 1.000000)
  78. cVector = (0.388235, 0.388235, 0.780392, 1.000000)
  79. cShader = (0.388235, 0.780392, 0.388235, 1.000000)
  80. cInt = (0.058824, 0.521569, 0.149020, 1.000000)
  81. cString = (0.388235, 0.388235, 0.388235, 1.000000)
  82. # cBool = (0.698039, 0.650980, 0.188235, 1.000000)
  83. cParameter = (0.48, 0.24, 0.24, 1.0)
  84. cDriver = (0.88, 0.11, 0.88, 1.0)
  85. cDriverVariable = (0.66, 0.33, 0.04, 1.0)
  86. cFCurve = (0.77, 0.77, 0.11, 1.0)
  87. cKeyframe = (0.06, 0.22, 0.88, 1.0)
  88. cEnable = (0.92, 0.92, 0.92, 1.0)
  89. cBoneCollection = (0.82, 0.82, 0.82, 1.0)
  90. cDeformer = (0.05, 0.08, 0.45, 1.0)
  91. cShapeKey = (0.95, 0.32, 0.05, 1.0)
  92. # custom colors:
  93. cIK = (0.596078, 0.596078, 0.364706, 1.000000) #because it's yellow in Blender
  94. cRelationship = (0.352941, 0.584314, 0.431373, 1.000000) #constraint color
  95. cMatrix = (0.0, 1.0, 0.75, 1)
  96. cxForm = (0.843137, 0.592157, 0.388235, 1.000000) #could even fetch the theme colors...
  97. cTransformSpace = (1.0, 0.4, 0.216, 1.0)
  98. cBool = (0.1, 0.1, 0.1, 1.0)
  99. cBool3 = (0.35, 0.25, 0.18, 1.0)
  100. cRotationOrder = (0.0, 0.8, 0.0, 1.0)
  101. cQuaternion = (0.85, 0.25, 0.18, 1.0)
  102. #
  103. cGeometry = (0.000000, 0.672443, 0.366253, 1.000000)
  104. # think about making colors that are representative of the data's purpose:
  105. # location
  106. # rotation
  107. # scale
  108. # OR make all of it a reference to the type of data within?
  109. def color_equivalent(color_a, color_b):
  110. # because Blender's floating point numbers are not quite equal. pain.
  111. from .base_definitions import FLOAT_EPSILON
  112. for channel_a, channel_b in zip(color_a, color_b):
  113. if abs(channel_a-channel_b) > FLOAT_EPSILON:
  114. return False
  115. return True
  116. def map_color_to_socket_type(socket_color):
  117. # let's get the socket type by color for e.g. wildcard sockets.
  118. # for some reason I can't use match-case here. dumb.
  119. if color_equivalent(socket_color, cFloat):
  120. return "FloatSocket"
  121. if color_equivalent(socket_color, cColor):
  122. return "ColorSetSocket"
  123. if color_equivalent(socket_color, cVector):
  124. return "VectorSocket"
  125. if color_equivalent(socket_color, cInt):
  126. return "IntSocket"
  127. if color_equivalent(socket_color, cDriver):
  128. return "DriverSocket"
  129. if color_equivalent(socket_color, cDriverVariable):
  130. return "DriverVariableSocket"
  131. if color_equivalent(socket_color, cFCurve):
  132. return "FCurveSocket"
  133. if color_equivalent(socket_color, cKeyframe):
  134. return "KeyframeSocket"
  135. if color_equivalent(socket_color, cEnable):
  136. return "BooleanSocket"
  137. if color_equivalent(socket_color, cDeformer):
  138. return "DeformerSocket"
  139. if color_equivalent(socket_color, cShapeKey):
  140. return "MorphTargetSocket"
  141. if color_equivalent(socket_color, cMatrix):
  142. return "MatrixSocket"
  143. if color_equivalent(socket_color, cxForm):
  144. return "xFormSocket"
  145. if color_equivalent(socket_color, cBool):
  146. return "BooleanSocket"
  147. if color_equivalent(socket_color, cBool3):
  148. return "BooleanThreeTupleSocket"
  149. return "StringSocket"
  150. # Hybrid approach: Make same-data, similar purpose have similar colors.
  151. from typing import List
  152. def TellClasses() -> List[MantisSocket]:
  153. return [ #MantisSocket,
  154. #DefaultSocket,
  155. #InputSocket,
  156. MatrixSocket,
  157. xFormSocket,
  158. RelationshipSocket,
  159. DeformerSocket,
  160. GeometrySocket,
  161. GenericRotationSocket,
  162. EnableSocket,
  163. HideSocket,
  164. # InverseKinematicsSocket,
  165. DriverSocket,
  166. DriverVariableSocket,
  167. FCurveSocket,
  168. # LayerMaskSocket,
  169. # LayerMaskInputSocket,
  170. BoneCollectionSocket,
  171. EnumArrayGetOptions,
  172. EnumCustomPropTypeSocket,
  173. CustomPropSocket,
  174. xFormParameterSocket,
  175. ParameterBoolSocket,
  176. ParameterIntSocket,
  177. ParameterFloatSocket,
  178. ParameterVectorSocket,
  179. ParameterStringSocket,
  180. TransformSpaceSocket,
  181. BooleanSocket,
  182. InvertedBooleanSocket,
  183. BooleanThreeTupleSocket,
  184. RotationOrderSocket,
  185. QuaternionSocket,
  186. QuaternionSocketAA,
  187. UnsignedIntSocket,
  188. IntSocket,
  189. StringSocket,
  190. CollectionDeclarationSocket,
  191. ColorSetDisplaySocket,
  192. ColorSetSocket,
  193. EnumMetaRigSocket,
  194. EnumMetaBoneSocket,
  195. EnumCurveSocket,
  196. EnumWidgetLibrarySocket,
  197. BoolUpdateParentNode,
  198. # LabelSocket,
  199. IKChainLengthSocket,
  200. EnumInheritScale,
  201. EnumRotationMix,
  202. EnumRotationMixCopyTransforms,
  203. EnumMaintainVolumeStretchTo,
  204. EnumRotationStretchTo,
  205. EnumTrackAxis,
  206. EnumUpAxis,
  207. EnumFollowPathForwardAxis,
  208. EnumFloorAxis,
  209. EnumLockAxis,
  210. EnumLimitMode,
  211. EnumYScaleMode,
  212. EnumXZScaleMode,
  213. EnumTransformationMap,
  214. EnumTransformationRotationMode,
  215. EnumTransformationRotationOrder,
  216. EnumTransformationTranslationMixMode,
  217. EnumTransformationRotationMixMode,
  218. EnumTransformationScaleMixMode,
  219. EnumTransformationAxes,
  220. EnumBBoneHandleType,
  221. # Shrinkwrap
  222. EnumShrinkwrapTypeSocket,
  223. EnumShrinkwrapFaceCullSocket,
  224. EnumShrinkwrapProjectAxisSocket,
  225. EnumShrinkwrapModeSocket,
  226. # Deformers
  227. EnumSkinning,
  228. MorphTargetSocket,
  229. #
  230. FloatSocket,
  231. FloatPositiveSocket,
  232. FloatFactorSocket,
  233. FloatAngleSocket,
  234. VectorSocket,
  235. VectorEulerSocket,
  236. VectorTranslationSocket,
  237. VectorScaleSocket,
  238. # Drivers
  239. EnumDriverVariableType,
  240. EnumDriverVariableEvaluationSpace,
  241. EnumDriverVariableTransformChannel,
  242. EnumDriverRotationMode,
  243. EnumDriverType,
  244. KeyframeSocket,
  245. EnumKeyframeInterpolationTypeSocket,
  246. EnumKeyframeBezierHandleTypeSocket,
  247. EnumLatticeInterpolationTypeSocket,
  248. EnumCorrectiveSmoothTypeSocket,
  249. eFCrvExtrapolationMode,
  250. # Math
  251. MathFloatOperation,
  252. MathVectorOperation,
  253. MatrixTransformOperation,
  254. #conditions
  255. EnumCompareOperation,
  256. # Schema
  257. WildcardSocket,
  258. # xFormArraySocket,
  259. # RelationshipArraySocket,
  260. # BooleanArraySocket,
  261. # IntArraySocket,
  262. # FloatArraySocket,
  263. # BooleanThreeTupleArraySocket,
  264. # VectorArraySocket,
  265. # QuaternionArraySocket,
  266. # MatrixArraySocket,
  267. # StringArraySocket,
  268. ]
  269. def Tell_bl_idnames(): # reroute nodes
  270. return [cls.bl_idname for cls in TellClasses()]#+["NodeSocketColor"]
  271. def tell_valid_bl_idnames():
  272. valid_classes = filter(lambda cls : cls.is_valid_interface_type, [cls for cls in TellClasses()])
  273. return (cls.bl_idname for cls in valid_classes)
  274. enum_default_xForm_values =(
  275. ('NONE', "None", "None - fail if unconnected (RECOMMENDED)."),
  276. ('ARMATURE', "Generated Armature", "Generate an armature automatically. "
  277. "PLEASE use this only for development and testing. "
  278. "If you use this as a feature in your rigs you will be sorry."),)
  279. # Custom Interface Types give the user the ability to set properties for the interface
  280. # we'll define a base class, and generate the individual classes from the base class
  281. # but we'll leave the option to define a few of them directly.
  282. from bpy.types import NodeTreeInterfaceSocket
  283. def interface_socket_update(self, context):
  284. # we're just gonna do this the dumb way for now and invalidate the tree
  285. # BUG HACK TODO actually I am gonna do this stuff later
  286. # later, I can do this based on the connections in the tree
  287. # and the socket updater can use the same code for group interface modifications
  288. # TODO do this stuff because the tree will be a lot snappier
  289. pass
  290. interface_default_value_description="The default value of the socket when it is not connected."
  291. class MantisInterfaceSocketBaseClass():
  292. is_array : bpy.props.BoolProperty(default =False, update=interface_socket_update,
  293. description="Whether the socket is an array, otherwise it is constant." )
  294. is_connection : bpy.props.BoolProperty(default =False, update=interface_socket_update,
  295. description="If the socket is a connection or not. Ensure this is always paired"
  296. " with an input and an output." )
  297. connected_to : bpy.props.StringProperty(default="", update=interface_socket_update,
  298. description="The name of the socket this one is connected to." )
  299. # we are just gonna use ONE base class (it's easier)
  300. # so generate ALL properties and show only what is needed.
  301. default_string : bpy.props.StringProperty(default="", update=interface_socket_update,
  302. description=interface_default_value_description, )
  303. default_float : bpy.props.FloatProperty(default=0.0, update=interface_socket_update,
  304. description=interface_default_value_description, )
  305. default_vector : bpy.props.FloatVectorProperty( size = 3, default = (0.0, 0.0, 0.0, ),
  306. description=interface_default_value_description, update=interface_socket_update,)
  307. default_int : bpy.props.IntProperty(default=0, update=interface_socket_update,
  308. description=interface_default_value_description, )
  309. default_bool : bpy.props.BoolProperty(default=False, update=interface_socket_update,
  310. description=interface_default_value_description, )
  311. default_bool_vector : bpy.props.BoolVectorProperty(subtype = "XYZ", update=interface_socket_update,
  312. description=interface_default_value_description, )
  313. default_xForm : bpy.props.EnumProperty( default = 'NONE', update = interface_socket_update,
  314. items=enum_default_xForm_values, description=interface_default_value_description,)
  315. def interface_draw(self, context, layout):
  316. if not self.is_connection:
  317. layout.prop(self, "is_array", text="Is Array", toggle=True,)
  318. if not self.is_array and self.id_data.bl_idname == 'SchemaTree':
  319. layout.prop(self, "is_connection", text="Is Connection", toggle=True,)
  320. if False: # DISABLED for now because it will take a big change to Schema to make this work.
  321. if self.is_connection: # only show this if in a Schema AND set to is_connection
  322. layout.prop(self, "connected_to", text="Connected To", toggle=True,)
  323. # Different classes to handle different data types. In the future, these should also
  324. # have settable min/max and such where appropriate
  325. def interface_string_draw(self, context, layout):
  326. layout.prop(self, "default_string", text="Default Value", toggle=True,)
  327. interface_draw(self, context, layout)
  328. def interface_float_draw(self, context, layout):
  329. layout.prop(self, "default_float", text="Default Value", toggle=True,)
  330. interface_draw(self, context, layout)
  331. def interface_vector_draw(self, context, layout):
  332. layout.prop(self, "default_vector", text="Default Value", toggle=True,)
  333. interface_draw(self, context, layout)
  334. def interface_int_draw(self, context, layout):
  335. layout.prop(self, "default_int", text="Default Value", toggle=True,)
  336. interface_draw(self, context, layout)
  337. def interface_bool_draw(self, context, layout):
  338. layout.prop(self, "default_bool", text="Default Value", toggle=True,)
  339. interface_draw(self, context, layout)
  340. def interface_bool_vector_draw(self, context, layout):
  341. layout.prop(self, "default_bool_vector", text="Default Value", toggle=True,)
  342. interface_draw(self, context, layout)
  343. def interface_xform_draw(self, context, layout):
  344. if self.in_out == 'INPUT':
  345. layout.prop(self, "default_xForm", text="Default Value", toggle=True,)
  346. interface_draw(self, context, layout)
  347. def generate_custom_interface_types():
  348. generated_classes = []
  349. # copied from above
  350. valid_classes = filter(lambda cls : cls.is_valid_interface_type, [cls for cls in TellClasses()])
  351. for cls in valid_classes:
  352. name = cls.__name__ + "Interface"
  353. my_interface_draw = interface_draw
  354. # set the right draw function by the value's type
  355. match map_color_to_socket_type(cls.color_simple): #there has to be a better way to do this
  356. case "BooleanSocket":
  357. my_interface_draw = interface_bool_draw
  358. case "IntSocket":
  359. my_interface_draw = interface_int_draw
  360. case "FloatSocket":
  361. my_interface_draw = interface_float_draw
  362. case "BooleanThreeTupleSocket":
  363. my_interface_draw = interface_bool_vector_draw
  364. case "VectorSocket":
  365. my_interface_draw = interface_vector_draw
  366. case "StringSocket":
  367. my_interface_draw = interface_string_draw
  368. case "xFormSocket":
  369. my_interface_draw = interface_xform_draw
  370. interface = type(
  371. name,
  372. (MantisInterfaceSocketBaseClass, NodeTreeInterfaceSocket,),
  373. {
  374. "draw" : my_interface_draw,
  375. "bl_idname" : name,
  376. "bl_socket_idname" : cls.bl_idname,
  377. "socket_type" : cls.bl_idname,
  378. },
  379. )
  380. generated_classes.append(interface)
  381. return generated_classes
  382. # Was setting color like this:
  383. # color : bpy.props.FloatVectorProperty(size = 4, default = cFCurve,)
  384. # but this didn't work when Blender automatically generated interface classes?
  385. # so changed it to color = cVariable
  386. # but for color-changing sockets, if I make them, this won' work? Maybe?
  387. #
  388. # I actually think I was wrong about all of that lol
  389. # TODO change it back, dingus
  390. ########################################################################
  391. # Update Callbacks
  392. ########################################################################
  393. def socket_update(mantis_node, ui_socket, socket_name=None):
  394. node_updated = mantis_node.ui_modify_socket(ui_socket, socket_name)
  395. if not node_updated: # so that we can tag its dependencies
  396. mantis_node.reset_execution_recursive()
  397. return node_updated
  398. def default_update(ui_socket, context, do_execute=True):
  399. context = bpy.context
  400. if not context.space_data:
  401. return
  402. if not hasattr(context.space_data, "path"):
  403. return
  404. try:
  405. node_tree = context.space_data.path[0].node_tree
  406. except IndexError: # not in the UI, for example, in a script instead.
  407. return
  408. if node_tree is None:
  409. return
  410. if node_tree.is_executing or node_tree.is_exporting or not node_tree.do_live_update:
  411. return
  412. # if it is a Schema Node, it will fail the checks below -- but we need it to update the tree.
  413. from .base_definitions import SchemaUINode
  414. if isinstance(ui_socket.node, SchemaUINode):
  415. node_tree.update_tree(context, force = True)
  416. prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
  417. node_tree.execute_tree(context)
  418. return
  419. if hasattr(ui_socket.node, "initialized"):
  420. if not ui_socket.node.initialized: return
  421. elif hasattr(ui_socket.node, 'is_updating'):
  422. if ui_socket.node.is_updating: return
  423. else: return
  424. # if the socket has survived THAT ordeal, then the context is OK.
  425. # first, we try to update the Mantis tree in-situ.
  426. # Some nodes can update their b-objects, others will have to force-update the tree
  427. # because we just modified the data without modifying the topology of the graph.
  428. # finally, try and execute it if mantis couldn't update the b_objects itself.
  429. from .base_definitions import array_output_types
  430. mantis_updated=True
  431. if (ui_socket.node.bl_idname in ["MantisNodeGroup", "MantisSchemaGroup"]):
  432. mantis_updated=False # this kind of socket can't be updated here (yet)
  433. node_tree.update_tree(context, force=True)
  434. elif ui_socket.node.bl_idname in array_output_types:
  435. mantis_updated=False
  436. node_tree.update_tree(context, force=True)
  437. elif hasattr(ui_socket, 'default_value'):
  438. # we may not have to regenerate the tree; try and update the socket
  439. from .utilities import tree_from_mantis_node
  440. for mantis_node in node_tree.parsed_tree.values():
  441. # check to see if the mantis node is in the same ui-tree as this ui_socket
  442. if mantis_node.ui_signature is None: continue # autogenerated nodes
  443. if mantis_node.ui_signature[-1] == ui_socket.node.name and \
  444. tree_from_mantis_node(mantis_node.ui_signature, node_tree) == ui_socket.node.id_data:
  445. node_updated = True
  446. from .misc_nodes import SimpleInputNode
  447. if isinstance(mantis_node, SimpleInputNode):
  448. node_updated = socket_update(mantis_node, ui_socket)
  449. for l in mantis_node.outputs[ui_socket.name].links:
  450. node_updated = node_updated and socket_update(l.to_node, ui_socket, l.to_socket)
  451. else:
  452. node_updated = socket_update(mantis_node, ui_socket)
  453. # execute the tree if even one node didn't update
  454. mantis_updated = node_updated and mantis_updated
  455. # we want to force it if we have made an unhandled change inside of a schema.
  456. node_tree.update_tree(context, force = (mantis_updated == False))
  457. node_tree.display_update(context)
  458. if mantis_updated==False:
  459. try:
  460. prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
  461. node_tree.execute_tree(context)
  462. except Exception as e:
  463. prRed("Automatic Tree Execution failed because of %s" % e)
  464. def update_socket(self, context,):
  465. default_update(self,context)
  466. def driver_variable_socket_update(self, context):
  467. default_update(self,context)
  468. def driver_socket_update(self, context):
  469. default_update(self,context)
  470. def update_mute_socket(self, context):
  471. self.node.mute = not self.default_value
  472. default_update(self,context)
  473. def update_hide_socket(self, context):
  474. self.node.mute = self.default_value
  475. default_update(self,context)
  476. def ik_chain_length_update_socket(self, context):
  477. default_update(self,context)
  478. # self.node.update_chain_length(context)
  479. def update_parent_node(self, context):
  480. default_update(self,context)
  481. if hasattr(self.node, "display_update"):
  482. self.node.display_update(context)
  483. def update_metarig_armature(self, context,):
  484. if self.search_prop:
  485. self.node.armature = self.search_prop.name
  486. self.node.inputs["Meta-Bone"].search_prop = self.search_prop
  487. default_update(self,context)
  488. def update_metarig_posebone(self, context,):
  489. self.node.pose_bone = self.default_value
  490. default_update(self,context)
  491. def update_socket_external_load(self, context):
  492. # this is a socket update for sockets that load data from a pack
  493. # e.g. widget, metarig, curve, or component selector sockets
  494. # currently no plans to add any but widgets, but whatever
  495. default_update(self, context)
  496. self.previous_value = self.default_value # this is all I need to do lol
  497. items = get_widget_library_items(self, context) # feels silly to do this here
  498. for item in items:
  499. if item[0] == self.default_value:
  500. self.previous_index = item[-1]
  501. break
  502. ########################################################################
  503. # Sockets
  504. ########################################################################
  505. text_only_output_types = ["NodeGroupInput", "NodeGroupOutput", "SchemaArrayInput",
  506. "SchemaArrayInputGet", "SchemaArrayInputAll", "SchemaConstInput",
  507. "SchemaIncomingConnection"]
  508. def ChooseDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  509. invert_checkbox = False
  510. if hasattr(self, "invert") and self.invert == True:
  511. invert_checkbox=True
  512. # TEXT ONLY
  513. if self.node.bl_idname in text_only_output_types:
  514. layout.label(text=text)
  515. elif hasattr(self, "display_text") and self.display_text and self.is_linked:
  516. layout.label(text=self.display_text)
  517. else:
  518. # ENUM VALUES (this is a HACK, fix it later)
  519. if ('Enum' in self.bl_idname) and (use_enum):
  520. if not (self.is_output or self.is_linked):
  521. layout.prop_tabs_enum(self, "default_value",)
  522. else:
  523. layout.label(text=text)
  524. # for OUTPUT sockets that take INPUT (confusing name!)
  525. elif ((hasattr(self, "default_value")) and hasattr(self, "input") and getattr(self, "input")):
  526. # for simple input nodes
  527. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True)
  528. # for INPUTS that are NOT CONNECTED
  529. elif (hasattr(self, "default_value")) and not (self.is_output or self.is_linked):
  530. # DO: expose these values as parameters for this function
  531. # and set them for each socket.
  532. if icon == 'NONE': icon_only = False
  533. elif icon_only == True : text = "" # "real" icon-only looks bad for strings, need to check other props types.
  534. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True, icon=icon,
  535. invert_checkbox=invert_checkbox)
  536. # CONNECTED sockets and outputs without input fields
  537. else:
  538. layout.label(text=text)
  539. def CollectionSocketDraw(socket, context, layout, node, text):
  540. # create the UI objects
  541. indent_length = len(socket.collection_path.split('>'))
  542. layout.alignment = 'EXPAND'
  543. # label_col = layout.row()
  544. label_col = layout.split(factor=0.20)
  545. label_col.alignment = 'LEFT' # seems backwards?
  546. label_col.scale_x = 9.0
  547. x_split = label_col.split(factor=0.35)
  548. x_split.scale_x=2.0
  549. x_split.alignment = 'RIGHT'
  550. operator_col = layout.row()
  551. # operator_col = layout
  552. operator_col.alignment = 'RIGHT' # seems backwards?
  553. operator_col.scale_x = 1.0
  554. # x_split = operator_col.split(factor=0.5)
  555. # x_split.scale_x = 0.5
  556. # x_split.alignment = 'RIGHT'
  557. # Now fill in the text and operators and such
  558. label_text = socket.collection_path.split('>')[-1]
  559. if indent_length > 1:
  560. label_text = '└'+label_text #┈ use this character to extend
  561. for indent in range(indent_length):
  562. if indent <= 1: continue
  563. indent_text = ' ▹ '
  564. label_text=indent_text+label_text
  565. op_props = x_split.operator('mantis.collection_remove')
  566. op_props.socket_invoked = socket.identifier
  567. label_col.label(text=label_text)
  568. op_props = operator_col.operator('mantis.collection_add_new')
  569. op_props.socket_invoked = socket.identifier
  570. # this works well enough!
  571. class RelationshipSocket(MantisSocket):
  572. # Description string
  573. '''Relationship'''
  574. # Optional identifier string. If not explicitly defined, the python class name is used.
  575. bl_idname = 'RelationshipSocket'
  576. bl_label = "Relationship"
  577. color_simple = cRelationship
  578. color : bpy.props.FloatVectorProperty(default=cRelationship, size=4)
  579. input : bpy.props.BoolProperty(default =False,)
  580. is_valid_interface_type=True
  581. def draw(self, context, layout, node, text):
  582. ChooseDraw(self, context, layout, node, text)
  583. def draw_color(self, context, node):
  584. return self.color
  585. @classmethod
  586. def draw_color_simple(self):
  587. return self.color_simple
  588. class DeformerSocket(MantisSocket):
  589. # Description string
  590. '''Deformer'''
  591. # Optional identifier string. If not explicitly defined, the python class name is used.
  592. bl_idname = 'DeformerSocket'
  593. bl_label = "Deformer"
  594. is_valid_interface_type=True
  595. color_simple = cDeformer
  596. color : bpy.props.FloatVectorProperty(default=cDeformer, size=4)
  597. input : bpy.props.BoolProperty(default =False,)
  598. def draw(self, context, layout, node, text):
  599. ChooseDraw(self, context, layout, node, text)
  600. def draw_color(self, context, node):
  601. return self.color
  602. @classmethod
  603. def draw_color_simple(self):
  604. return self.color_simple
  605. class MatrixSocket(MantisSocket):
  606. '''Matrix Input Output'''
  607. bl_idname = 'MatrixSocket'
  608. bl_label = "Matrix"
  609. default_value : bpy.props.FloatVectorProperty(
  610. default = (1.0, 0.0, 0.0, 0.0,
  611. 0.0, 1.0, 0.0, 0.0,
  612. 0.0, 0.0, 1.0, 0.0,
  613. 0.0, 0.0, 0.0, 1.0),
  614. size=16,
  615. update = update_socket,)
  616. color_simple = cMatrix
  617. color : bpy.props.FloatVectorProperty(default=cMatrix, size=4)
  618. input : bpy.props.BoolProperty(default =False,)
  619. is_valid_interface_type=True
  620. # Optional function for drawing the socket input value
  621. def draw(self, context, layout, node, text):
  622. layout.label(text=text)
  623. def draw_color(self, context, node):
  624. return self.color
  625. @classmethod
  626. def draw_color_simple(self):
  627. return self.color_simple
  628. # Utility functions to make handling the 16 numbers more bearable
  629. def SetValue(self, mat):
  630. self.default_value = ( mat[0][0], mat[0][1], mat[0][2], mat[0][3],
  631. mat[1][0], mat[1][1], mat[1][2], mat[1][3],
  632. mat[2][0], mat[2][1], mat[2][2], mat[2][3],
  633. mat[3][0], mat[3][1], mat[3][2], mat[3][3], )
  634. def TellValue(self):
  635. from mathutils import Matrix
  636. v = self.default_value
  637. return Matrix( ( ( v[ 0], v[ 1], v[ 2], v[ 3],),
  638. ( v[ 4], v[ 5], v[ 6], v[ 7],),
  639. ( v[ 8], v[ 9], v[10], v[11],),
  640. ( v[12], v[13], v[14], v[15]), ) )
  641. #NOTE, we're not using the last row
  642. # so we're gonna use it to store data
  643. # unused, unused, unused, bone_length
  644. # but we're not going to make it
  645. # available except by accessor functions
  646. # would like to make this stuff easier to deal with tho
  647. def TellBoneLength(self):
  648. return self.default_value[15]
  649. class xFormSocket(MantisSocket):
  650. '''xFrom Input Output'''
  651. bl_idname = 'xFormSocket'
  652. bl_label = "xForm"
  653. color_simple = cxForm
  654. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  655. input : bpy.props.BoolProperty(default =False,)
  656. is_valid_interface_type=True
  657. def draw(self, context, layout, node, text):
  658. ChooseDraw(self, context, layout, node, text)
  659. def draw_color(self, context, node):
  660. return self.color
  661. @classmethod
  662. def draw_color_simple(self):
  663. return self.color_simple
  664. class GeometrySocket(MantisSocket):
  665. '''Geometry Input Output'''
  666. bl_idname = 'GeometrySocket'
  667. bl_label = "Geometry"
  668. color_simple = cGeometry
  669. color : bpy.props.FloatVectorProperty(default=cGeometry, size=4)
  670. input : bpy.props.BoolProperty(default =False,)
  671. is_valid_interface_type=True
  672. def draw(self, context, layout, node, text):
  673. ChooseDraw(self, context, layout, node, text)
  674. def draw_color(self, context, node):
  675. return self.color
  676. @classmethod
  677. def draw_color_simple(self):
  678. return self.color_simple
  679. class GenericRotationSocket(MantisSocket):
  680. '''Custom node socket type'''
  681. bl_idname = 'GenericRotationSocket'
  682. bl_label = "Rotation"
  683. color = (0.0,0.0,0.0,0.0)
  684. input : bpy.props.BoolProperty(default =False,)
  685. def draw(self, context, layout, node, text):
  686. ChooseDraw(self, context, layout, node, text)
  687. def draw_color(self, context, node):
  688. return self.color
  689. @classmethod
  690. def draw_color_simple(self):
  691. return self.color_simple
  692. ###############################
  693. class EnableSocket(MantisSocket):
  694. '''Custom node socket type'''
  695. bl_idname = 'EnableSocket'
  696. bl_label = "Enable"
  697. default_value: bpy.props.BoolProperty(default=True, update = update_mute_socket,)
  698. color_simple = cEnable
  699. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  700. input : bpy.props.BoolProperty(default =False,)
  701. def draw(self, context, layout, node, text):
  702. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  703. def draw_color(self, context, node):
  704. return self.color
  705. @classmethod
  706. def draw_color_simple(self):
  707. return self.color_simple
  708. class HideSocket(MantisSocket):
  709. '''Custom node socket type'''
  710. bl_idname = 'HideSocket'
  711. bl_label = "Hide"
  712. default_value: bpy.props.BoolProperty(default=False, update = update_hide_socket,)
  713. color_simple = cEnable
  714. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  715. input : bpy.props.BoolProperty(default =False,)
  716. def draw(self, context, layout, node, text):
  717. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  718. def draw_color(self, context, node):
  719. return self.color
  720. @classmethod
  721. def draw_color_simple(self):
  722. return self.color_simple
  723. class FCurveSocket(MantisSocket):
  724. '''fCurve'''
  725. bl_idname = 'FCurveSocket'
  726. bl_label = "fCurve"
  727. color_simple = cFCurve
  728. color : bpy.props.FloatVectorProperty(default=cFCurve, size=4)
  729. input : bpy.props.BoolProperty(default =False, update = update_socket)
  730. is_valid_interface_type=True
  731. def init(self):
  732. self.display_shape = 'CIRCLE_DOT'
  733. def draw(self, context, layout, node, text):
  734. ChooseDraw(self, context, layout, node, text)
  735. def draw_color(self, context, node):
  736. return self.color
  737. @classmethod
  738. def draw_color_simple(self):
  739. return self.color_simple
  740. class DriverSocket(MantisSocket):
  741. '''Driver'''
  742. bl_idname = 'DriverSocket'
  743. bl_label = "Driver"
  744. color_simple = cDriver
  745. color : bpy.props.FloatVectorProperty(default=cDriver, size=4)
  746. input : bpy.props.BoolProperty(default =False, update = update_socket)
  747. is_valid_interface_type=True
  748. def init(self):
  749. self.display_shape = 'CIRCLE_DOT'
  750. def draw(self, context, layout, node, text):
  751. ChooseDraw(self, context, layout, node, text)
  752. def draw_color(self, context, node):
  753. return self.color
  754. @classmethod
  755. def draw_color_simple(self):
  756. return self.color_simple
  757. class DriverVariableSocket(MantisSocket):
  758. '''Driver'''
  759. bl_idname = 'DriverVariableSocket'
  760. bl_label = "Driver Variable"
  761. color_simple = cDriverVariable
  762. color : bpy.props.FloatVectorProperty(default=cDriverVariable, size=4)
  763. input : bpy.props.BoolProperty(default =False, update = update_socket)
  764. is_valid_interface_type=True
  765. def init(self):
  766. self.display_shape = 'CIRCLE_DOT'
  767. def draw(self, context, layout, node, text):
  768. ChooseDraw(self, context, layout, node, text)
  769. def draw_color(self, context, node):
  770. return self.color
  771. @classmethod
  772. def draw_color_simple(self):
  773. return self.color_simple
  774. # transform_spaces
  775. # transform_spaces_bone_object
  776. # transform_spaces_object
  777. # def get_transform_space_enum(self, context):
  778. # pass
  779. def get_transform_space(self, context):
  780. if "Owner" in self.name:
  781. return transform_spaces_bone_from
  782. else:
  783. return transform_spaces_bone_to
  784. class TransformSpaceSocket(MantisSocket):
  785. '''Custom node socket type'''
  786. bl_idname = 'TransformSpaceSocket'
  787. bl_label = "Transform Space"
  788. default_value: bpy.props.EnumProperty(
  789. name="Space Transform",
  790. description="Space Transform",
  791. items=get_transform_space,
  792. default=0,
  793. update = update_socket,)
  794. color_simple = cTransformSpace
  795. color : bpy.props.FloatVectorProperty(default=cTransformSpace, size=4)
  796. input : bpy.props.BoolProperty(default =False,)
  797. def draw(self, context, layout, node, text):
  798. ChooseDraw(self, context, layout, node, text)
  799. def draw_color(self, context, node):
  800. return self.color
  801. @classmethod
  802. def draw_color_simple(self):
  803. return self.color_simple
  804. class BooleanSocket(MantisSocket):
  805. '''Custom node socket type'''
  806. bl_idname = 'BooleanSocket'
  807. bl_label = "Boolean"
  808. default_value: bpy.props.BoolProperty(update = update_socket,)
  809. color_simple = cBool
  810. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  811. input : bpy.props.BoolProperty(default =False,)
  812. is_valid_interface_type=True
  813. def draw(self, context, layout, node, text):
  814. ChooseDraw(self, context, layout, node, text)
  815. def draw_color(self, context, node):
  816. return self.color
  817. @classmethod
  818. def draw_color_simple(self):
  819. return self.color_simple
  820. class InvertedBooleanSocket(MantisSocket):
  821. '''Custom node socket type'''
  822. bl_idname = 'InvertedBooleanSocket'
  823. bl_label = "Inverted Boolean"
  824. default_value: bpy.props.BoolProperty(update = update_socket,)
  825. color_simple = cBool
  826. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  827. input : bpy.props.BoolProperty(default =False,)
  828. invert : bpy.props.BoolProperty(default=True,)
  829. is_valid_interface_type=False
  830. def draw(self, context, layout, node, text):
  831. ChooseDraw(self, context, layout, node, text)
  832. def draw_color(self, context, node):
  833. return self.color
  834. @classmethod
  835. def draw_color_simple(self):
  836. return self.color_simple
  837. class BooleanThreeTupleSocket(MantisSocket):
  838. # Description string
  839. '''Custom node socket type'''
  840. # Optional identifier string. If not explicitly defined, the python class name is used.
  841. bl_idname = 'BooleanThreeTupleSocket'
  842. bl_label = "Boolean Vector"
  843. default_value: bpy.props.BoolVectorProperty(subtype = "XYZ",update = update_socket,)
  844. color_simple = cBool3
  845. color : bpy.props.FloatVectorProperty(default=cBool3, size=4)
  846. input : bpy.props.BoolProperty(default =False,)
  847. is_valid_interface_type=True
  848. def draw(self, context, layout, node, text):
  849. ChooseDraw(self, context, layout, node, text)
  850. def draw_color(self, context, node):
  851. return self.color
  852. @classmethod
  853. def draw_color_simple(self):
  854. return self.color_simple
  855. def TellValue(self):
  856. return (self.default_value[0], self.default_value[1], self.default_value[2])
  857. class RotationOrderSocket(MantisSocket):
  858. '''Custom node socket type'''
  859. bl_idname = 'RotationOrderSocket'
  860. bl_label = "Rotation Order"
  861. default_value: bpy.props.EnumProperty(
  862. name="Rotation Order",
  863. description="Rotation Order",
  864. items=enumRotationOrder,
  865. default='AUTO',
  866. update = update_socket,)
  867. color_simple = cRotationOrder
  868. color : bpy.props.FloatVectorProperty(default=cRotationOrder, size=4)
  869. input : bpy.props.BoolProperty(default =False,)
  870. def draw(self, context, layout, node, text):
  871. ChooseDraw(self, context, layout, node, text)
  872. def draw_color(self, context, node):
  873. return self.color
  874. @classmethod
  875. def draw_color_simple(self):
  876. return self.color_simple
  877. class QuaternionSocket(MantisSocket):
  878. '''Custom node socket type'''
  879. bl_idname = 'QuaternionSocket'
  880. bl_label = "Quaternion"
  881. default_value: bpy.props.FloatVectorProperty(
  882. subtype = "QUATERNION",
  883. size = 4,
  884. default = (1.0, 0.0, 0.0, 0.0,),
  885. update = update_socket,)
  886. color_simple = cQuaternion
  887. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  888. input : bpy.props.BoolProperty(default =False,)
  889. def draw(self, context, layout, node, text):
  890. ChooseDraw(self, context, layout, node, text)
  891. def draw_color(self, context, node):
  892. return self.color
  893. @classmethod
  894. def draw_color_simple(self):
  895. return self.color_simple
  896. class QuaternionSocketAA(MantisSocket):
  897. '''Custom node socket type'''
  898. bl_idname = 'QuaternionSocketAA'
  899. bl_label = "Axis Angle Quaternion"
  900. color_simple = cQuaternion
  901. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  902. input : bpy.props.BoolProperty(default =False,)
  903. default_value: bpy.props.FloatVectorProperty(
  904. subtype = "AXISANGLE",
  905. size = 4,
  906. default = (1.0, 0.0, 0.0, 0.0,),
  907. update = update_socket,)
  908. def draw(self, context, layout, node, text):
  909. ChooseDraw(self, context, layout, node, text)
  910. def draw_color(self, context, node):
  911. return self.color
  912. @classmethod
  913. def draw_color_simple(self):
  914. return self.color_simple
  915. class IntSocket(MantisSocket):
  916. '''Custom node socket type'''
  917. bl_idname = 'IntSocket'
  918. bl_label = "Integer"
  919. default_value: bpy.props.IntProperty(default=0, update = update_socket, soft_min=-256, soft_max=256)
  920. color_simple = cInt
  921. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  922. input : bpy.props.BoolProperty(default =False,)
  923. is_valid_interface_type=True
  924. def draw(self, context, layout, node, text):
  925. ChooseDraw(self, context, layout, node, text)
  926. def draw_color(self, context, node):
  927. return self.color
  928. @classmethod
  929. def draw_color_simple(self):
  930. return self.color_simple
  931. class UnsignedIntSocket(MantisSocket):
  932. '''Unsigned Integer Socket'''
  933. bl_idname = 'UnsignedIntSocket'
  934. bl_label = "Unsigned Integer"
  935. default_value: bpy.props.IntProperty(default=0, update = update_socket, min=0, soft_max=256, max=2**13)
  936. color_simple = cInt
  937. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  938. input : bpy.props.BoolProperty(default =False,)
  939. is_valid_interface_type=True
  940. def draw(self, context, layout, node, text):
  941. ChooseDraw(self, context, layout, node, text)
  942. def draw_color(self, context, node):
  943. return self.color
  944. @classmethod
  945. def draw_color_simple(self):
  946. return self.color_simple
  947. class StringSocket(MantisSocket):
  948. """Float Input socket"""
  949. bl_idname = 'StringSocket'
  950. bl_label = "String"
  951. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  952. color_simple = cString
  953. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  954. icon : bpy.props.StringProperty(default = "NONE",)
  955. input : bpy.props.BoolProperty(default =False,)
  956. display_text : bpy.props.StringProperty(default="")
  957. is_valid_interface_type=True
  958. # def init(self):
  959. # if self.node.bl_idname == 'UtilityBoneProperties':
  960. # self.display_shape='CIRCLE_DOT'
  961. def draw(self, context, layout, node, text):
  962. ChooseDraw(self, context, layout, node, text, icon=self.icon, icon_only=True,)
  963. def draw_color(self, context, node):
  964. return self.color
  965. @classmethod
  966. def draw_color_simple(self):
  967. return self.color_simple
  968. def collection_declaration_get_default_value(self):
  969. return self.collection_path
  970. class CollectionDeclarationSocket(MantisSocket):
  971. """Socket for declaring a collection"""
  972. bl_idname = 'CollectionDeclarationSocket'
  973. bl_label = "Collection"
  974. default_value : bpy.props.StringProperty(get=collection_declaration_get_default_value)
  975. collection_path : bpy.props.StringProperty(default="")
  976. color_simple = cBoneCollection
  977. color : bpy.props.FloatVectorProperty(default=cBoneCollection, size=4)
  978. icon : bpy.props.StringProperty(default = "NONE",)
  979. input : bpy.props.BoolProperty(default =True,)
  980. display_text : bpy.props.StringProperty(default="")
  981. is_valid_interface_type=False
  982. def draw(self, context, layout, node, text):
  983. CollectionSocketDraw(self, context, layout, node, text)
  984. def draw_color(self, context, node):
  985. return self.color
  986. @classmethod
  987. def draw_color_simple(self):
  988. return self.color_simple
  989. class BoneCollectionSocket(MantisSocket):
  990. """Collection socket"""
  991. bl_idname = 'BoneCollectionSocket'
  992. bl_label = "Collection"
  993. default_value: bpy.props.StringProperty(default = "Collection", update = update_socket,)
  994. input : bpy.props.BoolProperty(default =False,)
  995. color_simple = cBoneCollection
  996. color : bpy.props.FloatVectorProperty(default=cBoneCollection, size=4)
  997. is_valid_interface_type=True
  998. def draw(self, context, layout, node, text):
  999. ChooseDraw(self, context, layout, node, text)
  1000. def draw_color(self, context, node):
  1001. return self.color
  1002. @classmethod
  1003. def draw_color_simple(self):
  1004. return self.color_simple
  1005. def get_bone_theme_color(socket, prop,):
  1006. from bpy import context
  1007. color_index=socket.color_index
  1008. color_set = context.preferences.themes[0].bone_color_sets[color_index]
  1009. return getattr(color_set, prop )
  1010. def get_active_color(socket):
  1011. if socket is None:
  1012. from bpy import context
  1013. return context.preferences.themes[0].view_3d.bone_pose_active
  1014. return get_bone_theme_color(socket, 'active')
  1015. def get_normal_color(socket):
  1016. if socket is None:
  1017. from bpy import context
  1018. return context.preferences.themes[0].view_3d.bone_solid
  1019. return get_bone_theme_color(socket, 'normal')
  1020. def get_select_color(socket):
  1021. if socket is None:
  1022. from bpy import context
  1023. return context.preferences.themes[0].view_3d.bone_pose
  1024. return get_bone_theme_color(socket, 'select')
  1025. def get_color_set_value(socket,):
  1026. return [ socket.active_color[0],
  1027. socket.active_color[1],
  1028. socket.active_color[2],
  1029. socket.normal_color[0],
  1030. socket.normal_color[1],
  1031. socket.normal_color[2],
  1032. socket.selected_color[0],
  1033. socket.selected_color[1],
  1034. socket.selected_color[2],]
  1035. class ColorSetDisplaySocket(MantisSocket):
  1036. """Socket for displaying a bone color theme"""
  1037. bl_idname = 'ColorSetDisplaySocket'
  1038. bl_label = "Color Set"
  1039. default_value : bpy.props.FloatVectorProperty(get=get_color_set_value, size=9)
  1040. color_simple = cColor
  1041. color : bpy.props.FloatVectorProperty(default=cColor, size=4)
  1042. icon : bpy.props.StringProperty(default = "NONE",)
  1043. input : bpy.props.BoolProperty(default =False,)
  1044. display_text : bpy.props.StringProperty(default="")
  1045. color_index : bpy.props.IntProperty(default=0)
  1046. active_color : bpy.props.FloatVectorProperty(
  1047. name='Active Color', size=3, subtype='COLOR_GAMMA',
  1048. get=get_active_color )
  1049. normal_color : bpy.props.FloatVectorProperty(
  1050. name='Normal Color', size=3, subtype='COLOR_GAMMA',
  1051. get=get_normal_color )
  1052. selected_color : bpy.props.FloatVectorProperty(
  1053. name='Selected Color', size=3, subtype='COLOR_GAMMA',
  1054. get=get_select_color )
  1055. is_valid_interface_type=False
  1056. def draw(self, context, layout, node, text):
  1057. layout.prop( text='', data=self,
  1058. property='active_color', )
  1059. layout.prop( text='', data=self,
  1060. property='normal_color',)
  1061. layout.prop( text='', data=self,
  1062. property='selected_color',)
  1063. def draw_color(self, context, node):
  1064. return self.color
  1065. @classmethod
  1066. def draw_color_simple(self):
  1067. return self.color_simple
  1068. class ColorSetSocket(MantisSocket):
  1069. """Socket for setting a bone color"""
  1070. bl_idname = 'ColorSetSocket'
  1071. bl_label = "Custom Color Set"
  1072. default_value : bpy.props.FloatVectorProperty(get=get_color_set_value, size=9)
  1073. color_simple = cColor
  1074. color : bpy.props.FloatVectorProperty(default=cColor, size=4)
  1075. icon : bpy.props.StringProperty(default = "NONE",)
  1076. input : bpy.props.BoolProperty(default = True,)
  1077. display_text : bpy.props.StringProperty(default="")
  1078. active_color : bpy.props.FloatVectorProperty(
  1079. name='Active Color', size=3, subtype='COLOR_GAMMA',
  1080. default=get_active_color(None),)
  1081. normal_color : bpy.props.FloatVectorProperty(
  1082. name='Normal Color', size=3, subtype='COLOR_GAMMA',
  1083. default=get_normal_color(None),)
  1084. selected_color : bpy.props.FloatVectorProperty(
  1085. name='Selected Color', size=3, subtype='COLOR_GAMMA',
  1086. default=get_select_color(None),)
  1087. is_valid_interface_type=True
  1088. def draw(self, context, layout, node, text):
  1089. inherit_color_socket = self.node.inputs.get("Inherit Color")
  1090. if (self.is_output == False) and (self.is_linked == True):
  1091. layout.label(text=self.name)
  1092. elif self.node.bl_idname in text_only_output_types:
  1093. layout.label(text=self.name)
  1094. elif inherit_color_socket and inherit_color_socket.default_value == True:
  1095. layout.label(text='Using Inherit Color.')
  1096. else:
  1097. layout.prop( text='Color Set', data=self,
  1098. property='active_color', )
  1099. layout.prop( text='', data=self,
  1100. property='normal_color',)
  1101. layout.prop( text='', data=self,
  1102. property='selected_color',)
  1103. if self.node.bl_idname == 'InputColorSetPallete':
  1104. ops_props = layout.operator('mantis.color_pallete_socket_remove')
  1105. ops_props.tree_invoked = self.node.id_data.name
  1106. ops_props.node_invoked = self.node.name
  1107. ops_props.socket_invoked = self.identifier
  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. eArrayGetOptions =(
  1114. ('CAP', "Cap", "Fail if the index is out of bounds."),
  1115. ('WRAP', "Wrap", "Wrap around to the beginning of the array once the idex goes out of bounds."),
  1116. ('HOLD', "Hold", "Reuse the last element of the array if the index is out of bounds."),)
  1117. class EnumArrayGetOptions(MantisSocket):
  1118. '''Custom node socket type'''
  1119. bl_idname = 'EnumArrayGetOptions'
  1120. bl_label = "OoB Behaviour"
  1121. default_value: bpy.props.EnumProperty(
  1122. items=eArrayGetOptions,
  1123. name="OoB Behaviour",
  1124. description="Out-of-bounds behaviour.",
  1125. default = 'HOLD',
  1126. update = update_socket,)
  1127. color_simple = cString
  1128. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1129. input : bpy.props.BoolProperty(default =False,)
  1130. def draw(self, context, layout, node, text):
  1131. ChooseDraw(self, context, layout, node, text)
  1132. def draw_color(self, context, node):
  1133. return self.color
  1134. @classmethod
  1135. def draw_color_simple(self):
  1136. return self.color_simple
  1137. #####################################################################################
  1138. # Parameters
  1139. #####################################################################################
  1140. eCustomPropType = (
  1141. ('BOOL' , "Boolean", "Boolean", 0),
  1142. ('INT' , "Int" , "Integer", 1),
  1143. ('FLOAT' , "Float" , "Floating Point Number", 2),
  1144. ('VECTOR' , "Vector" , "Vector", 3),
  1145. ('STRING' , "String" , "String", 4),
  1146. )
  1147. class EnumCustomPropTypeSocket(MantisSocket):
  1148. """Custom Property Type"""
  1149. bl_idname = 'EnumCustomPropTypeSocket'
  1150. bl_label = "Property Type"
  1151. color_simple = cString
  1152. default_value: bpy.props.EnumProperty(
  1153. items=eCustomPropType,
  1154. description="Custom Property Type",
  1155. default = 'BOOL',
  1156. update = update_socket,)
  1157. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1158. input : bpy.props.BoolProperty(default =False,)
  1159. def draw(self, context, layout, node, text):
  1160. ChooseDraw(self, context, layout, node, text)
  1161. def draw_color(self, context, node):
  1162. return self.color
  1163. @classmethod
  1164. def draw_color_simple(self):
  1165. return self.color_simple
  1166. # what is this one again?
  1167. class CustomPropSocket(MantisSocket):
  1168. '''Custom Property'''
  1169. bl_idname = 'CustomPropSocket'
  1170. bl_label = "Custom Property"
  1171. color_simple = cString
  1172. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1173. input : bpy.props.BoolProperty(default =False,)
  1174. def init(self):
  1175. self.display_shape = 'CIRCLE_DOT'
  1176. def draw(self, context, layout, node, text):
  1177. ChooseDraw(self, context, layout, node, text)
  1178. def draw_color(self, context, node):
  1179. return self.color
  1180. @classmethod
  1181. def draw_color_simple(self):
  1182. return self.color_simple
  1183. class xFormParameterSocket(MantisSocket):
  1184. '''xFrom Parameter'''
  1185. bl_idname = 'xFormParameterSocket'
  1186. bl_label = "xForm Parameter"
  1187. color_simple = cxForm
  1188. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  1189. input : bpy.props.BoolProperty(default =False,)
  1190. def init(self):
  1191. self.display_shape = 'CIRCLE_DOT'
  1192. def draw(self, context, layout, node, text):
  1193. ChooseDraw(self, context, layout, node, text)
  1194. def draw_color(self, context, node):
  1195. return self.color
  1196. @classmethod
  1197. def draw_color_simple(self):
  1198. return self.color_simple
  1199. # what is this one again?
  1200. class ParameterBoolSocket(MantisSocket):
  1201. """Boolean Parameter Socket"""
  1202. bl_idname = 'ParameterBoolSocket'
  1203. bl_label = "Boolean Parameter"
  1204. color_simple = cBool
  1205. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  1206. input : bpy.props.BoolProperty(default =False,)
  1207. #custom properties:
  1208. min:bpy.props.FloatProperty(default = 0)
  1209. max:bpy.props.FloatProperty(default = 1)
  1210. soft_min:bpy.props.FloatProperty(default = 0)
  1211. soft_max:bpy.props.FloatProperty(default = 1)
  1212. description:bpy.props.StringProperty(default = "")
  1213. default_value : bpy.props.BoolProperty(default = False, update = update_socket,)
  1214. def init(self):
  1215. self.display_shape = 'CIRCLE_DOT'
  1216. # if True:
  1217. # print (self.is_property_set("default_value"))
  1218. # ui_data = self.id_properties_ui("default_value")
  1219. # ui_data.update(
  1220. # description=self.description,
  1221. # default=0,) # for now
  1222. # ui_data.update(
  1223. # min = self.min,
  1224. # max = self.max,
  1225. # soft_min = self.soft_min,
  1226. # soft_max = self.soft_max,)
  1227. def draw(self, context, layout, node, text):
  1228. ChooseDraw(self, context, layout, node, text)
  1229. def draw_color(self, context, node):
  1230. return self.color
  1231. @classmethod
  1232. def draw_color_simple(self):
  1233. return self.color_simple
  1234. class ParameterIntSocket(MantisSocket):
  1235. """Integer Parameter socket"""
  1236. bl_idname = 'ParameterIntSocket'
  1237. bl_label = "Integer Parameter"
  1238. default_value : bpy.props.IntProperty(default = 0, update = update_socket,)
  1239. color_simple = cInt
  1240. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1241. input : bpy.props.BoolProperty(default =False,)
  1242. #custom properties:
  1243. min:bpy.props.FloatProperty(default = 0)
  1244. max:bpy.props.FloatProperty(default = 1)
  1245. soft_min:bpy.props.FloatProperty(default = 0)
  1246. soft_max:bpy.props.FloatProperty(default = 1)
  1247. description:bpy.props.StringProperty(default = "")
  1248. def init(self):
  1249. self.display_shape = 'CIRCLE_DOT'
  1250. def draw(self, context, layout, node, text):
  1251. ChooseDraw(self, context, layout, node, text)
  1252. def draw_color(self, context, node):
  1253. return self.color
  1254. @classmethod
  1255. def draw_color_simple(self):
  1256. return self.color_simple
  1257. class ParameterFloatSocket(MantisSocket):
  1258. """Float Parameter socket"""
  1259. bl_idname = 'ParameterFloatSocket'
  1260. bl_label = "Float Parameter"
  1261. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  1262. color_simple = cFloat
  1263. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1264. input : bpy.props.BoolProperty(default =False,)
  1265. #custom properties:
  1266. min:bpy.props.FloatProperty(default = 0)
  1267. max:bpy.props.FloatProperty(default = 1)
  1268. soft_min:bpy.props.FloatProperty(default = 0)
  1269. soft_max:bpy.props.FloatProperty(default = 1)
  1270. description:bpy.props.StringProperty(default = "")
  1271. def init(self):
  1272. self.display_shape = 'CIRCLE_DOT'
  1273. def draw(self, context, layout, node, text):
  1274. ChooseDraw(self, context, layout, node, text)
  1275. def draw_color(self, context, node):
  1276. return self.color
  1277. @classmethod
  1278. def draw_color_simple(self):
  1279. return self.color_simple
  1280. class ParameterVectorSocket(MantisSocket):
  1281. """Vector Parameter socket"""
  1282. bl_idname = 'ParameterVectorSocket'
  1283. bl_label = "Vector Parameter"
  1284. default_value : bpy.props.FloatVectorProperty(
  1285. default = (0.0, 0.0, 0.0),
  1286. update = update_socket,)
  1287. color_simple = cVector
  1288. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1289. input : bpy.props.BoolProperty(default =False,)
  1290. #custom properties:
  1291. description:bpy.props.StringProperty(default = "")
  1292. def init(self):
  1293. self.display_shape = 'CIRCLE_DOT'
  1294. def draw(self, context, layout, node, text):
  1295. ChooseDraw(self, context, layout, node, text)
  1296. def draw_color(self, context, node):
  1297. return self.color
  1298. @classmethod
  1299. def draw_color_simple(self):
  1300. return self.color_simple
  1301. class ParameterStringSocket(MantisSocket):
  1302. """String Parameter socket"""
  1303. bl_idname = 'ParameterStringSocket'
  1304. bl_label = "String Parameter"
  1305. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  1306. color_simple = cString
  1307. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1308. input : bpy.props.BoolProperty(default =False,)
  1309. #custom properties:
  1310. description:bpy.props.StringProperty(default = "")
  1311. def init(self):
  1312. self.display_shape = 'CIRCLE_DOT'
  1313. def draw(self, context, layout, node, text):
  1314. ChooseDraw(self, context, layout, node, text)
  1315. def draw_color(self, context, node):
  1316. return self.color
  1317. @classmethod
  1318. def draw_color_simple(self):
  1319. return self.color_simple
  1320. #####################################################################################
  1321. # Additional socket types, for special cases
  1322. #####################################################################################
  1323. from bpy.props import PointerProperty, StringProperty
  1324. def poll_is_armature(self, obj):
  1325. return obj.type == "ARMATURE"
  1326. # def poll_is_armature(self, obj):
  1327. # return obj.type == "ARMATURE"
  1328. class EnumMetaRigSocket(MantisSocket):
  1329. '''Custom node socket type'''
  1330. bl_idname = 'EnumMetaRigSocket'
  1331. bl_label = "Meta Rig"
  1332. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  1333. def get_default_value(self):
  1334. if self.search_prop:
  1335. return self.search_prop.name
  1336. return ""
  1337. def set_default_value(self, value):
  1338. if ob:= bpy.data.objects.get(value):
  1339. if ob.type == 'ARMATURE':
  1340. self.search_prop=ob
  1341. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1342. color_simple = cString
  1343. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1344. def draw(self, context, layout, node, text):
  1345. if self.is_output:
  1346. layout.label(text=self.name)
  1347. elif not (self.is_linked):
  1348. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="OUTLINER_OB_ARMATURE", results_are_suggestions=True)
  1349. elif hasattr(self.node, "armature"):
  1350. layout.label(text=self.node.armature)
  1351. # TODO: we should actually use the parsed tree to query this info directly, since this socket may belong to a node group in/out
  1352. # which doesn't have this parameter. whatever.
  1353. else:
  1354. layout.label(text=self.name)
  1355. def draw_color(self, context, node):
  1356. return self.color
  1357. @classmethod
  1358. def draw_color_simple(self):
  1359. return self.color_simple
  1360. def poll_is_curve(self, obj):
  1361. return obj.type == "CURVE"
  1362. class EnumCurveSocket(MantisSocket):
  1363. '''Choose a curve'''
  1364. bl_idname = 'EnumCurveSocket'
  1365. bl_label = "Curve"
  1366. is_valid_interface_type=True
  1367. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_curve, update=update_socket)
  1368. def get_default_value(self):
  1369. if self.search_prop:
  1370. return self.search_prop.name
  1371. return ""
  1372. def set_default_value(self, value):
  1373. if ob:= bpy.data.objects.get(value):
  1374. if ob.type == 'CURVE':
  1375. self.search_prop=ob
  1376. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1377. color_simple = cString
  1378. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1379. def draw(self, context, layout, node, text):
  1380. if not (self.is_linked) and not self.is_output:
  1381. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="CURVE_DATA", results_are_suggestions=True)
  1382. else:
  1383. try:
  1384. layout.label(text=self.search_prop.name)
  1385. except AttributeError: # TODO make this show the graph's result
  1386. layout.label(text=self.name)
  1387. def draw_color(self, context, node):
  1388. return self.color
  1389. @classmethod
  1390. def draw_color_simple(self):
  1391. return self.color_simple
  1392. def SearchPBDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  1393. 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)
  1394. class EnumMetaBoneSocket(MantisSocket):
  1395. '''Custom node socket type'''
  1396. bl_idname = 'EnumMetaBoneSocket'
  1397. bl_label = "Meta Bone"
  1398. search_prop:PointerProperty(type=bpy.types.Object)
  1399. bone:StringProperty()
  1400. def populate_bones_list(self, context):
  1401. # just gonna hardcode the value
  1402. if (meta_rig := self.search_prop):
  1403. retList = []
  1404. armatures = []
  1405. i = -1
  1406. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  1407. for b in meta_rig.data.bones:
  1408. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  1409. return(retList)
  1410. return None
  1411. # default_value : bpy.props.EnumProperty(
  1412. # items = populate_bones_list,
  1413. # name = "Meta Rig")
  1414. # def get_default_value(self):
  1415. # return self.search_prop.name
  1416. default_value : StringProperty(name = "", update=update_metarig_posebone)
  1417. color_simple = cString
  1418. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1419. def draw(self, context, layout, node, text):
  1420. if not (self.is_linked):
  1421. if self.search_prop is None:
  1422. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  1423. else:
  1424. SearchPBDraw(self, context, layout, node, text="")
  1425. else:
  1426. layout.label(text=self.node.pose_bone)
  1427. def draw_color(self, context, node):
  1428. return self.color
  1429. @classmethod
  1430. def draw_color_simple(self):
  1431. return self.color_simple
  1432. # TODO: make it so that this makes an item for "missing" widgets
  1433. # for when a widget is moved or deleted
  1434. # Make it read .blend
  1435. # make it read the current directory, too?
  1436. def get_widget_library_items(self, context):
  1437. from .preferences import get_bl_addon_object
  1438. bl_mantis_addon = get_bl_addon_object()
  1439. from os import path as os_path
  1440. prev_name = os_path.split(self.previous_value)[-1]
  1441. default_missing_value = ('MISSING', f'MISSING: {prev_name}', self.previous_value, 'ERROR', self.previous_index)
  1442. return_value = [default_missing_value]
  1443. widget_names={}
  1444. if bl_mantis_addon and bl_mantis_addon.preferences:
  1445. widgets_path = bl_mantis_addon.preferences.WidgetsLibraryFolder
  1446. from os import walk as os_walk
  1447. for path_root, dirs, files, in os_walk(widgets_path):
  1448. # TODO handle .blend files
  1449. for file in files:
  1450. relative_file_name = os_path.join(os_path.sep.join(dirs), file)
  1451. if file.endswith('.obj'):
  1452. widget_names[relative_file_name[:-4]] = relative_file_name
  1453. if widget_names.keys():
  1454. return_value=[]
  1455. # first we select the previous value if it exists
  1456. add_missing_key=False
  1457. add_one=0
  1458. if self.previous_value and self.previous_value not in widget_names.values():
  1459. add_missing_key=True # we need to add the missing key at the previous index
  1460. sorted_keys = list(widget_names.keys())
  1461. sorted_keys.sort()
  1462. for i, name in enumerate(sorted_keys):
  1463. path = widget_names[name]
  1464. if add_missing_key and i == self.previous_index:
  1465. add_one+=1; return_value.append(default_missing_value)
  1466. return_value.append( (path, name, path, 'GIZMO', i+add_one) )
  1467. return return_value
  1468. # THIS is a special socket type that finds the widgets in your widgets library (set in preferences)
  1469. class EnumWidgetLibrarySocket(MantisSocket):
  1470. '''Choose a Wdiget'''
  1471. bl_idname = 'EnumWidgetLibrarySocket'
  1472. bl_label = "Widget"
  1473. is_valid_interface_type=False
  1474. default_value : bpy.props.EnumProperty(
  1475. items=get_widget_library_items,
  1476. name="Widget",
  1477. description="Which widget to use",
  1478. default = 0,
  1479. update = update_socket_external_load,)
  1480. color_simple = cString
  1481. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1482. previous_value : bpy.props.StringProperty(default="")
  1483. previous_index : bpy.props.IntProperty(default=0)
  1484. def draw(self, context, layout, node, text):
  1485. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1486. def draw_color(self, context, node):
  1487. return self.color
  1488. @classmethod
  1489. def draw_color_simple(self):
  1490. return self.color_simple
  1491. class BoolUpdateParentNode(MantisSocket):
  1492. '''Custom node socket type'''
  1493. bl_idname = 'BoolUpdateParentNode'
  1494. bl_label = "Boolean"
  1495. default_value: bpy.props.BoolProperty(default=False, update = update_parent_node)
  1496. color_simple = cBool
  1497. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  1498. input : bpy.props.BoolProperty(default =False,)
  1499. def draw(self, context, layout, node, text):
  1500. ChooseDraw(self, context, layout, node, text)
  1501. def draw_color(self, context, node):
  1502. return self.color
  1503. @classmethod
  1504. def draw_color_simple(self):
  1505. return self.color_simple
  1506. class IKChainLengthSocket(MantisSocket):
  1507. '''Custom node socket type'''
  1508. bl_idname = 'IKChainLengthSocket'
  1509. bl_label = "IK Chain Length"
  1510. default_value: bpy.props.IntProperty(default=0, update = ik_chain_length_update_socket, min = 0, max = 255)
  1511. color_simple = cInt
  1512. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1513. input : bpy.props.BoolProperty(default =False,)
  1514. def draw(self, context, layout, node, text):
  1515. ChooseDraw(self, context, layout, node, text)
  1516. def draw_color(self, context, node):
  1517. return self.color
  1518. @classmethod
  1519. def draw_color_simple(self):
  1520. return self.color_simple
  1521. # Inherit
  1522. eInheritScale = (
  1523. ('FULL', "Full", "Fully inherit scale", 1),
  1524. ('AVERAGE', "Average", "todo", 2),
  1525. ('ALIGNED', "Aligned", "todo", 3),
  1526. ('FIX_SHEAR', "Fix Shear", "todo", 4),
  1527. ('NONE', "None", "todo", 5),
  1528. )
  1529. class EnumInheritScale(MantisSocket):
  1530. '''Custom node socket type'''
  1531. bl_idname = 'EnumInheritScale'
  1532. bl_label = "Inherit Scale"
  1533. default_value: bpy.props.EnumProperty(
  1534. items=eInheritScale,
  1535. name="Inherit Scale",
  1536. description="Inherit Scale",
  1537. default = 'FULL',
  1538. #options = set(),
  1539. update = update_socket,)
  1540. color_simple = cString
  1541. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1542. input : bpy.props.BoolProperty(default =False,)
  1543. def draw(self, context, layout, node, text):
  1544. ChooseDraw(self, context, layout, node, text)
  1545. def draw_color(self, context, node):
  1546. return self.color
  1547. @classmethod
  1548. def draw_color_simple(self):
  1549. return self.color_simple
  1550. # Copy Rotation
  1551. eRotationMix =(
  1552. ('REPLACE', "Replace", "Fully inherit scale", 0),
  1553. ('BEFORE', "Before", "Fully inherit scale", 1),
  1554. ('AFTER', "After", "Fully inherit scale", 2),
  1555. ('ADD', "Add", "Fully inherit scale", 3),
  1556. #todo, but i don't care much
  1557. )
  1558. # TODO HACK
  1559. # I am trying to figure out how to do enum_flag as
  1560. # mutually exclusive options
  1561. # but! I don't think it's possible
  1562. # I just like the UI for it :P
  1563. class EnumRotationMix(MantisSocket):
  1564. '''Custom node socket type'''
  1565. bl_idname = 'EnumRotationMix'
  1566. bl_label = "Rotation Mix"
  1567. default_value: bpy.props.EnumProperty(
  1568. items=eRotationMix,
  1569. name="Rotation Mix",
  1570. description="Rotation Mix",
  1571. default = 'REPLACE',#{'REPLACE'},
  1572. options = set(), # this has to be a set lol
  1573. update = update_socket,)
  1574. color_simple = cString
  1575. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1576. input : bpy.props.BoolProperty(default =False,)
  1577. def draw(self, context, layout, node, text):
  1578. ChooseDraw(self, context, layout, node, text)
  1579. def draw_color(self, context, node):
  1580. return self.color
  1581. @classmethod
  1582. def draw_color_simple(self):
  1583. return self.color_simple
  1584. eRotationMix_copytransforms =(
  1585. ('REPLACE', "Replace (Aligned)", "Fully inherit scale"),
  1586. ('BEFORE', "Before (Aligned)", "Fully inherit scale"),
  1587. ('AFTER', "After (Aligned)", "Fully inherit scale"),
  1588. ('REPLACE_SPLIT', "Replace (Split Channels)", "Fully inherit scale"),
  1589. ('BEFORE_SPLIT', "Before (Split Channels)", "Fully inherit scale"),
  1590. ('AFTER_SPLIT', "After (Split Channels)", "Fully inherit scale"),
  1591. ('REPLACE_FULL', "Replace (Full)", "Fully inherit scale"),
  1592. ('BEFORE_FULL', "Before (Full)", "Fully inherit scale"),
  1593. ('AFTER_FULL', "After (Full)", "Fully inherit scale"),)
  1594. class EnumRotationMixCopyTransforms(MantisSocket):
  1595. '''Custom node socket type'''
  1596. bl_idname = 'EnumRotationMixCopyTransforms'
  1597. bl_label = "Rotation Mix"
  1598. default_value: bpy.props.EnumProperty(
  1599. items=eRotationMix_copytransforms,
  1600. name="Rotation Mix",
  1601. description="Rotation Mix",
  1602. default = 'REPLACE', #{'REPLACE'},
  1603. #options = {'ENUM_FLAG'}, # this sux
  1604. update = update_socket,)
  1605. color_simple = cString
  1606. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1607. input : bpy.props.BoolProperty(default =False,)
  1608. def draw(self, context, layout, node, text):
  1609. ChooseDraw(self, context, layout, node, text)
  1610. def draw_color(self, context, node):
  1611. return self.color
  1612. @classmethod
  1613. def draw_color_simple(self):
  1614. return self.color_simple
  1615. # STRETCH TO
  1616. eMaintainVolumeStretchTo = (('VOLUME_XZX', "XZ", "XZ", 1),
  1617. ('VOLUME_X', "X", "X", 2),
  1618. ('VOLUME_Z', "Z", "Z", 4),
  1619. ('NO_VOLUME', "None", "None", 8),)
  1620. class EnumMaintainVolumeStretchTo(MantisSocket):
  1621. '''Custom node socket type'''
  1622. bl_idname = 'EnumMaintainVolumeStretchToSocket'
  1623. bl_label = "Maintain Volume"
  1624. default_value: bpy.props.EnumProperty(
  1625. items=eMaintainVolumeStretchTo,
  1626. name="Maintain Volume",
  1627. description="Maintain Volume",
  1628. default = 'VOLUME_XZX',
  1629. #options = {'ENUM_FLAG'},
  1630. update = update_socket,)
  1631. color_simple = cString
  1632. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1633. input : bpy.props.BoolProperty(default =False,)
  1634. def draw(self, context, layout, node, text):
  1635. ChooseDraw(self, context, layout, node, text)
  1636. def draw_color(self, context, node):
  1637. return self.color
  1638. @classmethod
  1639. def draw_color_simple(self):
  1640. return self.color_simple
  1641. eRotationStretchTo = (('PLANE_X', "XZ", "XZ", 1),
  1642. ('PLANE_Z', "ZX", "ZX", 2),
  1643. ('SWING_Y', "Swing", "Swing", 4),)
  1644. class EnumRotationStretchTo(MantisSocket):
  1645. '''Custom node socket type'''
  1646. bl_idname = 'EnumRotationStretchTo'
  1647. bl_label = "Rotation"
  1648. default_value: bpy.props.EnumProperty(
  1649. items=eRotationStretchTo,
  1650. name="Rotation",
  1651. description="Rotation",
  1652. default = 'PLANE_X',
  1653. #options = {'ENUM_FLAG'},
  1654. update = update_socket,)
  1655. color_simple = cString
  1656. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1657. input : bpy.props.BoolProperty(default =False,)
  1658. def draw(self, context, layout, node, text):
  1659. ChooseDraw(self, context, layout, node, text)
  1660. def draw_color(self, context, node):
  1661. return self.color
  1662. @classmethod
  1663. def draw_color_simple(self):
  1664. return self.color_simple
  1665. # Track-To
  1666. eTrackAxis = (('TRACK_X', "X", "X", 1),
  1667. ('TRACK_Y', "Y", "Y", 2),
  1668. ('TRACK_Z', "Z", "Z", 4),
  1669. ('TRACK_NEGATIVE_X', "-X", "-X", 8),
  1670. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 16),
  1671. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 32,))
  1672. eUpAxis = (('UP_X', "X", "X", 1),
  1673. ('UP_Y', "Y", "Y", 2),
  1674. ('UP_Z', "Z", "Z", 4),)
  1675. # ugly but I can't change it easily without messing up versioning
  1676. class EnumTrackAxis(MantisSocket):
  1677. '''Custom node socket type'''
  1678. bl_idname = 'EnumTrackAxis'
  1679. bl_label = "Track Axis"
  1680. default_value: bpy.props.EnumProperty(
  1681. items=eTrackAxis,
  1682. name="Track Axis",
  1683. description="Track Axis",
  1684. default = 'TRACK_X',
  1685. #options = {'ENUM_FLAG'},
  1686. update = update_socket,)
  1687. color_simple = cString
  1688. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1689. input : bpy.props.BoolProperty(default =False,)
  1690. def draw(self, context, layout, node, text):
  1691. ChooseDraw(self, context, layout, node, text)
  1692. def draw_color(self, context, node):
  1693. return self.color
  1694. @classmethod
  1695. def draw_color_simple(self):
  1696. return self.color_simple
  1697. class EnumUpAxis(MantisSocket):
  1698. '''Custom node socket type'''
  1699. bl_idname = 'EnumUpAxis'
  1700. bl_label = "Up Axis"
  1701. default_value: bpy.props.EnumProperty(
  1702. items=eUpAxis,
  1703. name="Up Axis",
  1704. description="Up Axis",
  1705. default = 'UP_X',
  1706. #options = {'ENUM_FLAG'},
  1707. update = update_socket,)
  1708. color_simple = cString
  1709. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1710. input : bpy.props.BoolProperty(default =False,)
  1711. def draw(self, context, layout, node, text):
  1712. ChooseDraw(self, context, layout, node, text)
  1713. def draw_color(self, context, node):
  1714. return self.color
  1715. @classmethod
  1716. def draw_color_simple(self):
  1717. return self.color_simple
  1718. # Follow Track Forward axis
  1719. eForwardAxis = (('FORWARD_X', "X", "X", 0),
  1720. ('FORWARD_Y', "Y", "Y", 1),
  1721. ('FORWARD_Z', "Z", "Z", 2),
  1722. ('TRACK_NEGATIVE_X', "-X", "-X", 3),
  1723. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 4),
  1724. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 5),)
  1725. class EnumFollowPathForwardAxis(MantisSocket):
  1726. '''Custom node socket type'''
  1727. bl_idname = 'EnumFollowPathForwardAxis'
  1728. bl_label = "Forward Axis"
  1729. default_value: bpy.props.EnumProperty(
  1730. items=eForwardAxis,
  1731. name="Forward Axis",
  1732. description="Forward Axis",
  1733. default = 'FORWARD_X',
  1734. update = update_socket,)
  1735. color_simple = cString
  1736. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1737. input : bpy.props.BoolProperty(default =False,)
  1738. def draw(self, context, layout, node, text):
  1739. ChooseDraw(self, context, layout, node, text)
  1740. def draw_color(self, context, node):
  1741. return self.color
  1742. @classmethod
  1743. def draw_color_simple(self):
  1744. return self.color_simple
  1745. # Follow Track Forward axis
  1746. eFloorAxis = (('FLOOR_X', "X", "X", 0),
  1747. ('FLOOR_Y', "Y", "Y", 1),
  1748. ('FLOOR_Z', "Z", "Z", 2),
  1749. ('FLOOR_NEGATIVE_X', "-X", "-X", 3),
  1750. ('FLOOR_NEGATIVE_Y', "-Y", "-Y", 4),
  1751. ('FLOOR_NEGATIVE_Z', "-Z", "-Z", 5),)
  1752. class EnumFloorAxis(MantisSocket):
  1753. '''Floor Constraint Axis'''
  1754. bl_idname = 'EnumFloorAxis'
  1755. bl_label = "Floor Axis"
  1756. default_value: bpy.props.EnumProperty(
  1757. items=eFloorAxis,
  1758. name="Floor Axis",
  1759. description="Floor Axis",
  1760. default = 'FLOOR_X',
  1761. update = update_socket,)
  1762. color_simple = cString
  1763. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1764. input : bpy.props.BoolProperty(default =False,)
  1765. def draw(self, context, layout, node, text):
  1766. ChooseDraw(self, context, layout, node, text)
  1767. def draw_color(self, context, node):
  1768. return self.color
  1769. @classmethod
  1770. def draw_color_simple(self):
  1771. return self.color_simple
  1772. # Locked Track
  1773. eLockAxis = (('LOCK_X', "X", "X", 1),
  1774. ('LOCK_Y', "Y", "Y", 2),
  1775. ('LOCK_Z', "Z", "Z", 4),)
  1776. class EnumLockAxis(MantisSocket):
  1777. '''Custom node socket type'''
  1778. bl_idname = 'EnumLockAxis'
  1779. bl_label = "Lock Axis"
  1780. default_value: bpy.props.EnumProperty(
  1781. items=eLockAxis,
  1782. name="Lock Axis",
  1783. description="Lock Axis",
  1784. default = 'LOCK_X',
  1785. #options = {'ENUM_FLAG'},
  1786. update = update_socket,)
  1787. color_simple = cString
  1788. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1789. input : bpy.props.BoolProperty(default =False,)
  1790. def draw(self, context, layout, node, text):
  1791. ChooseDraw(self, context, layout, node, text)
  1792. def draw_color(self, context, node):
  1793. return self.color
  1794. @classmethod
  1795. def draw_color_simple(self):
  1796. return self.color_simple
  1797. # Limit Distance:
  1798. eLimitMode = (('LIMITDIST_INSIDE', "Inside", "Inside",),
  1799. ('LIMITDIST_OUTSIDE', "Outside", "Outside",),
  1800. ('LIMITDIST_ONSURFACE', "On Surface", "On Surface",),)
  1801. class EnumLimitMode(MantisSocket):
  1802. '''Custom node socket type'''
  1803. bl_idname = 'EnumLimitMode'
  1804. bl_label = "Clamp Region"
  1805. default_value: bpy.props.EnumProperty(
  1806. items=eLimitMode,
  1807. name="Clamp Region",
  1808. description="Clamp Region",
  1809. default = 'LIMITDIST_INSIDE',
  1810. update = update_socket,)
  1811. color_simple = cString
  1812. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1813. input : bpy.props.BoolProperty(default =False,)
  1814. def draw(self, context, layout, node, text):
  1815. ChooseDraw(self, context, layout, node, text)
  1816. def draw_color(self, context, node):
  1817. return self.color
  1818. @classmethod
  1819. def draw_color_simple(self):
  1820. return self.color_simple
  1821. # Spline IK
  1822. eYScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1823. ('FIT_CURVE', "Fit Curve", "Scale the bones to fit the entire length of the curve.",),
  1824. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),)
  1825. eXZScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1826. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),
  1827. ('INVERSE_PRESERVE', "Inverse Scale", "Scale of the X and Z axes is the inverse of the Y-Scale.",),
  1828. ('VOLUME_PRESERVE', "Volume Preservation", "Scale of the X and Z axes are adjusted to preserve the volume of the bones.",),)
  1829. class EnumYScaleMode(MantisSocket):
  1830. '''Custom node socket type'''
  1831. bl_idname = 'EnumYScaleMode'
  1832. bl_label = "Y Scale Mode"
  1833. default_value: bpy.props.EnumProperty(
  1834. items=eYScaleMode,
  1835. name="Y Scale Mode",
  1836. description="Y Scale Mode",
  1837. default = 'FIT_CURVE',
  1838. update = update_socket,)
  1839. color_simple = cString
  1840. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1841. input : bpy.props.BoolProperty(default =False,)
  1842. def draw(self, context, layout, node, text):
  1843. ChooseDraw(self, context, layout, node, text)
  1844. def draw_color(self, context, node):
  1845. return self.color
  1846. @classmethod
  1847. def draw_color_simple(self):
  1848. return self.color_simple
  1849. class EnumXZScaleMode(MantisSocket):
  1850. '''Custom node socket type'''
  1851. bl_idname = 'EnumXZScaleMode'
  1852. bl_label = "XZ Scale Mode"
  1853. default_value: bpy.props.EnumProperty(
  1854. items=eXZScaleMode,
  1855. name="XZ Scale Mode",
  1856. description="XZ Scale Mode",
  1857. default = 'NONE',
  1858. update = update_socket,)
  1859. color_simple = cString
  1860. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1861. input : bpy.props.BoolProperty(default =False,)
  1862. def draw(self, context, layout, node, text):
  1863. ChooseDraw(self, context, layout, node, text)
  1864. def draw_color(self, context, node):
  1865. return self.color
  1866. @classmethod
  1867. def draw_color_simple(self):
  1868. return self.color_simple
  1869. eMapxForm = (('LOCATION', "Location", "Location",),
  1870. ('ROTATION', "Rotation", "Rotation",),
  1871. ('SCALE', "Scale", "Scale",),)
  1872. eRotationMode = (('AUTO', 'Auto', 'Automattically Selected.', 0),
  1873. ('XYZ', "XYZ", "Euler using the XYZ rotation order", 1),
  1874. ('XZY', "XZY", "Euler using the XZY rotation order", 2),
  1875. ('ZXY', "ZXY", "Euler using the ZXY rotation order", 3),
  1876. ('ZYX', "ZYX", "Euler using the ZYX rotation order", 4),
  1877. ('YXZ', "YXZ", "Euler using the YXZ rotation order", 5),
  1878. ('YZX', "YZX", "Euler using the YZX rotation order", 6),
  1879. ('QUATERNION', "Quaternion", "Quaternion", 7),
  1880. ('SWING_TWIST_X', 'Swing and X Twist.', 'Decompose into a swing rotation to aim the X axis, followed by twist around it.', 8),
  1881. ('SWING_TWIST_Y', 'Swing and Y Twist.', 'Decompose into a swing rotation to aim the Y axis, followed by twist around it.', 9),
  1882. ('SWING_TWIST_Z', 'Swing and Z Twist.', 'Decompose into a swing rotation to aim the Z axis, followed by twist around it.', 10),)
  1883. enumTransformationRotationOrder = enumRotationOrder[:6]
  1884. eTranslationMix =(
  1885. ('ADD', "Add", "", 0),
  1886. ('REPLACE', "Replace", "", 1),
  1887. )
  1888. eScaleMix =(
  1889. ('MULTIPLY', "Multiply", "", 0),
  1890. ('REPLACE', "Replace", "", 1),
  1891. )
  1892. class EnumTransformationMap(MantisSocket):
  1893. '''Custom node socket type'''
  1894. bl_idname = 'EnumTransformationMap'
  1895. bl_label = "Map To/From"
  1896. default_value: bpy.props.EnumProperty(
  1897. items=eMapxForm,
  1898. name="Map To/From",
  1899. description="Map To/From",
  1900. default = 'LOCATION',
  1901. update = update_socket,)
  1902. color_simple = cString
  1903. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1904. input : bpy.props.BoolProperty(default =False,)
  1905. def draw(self, context, layout, node, text):
  1906. ChooseDraw(self, context, layout, node, text)
  1907. def draw_color(self, context, node):
  1908. return self.color
  1909. @classmethod
  1910. def draw_color_simple(self):
  1911. return self.color_simple
  1912. class EnumTransformationRotationMode(MantisSocket):
  1913. '''Custom node socket type'''
  1914. bl_idname = 'EnumTransformationRotationMode'
  1915. bl_label = "Map To/From"
  1916. default_value: bpy.props.EnumProperty(
  1917. items=eRotationMode,
  1918. name="Rotation Mode",
  1919. description="Rotation Mode",
  1920. default = 'AUTO',
  1921. update = update_socket,)
  1922. color_simple = cString
  1923. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1924. input : bpy.props.BoolProperty(default =False,)
  1925. def draw(self, context, layout, node, text):
  1926. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1927. def draw_color(self, context, node):
  1928. return self.color
  1929. @classmethod
  1930. def draw_color_simple(self):
  1931. return self.color_simple
  1932. class EnumTransformationRotationOrder(MantisSocket):
  1933. '''Custom node socket type'''
  1934. bl_idname = 'EnumTransformationRotationOrder'
  1935. bl_label = "Map To/From"
  1936. default_value: bpy.props.EnumProperty(
  1937. items=enumTransformationRotationOrder,
  1938. name="Rotation Order",
  1939. description="Rotation Order",
  1940. default = 'AUTO',
  1941. update = update_socket,)
  1942. color_simple = cString
  1943. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1944. input : bpy.props.BoolProperty(default =False,)
  1945. def draw(self, context, layout, node, text):
  1946. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1947. def draw_color(self, context, node):
  1948. return self.color
  1949. @classmethod
  1950. def draw_color_simple(self):
  1951. return self.color_simple
  1952. class EnumTransformationTranslationMixMode(MantisSocket):
  1953. '''Custom node socket type'''
  1954. bl_idname = 'EnumTransformationTranslationMixMode'
  1955. bl_label = "Mix Mode"
  1956. default_value: bpy.props.EnumProperty(
  1957. items=eTranslationMix,
  1958. name="Mix Translation",
  1959. description="Mix Translation",
  1960. default = 'ADD',
  1961. update = update_socket,)
  1962. color_simple = cString
  1963. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1964. input : bpy.props.BoolProperty(default =False,)
  1965. def draw(self, context, layout, node, text):
  1966. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1967. def draw_color(self, context, node):
  1968. return self.color
  1969. @classmethod
  1970. def draw_color_simple(self):
  1971. return self.color_simple
  1972. class EnumTransformationRotationMixMode(MantisSocket):
  1973. '''Custom node socket type'''
  1974. bl_idname = 'EnumTransformationRotationMixMode'
  1975. bl_label = "Mix Mode"
  1976. default_value: bpy.props.EnumProperty(
  1977. items=eRotationMix,
  1978. name="Mix Rotation",
  1979. description="Mix Rotation",
  1980. default = 'ADD',
  1981. update = update_socket,)
  1982. color_simple = cString
  1983. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1984. input : bpy.props.BoolProperty(default =False,)
  1985. def draw(self, context, layout, node, text):
  1986. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1987. def draw_color(self, context, node):
  1988. return self.color
  1989. @classmethod
  1990. def draw_color_simple(self):
  1991. return self.color_simple
  1992. class EnumTransformationScaleMixMode(MantisSocket):
  1993. '''Custom node socket type'''
  1994. bl_idname = 'EnumTransformationScaleMixMode'
  1995. bl_label = "Mix Mode"
  1996. default_value: bpy.props.EnumProperty(
  1997. items=eScaleMix,
  1998. name="Mix Scale",
  1999. description="Mix Scale",
  2000. default = 'REPLACE',
  2001. update = update_socket,)
  2002. color_simple = cString
  2003. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2004. input : bpy.props.BoolProperty(default =False,)
  2005. def draw(self, context, layout, node, text):
  2006. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2007. def draw_color(self, context, node):
  2008. return self.color
  2009. @classmethod
  2010. def draw_color_simple(self):
  2011. return self.color_simple
  2012. eAxes = (
  2013. ('X', "X", "X", 0),
  2014. ('Y', "Y", "Y", 1),
  2015. ('Z', "Z", "Z", 2),
  2016. )
  2017. class EnumTransformationAxes(MantisSocket):
  2018. '''Custom node socket type'''
  2019. bl_idname = 'EnumTransformationAxes'
  2020. bl_label = "Axes"
  2021. default_value: bpy.props.EnumProperty(
  2022. items=eAxes,
  2023. # name="",
  2024. # description="",
  2025. default = 'X',
  2026. update = update_socket,)
  2027. color_simple = cString
  2028. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2029. input : bpy.props.BoolProperty(default =False,)
  2030. def draw(self, context, layout, node, text):
  2031. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2032. def draw_color(self, context, node):
  2033. return self.color
  2034. @classmethod
  2035. def draw_color_simple(self):
  2036. return self.color_simple
  2037. #
  2038. eBBoneHandleType = (
  2039. ('AUTO', "Automatic", "", 0),
  2040. ('ABSOLUTE', "Absolute", "", 1),
  2041. ('RELATIVE', "Relative", "", 2),
  2042. ('TANGENT', "Tangent", "", 3),
  2043. )
  2044. class EnumBBoneHandleType(MantisSocket):
  2045. '''Custom node socket type'''
  2046. bl_idname = 'EnumBBoneHandleType'
  2047. bl_label = "Axes"
  2048. default_value: bpy.props.EnumProperty(
  2049. items=eBBoneHandleType,
  2050. # name="",
  2051. # description="",
  2052. default = 'AUTO',
  2053. update = update_socket,)
  2054. color_simple = cString
  2055. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2056. input : bpy.props.BoolProperty(default =False,)
  2057. def draw(self, context, layout, node, text):
  2058. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2059. def draw_color(self, context, node):
  2060. return self.color
  2061. @classmethod
  2062. def draw_color_simple(self):
  2063. return self.color_simple
  2064. eShrinkwrapType = (
  2065. ('NEAREST_SURFACE', "Nearest Surface Point",
  2066. "Shrink the location to the nearest target surface.", 0),
  2067. ('PROJECT', "Project", "Shrink the location to the nearest target "
  2068. "surface along a given axis.", 1),
  2069. ('NEAREST_VERTEX', "Nearest Vertex", "Shrink the location to the"
  2070. " nearest target vertex.", 2),
  2071. ('TARGET_PROJECT', "Target Normal Project", "Shrink the location to the"
  2072. " nearest target surface along the interpolated vertex"
  2073. " normals of the target.", 3),
  2074. )
  2075. class EnumShrinkwrapTypeSocket(MantisSocket):
  2076. '''Shrinkwrap Type Socket'''
  2077. bl_idname = 'EnumShrinkwrapTypeSocket'
  2078. bl_label = "Shrinkwrap Type"
  2079. default_value: bpy.props.EnumProperty(
  2080. items=eShrinkwrapType,
  2081. description="Select type of shrinkwrap algorithm for target position",
  2082. default = 'TARGET_PROJECT',
  2083. update = update_socket,)
  2084. color_simple = cString
  2085. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2086. input : bpy.props.BoolProperty(default =False,)
  2087. def draw(self, context, layout, node, text):
  2088. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2089. def draw_color(self, context, node):
  2090. return self.color
  2091. @classmethod
  2092. def draw_color_simple(self):
  2093. return self.color_simple
  2094. eShrinkwrapFaceCull = (
  2095. ('OFF', "Off", "No Culling.", 0),
  2096. ('FRONT', "Front", "No projection when in front of the face.", 1),
  2097. ('BACK', "Back", "No projection when behind the face.", 2),
  2098. )
  2099. class EnumShrinkwrapFaceCullSocket(MantisSocket):
  2100. '''Shrinkwrap Face Cull method Socket'''
  2101. bl_idname = 'EnumShrinkwrapFaceCullSocket'
  2102. bl_label = "Shrinkwrap Type"
  2103. default_value: bpy.props.EnumProperty(
  2104. items=eShrinkwrapFaceCull,
  2105. description="Stop vertices from projecting to a face on the target"
  2106. " when facing towards/away",
  2107. default = 'OFF',
  2108. update = update_socket,)
  2109. color_simple = cString
  2110. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2111. input : bpy.props.BoolProperty(default =False,)
  2112. def draw(self, context, layout, node, text):
  2113. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2114. def draw_color(self, context, node):
  2115. return self.color
  2116. @classmethod
  2117. def draw_color_simple(self):
  2118. return self.color_simple
  2119. eShrinkwrapProjectAxis = (
  2120. ('POS_X', "+X", "", 0),
  2121. ('POS_Y', "+Y", "", 1),
  2122. ('POS_Z', "+Z", "", 2),
  2123. ('NEG_X', "-X", "", 3),
  2124. ('NEG_Y', "-Y", "", 4),
  2125. ('NEG_Z', "-Z", "", 5), )
  2126. class EnumShrinkwrapProjectAxisSocket(MantisSocket):
  2127. '''Shrinkwrap Projection Axis Socket'''
  2128. bl_idname = 'EnumShrinkwrapProjectAxisSocket'
  2129. bl_label = "Shrinkwrap Projection Axis"
  2130. default_value: bpy.props.EnumProperty(
  2131. items=eShrinkwrapProjectAxis,
  2132. description="Axis constrain to",
  2133. default = 'POS_X',
  2134. update = update_socket,)
  2135. color_simple = cString
  2136. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2137. input : bpy.props.BoolProperty(default =False,)
  2138. def draw(self, context, layout, node, text):
  2139. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2140. def draw_color(self, context, node):
  2141. return self.color
  2142. @classmethod
  2143. def draw_color_simple(self):
  2144. return self.color_simple
  2145. eShrinkwrapMode = (
  2146. ('ON_SURFACE', "On Surface", "The point is constrained to the surface"
  2147. " of the target object, with distance offset towards the"
  2148. " original point location.", 0),
  2149. ('INSIDE', "Inside", "The point is constrained to be inside the target"
  2150. " object", 1),
  2151. ('OUTSIDE', "Outside", "The point is constrained to be outside the "
  2152. "target object.", 2),
  2153. ('OUTSIDE_SURFACE', "Outside Surface", "The point is constrained to the"
  2154. " surface of the target object, with distance"
  2155. " offset always to the outside, towards or away"
  2156. " from the original location.", 3),
  2157. ('ABOVE_SURFACE', "Above Surface", "The point is constrained to the"
  2158. " surface of the target object, with distance offset "
  2159. "applied exactly along the target normal.", 4), )
  2160. class EnumShrinkwrapModeSocket(MantisSocket):
  2161. '''Shrinkwrap Mode Socket'''
  2162. bl_idname = 'EnumShrinkwrapModeSocket'
  2163. bl_label = "Shrinkwrap Mode"
  2164. default_value: bpy.props.EnumProperty(
  2165. items=eShrinkwrapMode,
  2166. description="Select how to constrain the object to the target surface",
  2167. default = 'ON_SURFACE',
  2168. update = update_socket,)
  2169. color_simple = cString
  2170. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2171. input : bpy.props.BoolProperty(default =False,)
  2172. def draw(self, context, layout, node, text):
  2173. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2174. def draw_color(self, context, node):
  2175. return self.color
  2176. @classmethod
  2177. def draw_color_simple(self):
  2178. return self.color_simple
  2179. eSkinningMethod = (('EXISTING_GROUPS', "Use Existing Groups", "Use the existing vertex groups, or create empty groups if not found.",),
  2180. ('AUTOMATIC_HEAT', "Automatic (Heat)", "Use Blender's heatmap automatic skinning",),
  2181. ('COPY_FROM_OBJECT', "Copy from object", "Copy skin weights from the selected object"),)
  2182. class EnumSkinning(MantisSocket):
  2183. '''Custom node socket type'''
  2184. bl_idname = 'EnumSkinning'
  2185. bl_label = "Skinning Method"
  2186. default_value: bpy.props.EnumProperty(
  2187. items=eSkinningMethod,
  2188. name="Skinning Method",
  2189. description="Skinning Method",
  2190. default = 'AUTOMATIC_HEAT',
  2191. update = update_socket,)
  2192. color_simple = cString
  2193. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2194. input : bpy.props.BoolProperty(default =False,)
  2195. def draw(self, context, layout, node, text):
  2196. ChooseDraw(self, context, layout, node, text)
  2197. def draw_color(self, context, node):
  2198. return self.color
  2199. @classmethod
  2200. def draw_color_simple(self):
  2201. return self.color_simple
  2202. class MorphTargetSocket(MantisSocket):
  2203. """Morph Target"""
  2204. bl_idname = 'MorphTargetSocket'
  2205. bl_label = "Morph Target"
  2206. color_simple = cShapeKey
  2207. color : bpy.props.FloatVectorProperty(default=cShapeKey, size=4)
  2208. input : bpy.props.BoolProperty(default =False,)
  2209. is_valid_interface_type=True
  2210. def draw(self, context, layout, node, text):
  2211. ChooseDraw(self, context, layout, node, text)
  2212. def draw_color(self, context, node):
  2213. return self.color
  2214. @classmethod
  2215. def draw_color_simple(self):
  2216. return self.color_simple
  2217. eDriverVariableType = (
  2218. ( 'SINGLE_PROP',
  2219. "Property",
  2220. "Property",
  2221. 1),
  2222. ( 'LOC_DIFF',
  2223. "Distance",
  2224. "Distance",
  2225. 2),
  2226. ( 'ROTATION_DIFF',
  2227. "Rotational Difference",
  2228. "Rotational Difference",
  2229. 3),
  2230. # ( 'TRANSFORMS',
  2231. # "Transform Channel",
  2232. # "Transform Channel",
  2233. # 4),
  2234. )
  2235. class EnumDriverVariableType(MantisSocket):
  2236. '''Custom node socket type'''
  2237. bl_idname = 'EnumDriverVariableType'
  2238. bl_label = "Variable Type"
  2239. default_value: bpy.props.EnumProperty(
  2240. items = eDriverVariableType,
  2241. name = "Variable Type",
  2242. description = "Variable Type",
  2243. default = 'SINGLE_PROP',
  2244. update = driver_variable_socket_update,)
  2245. color_simple = cString
  2246. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2247. input : bpy.props.BoolProperty(default =False,)
  2248. def draw(self, context, layout, node, text):
  2249. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2250. def draw_color(self, context, node):
  2251. return self.color
  2252. @classmethod
  2253. def draw_color_simple(self):
  2254. return self.color_simple
  2255. eDriverVariableEvaluationSpace = (
  2256. ( 'WORLD_SPACE',
  2257. "World",
  2258. "World",
  2259. 1),
  2260. ( 'TRANSFORM_SPACE',
  2261. "Transform",
  2262. "Transform",
  2263. 2),
  2264. ( 'LOCAL_SPACE',
  2265. "Local",
  2266. "Local",
  2267. 3),
  2268. )
  2269. class EnumDriverVariableEvaluationSpace(MantisSocket):
  2270. '''Custom node socket type'''
  2271. bl_idname = 'EnumDriverVariableEvaluationSpace'
  2272. bl_label = "Evaluation Space"
  2273. default_value: bpy.props.EnumProperty(
  2274. items = eDriverVariableEvaluationSpace,
  2275. name = "Evaluation Space",
  2276. description = "Evaluation Space",
  2277. default = 'WORLD_SPACE',
  2278. update = driver_variable_socket_update,)
  2279. color_simple = cString
  2280. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2281. input : bpy.props.BoolProperty(default =False,)
  2282. def draw(self, context, layout, node, text):
  2283. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2284. def draw_color(self, context, node):
  2285. return self.color
  2286. @classmethod
  2287. def draw_color_simple(self):
  2288. return self.color_simple
  2289. eDriverVariableTransformChannel = (
  2290. ("LOC_X", "X Location", "The X-coordinate of an object's location.", 1),
  2291. ("LOC_Y", "Y Location", "The Y-coordinate of an object's location.", 2),
  2292. ("LOC_Z", "Z Location", "The Z-coordinate of an object's location.", 3),
  2293. ("ROT_X", "X Rotation", "Rotation X-axis.", 4),
  2294. ("ROT_Y", "Y Rotation", "Rotation Y-axis.", 5),
  2295. ("ROT_Z", "Z Rotation", "Rotation Z-axis.", 6),
  2296. ("ROT_W", "W Rotation", "Rotation W-axis.", 7),
  2297. ("SCALE_X", "X Scale", "The X-scale of an object's scale.", 8),
  2298. ("SCALE_Y", "Y Scale", "The Y-scale of an object's scale.", 9),
  2299. ("SCALE_Z", "Z Scale", "The Z-scale of an object's scale.", 10),
  2300. ("SCALE_AVG", "Average Scale", "The scale factor of an object's scale.", 11),
  2301. )
  2302. class EnumDriverVariableTransformChannel(MantisSocket):
  2303. '''Custom node socket type'''
  2304. bl_idname = 'EnumDriverVariableTransformChannel'
  2305. bl_label = "Transform Channel"
  2306. default_value: bpy.props.EnumProperty(
  2307. items = eDriverVariableTransformChannel,
  2308. name = "Transform Channel",
  2309. description = "Transform Channel",
  2310. default = 'LOC_X',
  2311. update = driver_variable_socket_update,)
  2312. color_simple = cString
  2313. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2314. input : bpy.props.BoolProperty(default =False,)
  2315. def draw(self, context, layout, node, text):
  2316. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2317. def draw_color(self, context, node):
  2318. return self.color
  2319. @classmethod
  2320. def draw_color_simple(self):
  2321. return self.color_simple
  2322. class EnumDriverRotationMode(MantisSocket):
  2323. '''Custom node socket type'''
  2324. bl_idname = 'EnumDriverRotationMode'
  2325. bl_label = "Rotaton Mode"
  2326. default_value: bpy.props.EnumProperty(
  2327. items = eRotationMode,
  2328. name = "Rotation Mode",
  2329. description = "Rotation Mode",
  2330. default = 'AUTO',
  2331. update = driver_variable_socket_update,)
  2332. color_simple = cString
  2333. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2334. input : bpy.props.BoolProperty(default =False,)
  2335. def draw(self, context, layout, node, text):
  2336. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2337. def draw_color(self, context, node):
  2338. return self.color
  2339. @classmethod
  2340. def draw_color_simple(self):
  2341. return self.color_simple
  2342. #
  2343. eDriverType = (('AVERAGE', 'Average', 'Average', 0),
  2344. ('SUM', "Sum", "Sum", 1),
  2345. ('SCRIPTED', "Scripted", "Scripted Expression", 2),
  2346. ('MIN', "Min", "Minimum", 3),
  2347. ('MAX', "Max", "Maximum", 4),)
  2348. class EnumDriverType(MantisSocket):
  2349. '''Custom node socket type'''
  2350. bl_idname = 'EnumDriverType'
  2351. bl_label = "Driver Type"
  2352. default_value: bpy.props.EnumProperty(
  2353. items = eDriverType,
  2354. name = "Driver Type",
  2355. description = "Driver Type",
  2356. default = 'AVERAGE',
  2357. update = driver_socket_update,)
  2358. color_simple = cString
  2359. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2360. input : bpy.props.BoolProperty(default =False,)
  2361. def draw(self, context, layout, node, text):
  2362. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2363. def draw_color(self, context, node):
  2364. return self.color
  2365. @classmethod
  2366. def draw_color_simple(self):
  2367. return self.color_simple
  2368. # Keyframe
  2369. # Enum for kf handle type
  2370. # enum for interpolation type
  2371. # eventually gonna make it to the fancy stuff
  2372. class FloatSocket(MantisSocket):
  2373. """Float Input socket"""
  2374. bl_idname = 'FloatSocket'
  2375. bl_label = "Float"
  2376. is_valid_interface_type=True
  2377. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  2378. color_simple = cFloat
  2379. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2380. input : bpy.props.BoolProperty(default =False,)
  2381. def draw(self, context, layout, node, text):
  2382. ChooseDraw(self, context, layout, node, text)
  2383. def draw_color(self, context, node):
  2384. return self.color
  2385. @classmethod
  2386. def draw_color_simple(self):
  2387. return self.color_simple
  2388. class FloatPositiveSocket(MantisSocket):
  2389. """Float Input socket"""
  2390. bl_idname = 'FloatPositiveSocket'
  2391. bl_label = "Float (Positive)"
  2392. is_valid_interface_type=True
  2393. default_value : bpy.props.FloatProperty(default = 0.0, min=0, update = update_socket,)
  2394. color_simple = cFloat
  2395. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2396. input : bpy.props.BoolProperty(default =False,)
  2397. def draw(self, context, layout, node, text):
  2398. ChooseDraw(self, context, layout, node, text)
  2399. def draw_color(self, context, node):
  2400. return self.color
  2401. @classmethod
  2402. def draw_color_simple(self):
  2403. return self.color_simple
  2404. class FloatFactorSocket(MantisSocket):
  2405. '''xFrom Input Output'''
  2406. bl_idname = 'FloatFactorSocket'
  2407. bl_label = "Float (Factor)"
  2408. is_valid_interface_type=True
  2409. default_value : bpy.props.FloatProperty(
  2410. default = 0.0,
  2411. min = 0.0,
  2412. max=1.0,
  2413. update = update_socket,
  2414. subtype='FACTOR',)
  2415. color_simple = cFloat
  2416. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2417. input : bpy.props.BoolProperty(default =False,)
  2418. def draw(self, context, layout, node, text):
  2419. ChooseDraw(self, context, layout, node, text)
  2420. def draw_color(self, context, node):
  2421. return self.color
  2422. @classmethod
  2423. def draw_color_simple(self):
  2424. return self.color_simple
  2425. class FloatAngleSocket(MantisSocket):
  2426. '''xFrom Input Output'''
  2427. bl_idname = 'FloatAngleSocket'
  2428. bl_label = "Float (Angle)"
  2429. is_valid_interface_type=True
  2430. default_value : bpy.props.FloatProperty(
  2431. default = 0.0,
  2432. min = -180,
  2433. max=180,
  2434. update = update_socket,
  2435. subtype='ANGLE',)
  2436. color_simple = cFloat
  2437. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2438. input : bpy.props.BoolProperty(default =False,)
  2439. def draw(self, context, layout, node, text):
  2440. ChooseDraw(self, context, layout, node, text)
  2441. def draw_color(self, context, node):
  2442. return self.color
  2443. @classmethod
  2444. def draw_color_simple(self):
  2445. return self.color_simple
  2446. class VectorSocket(MantisSocket):
  2447. """Vector Input socket"""
  2448. bl_idname = 'VectorSocket'
  2449. bl_label = "Vector"
  2450. is_valid_interface_type=True
  2451. default_value : bpy.props.FloatVectorProperty(
  2452. default = (0.0, 0.0, 0.0),
  2453. update = update_socket,)
  2454. color_simple = cVector
  2455. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2456. input : bpy.props.BoolProperty(default =False,)
  2457. def draw(self, context, layout, node, text):
  2458. ChooseDraw(self, context, layout, node, text)
  2459. def draw_color(self, context, node):
  2460. return self.color
  2461. @classmethod
  2462. def draw_color_simple(self):
  2463. return self.color_simple
  2464. class VectorEulerSocket(MantisSocket):
  2465. """Vector Input socket"""
  2466. bl_idname = 'VectorEulerSocket'
  2467. bl_label = "Euler"
  2468. is_valid_interface_type=True
  2469. default_value : bpy.props.FloatVectorProperty(
  2470. default = (0.0, 0.0, 0.0),
  2471. update = update_socket,
  2472. subtype='EULER',)
  2473. color_simple = cVector
  2474. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2475. input : bpy.props.BoolProperty(default =False,)
  2476. def draw(self, context, layout, node, text):
  2477. ChooseDraw(self, context, layout, node, text)
  2478. def draw_color(self, context, node):
  2479. return self.color
  2480. @classmethod
  2481. def draw_color_simple(self):
  2482. return self.color_simple
  2483. class VectorTranslationSocket(MantisSocket):
  2484. """Vector Input socket"""
  2485. bl_idname = 'VectorTranslationSocket'
  2486. bl_label = "Vector (Translation)"
  2487. default_value : bpy.props.FloatVectorProperty(
  2488. default = (0.0, 0.0, 0.0),
  2489. update = update_socket,
  2490. subtype='TRANSLATION',)
  2491. color_simple = cVector
  2492. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2493. input : bpy.props.BoolProperty(default =False,)
  2494. def draw(self, context, layout, node, text):
  2495. ChooseDraw(self, context, layout, node, text)
  2496. def draw_color(self, context, node):
  2497. return self.color
  2498. @classmethod
  2499. def draw_color_simple(self):
  2500. return self.color_simple
  2501. class VectorScaleSocket(MantisSocket):
  2502. """Vector Input socket"""
  2503. bl_idname = 'VectorScaleSocket'
  2504. bl_label = "Vector (Scale)"
  2505. default_value : bpy.props.FloatVectorProperty(
  2506. default = (1.0, 1.0, 1.0),
  2507. update = update_socket,
  2508. subtype='XYZ',)
  2509. color_simple = cVector
  2510. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2511. input : bpy.props.BoolProperty(default =False,)
  2512. def draw(self, context, layout, node, text):
  2513. ChooseDraw(self, context, layout, node, text)
  2514. def draw_color(self, context, node):
  2515. return self.color
  2516. @classmethod
  2517. def draw_color_simple(self):
  2518. return self.color_simple
  2519. class KeyframeSocket(MantisSocket):
  2520. '''Keyframe'''
  2521. bl_idname = 'KeyframeSocket'
  2522. bl_label = "Keyframe"
  2523. is_valid_interface_type=True
  2524. color_simple = cKeyframe
  2525. color : bpy.props.FloatVectorProperty(default=cKeyframe, size=4)
  2526. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2527. def init(self):
  2528. self.display_shape = 'CIRCLE_DOT'
  2529. def draw(self, context, layout, node, text):
  2530. ChooseDraw(self, context, layout, node, text)
  2531. def draw_color(self, context, node):
  2532. return self.color
  2533. @classmethod
  2534. def draw_color_simple(self):
  2535. return self.color_simple
  2536. EnumKeyframeInterpolationType = (('CONSTANT', 'Stepped', 'Stepped'),
  2537. ('LINEAR', "Linear", "Linear"),
  2538. ('BEZIER', "Bezier", "Bezier"),)
  2539. class EnumKeyframeInterpolationTypeSocket(MantisSocket):
  2540. '''Keyframe Interpolation Type'''
  2541. bl_idname = 'EnumKeyframeInterpolationTypeSocket'
  2542. bl_label = "Keyframe Interpolation Type"
  2543. default_value :bpy.props.EnumProperty(
  2544. name="",
  2545. description="Interpolation",
  2546. items=EnumKeyframeInterpolationType,
  2547. default='LINEAR',
  2548. update = update_socket,)
  2549. color_simple = cString
  2550. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2551. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2552. def draw(self, context, layout, node, text):
  2553. ChooseDraw(self, context, layout, node, text)
  2554. def draw_color(self, context, node):
  2555. return self.color
  2556. @classmethod
  2557. def draw_color_simple(self):
  2558. return self.color_simple
  2559. EnumKeyframeBezierHandleType = (('FREE', 'Free', 'Completely independent manually set handle.'),
  2560. ('ALIGNED', "Aligned", "Manually set handle with rotation locked together with its pair."),
  2561. ('VECTOR', "Vector", "Automatic handles that create straight lines."),
  2562. ('AUTO', "Automatic", "Automatic handles that create smooth curves."),
  2563. ('AUTO_CLAMPED', "Auto Clamped", "Automatic handles that create smooth curves which only change direction at keyframes."),)
  2564. class EnumKeyframeBezierHandleTypeSocket(MantisSocket):
  2565. '''Keyframe Bezier Handle Type'''
  2566. bl_idname = 'EnumKeyframeBezierHandleTypeSocket'
  2567. bl_label = "Keyframe Bezier Handle Type"
  2568. default_value :bpy.props.EnumProperty(
  2569. name="",
  2570. description="Handle Type",
  2571. items=EnumKeyframeBezierHandleType,
  2572. default='AUTO_CLAMPED',
  2573. update = update_socket,)
  2574. color_simple = cString
  2575. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2576. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2577. def draw(self, context, layout, node, text):
  2578. ChooseDraw(self, context, layout, node, text)
  2579. def draw_color(self, context, node):
  2580. return self.color
  2581. @classmethod
  2582. def draw_color_simple(self):
  2583. return self.color_simple
  2584. enumExtrapolationMode = (('CONSTANT', 'Constant', 'Constant'),
  2585. ('LINEAR', "Linear", "Linear"),)
  2586. class eFCrvExtrapolationMode(MantisSocket):
  2587. '''FCurve Extrapolation Mode'''
  2588. bl_idname = 'eFCrvExtrapolationMode'
  2589. bl_label = "Extrapolation Mode"
  2590. default_value :bpy.props.EnumProperty(
  2591. name="",
  2592. description="Handle Type",
  2593. items=enumExtrapolationMode,
  2594. default='CONSTANT',
  2595. update = update_socket,)
  2596. color_simple = cString
  2597. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2598. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2599. def draw(self, context, layout, node, text):
  2600. ChooseDraw(self, context, layout, node, text)
  2601. def draw_color(self, context, node):
  2602. return self.color
  2603. @classmethod
  2604. def draw_color_simple(self):
  2605. return self.color_simple
  2606. EnumLatticeInterpolationType = (('KEY_LINEAR', 'Linear', 'Linear Interpolation.'),
  2607. ('KEY_CARDINAL', "Cardinal", "Cardinal Interpolation."),
  2608. ('KEY_CATMULL_ROM', "Catmull Rom", "Catmull Rom Interpolation."),
  2609. ('KEY_BSPLINE', "B-Spline", "B Spline Interpolation."),)
  2610. class EnumLatticeInterpolationTypeSocket(MantisSocket):
  2611. '''Lattice Interpolation Type'''
  2612. bl_idname = 'EnumLatticeInterpolationTypeSocket'
  2613. bl_label = "Lattice Interpolation Type"
  2614. default_value :bpy.props.EnumProperty(
  2615. name="",
  2616. description="Interpolation Type",
  2617. items=EnumLatticeInterpolationType,
  2618. default='KEY_BSPLINE',
  2619. update = update_socket,)
  2620. color_simple = cString
  2621. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2622. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2623. def draw(self, context, layout, node, text):
  2624. ChooseDraw(self, context, layout, node, text)
  2625. def draw_color(self, context, node):
  2626. return self.color
  2627. @classmethod
  2628. def draw_color_simple(self):
  2629. return self.color_simple
  2630. EnumCorrectiveSmoothType = (('SIMPLE', 'Simple', 'Use the average of adjacent edge-vertices.'),
  2631. ('LENGTH_WEIGHTED', "Length Weight", "Use the average of adjacent"
  2632. "edge-vertices weighted by their length."),)
  2633. class EnumCorrectiveSmoothTypeSocket(MantisSocket):
  2634. '''Lattice Interpolation Type'''
  2635. bl_idname = 'EnumCorrectiveSmoothTypeSocket'
  2636. bl_label = "Lattice Interpolation Type"
  2637. default_value :bpy.props.EnumProperty(
  2638. name="",
  2639. description="Interpolation Type",
  2640. items=EnumCorrectiveSmoothType,
  2641. default='SIMPLE',
  2642. update = update_socket,)
  2643. color_simple = cString
  2644. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2645. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2646. def draw(self, context, layout, node, text):
  2647. ChooseDraw(self, context, layout, node, text)
  2648. def draw_color(self, context, node):
  2649. return self.color
  2650. @classmethod
  2651. def draw_color_simple(self):
  2652. return self.color_simple
  2653. enumFloatOperations = (('ADD', 'Add', 'Add'),
  2654. ('SUBTRACT', "Subtract", "Subtract"),
  2655. ('MULTIPLY', "Multiply", "Multiply"),
  2656. ('DIVIDE', "Divide", "Divide"),
  2657. ('POWER', "Power", "Power"),
  2658. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2659. ('MODULUS', "Modulus", "Modulus"),
  2660. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2661. ('MAXIMUM', "Maximum", "Maximum"),
  2662. ('MINIMUM', "Minimum", "Minimum"),
  2663. ('GREATER THAN', "Greater Than", "Greater Than"),
  2664. ('LESS THAN', "Less Than", "Less Than"),
  2665. ('ARCTAN2', "atan2", "2-argument arctan function"),
  2666. ('FLOOR', "Floor", "the nearest integer lower than input A"),
  2667. ('CEIL', "Ceiling", "the next integer higher than input A"),
  2668. ('ROUND', "Round", "Round to the nearest integer"),)
  2669. class MathFloatOperation(MantisSocket):
  2670. """Float Math Operation"""
  2671. bl_idname = 'MathFloatOperation'
  2672. bl_label = "Operation"
  2673. default_value :bpy.props.EnumProperty(
  2674. name="",
  2675. description="Operation",
  2676. items=enumFloatOperations,
  2677. default='MULTIPLY',
  2678. update = update_socket,)
  2679. color_simple = cString
  2680. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2681. input : bpy.props.BoolProperty(default =False,)
  2682. def draw(self, context, layout, node, text):
  2683. ChooseDraw(self, context, layout, node, text)
  2684. def draw_color(self, context, node):
  2685. return self.color
  2686. @classmethod
  2687. def draw_color_simple(self):
  2688. return self.color_simple
  2689. enumVectorOperations = (('ADD', 'Add', 'Add (Component-wise)'),
  2690. ('SUBTRACT', "Subtract", "Subtract (Component-wise)"),
  2691. ('MULTIPLY', "Multiply", "Multiply (Component-wise)"),
  2692. ('SCALE', "Scale", "Scales vector by input float or average magnitude of input vector's components."),
  2693. ('DIVIDE', "Divide", "Divide (Component-wise)"),
  2694. ('POWER', "Power", "Power (Component-wise)"),
  2695. ('LENGTH', "Length", "Length"),
  2696. ('CROSS', "Cross Product", "Cross product of A X B"),
  2697. ('NORMALIZE', "Normalize", "Returns a normalized vector."),
  2698. ('DOT', "Dot Product", "Dot product of A . B"),
  2699. ('LINEAR_INTERP', "Linear Interpolation", "Linear Interpolation between vectors A and B by factor"))
  2700. class MathVectorOperation(MantisSocket):
  2701. """Vector Math Operation"""
  2702. bl_idname = 'MathVectorOperation'
  2703. bl_label = "Operation"
  2704. default_value :bpy.props.EnumProperty(
  2705. name="",
  2706. description="Operation",
  2707. items=enumVectorOperations,
  2708. default='MULTIPLY',
  2709. update = update_socket,)
  2710. color_simple = cString
  2711. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2712. input : bpy.props.BoolProperty(default =False,)
  2713. def draw(self, context, layout, node, text):
  2714. ChooseDraw(self, context, layout, node, text)
  2715. def draw_color(self, context, node):
  2716. return self.color
  2717. @classmethod
  2718. def draw_color_simple(self):
  2719. return self.color_simple
  2720. enumMatrixTransform = (('TRANSLATE', 'Translate', 'Translate'),
  2721. ('ROTATE_AXIS_ANGLE', "Rotate (Axis-angle)", "Rotates a number of radians around an axis"),
  2722. # ('ROTATE_EULER', "Rotate (Euler)", "Euler Rotation"),
  2723. # ('ROTATE_QUATERNION', "Rotate (Quaternion)", "Quaternion Rotation"),
  2724. ('SCALE', "Scale", "Scale"),)
  2725. class MatrixTransformOperation(MantisSocket):
  2726. """Matrix Transform Operation"""
  2727. bl_idname = 'MatrixTransformOperation'
  2728. bl_label = "Operation"
  2729. default_value :bpy.props.EnumProperty(
  2730. name="",
  2731. description="Operation",
  2732. items=enumMatrixTransform,
  2733. default='TRANSLATE',
  2734. update = update_socket,)
  2735. color_simple = cString
  2736. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2737. input : bpy.props.BoolProperty(default =False,)
  2738. def draw(self, context, layout, node, text):
  2739. ChooseDraw(self, context, layout, node, text)
  2740. def draw_color(self, context, node):
  2741. return self.color
  2742. @classmethod
  2743. def draw_color_simple(self):
  2744. return self.color_simple
  2745. enumIntOperations = (('ADD', 'Add', 'Add'),
  2746. ('SUBTRACT', "Subtract", "Subtract"),
  2747. ('MULTIPLY', "Multiply", "Multiply"),
  2748. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2749. ('POWER', "Power", "Power"),
  2750. ('MODULUS', "Modulus", "Modulus"),
  2751. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2752. ('MAXIMUM', "Maximum", "Maximum"),
  2753. ('MINIMUM', "Minimum", "Minimum"),
  2754. ('GREATER THAN', "Greater Than", "Greater Than"),
  2755. ('LESS THAN', "Less Than", "Less Than"),)
  2756. class MathIntOperation(MantisSocket):
  2757. """Int Math Operation"""
  2758. bl_idname = 'MathIntOperation'
  2759. bl_label = "Operation"
  2760. default_value :bpy.props.EnumProperty(
  2761. name="",
  2762. description="Operation",
  2763. items=enumIntOperations,
  2764. default='MULTIPLY',
  2765. update = update_socket,)
  2766. color_simple = cString
  2767. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2768. input : bpy.props.BoolProperty(default =False,)
  2769. def draw(self, context, layout, node, text):
  2770. ChooseDraw(self, context, layout, node, text)
  2771. def draw_color(self, context, node):
  2772. return self.color
  2773. @classmethod
  2774. def draw_color_simple(self):
  2775. return self.color_simple
  2776. enumCompareOperations = (('EQUAL', "Equal", "Equal"),
  2777. ('NOT_EQUAL', "Not Equal", "Not Equal"),
  2778. ('GREATER_THAN', "Greater Than", "Greater Than"),
  2779. ('GREATER_THAN_EQUAL', "Greater Than or Equal", "Greater Than or Equal"),
  2780. ('LESS_THAN', "Less Than", "Less Than"),
  2781. ('LESS_THAN_EQUAL', "Equal or Less Than", "Equal or Less Than"),)
  2782. class EnumCompareOperation(MantisSocket):
  2783. """Compare Operation"""
  2784. bl_idname = 'EnumCompareOperation'
  2785. bl_label = "Comparison"
  2786. default_value :bpy.props.EnumProperty(
  2787. name="",
  2788. description="Comparison",
  2789. items=enumCompareOperations,
  2790. default='EQUAL',
  2791. update = update_socket,)
  2792. color_simple = cString
  2793. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2794. input : bpy.props.BoolProperty(default =False,)
  2795. def draw(self, context, layout, node, text):
  2796. ChooseDraw(self, context, layout, node, text)
  2797. def draw_color(self, context, node):
  2798. return self.color
  2799. @classmethod
  2800. def draw_color_simple(self):
  2801. return self.color_simple
  2802. class WildcardSocket(MantisSocket):
  2803. """Some kind of node socket lol I donno"""
  2804. bl_idname = 'WildcardSocket'
  2805. bl_label = ""
  2806. color_simple = (0.0,0.0,0.0,0.0)
  2807. color : bpy.props.FloatVectorProperty(default=(0.0,0.0,0.0,0.0), size=4)
  2808. input : bpy.props.BoolProperty(default =False,)
  2809. def draw(self, context, layout, node, text):
  2810. ChooseDraw(self, context, layout, node, text)
  2811. def draw_color(self, context, node):
  2812. return self.color
  2813. @classmethod
  2814. def draw_color_simple(self):
  2815. return self.color_simple