Creating dynamic instances of shapes using jit.gl.sketch
I’m curious how one would go about creating dynamic instances of a shape in MaxMSP using either jit.gl.sketch, jit.gl.gridshape, or another object that might work. In other words, I want to create spheres using bangs with dynamic starting positions and movement based on input data (simulated or otherwise) using only one (or a couple) object(s).
In a scripting language I would do this by creating a class called MyShape and define the shape and variables that would control its position and movement. Then I would initialize the class and create one or more instances every time my trigger event happened using a for loop to give each instance a unique name: MyShape1, MyShape2, etc. After that my input data would govern the movement of the instances via variable set up in the class.
How would one do this in Max and with what objects? I’m guessing jit.gl.sketch would be best but I’m not sure. Could it be done with jit.gl.gridshape, or jit.gl.multiple? In this case I would most likely control the movement of the spheres via jit.anim.drive.
my understanding of jit.gl.multiple is rather shallow, the way to control it via matrices seems rather cumbersome for your task.
But you could use a Java external that does exactly this. You can create a jit.gl.sketch (or jit.gl.gridshape or even jit.gl.model) wrapper class and instantiate it with your bang. obviously you need to sort out how to manage and animate those instances. it should be even possible to add a jit.anim.drive to each wrapper (linked to the jit.gl.sketch or jit.gl.gridshape or jit.gl.model), this way you can control the appearance and its animation with one instance…
it all depends on what you wanna achieve. certain things are easier done with scripting languages.
@cclavio, there are many many ways to approach this. I’ll list a few below (there are many more). Which you use, will greatly depends on what you like coding, prior knowledge vs. wanting to learn more, style of patching/coding, etc…
* Do it all in patching using jit.gl.sketch
* Do it all in patching using matricies, jit.gl.multiple, jit.gl.gridshape/model/iso/etc.
* Partial combinations of the above
I suggest you look at the Jitter Recipes. There is good code there that you can use for your own. Some to look at include: 00, 06, 09, 19
In my opinion, the easiest to use of the objects mentioned is jit.gl.gridshape.
Here’s a simple example:
----------begin_max5_patcher---------- 844.3oc2Xs0SaCCF841eEVQ71Jc1N2Z1aHQQiGVKB3sIDxswTLKwtKwH5Fh+ 6KwIEJiTlaRlaDRUtJewI4bN96l8i86YMSrhlZA9B36fd8dreudJS4F5UdcO qXxp4QjT0zrlKhiobo0fh6IoqjJ6Sm.ldxIqMyuOVbuLhJUODrzJKTMUwr6N D6udp2H3RNIlpt0QILRz56rjHmeKiu35D5bYAFQ1ngvA.+7AW67QzngPvUa7 tRY+V8tPvgvWPCiuFLnbaO0ue9vfFR5yGO43wmqOosqEowdJhhU70CZLVyoO jg52P56XxgOv3ghG.2HDUSdbo0BSxesjVPEqYD9BqA.KqmQ+l5CrdNEA4RBN P8mOxX5iTrXQDsZA.sMAfk4FUE2QAuGCQJOdrZzez5wmeO+uVpioxDAvEB2Q RpVkqjk0Kr2F6nVUQXUfuWsVhwsmt7yBgA2d5hW877UtBHOT2PVjfY.ZBIkV yjBEOak5iaSzm.UbiSPWHy4hngITdHMosSdhbZfDgKbg7822RzRx7e.fCK9s iQWUKK0rlqqRJrKp854VKcwt8zkOm8Qf6rhbSjfrkxM0qTqCDWTHRkO1Asuy 3bXFh14pSasDLpQZRQaH1A6aMIgj0aVbqJL3lHLHOkyh2dWXZ6XnZ1KiMrHD B2UBgPsmmxnFIIE0h5LQP31SWBZht7gM.xqIkl+XF.41HI4ia.jSSzEyG.ES SSIKnus8VQJSxDbvAHvAXvA1sQKtMqC2QpbLiJEp8mOS4liVjvBSukrjVi8G k8JtNlHSXq19tjZhV4Xq7iBvFaWRKIbZj9muH5cOCIEpcvabXhnfV8Tj11wj d73KGe92NcxXvEe8nyFC9D3roWb5kmNch9TqlI.7U7Ln7PSC5pKbtuGGvE69 DU12nhQ1tZsxolgUDi+2Gxu56ja+0bHUbex70gSqOVRvKenPZpjwI4ov1bR9 uZR2xBCo7MoZLKboHK0dIH.WUoh1tXxyrXxWGLg6dXJn6AIGyBIOcV4bMKlx +bn+ElbLOlfcLLYqAlrMJjzxaxrPxWWHgL2BGTWLgMGlv5fIjYcvQ5fInQwj NUeGYTDMRCDY1VTzIWoYaPwQCDY1hb5j6tIQaYW7T++.HF88MA -----------end_max5_patcher-----------
The section labeled "DETERMINE SHAPE + POSITION" could then be encapsulated (see Basic Max Tutorial ‘Encapsulation’), and duplicated to create instances that could be triggered (see counter + select combination). You could potentially keep the encapsulated object in [poly~] as well for cleanliness of the patch.
Forums > Jitter