socket_definitions.py 114 KB

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