socket_definitions.py 88 KB

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