socket_definitions.py 101 KB

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