misc_nodes_socket_templates.py 17 KB

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