Managing Multiples Made Easy


    One of the most powerful objects in the jitter library is jit.gl.multiple. It allows you to quickly create and manage arrays of OpenGL objects by manipulating matrix data to control the GL parameters, with results that would be incredibly tedious and difficult if done by hand. For the expert in jit.expr, it seems like anything is possible, but for beginning users the barrier to entry can feel really high. Over the years I’ve seen a lot of people get hung up trying to get started with it and wanted to provide an example of how easy it can be to use.
    In this patch we leverage the matrixoutput attribute of jit.gl.gridshape to generate interesting and organized position data to feed our jit.gl.multiple. In this case, we use ‘@matrixoutput 2’, which not only gives us access to the basic shapes that jit.gl.gridshape provides in the desired float32 type, but also includes transforms (scaling, rotation, positioning) performed on the object in the output matrix data. This makes it easy to manipulate the entire group all at once.
    Furthermore, now that the geometry is a standard matrix, we can use any number of jitter objects to tweak it. A jit.xfade allows us to combine the outputs of two separate jit.gl.gridshape objects, opening up a world of possibilities.
    For the rotation data, we use jit.expr to create a normalized range of values across each axis of rotation, then multiply that by a custom value in degrees. If we set the value to 360, we will see the forms make one full rotation over the length of the array, regardless of how many we are drawing. Adjusting the offset determines the initial angle of rotation.
    The scale is being set globally using the setall message to a jit.matrix, but could also be controlled by any matrix data we choose.
    Download the patch and give it a try!
    For those looking to take this further, make sure to check out Andrew Benson’s article Demystifying Expressions in Jitter as well as the many posts in the forums.

    • Sep 21 2016 | 7:43 pm
      Great! LFO driven gold colored writhing objects in no time.
    • Sep 22 2016 | 8:57 am
      Fantastic patch. I've not been using openGL for long and I didn't even know this object existed let alone how to use it. Hope you will keep these tutorials coming!
    • Sep 23 2016 | 2:31 pm
      the xfade is a cool method to be used with gl.multiple.
      i'm a little confused why you would use jit.expr, figured you'd want to display the virtues of gen. I guess for simple rotations that are applied to all instances, using jit.expr is a little easier to see what's going on since it's all written directly in the object box.
    • Sep 26 2016 | 11:42 am
      @matrixoutput 2 - why did i not know about this?! Great tutorial, that one revelation alone is invaluable.
    • Oct 11 2016 | 1:40 pm
      Beautiful :D Thank you!
    • Jun 21 2017 | 6:55 pm
      Thank you for sharing !
      I want to know if it's possible to implement this with other object (use jit.gl.text in 3d mode instead of "gridshape" to generate the shape ?)... Here's the patch I'm working on...
      Thank's for your help !