socket_definitions.py 117 KB

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