socket_definitions.py 128 KB

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