socket_definitions.py 111 KB

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