misc_nodes_socket_templates.py 18 KB

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