socket_definitions.py 118 KB

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