socket_definitions.py 123 KB

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