socket_definitions.py 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754
  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. inherit_color_socket = self.node.inputs.get("Inherit Color")
  899. if (self.is_output == False) and (self.is_linked == True):
  900. layout.label(text=self.name)
  901. elif self.node.bl_idname in text_only_output_types:
  902. layout.label(text=self.name)
  903. elif inherit_color_socket and inherit_color_socket.default_value == True:
  904. layout.label(text='Using Inherit Color.')
  905. else:
  906. layout.prop( text='Color Set', data=self,
  907. property='active_color', )
  908. layout.prop( text='', data=self,
  909. property='normal_color',)
  910. layout.prop( text='', data=self,
  911. property='selected_color',)
  912. if self.node.bl_idname == 'InputColorSetPallete':
  913. ops_props = layout.operator('mantis.color_pallete_socket_remove')
  914. ops_props.tree_invoked = self.node.id_data.name
  915. ops_props.node_invoked = self.node.name
  916. ops_props.socket_invoked = self.identifier
  917. def draw_color(self, context, node):
  918. return self.color
  919. @classmethod
  920. def draw_color_simple(self):
  921. return self.color_simple
  922. eArrayGetOptions =(
  923. ('CAP', "Cap", "Fail if the index is out of bounds."),
  924. ('WRAP', "Wrap", "Wrap around to the beginning of the array once the idex goes out of bounds."),
  925. ('HOLD', "Hold", "Reuse the last element of the array if the index is out of bounds."),)
  926. class EnumArrayGetOptions(MantisSocket):
  927. '''Custom node socket type'''
  928. bl_idname = 'EnumArrayGetOptions'
  929. bl_label = "OoB Behaviour"
  930. default_value: bpy.props.EnumProperty(
  931. items=eArrayGetOptions,
  932. name="OoB Behaviour",
  933. description="Out-of-bounds behaviour.",
  934. default = 'HOLD',
  935. update = update_socket,)
  936. color_simple = cString
  937. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  938. input : bpy.props.BoolProperty(default =False,)
  939. def draw(self, context, layout, node, text):
  940. ChooseDraw(self, context, layout, node, text)
  941. def draw_color(self, context, node):
  942. return self.color
  943. @classmethod
  944. def draw_color_simple(self):
  945. return self.color_simple
  946. #####################################################################################
  947. # Parameters
  948. #####################################################################################
  949. class xFormParameterSocket(MantisSocket):
  950. '''xFrom Parameter'''
  951. bl_idname = 'xFormParameterSocket'
  952. bl_label = "sForm Parameter"
  953. color_simple = cxForm
  954. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  955. input : bpy.props.BoolProperty(default =False,)
  956. def init(self):
  957. self.display_shape = 'CIRCLE_DOT'
  958. def draw(self, context, layout, node, text):
  959. ChooseDraw(self, context, layout, node, text)
  960. def draw_color(self, context, node):
  961. return self.color
  962. @classmethod
  963. def draw_color_simple(self):
  964. return self.color_simple
  965. # what is this one again?
  966. class ParameterBoolSocket(MantisSocket):
  967. """Boolean Parameter Socket"""
  968. bl_idname = 'ParameterBoolSocket'
  969. bl_label = "Boolean Parameter"
  970. color_simple = cBool
  971. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  972. input : bpy.props.BoolProperty(default =False,)
  973. #custom properties:
  974. min:bpy.props.FloatProperty(default = 0)
  975. max:bpy.props.FloatProperty(default = 1)
  976. soft_min:bpy.props.FloatProperty(default = 0)
  977. soft_max:bpy.props.FloatProperty(default = 1)
  978. description:bpy.props.StringProperty(default = "")
  979. default_value : bpy.props.BoolProperty(default = False, update = update_socket,)
  980. def init(self):
  981. self.display_shape = 'CIRCLE_DOT'
  982. # if True:
  983. # print (self.is_property_set("default_value"))
  984. # ui_data = self.id_properties_ui("default_value")
  985. # ui_data.update(
  986. # description=self.description,
  987. # default=0,) # for now
  988. # ui_data.update(
  989. # min = self.min,
  990. # max = self.max,
  991. # soft_min = self.soft_min,
  992. # soft_max = self.soft_max,)
  993. def draw(self, context, layout, node, text):
  994. ChooseDraw(self, context, layout, node, text)
  995. def draw_color(self, context, node):
  996. return self.color
  997. @classmethod
  998. def draw_color_simple(self):
  999. return self.color_simple
  1000. class ParameterIntSocket(MantisSocket):
  1001. """Integer Parameter socket"""
  1002. bl_idname = 'ParameterIntSocket'
  1003. bl_label = "Integer Parameter"
  1004. default_value : bpy.props.IntProperty(default = 0, update = update_socket,)
  1005. color_simple = cInt
  1006. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1007. input : bpy.props.BoolProperty(default =False,)
  1008. #custom properties:
  1009. min:bpy.props.FloatProperty(default = 0)
  1010. max:bpy.props.FloatProperty(default = 1)
  1011. soft_min:bpy.props.FloatProperty(default = 0)
  1012. soft_max:bpy.props.FloatProperty(default = 1)
  1013. description:bpy.props.StringProperty(default = "")
  1014. def init(self):
  1015. self.display_shape = 'CIRCLE_DOT'
  1016. def draw(self, context, layout, node, text):
  1017. ChooseDraw(self, context, layout, node, text)
  1018. def draw_color(self, context, node):
  1019. return self.color
  1020. @classmethod
  1021. def draw_color_simple(self):
  1022. return self.color_simple
  1023. class ParameterFloatSocket(MantisSocket):
  1024. """Float Parameter socket"""
  1025. bl_idname = 'ParameterFloatSocket'
  1026. bl_label = "Float Parameter"
  1027. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  1028. color_simple = cFloat
  1029. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1030. input : bpy.props.BoolProperty(default =False,)
  1031. #custom properties:
  1032. min:bpy.props.FloatProperty(default = 0)
  1033. max:bpy.props.FloatProperty(default = 1)
  1034. soft_min:bpy.props.FloatProperty(default = 0)
  1035. soft_max:bpy.props.FloatProperty(default = 1)
  1036. description:bpy.props.StringProperty(default = "")
  1037. def init(self):
  1038. self.display_shape = 'CIRCLE_DOT'
  1039. def draw(self, context, layout, node, text):
  1040. ChooseDraw(self, context, layout, node, text)
  1041. def draw_color(self, context, node):
  1042. return self.color
  1043. @classmethod
  1044. def draw_color_simple(self):
  1045. return self.color_simple
  1046. class ParameterVectorSocket(MantisSocket):
  1047. """Vector Parameter socket"""
  1048. bl_idname = 'ParameterVectorSocket'
  1049. bl_label = "Vector Parameter"
  1050. default_value : bpy.props.FloatVectorProperty(
  1051. default = (0.0, 0.0, 0.0),
  1052. update = update_socket,)
  1053. color_simple = cVector
  1054. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1055. input : bpy.props.BoolProperty(default =False,)
  1056. #custom properties:
  1057. description:bpy.props.StringProperty(default = "")
  1058. def init(self):
  1059. self.display_shape = 'CIRCLE_DOT'
  1060. def draw(self, context, layout, node, text):
  1061. ChooseDraw(self, context, layout, node, text)
  1062. def draw_color(self, context, node):
  1063. return self.color
  1064. @classmethod
  1065. def draw_color_simple(self):
  1066. return self.color_simple
  1067. class ParameterStringSocket(MantisSocket):
  1068. """String Parameter socket"""
  1069. bl_idname = 'ParameterStringSocket'
  1070. bl_label = "String Parameter"
  1071. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  1072. color_simple = cString
  1073. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1074. input : bpy.props.BoolProperty(default =False,)
  1075. #custom properties:
  1076. description:bpy.props.StringProperty(default = "")
  1077. def init(self):
  1078. self.display_shape = 'CIRCLE_DOT'
  1079. def draw(self, context, layout, node, text):
  1080. ChooseDraw(self, context, layout, node, text)
  1081. def draw_color(self, context, node):
  1082. return self.color
  1083. @classmethod
  1084. def draw_color_simple(self):
  1085. return self.color_simple
  1086. #####################################################################################
  1087. # Additional socket types, for special cases
  1088. #####################################################################################
  1089. from bpy.props import PointerProperty, StringProperty
  1090. def poll_is_armature(self, obj):
  1091. return obj.type == "ARMATURE"
  1092. # def poll_is_armature(self, obj):
  1093. # return obj.type == "ARMATURE"
  1094. class EnumMetaRigSocket(MantisSocket):
  1095. '''Custom node socket type'''
  1096. bl_idname = 'EnumMetaRigSocket'
  1097. bl_label = "Meta Rig"
  1098. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  1099. def get_default_value(self):
  1100. if self.search_prop:
  1101. return self.search_prop.name
  1102. return ""
  1103. def set_default_value(self, value):
  1104. if ob:= bpy.data.objects.get(value):
  1105. if ob.type == 'ARMATURE':
  1106. self.search_prop=ob
  1107. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1108. color_simple = cString
  1109. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1110. def draw(self, context, layout, node, text):
  1111. if self.is_output:
  1112. layout.label(text=self.name)
  1113. elif not (self.is_linked):
  1114. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="OUTLINER_OB_ARMATURE", results_are_suggestions=True)
  1115. elif hasattr(self.node, "armature"):
  1116. layout.label(text=self.node.armature)
  1117. # TODO: we should actually use the parsed tree to query this info directly, since this socket may belong to a node group in/out
  1118. # which doesn't have this parameter. whatever.
  1119. else:
  1120. layout.label(text=self.name)
  1121. def draw_color(self, context, node):
  1122. return self.color
  1123. @classmethod
  1124. def draw_color_simple(self):
  1125. return self.color_simple
  1126. def poll_is_curve(self, obj):
  1127. return obj.type == "CURVE"
  1128. class EnumCurveSocket(MantisSocket):
  1129. '''Choose a curve'''
  1130. bl_idname = 'EnumCurveSocket'
  1131. bl_label = "Curve"
  1132. is_valid_interface_type=True
  1133. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_curve, update=update_socket)
  1134. def get_default_value(self):
  1135. if self.search_prop:
  1136. return self.search_prop.name
  1137. return ""
  1138. def set_default_value(self, value):
  1139. if ob:= bpy.data.objects.get(value):
  1140. if ob.type == 'CURVE':
  1141. self.search_prop=ob
  1142. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1143. color_simple = cString
  1144. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1145. def draw(self, context, layout, node, text):
  1146. if not (self.is_linked) and not self.is_output:
  1147. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="CURVE_DATA", results_are_suggestions=True)
  1148. else:
  1149. try:
  1150. layout.label(text=self.search_prop.name)
  1151. except AttributeError: # TODO make this show the graph's result
  1152. layout.label(text=self.name)
  1153. def draw_color(self, context, node):
  1154. return self.color
  1155. @classmethod
  1156. def draw_color_simple(self):
  1157. return self.color_simple
  1158. def SearchPBDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  1159. 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)
  1160. class EnumMetaBoneSocket(MantisSocket):
  1161. '''Custom node socket type'''
  1162. bl_idname = 'EnumMetaBoneSocket'
  1163. bl_label = "Meta Bone"
  1164. search_prop:PointerProperty(type=bpy.types.Object)
  1165. bone:StringProperty()
  1166. def populate_bones_list(self, context):
  1167. # just gonna hardcode the value
  1168. if (meta_rig := self.search_prop):
  1169. retList = []
  1170. armatures = []
  1171. i = -1
  1172. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  1173. for b in meta_rig.data.bones:
  1174. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  1175. return(retList)
  1176. return None
  1177. # default_value : bpy.props.EnumProperty(
  1178. # items = populate_bones_list,
  1179. # name = "Meta Rig")
  1180. # def get_default_value(self):
  1181. # return self.search_prop.name
  1182. default_value : StringProperty(name = "", update=update_metarig_posebone)
  1183. color_simple = cString
  1184. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1185. def draw(self, context, layout, node, text):
  1186. if not (self.is_linked):
  1187. if self.search_prop is None:
  1188. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  1189. else:
  1190. SearchPBDraw(self, context, layout, node, text="")
  1191. else:
  1192. layout.label(text=self.node.pose_bone)
  1193. def draw_color(self, context, node):
  1194. return self.color
  1195. @classmethod
  1196. def draw_color_simple(self):
  1197. return self.color_simple
  1198. class BoolUpdateParentNode(MantisSocket):
  1199. '''Custom node socket type'''
  1200. bl_idname = 'BoolUpdateParentNode'
  1201. bl_label = "Boolean"
  1202. default_value: bpy.props.BoolProperty(default=False, update = update_parent_node)
  1203. color_simple = cBool
  1204. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  1205. input : bpy.props.BoolProperty(default =False,)
  1206. def draw(self, context, layout, node, text):
  1207. ChooseDraw(self, context, layout, node, text)
  1208. def draw_color(self, context, node):
  1209. return self.color
  1210. @classmethod
  1211. def draw_color_simple(self):
  1212. return self.color_simple
  1213. class IKChainLengthSocket(MantisSocket):
  1214. '''Custom node socket type'''
  1215. bl_idname = 'IKChainLengthSocket'
  1216. bl_label = "IK Chain Length"
  1217. default_value: bpy.props.IntProperty(default=0, update = ik_chain_length_update_socket, min = 0, max = 255)
  1218. color_simple = cInt
  1219. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1220. input : bpy.props.BoolProperty(default =False,)
  1221. def draw(self, context, layout, node, text):
  1222. ChooseDraw(self, context, layout, node, text)
  1223. def draw_color(self, context, node):
  1224. return self.color
  1225. @classmethod
  1226. def draw_color_simple(self):
  1227. return self.color_simple
  1228. # Inherit
  1229. eInheritScale = (
  1230. ('FULL', "Full", "Fully inherit scale", 1),
  1231. ('AVERAGE', "Average", "todo", 2),
  1232. ('ALIGNED', "Aligned", "todo", 3),
  1233. ('FIX_SHEAR', "Fix Shear", "todo", 4),
  1234. ('NONE', "None", "todo", 5),
  1235. )
  1236. class EnumInheritScale(MantisSocket):
  1237. '''Custom node socket type'''
  1238. bl_idname = 'EnumInheritScale'
  1239. bl_label = "Inherit Scale"
  1240. default_value: bpy.props.EnumProperty(
  1241. items=eInheritScale,
  1242. name="Inherit Scale",
  1243. description="Inherit Scale",
  1244. default = 'FULL',
  1245. #options = set(),
  1246. update = update_socket,)
  1247. color_simple = cString
  1248. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1249. input : bpy.props.BoolProperty(default =False,)
  1250. def draw(self, context, layout, node, text):
  1251. ChooseDraw(self, context, layout, node, text)
  1252. def draw_color(self, context, node):
  1253. return self.color
  1254. @classmethod
  1255. def draw_color_simple(self):
  1256. return self.color_simple
  1257. # Copy Rotation
  1258. eRotationMix =(
  1259. ('REPLACE', "Replace", "Fully inherit scale", 0),
  1260. ('BEFORE', "Before", "Fully inherit scale", 1),
  1261. ('AFTER', "After", "Fully inherit scale", 2),
  1262. ('ADD', "Add", "Fully inherit scale", 3),
  1263. #todo, but i don't care much
  1264. )
  1265. # TODO HACK
  1266. # I am trying to figure out how to do enum_flag as
  1267. # mutually exclusive options
  1268. # but! I don't think it's possible
  1269. # I just like the UI for it :P
  1270. class EnumRotationMix(MantisSocket):
  1271. '''Custom node socket type'''
  1272. bl_idname = 'EnumRotationMix'
  1273. bl_label = "Rotation Mix"
  1274. default_value: bpy.props.EnumProperty(
  1275. items=eRotationMix,
  1276. name="Rotation Mix",
  1277. description="Rotation Mix",
  1278. default = 'REPLACE',#{'REPLACE'},
  1279. options = set(), # this has to be a set lol
  1280. update = update_socket,)
  1281. color_simple = cString
  1282. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1283. input : bpy.props.BoolProperty(default =False,)
  1284. def draw(self, context, layout, node, text):
  1285. ChooseDraw(self, context, layout, node, text)
  1286. def draw_color(self, context, node):
  1287. return self.color
  1288. @classmethod
  1289. def draw_color_simple(self):
  1290. return self.color_simple
  1291. eRotationMix_copytransforms =(
  1292. ('REPLACE', "Replace (Aligned)", "Fully inherit scale"),
  1293. ('BEFORE', "Before (Aligned)", "Fully inherit scale"),
  1294. ('AFTER', "After (Aligned)", "Fully inherit scale"),
  1295. ('REPLACE_SPLIT', "Replace (Split Channels)", "Fully inherit scale"),
  1296. ('BEFORE_SPLIT', "Before (Split Channels)", "Fully inherit scale"),
  1297. ('AFTER_SPLIT', "After (Split Channels)", "Fully inherit scale"),
  1298. ('REPLACE_FULL', "Replace (Full)", "Fully inherit scale"),
  1299. ('BEFORE_FULL', "Before (Full)", "Fully inherit scale"),
  1300. ('AFTER_FULL', "After (Full)", "Fully inherit scale"),)
  1301. class EnumRotationMixCopyTransforms(MantisSocket):
  1302. '''Custom node socket type'''
  1303. bl_idname = 'EnumRotationMixCopyTransforms'
  1304. bl_label = "Rotation Mix"
  1305. default_value: bpy.props.EnumProperty(
  1306. items=eRotationMix_copytransforms,
  1307. name="Rotation Mix",
  1308. description="Rotation Mix",
  1309. default = 'REPLACE', #{'REPLACE'},
  1310. #options = {'ENUM_FLAG'}, # this sux
  1311. update = update_socket,)
  1312. color_simple = cString
  1313. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1314. input : bpy.props.BoolProperty(default =False,)
  1315. def draw(self, context, layout, node, text):
  1316. ChooseDraw(self, context, layout, node, text)
  1317. def draw_color(self, context, node):
  1318. return self.color
  1319. @classmethod
  1320. def draw_color_simple(self):
  1321. return self.color_simple
  1322. # STRETCH TO
  1323. eMaintainVolumeStretchTo = (('VOLUME_XZX', "XZ", "XZ", 1),
  1324. ('VOLUME_X', "X", "X", 2),
  1325. ('VOLUME_Z', "Z", "Z", 4),
  1326. ('NO_VOLUME', "None", "None", 8),)
  1327. class EnumMaintainVolumeStretchTo(MantisSocket):
  1328. '''Custom node socket type'''
  1329. bl_idname = 'EnumMaintainVolumeStretchToSocket'
  1330. bl_label = "Maintain Volume"
  1331. default_value: bpy.props.EnumProperty(
  1332. items=eMaintainVolumeStretchTo,
  1333. name="Maintain Volume",
  1334. description="Maintain Volume",
  1335. default = 'VOLUME_XZX',
  1336. #options = {'ENUM_FLAG'},
  1337. update = update_socket,)
  1338. color_simple = cString
  1339. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1340. input : bpy.props.BoolProperty(default =False,)
  1341. def draw(self, context, layout, node, text):
  1342. ChooseDraw(self, context, layout, node, text)
  1343. def draw_color(self, context, node):
  1344. return self.color
  1345. @classmethod
  1346. def draw_color_simple(self):
  1347. return self.color_simple
  1348. eRotationStretchTo = (('PLANE_X', "XZ", "XZ", 1),
  1349. ('PLANE_Z', "ZX", "ZX", 2),
  1350. ('SWING_Y', "Swing", "Swing", 4),)
  1351. class EnumRotationStretchTo(MantisSocket):
  1352. '''Custom node socket type'''
  1353. bl_idname = 'EnumRotationStretchTo'
  1354. bl_label = "Rotation"
  1355. default_value: bpy.props.EnumProperty(
  1356. items=eRotationStretchTo,
  1357. name="Rotation",
  1358. description="Rotation",
  1359. default = 'PLANE_X',
  1360. #options = {'ENUM_FLAG'},
  1361. update = update_socket,)
  1362. color_simple = cString
  1363. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1364. input : bpy.props.BoolProperty(default =False,)
  1365. def draw(self, context, layout, node, text):
  1366. ChooseDraw(self, context, layout, node, text)
  1367. def draw_color(self, context, node):
  1368. return self.color
  1369. @classmethod
  1370. def draw_color_simple(self):
  1371. return self.color_simple
  1372. # Track-To
  1373. eTrackAxis = (('TRACK_X', "X", "X", 1),
  1374. ('TRACK_Y', "Y", "Y", 2),
  1375. ('TRACK_Z', "Z", "Z", 4),
  1376. ('TRACK_NEGATIVE_X', "-X", "-X", 8),
  1377. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 16),
  1378. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 32,))
  1379. eUpAxis = (('UP_X', "X", "X", 1),
  1380. ('UP_Y', "Y", "Y", 2),
  1381. ('UP_Z', "Z", "Z", 4),)
  1382. # ugly but I can't change it easily without messing up versioning
  1383. class EnumTrackAxis(MantisSocket):
  1384. '''Custom node socket type'''
  1385. bl_idname = 'EnumTrackAxis'
  1386. bl_label = "Track Axis"
  1387. default_value: bpy.props.EnumProperty(
  1388. items=eTrackAxis,
  1389. name="Track Axis",
  1390. description="Track Axis",
  1391. default = 'TRACK_X',
  1392. #options = {'ENUM_FLAG'},
  1393. update = update_socket,)
  1394. color_simple = cString
  1395. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1396. input : bpy.props.BoolProperty(default =False,)
  1397. def draw(self, context, layout, node, text):
  1398. ChooseDraw(self, context, layout, node, text)
  1399. def draw_color(self, context, node):
  1400. return self.color
  1401. @classmethod
  1402. def draw_color_simple(self):
  1403. return self.color_simple
  1404. class EnumUpAxis(MantisSocket):
  1405. '''Custom node socket type'''
  1406. bl_idname = 'EnumUpAxis'
  1407. bl_label = "Up Axis"
  1408. default_value: bpy.props.EnumProperty(
  1409. items=eUpAxis,
  1410. name="Up Axis",
  1411. description="Up Axis",
  1412. default = 'UP_X',
  1413. #options = {'ENUM_FLAG'},
  1414. update = update_socket,)
  1415. color_simple = cString
  1416. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1417. input : bpy.props.BoolProperty(default =False,)
  1418. def draw(self, context, layout, node, text):
  1419. ChooseDraw(self, context, layout, node, text)
  1420. def draw_color(self, context, node):
  1421. return self.color
  1422. @classmethod
  1423. def draw_color_simple(self):
  1424. return self.color_simple
  1425. # Follow Track Forward axis
  1426. eForwardAxis = (('FORWARD_X', "X", "X", 0),
  1427. ('FORWARD_Y', "Y", "Y", 1),
  1428. ('FORWARD_Z', "Z", "Z", 2),
  1429. ('TRACK_NEGATIVE_X', "-X", "-X", 3),
  1430. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 4),
  1431. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 5),)
  1432. class EnumFollowPathForwardAxis(MantisSocket):
  1433. '''Custom node socket type'''
  1434. bl_idname = 'EnumFollowPathForwardAxis'
  1435. bl_label = "Forward Axis"
  1436. default_value: bpy.props.EnumProperty(
  1437. items=eForwardAxis,
  1438. name="Forward Axis",
  1439. description="Forward Axis",
  1440. default = 'FORWARD_X',
  1441. update = update_socket,)
  1442. color_simple = cString
  1443. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1444. input : bpy.props.BoolProperty(default =False,)
  1445. def draw(self, context, layout, node, text):
  1446. ChooseDraw(self, context, layout, node, text)
  1447. def draw_color(self, context, node):
  1448. return self.color
  1449. @classmethod
  1450. def draw_color_simple(self):
  1451. return self.color_simple
  1452. # Follow Track Forward axis
  1453. eFloorAxis = (('FLOOR_X', "X", "X", 0),
  1454. ('FLOOR_Y', "Y", "Y", 1),
  1455. ('FLOOR_Z', "Z", "Z", 2),
  1456. ('FLOOR_NEGATIVE_X', "-X", "-X", 3),
  1457. ('FLOOR_NEGATIVE_Y', "-Y", "-Y", 4),
  1458. ('FLOOR_NEGATIVE_Z', "-Z", "-Z", 5),)
  1459. class EnumFloorAxis(MantisSocket):
  1460. '''Floor Constraint Axis'''
  1461. bl_idname = 'EnumFloorAxis'
  1462. bl_label = "Floor Axis"
  1463. default_value: bpy.props.EnumProperty(
  1464. items=eFloorAxis,
  1465. name="Floor Axis",
  1466. description="Floor Axis",
  1467. default = 'FLOOR_X',
  1468. update = update_socket,)
  1469. color_simple = cString
  1470. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1471. input : bpy.props.BoolProperty(default =False,)
  1472. def draw(self, context, layout, node, text):
  1473. ChooseDraw(self, context, layout, node, text)
  1474. def draw_color(self, context, node):
  1475. return self.color
  1476. @classmethod
  1477. def draw_color_simple(self):
  1478. return self.color_simple
  1479. # Locked Track
  1480. eLockAxis = (('LOCK_X', "X", "X", 1),
  1481. ('LOCK_Y', "Y", "Y", 2),
  1482. ('LOCK_Z', "Z", "Z", 4),)
  1483. class EnumLockAxis(MantisSocket):
  1484. '''Custom node socket type'''
  1485. bl_idname = 'EnumLockAxis'
  1486. bl_label = "Lock Axis"
  1487. default_value: bpy.props.EnumProperty(
  1488. items=eLockAxis,
  1489. name="Lock Axis",
  1490. description="Lock Axis",
  1491. default = 'LOCK_X',
  1492. #options = {'ENUM_FLAG'},
  1493. update = update_socket,)
  1494. color_simple = cString
  1495. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1496. input : bpy.props.BoolProperty(default =False,)
  1497. def draw(self, context, layout, node, text):
  1498. ChooseDraw(self, context, layout, node, text)
  1499. def draw_color(self, context, node):
  1500. return self.color
  1501. @classmethod
  1502. def draw_color_simple(self):
  1503. return self.color_simple
  1504. # Limit Distance:
  1505. eLimitMode = (('LIMITDIST_INSIDE', "Inside", "Inside",),
  1506. ('LIMITDIST_OUTSIDE', "Outside", "Outside",),
  1507. ('LIMITDIST_ONSURFACE', "On Surface", "On Surface",),)
  1508. class EnumLimitMode(MantisSocket):
  1509. '''Custom node socket type'''
  1510. bl_idname = 'EnumLimitMode'
  1511. bl_label = "Clamp Region"
  1512. default_value: bpy.props.EnumProperty(
  1513. items=eLimitMode,
  1514. name="Clamp Region",
  1515. description="Clamp Region",
  1516. default = 'LIMITDIST_INSIDE',
  1517. update = update_socket,)
  1518. color_simple = cString
  1519. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1520. input : bpy.props.BoolProperty(default =False,)
  1521. def draw(self, context, layout, node, text):
  1522. ChooseDraw(self, context, layout, node, text)
  1523. def draw_color(self, context, node):
  1524. return self.color
  1525. @classmethod
  1526. def draw_color_simple(self):
  1527. return self.color_simple
  1528. # Spline IK
  1529. eYScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1530. ('FIT_CURVE', "Fit Curve", "Scale the bones to fit the entire length of the curve.",),
  1531. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),)
  1532. eXZScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1533. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),
  1534. ('INVERSE_PRESERVE', "Inverse Scale", "Scale of the X and Z axes is the inverse of the Y-Scale.",),
  1535. ('VOLUME_PRESERVE', "Volume Preservation", "Scale of the X and Z axes are adjusted to preserve the volume of the bones.",),)
  1536. class EnumYScaleMode(MantisSocket):
  1537. '''Custom node socket type'''
  1538. bl_idname = 'EnumYScaleMode'
  1539. bl_label = "Y Scale Mode"
  1540. default_value: bpy.props.EnumProperty(
  1541. items=eYScaleMode,
  1542. name="Y Scale Mode",
  1543. description="Y Scale Mode",
  1544. default = 'FIT_CURVE',
  1545. update = update_socket,)
  1546. color_simple = cString
  1547. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1548. input : bpy.props.BoolProperty(default =False,)
  1549. def draw(self, context, layout, node, text):
  1550. ChooseDraw(self, context, layout, node, text)
  1551. def draw_color(self, context, node):
  1552. return self.color
  1553. @classmethod
  1554. def draw_color_simple(self):
  1555. return self.color_simple
  1556. class EnumXZScaleMode(MantisSocket):
  1557. '''Custom node socket type'''
  1558. bl_idname = 'EnumXZScaleMode'
  1559. bl_label = "XZ Scale Mode"
  1560. default_value: bpy.props.EnumProperty(
  1561. items=eXZScaleMode,
  1562. name="XZ Scale Mode",
  1563. description="XZ Scale Mode",
  1564. default = 'NONE',
  1565. update = update_socket,)
  1566. color_simple = cString
  1567. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1568. input : bpy.props.BoolProperty(default =False,)
  1569. def draw(self, context, layout, node, text):
  1570. ChooseDraw(self, context, layout, node, text)
  1571. def draw_color(self, context, node):
  1572. return self.color
  1573. @classmethod
  1574. def draw_color_simple(self):
  1575. return self.color_simple
  1576. eMapxForm = (('LOCATION', "Location", "Location",),
  1577. ('ROTATION', "Rotation", "Rotation",),
  1578. ('SCALE', "Scale", "Scale",),)
  1579. eRotationMode = (('AUTO', 'Auto', 'Automattically Selected.', 0),
  1580. ('XYZ', "XYZ", "Euler using the XYZ rotation order", 1),
  1581. ('XZY', "XZY", "Euler using the XZY rotation order", 2),
  1582. ('ZXY', "ZXY", "Euler using the ZXY rotation order", 3),
  1583. ('ZYX', "ZYX", "Euler using the ZYX rotation order", 4),
  1584. ('YXZ', "YXZ", "Euler using the YXZ rotation order", 5),
  1585. ('YZX', "YZX", "Euler using the YZX rotation order", 6),
  1586. ('QUATERNION', "Quaternion", "Quaternion", 7),
  1587. ('SWING_TWIST_X', 'Swing and X Twist.', 'Decompose into a swing rotation to aim the X axis, followed by twist around it.', 8),
  1588. ('SWING_TWIST_Y', 'Swing and Y Twist.', 'Decompose into a swing rotation to aim the Y axis, followed by twist around it.', 9),
  1589. ('SWING_TWIST_Z', 'Swing and Z Twist.', 'Decompose into a swing rotation to aim the Z axis, followed by twist around it.', 10),)
  1590. enumTransformationRotationOrder = enumRotationOrder[:6]
  1591. eTranslationMix =(
  1592. ('ADD', "Add", "", 0),
  1593. ('REPLACE', "Replace", "", 1),
  1594. )
  1595. eScaleMix =(
  1596. ('MULTIPLY', "Multiply", "", 0),
  1597. ('REPLACE', "Replace", "", 1),
  1598. )
  1599. class EnumTransformationMap(MantisSocket):
  1600. '''Custom node socket type'''
  1601. bl_idname = 'EnumTransformationMap'
  1602. bl_label = "Map To/From"
  1603. default_value: bpy.props.EnumProperty(
  1604. items=eMapxForm,
  1605. name="Map To/From",
  1606. description="Map To/From",
  1607. default = 'LOCATION',
  1608. update = update_socket,)
  1609. color_simple = cString
  1610. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1611. input : bpy.props.BoolProperty(default =False,)
  1612. def draw(self, context, layout, node, text):
  1613. ChooseDraw(self, context, layout, node, text)
  1614. def draw_color(self, context, node):
  1615. return self.color
  1616. @classmethod
  1617. def draw_color_simple(self):
  1618. return self.color_simple
  1619. class EnumTransformationRotationMode(MantisSocket):
  1620. '''Custom node socket type'''
  1621. bl_idname = 'EnumTransformationRotationMode'
  1622. bl_label = "Map To/From"
  1623. default_value: bpy.props.EnumProperty(
  1624. items=eRotationMode,
  1625. name="Rotation Mode",
  1626. description="Rotation Mode",
  1627. default = 'AUTO',
  1628. update = update_socket,)
  1629. color_simple = cString
  1630. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1631. input : bpy.props.BoolProperty(default =False,)
  1632. def draw(self, context, layout, node, text):
  1633. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1634. def draw_color(self, context, node):
  1635. return self.color
  1636. @classmethod
  1637. def draw_color_simple(self):
  1638. return self.color_simple
  1639. class EnumTransformationRotationOrder(MantisSocket):
  1640. '''Custom node socket type'''
  1641. bl_idname = 'EnumTransformationRotationOrder'
  1642. bl_label = "Map To/From"
  1643. default_value: bpy.props.EnumProperty(
  1644. items=enumTransformationRotationOrder,
  1645. name="Rotation Order",
  1646. description="Rotation Order",
  1647. default = 'AUTO',
  1648. update = update_socket,)
  1649. color_simple = cString
  1650. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1651. input : bpy.props.BoolProperty(default =False,)
  1652. def draw(self, context, layout, node, text):
  1653. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1654. def draw_color(self, context, node):
  1655. return self.color
  1656. @classmethod
  1657. def draw_color_simple(self):
  1658. return self.color_simple
  1659. class EnumTransformationTranslationMixMode(MantisSocket):
  1660. '''Custom node socket type'''
  1661. bl_idname = 'EnumTransformationTranslationMixMode'
  1662. bl_label = "Mix Mode"
  1663. default_value: bpy.props.EnumProperty(
  1664. items=eTranslationMix,
  1665. name="Mix Translation",
  1666. description="Mix Translation",
  1667. default = 'ADD',
  1668. update = update_socket,)
  1669. color_simple = cString
  1670. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1671. input : bpy.props.BoolProperty(default =False,)
  1672. def draw(self, context, layout, node, text):
  1673. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1674. def draw_color(self, context, node):
  1675. return self.color
  1676. @classmethod
  1677. def draw_color_simple(self):
  1678. return self.color_simple
  1679. class EnumTransformationRotationMixMode(MantisSocket):
  1680. '''Custom node socket type'''
  1681. bl_idname = 'EnumTransformationRotationMixMode'
  1682. bl_label = "Mix Mode"
  1683. default_value: bpy.props.EnumProperty(
  1684. items=eRotationMix,
  1685. name="Mix Rotation",
  1686. description="Mix Rotation",
  1687. default = 'ADD',
  1688. update = update_socket,)
  1689. color_simple = cString
  1690. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1691. input : bpy.props.BoolProperty(default =False,)
  1692. def draw(self, context, layout, node, text):
  1693. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1694. def draw_color(self, context, node):
  1695. return self.color
  1696. @classmethod
  1697. def draw_color_simple(self):
  1698. return self.color_simple
  1699. class EnumTransformationScaleMixMode(MantisSocket):
  1700. '''Custom node socket type'''
  1701. bl_idname = 'EnumTransformationScaleMixMode'
  1702. bl_label = "Mix Mode"
  1703. default_value: bpy.props.EnumProperty(
  1704. items=eScaleMix,
  1705. name="Mix Scale",
  1706. description="Mix Scale",
  1707. default = 'REPLACE',
  1708. update = update_socket,)
  1709. color_simple = cString
  1710. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1711. input : bpy.props.BoolProperty(default =False,)
  1712. def draw(self, context, layout, node, text):
  1713. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1714. def draw_color(self, context, node):
  1715. return self.color
  1716. @classmethod
  1717. def draw_color_simple(self):
  1718. return self.color_simple
  1719. eAxes = (
  1720. ('X', "X", "X", 0),
  1721. ('Y', "Y", "Y", 1),
  1722. ('Z', "Z", "Z", 2),
  1723. )
  1724. class EnumTransformationAxes(MantisSocket):
  1725. '''Custom node socket type'''
  1726. bl_idname = 'EnumTransformationAxes'
  1727. bl_label = "Axes"
  1728. default_value: bpy.props.EnumProperty(
  1729. items=eAxes,
  1730. # name="",
  1731. # description="",
  1732. default = 'X',
  1733. update = update_socket,)
  1734. color_simple = cString
  1735. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1736. input : bpy.props.BoolProperty(default =False,)
  1737. def draw(self, context, layout, node, text):
  1738. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1739. def draw_color(self, context, node):
  1740. return self.color
  1741. @classmethod
  1742. def draw_color_simple(self):
  1743. return self.color_simple
  1744. #
  1745. eBBoneHandleType = (
  1746. ('AUTO', "Automatic", "", 0),
  1747. ('ABSOLUTE', "Absolute", "", 1),
  1748. ('RELATIVE', "Relative", "", 2),
  1749. ('TANGENT', "Tangent", "", 3),
  1750. )
  1751. class EnumBBoneHandleType(MantisSocket):
  1752. '''Custom node socket type'''
  1753. bl_idname = 'EnumBBoneHandleType'
  1754. bl_label = "Axes"
  1755. default_value: bpy.props.EnumProperty(
  1756. items=eBBoneHandleType,
  1757. # name="",
  1758. # description="",
  1759. default = 'AUTO',
  1760. update = update_socket,)
  1761. color_simple = cString
  1762. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1763. input : bpy.props.BoolProperty(default =False,)
  1764. def draw(self, context, layout, node, text):
  1765. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1766. def draw_color(self, context, node):
  1767. return self.color
  1768. @classmethod
  1769. def draw_color_simple(self):
  1770. return self.color_simple
  1771. eSkinningMethod = (('EXISTING_GROUPS', "Use Existing Groups", "Use the existing vertex groups, or create empty groups if not found.",),
  1772. ('AUTOMATIC_HEAT', "Automatic (Heat)", "Use Blender's heatmap automatic skinning",),
  1773. ('COPY_FROM_OBJECT', "Copy from object", "Copy skin weights from the selected object"),)
  1774. class EnumSkinning(MantisSocket):
  1775. '''Custom node socket type'''
  1776. bl_idname = 'EnumSkinning'
  1777. bl_label = "Skinning Method"
  1778. default_value: bpy.props.EnumProperty(
  1779. items=eSkinningMethod,
  1780. name="Skinning Method",
  1781. description="Skinning Method",
  1782. default = 'AUTOMATIC_HEAT',
  1783. update = update_socket,)
  1784. color_simple = cString
  1785. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1786. input : bpy.props.BoolProperty(default =False,)
  1787. def draw(self, context, layout, node, text):
  1788. ChooseDraw(self, context, layout, node, text)
  1789. def draw_color(self, context, node):
  1790. return self.color
  1791. @classmethod
  1792. def draw_color_simple(self):
  1793. return self.color_simple
  1794. class MorphTargetSocket(MantisSocket):
  1795. """Morph Target"""
  1796. bl_idname = 'MorphTargetSocket'
  1797. bl_label = "Morph Target"
  1798. color_simple = cShapeKey
  1799. color : bpy.props.FloatVectorProperty(default=cShapeKey, size=4)
  1800. input : bpy.props.BoolProperty(default =False,)
  1801. is_valid_interface_type=True
  1802. def draw(self, context, layout, node, text):
  1803. ChooseDraw(self, context, layout, node, text)
  1804. def draw_color(self, context, node):
  1805. return self.color
  1806. @classmethod
  1807. def draw_color_simple(self):
  1808. return self.color_simple
  1809. eDriverVariableType = (
  1810. ( 'SINGLE_PROP',
  1811. "Property",
  1812. "Property",
  1813. 1),
  1814. ( 'LOC_DIFF',
  1815. "Distance",
  1816. "Distance",
  1817. 2),
  1818. ( 'ROTATION_DIFF',
  1819. "Rotational Difference",
  1820. "Rotational Difference",
  1821. 3),
  1822. # ( 'TRANSFORMS',
  1823. # "Transform Channel",
  1824. # "Transform Channel",
  1825. # 4),
  1826. )
  1827. class EnumDriverVariableType(MantisSocket):
  1828. '''Custom node socket type'''
  1829. bl_idname = 'EnumDriverVariableType'
  1830. bl_label = "Variable Type"
  1831. default_value: bpy.props.EnumProperty(
  1832. items = eDriverVariableType,
  1833. name = "Variable Type",
  1834. description = "Variable Type",
  1835. default = 'SINGLE_PROP',
  1836. update = driver_variable_socket_update,)
  1837. color_simple = cString
  1838. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1839. input : bpy.props.BoolProperty(default =False,)
  1840. def draw(self, context, layout, node, text):
  1841. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1842. def draw_color(self, context, node):
  1843. return self.color
  1844. @classmethod
  1845. def draw_color_simple(self):
  1846. return self.color_simple
  1847. eDriverVariableEvaluationSpace = (
  1848. ( 'WORLD_SPACE',
  1849. "World",
  1850. "World",
  1851. 1),
  1852. ( 'TRANSFORM_SPACE',
  1853. "Transform",
  1854. "Transform",
  1855. 2),
  1856. ( 'LOCAL_SPACE',
  1857. "Local",
  1858. "Local",
  1859. 3),
  1860. )
  1861. class EnumDriverVariableEvaluationSpace(MantisSocket):
  1862. '''Custom node socket type'''
  1863. bl_idname = 'EnumDriverVariableEvaluationSpace'
  1864. bl_label = "Evaluation Space"
  1865. default_value: bpy.props.EnumProperty(
  1866. items = eDriverVariableEvaluationSpace,
  1867. name = "Evaluation Space",
  1868. description = "Evaluation Space",
  1869. default = 'WORLD_SPACE',
  1870. update = driver_variable_socket_update,)
  1871. color_simple = cString
  1872. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1873. input : bpy.props.BoolProperty(default =False,)
  1874. def draw(self, context, layout, node, text):
  1875. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1876. def draw_color(self, context, node):
  1877. return self.color
  1878. @classmethod
  1879. def draw_color_simple(self):
  1880. return self.color_simple
  1881. eDriverVariableTransformChannel = (
  1882. ("LOC_X", "X Location", "The X-coordinate of an object's location.", 1),
  1883. ("LOC_Y", "Y Location", "The Y-coordinate of an object's location.", 2),
  1884. ("LOC_Z", "Z Location", "The Z-coordinate of an object's location.", 3),
  1885. ("ROT_X", "X Rotation", "Rotation X-axis.", 4),
  1886. ("ROT_Y", "Y Rotation", "Rotation Y-axis.", 5),
  1887. ("ROT_Z", "Z Rotation", "Rotation Z-axis.", 6),
  1888. ("ROT_W", "W Rotation", "Rotation W-axis.", 7),
  1889. ("SCALE_X", "X Scale", "The X-scale of an object's scale.", 8),
  1890. ("SCALE_Y", "Y Scale", "The Y-scale of an object's scale.", 9),
  1891. ("SCALE_Z", "Z Scale", "The Z-scale of an object's scale.", 10),
  1892. ("SCALE_AVG", "Average Scale", "The scale factor of an object's scale.", 11),
  1893. )
  1894. class EnumDriverVariableTransformChannel(MantisSocket):
  1895. '''Custom node socket type'''
  1896. bl_idname = 'EnumDriverVariableTransformChannel'
  1897. bl_label = "Transform Channel"
  1898. default_value: bpy.props.EnumProperty(
  1899. items = eDriverVariableTransformChannel,
  1900. name = "Transform Channel",
  1901. description = "Transform Channel",
  1902. default = 'LOC_X',
  1903. update = driver_variable_socket_update,)
  1904. color_simple = cString
  1905. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1906. input : bpy.props.BoolProperty(default =False,)
  1907. def draw(self, context, layout, node, text):
  1908. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1909. def draw_color(self, context, node):
  1910. return self.color
  1911. @classmethod
  1912. def draw_color_simple(self):
  1913. return self.color_simple
  1914. class EnumDriverRotationMode(MantisSocket):
  1915. '''Custom node socket type'''
  1916. bl_idname = 'EnumDriverRotationMode'
  1917. bl_label = "Rotaton Mode"
  1918. default_value: bpy.props.EnumProperty(
  1919. items = eRotationMode,
  1920. name = "Rotation Mode",
  1921. description = "Rotation Mode",
  1922. default = 'AUTO',
  1923. update = driver_variable_socket_update,)
  1924. color_simple = cString
  1925. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1926. input : bpy.props.BoolProperty(default =False,)
  1927. def draw(self, context, layout, node, text):
  1928. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1929. def draw_color(self, context, node):
  1930. return self.color
  1931. @classmethod
  1932. def draw_color_simple(self):
  1933. return self.color_simple
  1934. #
  1935. eDriverType = (('AVERAGE', 'Average', 'Average', 0),
  1936. ('SUM', "Sum", "Sum", 1),
  1937. ('SCRIPTED', "Scripted", "Scripted Expression", 2),
  1938. ('MIN', "Min", "Minimum", 3),
  1939. ('MAX', "Max", "Maximum", 4),)
  1940. class EnumDriverType(MantisSocket):
  1941. '''Custom node socket type'''
  1942. bl_idname = 'EnumDriverType'
  1943. bl_label = "Driver Type"
  1944. default_value: bpy.props.EnumProperty(
  1945. items = eDriverType,
  1946. name = "Driver Type",
  1947. description = "Driver Type",
  1948. default = 'AVERAGE',
  1949. update = driver_socket_update,)
  1950. color_simple = cString
  1951. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1952. input : bpy.props.BoolProperty(default =False,)
  1953. def draw(self, context, layout, node, text):
  1954. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1955. def draw_color(self, context, node):
  1956. return self.color
  1957. @classmethod
  1958. def draw_color_simple(self):
  1959. return self.color_simple
  1960. # Keyframe
  1961. # Enum for kf handle type
  1962. # enum for interpolation type
  1963. # eventually gonna make it to the fancy stuff
  1964. class FloatSocket(bpy.types.NodeSocketFloat, MantisSocket):
  1965. """Float Input socket"""
  1966. bl_idname = 'FloatSocket'
  1967. bl_label = "Float"
  1968. is_valid_interface_type=True
  1969. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  1970. color_simple = cFloat
  1971. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1972. input : bpy.props.BoolProperty(default =False,)
  1973. def draw(self, context, layout, node, text):
  1974. ChooseDraw(self, context, layout, node, text)
  1975. def draw_color(self, context, node):
  1976. return self.color
  1977. @classmethod
  1978. def draw_color_simple(self):
  1979. return self.color_simple
  1980. class FloatPositiveSocket(bpy.types.NodeSocketFloat, MantisSocket):
  1981. """Float Input socket"""
  1982. bl_idname = 'FloatPositiveSocket'
  1983. bl_label = "Float (Positive)"
  1984. is_valid_interface_type=True
  1985. default_value : bpy.props.FloatProperty(default = 0.0, min=0, update = update_socket,)
  1986. color_simple = cFloat
  1987. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1988. input : bpy.props.BoolProperty(default =False,)
  1989. def draw(self, context, layout, node, text):
  1990. ChooseDraw(self, context, layout, node, text)
  1991. def draw_color(self, context, node):
  1992. return self.color
  1993. @classmethod
  1994. def draw_color_simple(self):
  1995. return self.color_simple
  1996. class FloatFactorSocket(bpy.types.NodeSocketFloatFactor, MantisSocket):
  1997. '''xFrom Input Output'''
  1998. bl_idname = 'FloatFactorSocket'
  1999. bl_label = "Float (Factor)"
  2000. is_valid_interface_type=True
  2001. default_value : bpy.props.FloatProperty(
  2002. default = 0.0,
  2003. min = 0.0,
  2004. max=1.0,
  2005. update = update_socket,
  2006. subtype='FACTOR',)
  2007. color_simple = cFloat
  2008. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2009. input : bpy.props.BoolProperty(default =False,)
  2010. def draw(self, context, layout, node, text):
  2011. ChooseDraw(self, context, layout, node, text)
  2012. def draw_color(self, context, node):
  2013. return self.color
  2014. @classmethod
  2015. def draw_color_simple(self):
  2016. return self.color_simple
  2017. class FloatAngleSocket(bpy.types.NodeSocketFloatAngle, MantisSocket):
  2018. '''xFrom Input Output'''
  2019. bl_idname = 'FloatAngleSocket'
  2020. bl_label = "Float (Angle)"
  2021. is_valid_interface_type=True
  2022. default_value : bpy.props.FloatProperty(
  2023. default = 0.0,
  2024. min = -180,
  2025. max=180,
  2026. update = update_socket,
  2027. subtype='ANGLE',)
  2028. color_simple = cFloat
  2029. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2030. input : bpy.props.BoolProperty(default =False,)
  2031. def draw(self, context, layout, node, text):
  2032. ChooseDraw(self, context, layout, node, text)
  2033. def draw_color(self, context, node):
  2034. return self.color
  2035. @classmethod
  2036. def draw_color_simple(self):
  2037. return self.color_simple
  2038. class VectorSocket(bpy.types.NodeSocketVectorEuler, MantisSocket):
  2039. """Vector Input socket"""
  2040. bl_idname = 'VectorSocket'
  2041. bl_label = "Vector"
  2042. is_valid_interface_type=True
  2043. default_value : bpy.props.FloatVectorProperty(
  2044. default = (0.0, 0.0, 0.0),
  2045. update = update_socket,)
  2046. color_simple = cVector
  2047. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2048. input : bpy.props.BoolProperty(default =False,)
  2049. def draw(self, context, layout, node, text):
  2050. ChooseDraw(self, context, layout, node, text)
  2051. def draw_color(self, context, node):
  2052. return self.color
  2053. @classmethod
  2054. def draw_color_simple(self):
  2055. return self.color_simple
  2056. class VectorEulerSocket(bpy.types.NodeSocketVectorEuler, MantisSocket):
  2057. """Vector Input socket"""
  2058. bl_idname = 'VectorEulerSocket'
  2059. bl_label = "Euler"
  2060. is_valid_interface_type=True
  2061. default_value : bpy.props.FloatVectorProperty(
  2062. default = (0.0, 0.0, 0.0),
  2063. update = update_socket,
  2064. subtype='EULER',)
  2065. color_simple = cVector
  2066. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2067. input : bpy.props.BoolProperty(default =False,)
  2068. def draw(self, context, layout, node, text):
  2069. ChooseDraw(self, context, layout, node, text)
  2070. def draw_color(self, context, node):
  2071. return self.color
  2072. @classmethod
  2073. def draw_color_simple(self):
  2074. return self.color_simple
  2075. class VectorTranslationSocket(bpy.types.NodeSocketVectorTranslation, MantisSocket):
  2076. """Vector Input socket"""
  2077. bl_idname = 'VectorTranslationSocket'
  2078. bl_label = "Vector (Translation)"
  2079. default_value : bpy.props.FloatVectorProperty(
  2080. default = (0.0, 0.0, 0.0),
  2081. update = update_socket,
  2082. subtype='TRANSLATION',)
  2083. color_simple = cVector
  2084. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2085. input : bpy.props.BoolProperty(default =False,)
  2086. def draw(self, context, layout, node, text):
  2087. ChooseDraw(self, context, layout, node, text)
  2088. def draw_color(self, context, node):
  2089. return self.color
  2090. @classmethod
  2091. def draw_color_simple(self):
  2092. return self.color_simple
  2093. class VectorScaleSocket(bpy.types.NodeSocketVectorXYZ, MantisSocket):
  2094. """Vector Input socket"""
  2095. bl_idname = 'VectorScaleSocket'
  2096. bl_label = "Vector (Scale)"
  2097. default_value : bpy.props.FloatVectorProperty(
  2098. default = (1.0, 1.0, 1.0),
  2099. update = update_socket,
  2100. subtype='XYZ',)
  2101. color_simple = cVector
  2102. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2103. input : bpy.props.BoolProperty(default =False,)
  2104. def draw(self, context, layout, node, text):
  2105. ChooseDraw(self, context, layout, node, text)
  2106. def draw_color(self, context, node):
  2107. return self.color
  2108. @classmethod
  2109. def draw_color_simple(self):
  2110. return self.color_simple
  2111. class KeyframeSocket(MantisSocket):
  2112. '''Keyframe'''
  2113. bl_idname = 'KeyframeSocket'
  2114. bl_label = "Keyframe"
  2115. is_valid_interface_type=True
  2116. color_simple = cKeyframe
  2117. color : bpy.props.FloatVectorProperty(default=cKeyframe, size=4)
  2118. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2119. def init(self):
  2120. self.display_shape = 'CIRCLE_DOT'
  2121. def draw(self, context, layout, node, text):
  2122. ChooseDraw(self, context, layout, node, text)
  2123. def draw_color(self, context, node):
  2124. return self.color
  2125. @classmethod
  2126. def draw_color_simple(self):
  2127. return self.color_simple
  2128. EnumKeyframeInterpolationType = (('CONSTANT', 'Stepped', 'Stepped'),
  2129. ('LINEAR', "Linear", "Linear"),
  2130. ('BEZIER', "Bezier", "Bezier"),)
  2131. class EnumKeyframeInterpolationTypeSocket(MantisSocket):
  2132. '''Keyframe Interpolation Type'''
  2133. bl_idname = 'EnumKeyframeInterpolationTypeSocket'
  2134. bl_label = "Keyframe Interpolation Type"
  2135. default_value :bpy.props.EnumProperty(
  2136. name="",
  2137. description="Interpolation",
  2138. items=EnumKeyframeInterpolationType,
  2139. default='LINEAR',
  2140. update = update_socket,)
  2141. color_simple = cString
  2142. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2143. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2144. def draw(self, context, layout, node, text):
  2145. ChooseDraw(self, context, layout, node, text)
  2146. def draw_color(self, context, node):
  2147. return self.color
  2148. @classmethod
  2149. def draw_color_simple(self):
  2150. return self.color_simple
  2151. EnumKeyframeBezierHandleType = (('FREE', 'Free', 'Completely independent manually set handle.'),
  2152. ('ALIGNED', "Aligned", "Manually set handle with rotation locked together with its pair."),
  2153. ('VECTOR', "Vector", "Automatic handles that create straight lines."),
  2154. ('AUTO', "Automatic", "Automatic handles that create smooth curves."),
  2155. ('AUTO_CLAMPED', "Auto Clamped", "Automatic handles that create smooth curves which only change direction at keyframes."),)
  2156. class EnumKeyframeBezierHandleTypeSocket(MantisSocket):
  2157. '''Keyframe Bezier Handle Type'''
  2158. bl_idname = 'EnumKeyframeBezierHandleTypeSocket'
  2159. bl_label = "Keyframe Bezier Handle Type"
  2160. default_value :bpy.props.EnumProperty(
  2161. name="",
  2162. description="Handle Type",
  2163. items=EnumKeyframeBezierHandleType,
  2164. default='AUTO_CLAMPED',
  2165. update = update_socket,)
  2166. color_simple = cString
  2167. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2168. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2169. def draw(self, context, layout, node, text):
  2170. ChooseDraw(self, context, layout, node, text)
  2171. def draw_color(self, context, node):
  2172. return self.color
  2173. @classmethod
  2174. def draw_color_simple(self):
  2175. return self.color_simple
  2176. enumExtrapolationMode = (('CONSTANT', 'Constant', 'Constant'),
  2177. ('LINEAR', "Linear", "Linear"),)
  2178. class eFCrvExtrapolationMode(MantisSocket):
  2179. '''FCurve Extrapolation Mode'''
  2180. bl_idname = 'eFCrvExtrapolationMode'
  2181. bl_label = "Extrapolation Mode"
  2182. default_value :bpy.props.EnumProperty(
  2183. name="",
  2184. description="Handle Type",
  2185. items=enumExtrapolationMode,
  2186. default='CONSTANT',
  2187. update = update_socket,)
  2188. color_simple = cString
  2189. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2190. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2191. def draw(self, context, layout, node, text):
  2192. ChooseDraw(self, context, layout, node, text)
  2193. def draw_color(self, context, node):
  2194. return self.color
  2195. @classmethod
  2196. def draw_color_simple(self):
  2197. return self.color_simple
  2198. EnumLatticeInterpolationType = (('KEY_LINEAR', 'Linear', 'Linear Interpolation.'),
  2199. ('KEY_CARDINAL', "Cardinal", "Cardinal Interpolation."),
  2200. ('KEY_CATMULL_ROM', "Catmull Rom", "Catmull Rom Interpolation."),
  2201. ('KEY_BSPLINE', "B-Spline", "B Spline Interpolation."),)
  2202. class EnumLatticeInterpolationTypeSocket(MantisSocket):
  2203. '''Lattice Interpolation Type'''
  2204. bl_idname = 'EnumLatticeInterpolationTypeSocket'
  2205. bl_label = "Lattice Interpolation Type"
  2206. default_value :bpy.props.EnumProperty(
  2207. name="",
  2208. description="Interpolation Type",
  2209. items=EnumLatticeInterpolationType,
  2210. default='KEY_BSPLINE',
  2211. update = update_socket,)
  2212. color_simple = cString
  2213. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2214. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2215. def draw(self, context, layout, node, text):
  2216. ChooseDraw(self, context, layout, node, text)
  2217. def draw_color(self, context, node):
  2218. return self.color
  2219. @classmethod
  2220. def draw_color_simple(self):
  2221. return self.color_simple
  2222. EnumCorrectiveSmoothType = (('SIMPLE', 'Simple', 'Use the average of adjacent edge-vertices.'),
  2223. ('LENGTH_WEIGHTED', "Length Weight", "Use the average of adjacent"
  2224. "edge-vertices weighted by their length."),)
  2225. class EnumCorrectiveSmoothTypeSocket(MantisSocket):
  2226. '''Lattice Interpolation Type'''
  2227. bl_idname = 'EnumCorrectiveSmoothTypeSocket'
  2228. bl_label = "Lattice Interpolation Type"
  2229. default_value :bpy.props.EnumProperty(
  2230. name="",
  2231. description="Interpolation Type",
  2232. items=EnumCorrectiveSmoothType,
  2233. default='SIMPLE',
  2234. update = update_socket,)
  2235. color_simple = cString
  2236. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2237. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2238. def draw(self, context, layout, node, text):
  2239. ChooseDraw(self, context, layout, node, text)
  2240. def draw_color(self, context, node):
  2241. return self.color
  2242. @classmethod
  2243. def draw_color_simple(self):
  2244. return self.color_simple
  2245. enumFloatOperations = (('ADD', 'Add', 'Add'),
  2246. ('SUBTRACT', "Subtract", "Subtract"),
  2247. ('MULTIPLY', "Multiply", "Multiply"),
  2248. ('DIVIDE', "Divide", "Divide"),
  2249. ('POWER', "Power", "Power"),
  2250. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2251. ('MODULUS', "Modulus", "Modulus"),
  2252. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2253. ('MAXIMUM', "Maximum", "Maximum"),
  2254. ('MINIMUM', "Minimum", "Minimum"),
  2255. ('GREATER THAN', "Greater Than", "Greater Than"),
  2256. ('LESS THAN', "Less Than", "Less Than"),
  2257. ('ARCTAN2', "atan2", "2-argument arctan function"),
  2258. ('FLOOR', "Floor", "the nearest integer lower than input A"),
  2259. ('CEIL', "Ceiling", "the next integer higher than input A"),
  2260. ('ROUND', "Round", "Round to the nearest integer"),)
  2261. class MathFloatOperation(MantisSocket):
  2262. """Float Math Operation"""
  2263. bl_idname = 'MathFloatOperation'
  2264. bl_label = "Operation"
  2265. default_value :bpy.props.EnumProperty(
  2266. name="",
  2267. description="Operation",
  2268. items=enumFloatOperations,
  2269. default='MULTIPLY',
  2270. update = update_socket,)
  2271. color_simple = cString
  2272. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2273. input : bpy.props.BoolProperty(default =False,)
  2274. def draw(self, context, layout, node, text):
  2275. ChooseDraw(self, context, layout, node, text)
  2276. def draw_color(self, context, node):
  2277. return self.color
  2278. @classmethod
  2279. def draw_color_simple(self):
  2280. return self.color_simple
  2281. enumVectorOperations = (('ADD', 'Add', 'Add (Component-wise)'),
  2282. ('SUBTRACT', "Subtract", "Subtract (Component-wise)"),
  2283. ('MULTIPLY', "Multiply", "Multiply (Component-wise)"),
  2284. ('SCALE', "Scale", "Scales vector by input float or average magnitude of input vector's components."),
  2285. ('DIVIDE', "Divide", "Divide (Component-wise)"),
  2286. ('POWER', "Power", "Power (Component-wise)"),
  2287. ('LENGTH', "Length", "Length"),
  2288. ('CROSS', "Cross Product", "Cross product of A X B"),
  2289. ('NORMALIZE', "Normalize", "Returns a normalized vector."),
  2290. ('DOT', "Dot Product", "Dot product of A . B"),
  2291. ('LINEAR_INTERP', "Linear Interpolation", "Linear Interpolation between vectors A and B by factor"))
  2292. class MathVectorOperation(MantisSocket):
  2293. """Vector Math Operation"""
  2294. bl_idname = 'MathVectorOperation'
  2295. bl_label = "Operation"
  2296. default_value :bpy.props.EnumProperty(
  2297. name="",
  2298. description="Operation",
  2299. items=enumVectorOperations,
  2300. default='MULTIPLY',
  2301. update = update_socket,)
  2302. color_simple = cString
  2303. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2304. input : bpy.props.BoolProperty(default =False,)
  2305. def draw(self, context, layout, node, text):
  2306. ChooseDraw(self, context, layout, node, text)
  2307. def draw_color(self, context, node):
  2308. return self.color
  2309. @classmethod
  2310. def draw_color_simple(self):
  2311. return self.color_simple
  2312. enumMatrixTransform = (('TRANSLATE', 'Translate', 'Translate'),
  2313. ('ROTATE_AXIS_ANGLE', "Rotate (Axis-angle)", "Rotates a number of radians around an axis"),
  2314. # ('ROTATE_EULER', "Rotate (Euler)", "Euler Rotation"),
  2315. # ('ROTATE_QUATERNION', "Rotate (Quaternion)", "Quaternion Rotation"),
  2316. ('SCALE', "Scale", "Scale"),)
  2317. class MatrixTransformOperation(MantisSocket):
  2318. """Matrix Transform Operation"""
  2319. bl_idname = 'MatrixTransformOperation'
  2320. bl_label = "Operation"
  2321. default_value :bpy.props.EnumProperty(
  2322. name="",
  2323. description="Operation",
  2324. items=enumMatrixTransform,
  2325. default='TRANSLATE',
  2326. update = update_socket,)
  2327. color_simple = cString
  2328. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2329. input : bpy.props.BoolProperty(default =False,)
  2330. def draw(self, context, layout, node, text):
  2331. ChooseDraw(self, context, layout, node, text)
  2332. def draw_color(self, context, node):
  2333. return self.color
  2334. @classmethod
  2335. def draw_color_simple(self):
  2336. return self.color_simple
  2337. enumIntOperations = (('ADD', 'Add', 'Add'),
  2338. ('SUBTRACT', "Subtract", "Subtract"),
  2339. ('MULTIPLY', "Multiply", "Multiply"),
  2340. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2341. ('POWER', "Power", "Power"),
  2342. ('MODULUS', "Modulus", "Modulus"),
  2343. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2344. ('MAXIMUM', "Maximum", "Maximum"),
  2345. ('MINIMUM', "Minimum", "Minimum"),
  2346. ('GREATER THAN', "Greater Than", "Greater Than"),
  2347. ('LESS THAN', "Less Than", "Less Than"),)
  2348. class MathIntOperation(MantisSocket):
  2349. """Int Math Operation"""
  2350. bl_idname = 'MathIntOperation'
  2351. bl_label = "Operation"
  2352. default_value :bpy.props.EnumProperty(
  2353. name="",
  2354. description="Operation",
  2355. items=enumIntOperations,
  2356. default='MULTIPLY',
  2357. update = update_socket,)
  2358. color_simple = cString
  2359. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2360. input : bpy.props.BoolProperty(default =False,)
  2361. def draw(self, context, layout, node, text):
  2362. ChooseDraw(self, context, layout, node, text)
  2363. def draw_color(self, context, node):
  2364. return self.color
  2365. @classmethod
  2366. def draw_color_simple(self):
  2367. return self.color_simple
  2368. enumCompareOperations = (('EQUAL', "Equal", "Equal"),
  2369. ('NOT_EQUAL', "Not Equal", "Not Equal"),
  2370. ('GREATER_THAN', "Greater Than", "Greater Than"),
  2371. ('GREATER_THAN_EQUAL', "Greater Than or Equal", "Greater Than or Equal"),
  2372. ('LESS_THAN', "Less Than", "Less Than"),
  2373. ('LESS_THAN_EQUAL', "Equal or Less Than", "Equal or Less Than"),)
  2374. class EnumCompareOperation(MantisSocket):
  2375. """Compare Operation"""
  2376. bl_idname = 'EnumCompareOperation'
  2377. bl_label = "Comparison"
  2378. default_value :bpy.props.EnumProperty(
  2379. name="",
  2380. description="Comparison",
  2381. items=enumCompareOperations,
  2382. default='EQUAL',
  2383. update = update_socket,)
  2384. color_simple = cString
  2385. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2386. input : bpy.props.BoolProperty(default =False,)
  2387. def draw(self, context, layout, node, text):
  2388. ChooseDraw(self, context, layout, node, text)
  2389. def draw_color(self, context, node):
  2390. return self.color
  2391. @classmethod
  2392. def draw_color_simple(self):
  2393. return self.color_simple
  2394. class WildcardSocket(MantisSocket):
  2395. """Some kind of node socket lol I donno"""
  2396. bl_idname = 'WildcardSocket'
  2397. bl_label = ""
  2398. color_simple = (0.0,0.0,0.0,0.0)
  2399. color : bpy.props.FloatVectorProperty(default=(0.0,0.0,0.0,0.0), size=4)
  2400. input : bpy.props.BoolProperty(default =False,)
  2401. def draw(self, context, layout, node, text):
  2402. ChooseDraw(self, context, layout, node, text)
  2403. def draw_color(self, context, node):
  2404. return self.color
  2405. @classmethod
  2406. def draw_color_simple(self):
  2407. return self.color_simple