socket_definitions.py 110 KB

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