socket_definitions.py 123 KB

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