socket_definitions.py 113 KB

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