socket_definitions.py 106 KB

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