socket_definitions.py 101 KB

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