socket_definitions.py 90 KB

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