socket_definitions.py 96 KB

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