socket_definitions.py 120 KB

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