misc_nodes_socket_templates.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. from .mantis_dataclasses import MantisSocketTemplate as ST
  2. from dataclasses import replace
  3. # reused templates
  4. SplineIndexTemplate = ST(name="Spline Index",
  5. bl_idname='UnsignedIntSocket', is_input=True, default_value=0,)
  6. FactorTemplate = ST(name="Factor", bl_idname='FloatFactorSocket', is_input=True,)
  7. MatrixOutput = ST( name="Matrix", is_input=False, bl_idname='MatrixSocket', )
  8. MatricesOutTemplate = replace(MatrixOutput, name='Matrices', use_multi_input=True)
  9. StringOutput = ST( name="String", is_input=False, bl_idname='StringSocket', )
  10. MatrixInput = replace(MatrixOutput, is_input=True)
  11. VectorOutput = ST(name="Vector", bl_idname="VectorSocket", is_input=False)
  12. VectorInput = replace(VectorOutput, is_input = True)
  13. # input classes
  14. InputFloatSockets = [
  15. FloatInput := ST(name='Float Input',
  16. bl_idname='FloatSocket', is_input=False),
  17. ]
  18. InputIntSockets = [
  19. IntInput := ST(name='Integer',
  20. bl_idname='IntSocket', is_input=False),
  21. ]
  22. InputVectorSockets = [
  23. replace(VectorOutput, name='',),
  24. ]
  25. InputBooleanSockets = [
  26. BoolInput := ST(name='',
  27. bl_idname='BooleanSocket', is_input=False),
  28. ]
  29. InputBooleanThreeTupleSockets = [
  30. BoolThreeTupleInput := ST(name='',
  31. bl_idname='BooleanThreeTupleSocket', is_input=False),
  32. ]
  33. InputRotationOrderSockets = [
  34. RotationOrderInput := ST(name='',
  35. bl_idname='RotationOrderSocket', is_input=False),
  36. ]
  37. InputTransformSpaceSockets = [
  38. TransformSpaceInput := ST(name='',
  39. bl_idname='TransformSpaceSocket', is_input=False),
  40. ]
  41. InputStringSockets = [
  42. StringInput := ST(name='', bl_idname='StringSocket',
  43. is_input=False),
  44. ]
  45. InputMatrixSockets = [
  46. MatrixOutput
  47. ]
  48. MatrixFromCurveSockets=[
  49. MatrixFromCurveMode := ST(name="Mode", bl_idname="EnumMatrixFromCurveMode",
  50. is_input = True, ),
  51. CurveTemplate := ST(name="Curve", bl_idname='EnumCurveSocket',
  52. is_input=True,),
  53. SplineIndexTemplate,
  54. TotalDivisionsTemplate := ST(name="Total Divisions", category = "divisions",
  55. bl_idname='UnsignedIntSocket', is_input=True, default_value=0,),
  56. MatrixIndexTemplate := ST(name="Matrix Index", category = "divisions",
  57. bl_idname='UnsignedIntSocket', is_input=True, default_value=0,),
  58. replace(FactorTemplate, category="factor"),
  59. MatrixOutput,
  60. ]
  61. MatricesFromCurveSockets=[
  62. CurveTemplate,
  63. SplineIndexTemplate,
  64. TotalDivisionsTemplate,
  65. MatricesOutTemplate,
  66. ]
  67. MatrixFromCurveSegmentSockets=[
  68. CurveTemplate,
  69. SplineIndexTemplate,
  70. SegmentIndexTemplate := replace(SplineIndexTemplate, name="Segment Index"),
  71. MatrixOutput,
  72. ]
  73. PointFromCurveSockets=[
  74. CurveTemplate,
  75. SplineIndexTemplate,
  76. FactorTemplate,
  77. PointOutTemplate := ST(name="Point", bl_idname="VectorSocket",
  78. is_input=False, )
  79. ]
  80. NumberOfCurveSegmentsSockets = [
  81. CurveTemplate,
  82. SplineIndexTemplate,
  83. NumberOfSegments := ST(name='Number of Segments',
  84. bl_idname='UnsignedIntSocket', is_input=False),
  85. ]
  86. GetCurvePointSockets=[
  87. CurveTemplate,
  88. SplineIndexTemplate,
  89. IndexTemplate := ST(name="Index",
  90. bl_idname='UnsignedIntSocket', is_input=True, default_value=0,),
  91. OutputPointTemplate := ST(name="Point",
  92. bl_idname='VectorSocket', is_input=False,),
  93. OutputLeftHandleTemplate := ST(name="Left Handle",
  94. bl_idname='VectorSocket', is_input=False, hide=True),
  95. OutputRightHandleTemplate := ST(name="Right Handle",
  96. bl_idname='VectorSocket', is_input=False, hide=True),
  97. ]
  98. GetNearestFactorOnCurveSockets=[
  99. CurveTemplate,
  100. SplineIndexTemplate,
  101. ReferencePointTemplate := ST(name="Reference Point",
  102. bl_idname='VectorSocket', is_input=True,),
  103. OutputFactorTemplate := ST(name="Factor",
  104. bl_idname='FloatSocket', is_input=False,),
  105. ]
  106. KDChoosePointSockets = [
  107. ReferencePointTemplate,
  108. PointsArray := ST(name="Points", bl_idname="VectorSocket",
  109. use_multi_input=True, is_input=True),
  110. NumberToFind := ST(name='Number to Find',
  111. bl_idname = "UnsignedIntSocket", default_value=1, is_input=True),
  112. ResultPoint :=ST(name='Result Point', bl_idname="VectorSocket",
  113. is_input=False, ),
  114. ResultIndex :=ST(name='Result Index',
  115. bl_idname="UnsignedIntSocket", is_input=False, ),
  116. ResultDistance :=ST(name='Result Distance',
  117. bl_idname="FloatSocket", is_input=False, ),
  118. ]
  119. KDChooseXFormSockets = [
  120. ReferencePointTemplate,
  121. xFormsArray := ST(name="xForm Nodes", bl_idname="xFormSocket",
  122. use_multi_input=True, is_input=True,),
  123. GetPointHeadTail := ST(name="Get Point Head/Tail",
  124. bl_idname = "FloatFactorSocket", is_input=True,),
  125. NumberToFind,
  126. ResultxForm := ST(name='Result xForm', bl_idname='xFormSocket', is_input=False),
  127. ResultIndex,
  128. ResultDistance,
  129. ]
  130. MetaRigSockets = [
  131. MetaArmature := ST(name='Meta-Armature', bl_idname="EnumMetaRigSocket",
  132. is_input = True, ),
  133. MetaBone := ST(name='Meta-Bone', bl_idname="EnumMetaBoneSocket",
  134. is_input = True, hide=True ),
  135. MatrixOutput,
  136. ]
  137. BonePropertiesSockets = [
  138. replace( StringOutput, name='matrix'),
  139. replace( StringOutput, name='matrix_local'),
  140. replace( StringOutput, name='matrix_basis'),
  141. replace( StringOutput, name='head'),
  142. replace( StringOutput, name='tail'),
  143. replace( StringOutput, name='length'),
  144. replace( StringOutput, name='rotation'),
  145. replace( StringOutput, name='location'),
  146. replace( StringOutput, name='scale'),
  147. ]
  148. DriverVariableSockets = [
  149. VariableType := ST(name='Variable Type', bl_idname="EnumDriverVariableType", is_input=True),
  150. Property := ST(name='Property', bl_idname="ParameterStringSocket", is_input=True),
  151. PropertyIndex := ST(name='Property Index', bl_idname="IntSocket", is_input=True),
  152. EvaluationSpace := ST(name='Evaluation Space', bl_idname="EnumDriverVariableEvaluationSpace", is_input=True,
  153. hide = True,),
  154. RotationMode := ST(name='Rotation Mode', bl_idname="EnumDriverRotationMode", is_input=True),
  155. xForm1 := ST(name='xForm 1', bl_idname="xFormSocket", is_input=True),
  156. xForm2 := ST(name='xForm 2', bl_idname="xFormSocket", is_input=True),
  157. DriverVariable := ST(name='Driver Variable', bl_idname="DriverVariableSocket", is_input=False),
  158. ]
  159. FCurveSockets = [
  160. ExtrapolationMode := ST( name="Extrapolation Mode",
  161. bl_idname="eFCrvExtrapolationMode", is_input=True),
  162. Keyframes := ST(name='Keyframes', bl_idname="KeyframeSocket", is_input=True,
  163. use_multi_input=True,),
  164. fCurveOutput := ST(name="fCurve", bl_idname="FCurveSocket", is_input=False),
  165. ]
  166. DriverSockets = [
  167. DriverType := ST(name="Driver Type", bl_idname="EnumDriverType", is_input=True),
  168. FCurve := ST(name="fCurve", bl_idname="FCurveSocket", is_input=True),
  169. Expression := ST(name="Expression", bl_idname="StringSocket", is_input=True),
  170. DriverOutput := ST(name="Driver", bl_idname="DriverSocket", is_input=False),
  171. ]
  172. SwitchSockets = [
  173. Parameter := ST(name="Parameter", bl_idname="ParameterStringSocket", is_input=True),
  174. ParameterIndex := ST(name="Parameter Index", bl_idname="IntSocket", is_input=True),
  175. InvertSwitch := ST(name="Invert Switch", bl_idname="BooleanSocket", is_input=True),
  176. DriverOutput,
  177. ]
  178. CombineThreeBoolSockets = [
  179. AxisX := ST(name="X", bl_idname="BooleanSocket", is_input=True),
  180. AxisY := replace(AxisX, name='Y'),
  181. AxisZ := replace(AxisX, name='Z'),
  182. ThreeBoolOutput := ST(name="Three-Bool", bl_idname="BooleanThreeTupleSocket", is_input=False),
  183. ]
  184. CombineThreeBoolSockets = [
  185. AxisX := ST(name="X", bl_idname="BooleanSocket", is_input=True),
  186. AxisY := replace(AxisX, name='Y'),
  187. AxisZ := replace(AxisX, name='Z'),
  188. ThreeBoolOutput := ST(name="Three-Bool", bl_idname="BooleanThreeTupleSocket", is_input=False),
  189. ]
  190. CombineVectorSockets = [
  191. AxisX := replace(AxisX, bl_idname="FloatSocket", name='X'),
  192. AxisY := replace(AxisY, bl_idname="FloatSocket", name='Y'),
  193. AxisZ := replace(AxisZ, bl_idname="FloatSocket", name='Z'),
  194. VectorOutput := ST(name="Vector", bl_idname="VectorSocket", is_input=False),
  195. ]
  196. SeparateVectorSockets = [
  197. Vector := ST(name="Vector", bl_idname="VectorSocket", is_input=True),
  198. AxisXOutput := replace(AxisX, bl_idname="FloatSocket", is_input=False),
  199. AxisYOutput := replace(AxisXOutput, name='Y'),
  200. AxisZOutput := replace(AxisXOutput, name='Z'),
  201. ]
  202. CatStringsSockets = [
  203. String_1 := ST(name="String_1", bl_idname="StringSocket", is_input=True),
  204. String_2 := replace(String_1, name="String_2"),
  205. OutputString := ST(name="OutputString", bl_idname="StringSocket", is_input=False),
  206. ]
  207. InputWidgetSockets = [
  208. WidgetName := ST(name='Name', is_input=True,
  209. bl_idname="EnumWidgetLibrarySocket",),
  210. Scale := ST(name='Scale', is_input=True,
  211. bl_idname="VectorScaleSocket", default_value=(1.0, 1.0, 1.0)),
  212. FlipAxes := ST(name='Flip Axes', is_input=True,
  213. bl_idname="BooleanThreeTupleSocket",),
  214. xFormOutput := ST(name='Widget',
  215. bl_idname='xFormSocket', is_input=False),
  216. ]
  217. InputExistingGeometryObjectSockets = [
  218. Name := ST(name="Name", bl_idname="StringSocket", is_input=True),
  219. ObjectOutput := ST(name="Object", bl_idname="xFormSocket", is_input=False),
  220. ]
  221. InputExistingGeometrySockets = [
  222. Name,
  223. GeometryOutput := ST(name="Geometry", bl_idname="GeometrySocket", is_input=False),
  224. ]
  225. UtilityCustomPropertySockets = [
  226. Name := ST(name='Name', is_input=True,
  227. bl_idname="StringSocket", category='general'),
  228. CustomPropType := ST(name='Type', is_input=True,
  229. bl_idname="EnumCustomPropTypeSocket", category='general'),
  230. # Subtype - add this later
  231. # float properties
  232. DefaultFloatValue := ST(name='Default (Float)', is_input=True,
  233. bl_idname="FloatSocket", category='float'),
  234. Min := ST(name='Min (Float)', is_input=True,
  235. bl_idname="FloatSocket", category='float'),
  236. Max := ST(name='Max (Float)', is_input=True,
  237. bl_idname="FloatSocket", category='float'),
  238. SoftMin := ST(name='Soft Min (Float)', is_input=True,
  239. bl_idname="FloatSocket", category='float'),
  240. SoftMax := ST(name='Soft Max (Float)', is_input=True,
  241. bl_idname="FloatSocket", category='float'),
  242. # bool properties
  243. DefaultVectorValue := ST(name='Default (Bool)', is_input=True,
  244. bl_idname="BooleanSocket", hide=True, category='bool'),
  245. # int properties
  246. DefaultIntValue := ST(name='Default (Int)', is_input=True,
  247. bl_idname="IntSocket", hide=True, category='int'),
  248. IntMin := ST(name='Min (Int)', is_input=True,
  249. bl_idname="IntSocket", hide=True, category='int'),
  250. IntMax := ST(name='Max (Int)', is_input=True,
  251. bl_idname="IntSocket", hide=True, category='int'),
  252. IntSoftMin := ST(name='Soft Min (Int)', is_input=True,
  253. bl_idname="IntSocket", hide=True, category='int'),
  254. IntSoftMax := ST(name='Soft Max (Int)', is_input=True,
  255. bl_idname="IntSocket", hide=True, category='int'),
  256. # vector properties
  257. DefaultVectorValue := ST(name='Default (Vector)', is_input=True,
  258. bl_idname="VectorSocket", hide=True, category='vector'),
  259. # String Properties
  260. DefaultStringValue := ST(name='Default (String)', is_input=True,
  261. bl_idname="StringSocket", hide=True, category='string'),
  262. # general:
  263. Description := ST(name='Description', is_input=True,
  264. bl_idname="StringSocket", category='general'),
  265. PropertyDeclaration := ST(name='Custom Property',
  266. is_input=False, bl_idname="CustomPropSocket", category='general'),
  267. ]
  268. CollectionJoinSockets = [
  269. JoinCollections := ST(name='Collections', is_input=True,
  270. bl_idname="BoneCollectionSocket", display_shape='SQUARE_DOT',
  271. use_multi_input=True,),
  272. CollectionDeclarationOutput := ST(name='Collection',
  273. bl_idname="BoneCollectionSocket", is_input=False,)
  274. ]
  275. CollectionHierarchySockets = [
  276. ParentCollection := ST(name='Parent Collection', is_input=True,
  277. bl_idname="BoneCollectionSocket",),
  278. ChildCollection := ST(name='Child Collection', is_input=True,
  279. bl_idname="BoneCollectionSocket",),
  280. CollectionDeclarationOutput,
  281. ]
  282. GeometryOfXFormSockets = [
  283. xForm := ST(name="xForm", bl_idname="xFormSocket", is_input=True),
  284. GeometryOutput,
  285. ]
  286. NameOfXFormSockets = [
  287. xForm,
  288. replace(Name, is_input=False),
  289. ]
  290. GetBoneLengthSockets = [
  291. BoneMatrix := ST(name="Bone Matrix", bl_idname="MatrixSocket", is_input=True),
  292. BoneLength := ST(name="Bone Length", bl_idname="FloatSocket", is_input=False),
  293. ]
  294. PointFromBoneMatrixSockets = [
  295. replace(MatrixInput, name = "Bone Matrix",),
  296. HeadTail := ST(name="Head/Tail", bl_idname = "FloatFactorSocket", is_input=True) ,
  297. replace(VectorOutput, name="Point"),
  298. ]
  299. SetBoneLengthSockets = [
  300. replace(MatrixInput, name = "Bone Matrix"),
  301. Length := ST(name="Length", bl_idname = "FloatSocket", is_input=True) ,
  302. replace(MatrixOutput, name = "Bone Matrix"),
  303. ]
  304. # there will eventually be inputs for e.g. key type, key handles, etc.
  305. # right now I am gonna hardcode LINEAR keyframes so I don't have to deal with anything else
  306. # TODO TODO TODO
  307. KeyframeSockets = [
  308. # Interpolation := ST(name="Interpolation", bl_idname="EnumKeyframeInterpolationTypeSocket", is_input=True),
  309. # LeftHandleType := ST(name="Left Handle Type", bl_idname="EnumKeyframeBezierHandleType", is_input=True),
  310. # RightHandleType := ST(name="Right Handle Type", bl_idname="EnumKeyframeBezierHandleType", is_input=True),
  311. # LeftHandleDistance := ST(name="Left Handle Distance", bl_idname="FloatSocket", is_input=True),
  312. # LeftHandleValue := ST(name="Left Handle Value", bl_idname="FloatSocket", is_input=True),
  313. # RightHandleFrame := ST(name="Right Handle Frame", bl_idname="FloatSocket", is_input=True),
  314. # RightHandleValue := ST(name="Right Handle Value", bl_idname="FloatSocket", is_input=True),
  315. Frame := ST(name="Frame", bl_idname="FloatSocket", is_input=True),
  316. Value := ST(name="Value", bl_idname="FloatSocket", is_input=True),
  317. Keyframe := ST(name="Keyframe", bl_idname="KeyframeSocket", is_input=False),
  318. ]
  319. BoneMatrixHeadTailFlipSockets = [
  320. replace(MatrixInput, name = "Bone Matrix",),
  321. replace(MatrixOutput, name = "Bone Matrix"),
  322. ]
  323. MatrixTransformSockets = [
  324. Matrix1Template := ST( name="Matrix 1", is_input=True,
  325. bl_idname='MatrixSocket', ),
  326. Matrix2Template := replace(Matrix1Template, name = "Matrix 2"),
  327. replace(MatrixOutput, name = "Out Matrix"),
  328. ]
  329. MatrixInvertSockets=[
  330. Matrix1Template,
  331. MatrixOutput,
  332. ]
  333. MatrixComposeSockets=[
  334. XBasisVector := ST(
  335. name="X Basis Vector", is_input=True, bl_idname='VectorSocket',
  336. default_value = (1.0, 0.0, 0.0) ),
  337. YBasisVector := replace(XBasisVector, name="Y Basis Vector",
  338. default_value = (0.0, 1.0, 0.0) ),
  339. ZBasisVector := replace(XBasisVector, name="Z Basis Vector",
  340. default_value = (0.0, 0.0, 1.0) ),
  341. Translation := replace(XBasisVector, name="Translation"),
  342. MatrixOutput,
  343. ]
  344. MatrixAlignRollSockets = [
  345. MatrixInTemplate := replace(Matrix1Template, name="Matrix"),
  346. AlignVector := ST(name="Alignment Vector", is_input=True,
  347. bl_idname='VectorSocket', default_value=(0.0,-1.0,0.0)),
  348. MatrixOutput,
  349. ]
  350. MatrixSetLocationSockets = [
  351. MatrixInput,
  352. replace(VectorInput, name="Location"),
  353. MatrixOutput,
  354. ]
  355. MatrixGetLocationSockets = [
  356. MatrixInput,
  357. replace(VectorInput, is_input=False, name="Location"),
  358. ]
  359. TransformationMatrixSockets = [
  360. MatrixTransformOperation := ST(name="Operation",
  361. bl_idname="MatrixTransformOperation", is_input=True),
  362. Vector,
  363. AxisW := replace(AxisX, name="W"),
  364. MatrixOutput,
  365. ]
  366. SetBoneMatrixTailSockets = [
  367. MatrixInput,
  368. replace(VectorInput, name="Tail Location"),
  369. replace(MatrixOutput, name = "Result"),
  370. ]
  371. MatrixFromXFormSockets = [
  372. xForm,
  373. MatrixOutput,
  374. ]
  375. AxesFromMatrixSockets = [
  376. MatrixInput,
  377. replace(VectorOutput, name='X Axis',),
  378. replace(VectorOutput, name='Y Axis',),
  379. replace(VectorOutput, name='Z Axis',),
  380. ]
  381. IntToStringSockets = [
  382. Number := ST(name = 'Number', bl_idname = 'IntSocket',
  383. is_input = True),
  384. Number := ST(name = 'Zero Padding', bl_idname = 'IntSocket',
  385. is_input = True),
  386. StringOutput,
  387. ]
  388. ArrayGetSockets = [
  389. OoBBehaviour := ST(name="OoB Behaviour", bl_idname="EnumArrayGetOptions",
  390. is_input=True),
  391. Index := ST(name="Index", bl_idname="IntSocket", is_input=True),
  392. Array := ST(name="Array", bl_idname="WildcardSocket", is_input=True,
  393. use_multi_input=True, display_shape='SQUARE_DOT'),
  394. WildcardOutput := ST(name="Output", bl_idname="WildcardSocket", is_input=False),
  395. ]
  396. UtilityArrayLengthSockets = [
  397. Array,
  398. replace(NumberOfSegments, name="Length"),
  399. ]
  400. CompareSockets = [
  401. ComparisonOperation := ST( name='Comparison',
  402. is_input=True, bl_idname="EnumCompareOperation",
  403. default_value="EQUAL",),
  404. WildcardATemplate := ST(
  405. name="A", is_input=True, bl_idname='WildcardSocket', ),
  406. WildcardBTemplate := replace(WildcardATemplate, name="B"),
  407. CompareOutputTemplate := ST(
  408. name="Result", is_input=False, bl_idname="BooleanSocket",),
  409. ]
  410. ChooseSockets = [
  411. Condition := ST(name="Condition", bl_idname="BooleanSocket", is_input=True),
  412. ChooseA := ST(name="A", bl_idname="WildcardSocket", is_input=True),
  413. ChooseB := ST(name="B", bl_idname="WildcardSocket", is_input=True),
  414. replace(WildcardOutput, name='Result'),
  415. ]
  416. PrintSockets = [
  417. replace(ChooseA, name='Input'),
  418. ]
  419. NumberOfSplinesSockets=[
  420. CurveTemplate,
  421. NumberOfSplinesOut := ST(name="Number of Splines",
  422. bl_idname='UnsignedIntSocket', is_input=False),
  423. ]