Forums > Jitter

Creating dynamic instances of shapes using jit.gl.sketch

May 8, 2013 | 6:54 am

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.


May 8, 2013 | 11:03 am

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.


May 9, 2013 | 11:34 am

@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 procedural coding of java, LUA, or javascript.
* 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


May 14, 2013 | 6:27 pm

In my opinion, the easiest to use of the objects mentioned is jit.gl.gridshape.

Here’s a simple example:

 

<pre><code>

– Pasted Max Patch, click to expand. –

</code></pre>

 

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.


Viewing 4 posts - 1 through 4 (of 4 total)