misc_nodes_socket_templates.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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. fCurveOutput := ST(name="fCurve", bl_idname="FCurveSocket", is_input=False),
  157. ]
  158. DriverSockets = [
  159. DriverType := ST(name="Driver Type", bl_idname="EnumDriverType", is_input=True),
  160. FCurve := ST(name="fCurve", bl_idname="FCurveSocket", is_input=True),
  161. Expression := ST(name="Expression", bl_idname="StringSocket", is_input=True),
  162. DriverOutput := ST(name="Driver", bl_idname="DriverSocket", is_input=False),
  163. ]
  164. SwitchSockets = [
  165. Parameter := ST(name="Parameter", bl_idname="ParameterStringSocket", is_input=True),
  166. ParameterIndex := ST(name="Parameter Index", bl_idname="IntSocket", is_input=True),
  167. InvertSwitch := ST(name="Invert Switch", bl_idname="BooleanSocket", is_input=True),
  168. DriverOutput,
  169. ]
  170. CombineThreeBoolSockets = [
  171. AxisX := ST(name="X", bl_idname="BooleanSocket", is_input=True),
  172. AxisY := replace(AxisX, name='Y'),
  173. AxisZ := replace(AxisX, name='Z'),
  174. ThreeBoolOutput := ST(name="Three-Bool", bl_idname="BooleanThreeTupleSocket", is_input=False),
  175. ]
  176. CombineThreeBoolSockets = [
  177. AxisX := ST(name="X", bl_idname="BooleanSocket", is_input=True),
  178. AxisY := replace(AxisX, name='Y'),
  179. AxisZ := replace(AxisX, name='Z'),
  180. ThreeBoolOutput := ST(name="Three-Bool", bl_idname="BooleanThreeTupleSocket", is_input=False),
  181. ]
  182. CombineVectorSockets = [
  183. AxisX := replace(AxisX, bl_idname="FloatSocket", name='X'),
  184. AxisY := replace(AxisY, bl_idname="FloatSocket", name='Y'),
  185. AxisZ := replace(AxisZ, bl_idname="FloatSocket", name='Z'),
  186. VectorOutput := ST(name="Vector", bl_idname="VectorSocket", is_input=False),
  187. ]
  188. SeparateVectorSockets = [
  189. Vector := ST(name="Vector", bl_idname="VectorSocket", is_input=True),
  190. AxisXOutput := replace(AxisX, bl_idname="FloatSocket", is_input=False),
  191. AxisYOutput := replace(AxisXOutput, name='Y'),
  192. AxisZOutput := replace(AxisXOutput, name='Z'),
  193. ]
  194. CatStringsSockets = [
  195. String_1 := ST(name="String_1", bl_idname="StringSocket", is_input=True),
  196. String_2 := replace(String_1, name="String_2"),
  197. OutputString := ST(name="OutputString", bl_idname="StringSocket", is_input=False),
  198. ]
  199. InputWidgetSockets = [
  200. WidgetName := ST(name='Name', is_input=True,
  201. bl_idname="EnumWidgetLibrarySocket",),
  202. Scale := ST(name='Scale', is_input=True,
  203. bl_idname="VectorScaleSocket", default_value=(1.0, 1.0, 1.0)),
  204. FlipAxes := ST(name='Flip Axes', is_input=True,
  205. bl_idname="BooleanThreeTupleSocket",),
  206. xFormOutput := ST(name='Widget',
  207. bl_idname='xFormSocket', is_input=False),
  208. ]
  209. InputExistingGeometryObjectSockets = [
  210. Name := ST(name="Name", bl_idname="StringSocket", is_input=True),
  211. ObjectOutput := ST(name="Object", bl_idname="xFormSocket", is_input=False),
  212. ]
  213. InputExistingGeometrySockets = [
  214. Name,
  215. GeometryOutput := ST(name="Geometry", bl_idname="GeometrySocket", is_input=False),
  216. ]
  217. UtilityCustomPropertySockets = [
  218. Name := ST(name='Name', is_input=True,
  219. bl_idname="StringSocket", category='general'),
  220. CustomPropType := ST(name='Type', is_input=True,
  221. bl_idname="EnumCustomPropTypeSocket", category='general'),
  222. # Subtype - add this later
  223. # float properties
  224. DefaultFloatValue := ST(name='Default (Float)', is_input=True,
  225. bl_idname="FloatSocket", category='float'),
  226. Min := ST(name='Min (Float)', is_input=True,
  227. bl_idname="FloatSocket", category='float'),
  228. Max := ST(name='Max (Float)', is_input=True,
  229. bl_idname="FloatSocket", category='float'),
  230. SoftMin := ST(name='Soft Min (Float)', is_input=True,
  231. bl_idname="FloatSocket", category='float'),
  232. SoftMax := ST(name='Soft Max (Float)', is_input=True,
  233. bl_idname="FloatSocket", category='float'),
  234. # bool properties
  235. DefaultVectorValue := ST(name='Default (Bool)', is_input=True,
  236. bl_idname="BooleanSocket", hide=True, category='bool'),
  237. # int properties
  238. DefaultIntValue := ST(name='Default (Int)', is_input=True,
  239. bl_idname="IntSocket", hide=True, category='int'),
  240. IntMin := ST(name='Min (Int)', is_input=True,
  241. bl_idname="IntSocket", hide=True, category='int'),
  242. IntMax := ST(name='Max (Int)', is_input=True,
  243. bl_idname="IntSocket", hide=True, category='int'),
  244. IntSoftMin := ST(name='Soft Min (Int)', is_input=True,
  245. bl_idname="IntSocket", hide=True, category='int'),
  246. IntSoftMax := ST(name='Soft Max (Int)', is_input=True,
  247. bl_idname="IntSocket", hide=True, category='int'),
  248. # vector properties
  249. DefaultVectorValue := ST(name='Default (Vector)', is_input=True,
  250. bl_idname="VectorSocket", hide=True, category='vector'),
  251. # String Properties
  252. DefaultStringValue := ST(name='Default (String)', is_input=True,
  253. bl_idname="StringSocket", hide=True, category='string'),
  254. # general:
  255. Description := ST(name='Description', is_input=True,
  256. bl_idname="StringSocket", category='general'),
  257. PropertyDeclaration := ST(name='Custom Property',
  258. is_input=False, bl_idname="CustomPropSocket", category='general'),
  259. ]
  260. CollectionJoinSockets = [
  261. JoinCollections := ST(name='Collections', is_input=True,
  262. bl_idname="BoneCollectionSocket", display_shape='SQUARE_DOT',
  263. use_multi_input=True,),
  264. CollectionDeclarationOutput := ST(name='Collection',
  265. bl_idname="BoneCollectionSocket", is_input=False,)
  266. ]
  267. CollectionHierarchySockets = [
  268. ParentCollection := ST(name='Parent Collection', is_input=True,
  269. bl_idname="BoneCollectionSocket",),
  270. ChildCollection := ST(name='Child Collection', is_input=True,
  271. bl_idname="BoneCollectionSocket",),
  272. CollectionDeclarationOutput,
  273. ]
  274. GeometryOfXFormSockets = [
  275. xForm := ST(name="xForm", bl_idname="xFormSocket", is_input=True),
  276. GeometryOutput,
  277. ]
  278. NameOfXFormSockets = [
  279. xForm,
  280. replace(Name, is_input=False),
  281. ]
  282. GetBoneLengthSockets = [
  283. BoneMatrix := ST(name="Bone Matrix", bl_idname="MatrixSocket", is_input=True),
  284. BoneLength := ST(name="Bone Length", bl_idname="FloatSocket", is_input=False),
  285. ]
  286. PointFromBoneMatrixSockets = [
  287. replace(MatrixInput, name = "Bone Matrix",),
  288. HeadTail := ST(name="Head/Tail", bl_idname = "FloatFactorSocket", is_input=True) ,
  289. replace(VectorOutput, name="Point"),
  290. ]
  291. SetBoneLengthSockets = [
  292. replace(MatrixInput, name = "Bone Matrix"),
  293. Length := ST(name="Length", bl_idname = "FloatSocket", is_input=True) ,
  294. replace(MatrixOutput, name = "Bone Matrix"),
  295. ]
  296. # there will eventually be inputs for e.g. key type, key handles, etc.
  297. # right now I am gonna hardcode LINEAR keyframes so I don't have to deal with anything else
  298. # TODO TODO TODO
  299. KeyframeSockets = [
  300. # Interpolation := ST(name="Interpolation", bl_idname="EnumKeyframeInterpolationTypeSocket", is_input=True),
  301. # LeftHandleType := ST(name="Left Handle Type", bl_idname="EnumKeyframeBezierHandleType", is_input=True),
  302. # RightHandleType := ST(name="Right Handle Type", bl_idname="EnumKeyframeBezierHandleType", is_input=True),
  303. # LeftHandleDistance := ST(name="Left Handle Distance", bl_idname="FloatSocket", is_input=True),
  304. # LeftHandleValue := ST(name="Left Handle Value", bl_idname="FloatSocket", is_input=True),
  305. # RightHandleFrame := ST(name="Right Handle Frame", bl_idname="FloatSocket", is_input=True),
  306. # RightHandleValue := ST(name="Right Handle Value", bl_idname="FloatSocket", is_input=True),
  307. Frame := ST(name="Frame", bl_idname="FloatSocket", is_input=True),
  308. Value := ST(name="Value", bl_idname="FloatSocket", is_input=True),
  309. Keyframe := ST(name="Keyframe", bl_idname="KeyframeSocket", is_input=False),
  310. ]
  311. BoneMatrixHeadTailFlipSockets = [
  312. replace(MatrixInput, name = "Bone Matrix",),
  313. replace(MatrixOutput, name = "Bone Matrix"),
  314. ]
  315. MatrixTransformSockets = [
  316. Matrix1Template := ST( name="Matrix 1", is_input=True,
  317. bl_idname='MatrixSocket', ),
  318. Matrix2Template := replace(Matrix1Template, name = "Matrix 2"),
  319. replace(MatrixOutput, name = "Out Matrix"),
  320. ]
  321. MatrixInvertSockets=[
  322. Matrix1Template,
  323. MatrixOutput,
  324. ]
  325. MatrixComposeSockets=[
  326. XBasisVector := ST(
  327. name="X Basis Vector", is_input=True, bl_idname='VectorSocket',
  328. default_value = (1.0, 0.0, 0.0) ),
  329. YBasisVector := replace(XBasisVector, name="Y Basis Vector",
  330. default_value = (0.0, 1.0, 0.0) ),
  331. ZBasisVector := replace(XBasisVector, name="Z Basis Vector",
  332. default_value = (0.0, 0.0, 1.0) ),
  333. Translation := replace(XBasisVector, name="Translation"),
  334. MatrixOutput,
  335. ]
  336. MatrixAlignRollSockets = [
  337. MatrixInTemplate := replace(Matrix1Template, name="Matrix"),
  338. AlignVector := ST(name="Alignment Vector", is_input=True,
  339. bl_idname='VectorSocket', default_value=(0.0,-1.0,0.0)),
  340. MatrixOutput,
  341. ]
  342. MatrixSetLocationSockets = [
  343. MatrixInput,
  344. replace(VectorInput, name="Location"),
  345. MatrixOutput,
  346. ]
  347. MatrixGetLocationSockets = [
  348. MatrixInput,
  349. replace(VectorInput, is_input=False, name="Location"),
  350. ]
  351. TransformationMatrixSockets = [
  352. MatrixTransformOperation := ST(name="Operation",
  353. bl_idname="MatrixTransformOperation", is_input=True),
  354. Vector,
  355. AxisW := replace(AxisX, name="W"),
  356. MatrixOutput,
  357. ]
  358. SetBoneMatrixTailSockets = [
  359. MatrixInput,
  360. replace(VectorInput, name="Tail Location"),
  361. replace(MatrixOutput, name = "Result"),
  362. ]
  363. MatrixFromXFormSockets = [
  364. xForm,
  365. MatrixOutput,
  366. ]
  367. AxesFromMatrixSockets = [
  368. MatrixInput,
  369. replace(VectorOutput, name='X Axis',),
  370. replace(VectorOutput, name='Y Axis',),
  371. replace(VectorOutput, name='Z Axis',),
  372. ]
  373. IntToStringSockets = [
  374. Number := ST(name = 'Number', bl_idname = 'IntSocket',
  375. is_input = True),
  376. Number := ST(name = 'Zero Padding', bl_idname = 'IntSocket',
  377. is_input = True),
  378. StringOutput,
  379. ]
  380. ArrayGetSockets = [
  381. OoBBehaviour := ST(name="OoB Behaviour", bl_idname="EnumArrayGetOptions",
  382. is_input=True),
  383. Index := ST(name="Index", bl_idname="IntSocket", is_input=True),
  384. Array := ST(name="Array", bl_idname="WildcardSocket", is_input=True,
  385. use_multi_input=True, display_shape='SQUARE_DOT'),
  386. WildcardOutput := ST(name="Output", bl_idname="WildcardSocket", is_input=False),
  387. ]
  388. UtilityArrayLengthSockets = [
  389. Array,
  390. replace(NumberOfSegments, name="Length"),
  391. ]
  392. CompareSockets = [
  393. ComparisonOperation := ST( name='Comparison',
  394. is_input=True, bl_idname="EnumCompareOperation",
  395. default_value="EQUAL",),
  396. WildcardATemplate := ST(
  397. name="A", is_input=True, bl_idname='WildcardSocket', ),
  398. WildcardBTemplate := replace(WildcardATemplate, name="B"),
  399. CompareOutputTemplate := ST(
  400. name="Result", is_input=False, bl_idname="BooleanSocket",),
  401. ]
  402. ChooseSockets = [
  403. Condition := ST(name="Condition", bl_idname="BooleanSocket", is_input=True),
  404. ChooseA := ST(name="A", bl_idname="WildcardSocket", is_input=True),
  405. ChooseB := ST(name="B", bl_idname="WildcardSocket", is_input=True),
  406. replace(WildcardOutput, name='Result'),
  407. ]
  408. PrintSockets = [
  409. replace(ChooseA, name='Input'),
  410. ]
  411. NumberOfSplinesSockets=[
  412. CurveTemplate,
  413. NumberOfSplinesOut := ST(name="Number of Splines",
  414. bl_idname='UnsignedIntSocket', is_input=False),
  415. ]