socket_definitions.py 89 KB

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