socket_definitions.py 115 KB

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