socket_definitions.py 106 KB

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