socket_definitions.py 128 KB

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