socket_definitions.py 87 KB

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