n planes matrices as input of jit.gen / how to retrieve planes ..?

    Jun 15 2012 | 9:22 pm
    if I sent an n planes matrix to a jit.gen, what is the rule to retrieve a particular plane ??
    I'm currently sending an 1x1 matrix with 4 planes to the first inlet of my jit.gen I'm mapping the in 1 to a codebox, on the first inlet too so in1.x, .y, .z are the first 3 planes
    how can I have the fourth and more generally, the n-th for an m planes matrix ?

    • Jun 15 2012 | 10:29 pm
      if i am right the swiz message works like unpack. for example swiz r - red plane, or for geometry swiz 0 for x :) have you checked out gen tutorials? they are great! https://cycling74.com/tutorials/gen-tutorial-1-the-garden-of-earthly-delays/
    • Jun 15 2012 | 10:39 pm
      I checked those. probably not enough.
      so swiz n would "unpack" the plane n ..? mmmh testing.
    • Jun 15 2012 | 10:50 pm
      it works (of course it does, I didn't think ever you pointed me on a wrong way :)
      I thought about a solution inside a codebox/genexpr, but this is totally ok to split things before then to wire the codebox.
      MAXi thanks, napentro :)
    • Jun 16 2012 | 9:02 am
      in1.0, in1.1, etc doesn't work?
    • Jun 16 2012 | 9:08 am
      it doesn't in1.x, in1.y, in1.z ... works very fine but grabbing the 4th planes (and the other) ... I don't know.
      swiz works correctly. but if you wanted to do all in codebox .. I couldn't help :-/
    • Jun 16 2012 | 9:14 am
      4th plane you should get with in1.w .x .y .z or .r .g .b .a (doesn't matter if it's not colors in your matrix). 4+ planes i don't know...
    • Jun 16 2012 | 9:22 am
      oh .. so 6 would be u, v, w, y ,x,z ? I'll test that asap :p
      but you know, swiz is the way I guess easy numbering 0, 1 ,2 with swiz 0, swiz 1 for the 2 first planes etc
      (still in the view frustum culling stuff here :)
    • Feb 27 2013 | 11:44 pm
      A bit different question, but I'm trying to swiz a 12 plane matrix, but
      "swiz 10 11" will be translated as "swiz_3 = swiz(in1, vec(1, 0, 1, 1));"
      so seems swiz can handle only 0-9 planes?
      is there a workaround for this?
      thanx in adv, Kevin
      ps: i can do it if i write in a codebox "out1 = swiz(in1, vec(3,4,5,6,7,8,9,10, 11));" but i'm not sure it's the best solution...
    • Sep 22 2016 | 4:30 pm
      The syntax for codebox is: out=swiz(in1,n);
    • Sep 23 2016 | 1:24 am
      The first four elements of a vector can be addressed with r, g, b, a or x, y, z, w, respectively. ex: var.b or var.yyz.
      The swiz operator takes two args and can address any vector element using the above variables, a number or a vector. ex. swiz(var, z) is the same as var.z... or swiz(var, 8) is the 9th element of the var vector. ex: swiz(var, vec(3, 2, 1, 0)) is equivalent to var.wzyx.
      You can use swiz in place of letter variables but you must use swiz for any element beyond the fourth.
      What you can not do is include more than two arguments for swiz. ex: swiz(var, 8,7,6,5) is NOT valid. Use swiz(var, vec(8,7,6,5)).
      For something more flexible, you can create a param to map planes and a function to swiz the planemapping vector.
      In [codebox], it might look something like:
      mapthis (x, n) {
      return vec( swiz(x, swiz(n, 0)), swiz(x, swiz(n, 1)), swiz(x, swiz(n,2)), swiz(x, swiz(n,3)), 
      		    swiz(x, swiz(n, 4)), swiz(x, swiz(n, 5)), swiz(x, swiz(n,6)), swiz(x, swiz(n,7)), 
      		    swiz(x, swiz(n, 8)), swiz(x, swiz(n, 9)), swiz(x, swiz(n,10)), swiz(x, swiz(n,11)) );
      Param mplane(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
      out = mapthis(in1, plane);
      Note that it's NOT possible, given the above example, to simply use:
      out = swiz(in1, mplane);
      Not sure why that is. [jit.gen] seems to be interpreting the param variables as single elements not a vector (resulting in more than one arg for swiz?) , which is odd because [jit.pix] (which limits vectors to 4 elements) limits the number of param elements that can be used as if multi-value params were equivalent to vectors. If anyone knows of a simpler way to reproduce the behavior of the planemap operator in an genexpr function, please share.
      Last thing.. as mentioned, pix objects handle plane mapping differently than [jit.gen]. Specifically, vector length limits and the way that alpha is mapped. Be sure to look it up.
    • Sep 23 2016 | 1:36 am
      To clarify, the [swiz] patcher object can take more than one variable. Only the [codebox] version seems to require multi-element references to be packed into a single vector.