socket_definitions.py 117 KB

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