socket_definitions.py 114 KB

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