socket_definitions.py 117 KB

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