socket_definitions.py 94 KB

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