Cross.hx 644 B

12345678910111213141516171819202122232425262728
  1. package hrt.shgraph.nodes;
  2. using hxsl.Ast;
  3. @name("Cross")
  4. @description("The output is the cross product of a and b")
  5. @width(80)
  6. @group("Math")
  7. class Cross extends ShaderFunction {
  8. @input("A") var a = SType.Number;
  9. @input("B") var b = SType.Number;
  10. public function new() {
  11. super(Cross);
  12. }
  13. override public function computeOutputs() {
  14. if (a != null && !a.isEmpty() && b != null && !b.isEmpty())
  15. addOutput("output", a.getVar(b.getType()).t);
  16. else if (a != null && !a.isEmpty() )
  17. addOutput("output", a.getType());
  18. else if (b != null && !b.isEmpty())
  19. addOutput("output", b.getType());
  20. else
  21. removeOutput("output");
  22. }
  23. }