## driving a ledcube with jitter

Oct 15, 2010 at 2:35pm

# driving a ledcube with jitter

Hi guys i’m in desperate searching of helpâ€¦
I need to control a ledcube made of 512 monocolor leds (8*8*8), driven via max and arduino.
To draw things in/on the cube i need to send a list of 512 values each one representing the alpha value of one specific led.

Nowâ€¦the idea is to use this cube like a really low resolution 3D screen, drawing a gl scene with Jitter, and here i’m stuckâ€¦since i don’t know a way to extract the alpha value of each “3D pixel” of the scene.
For “3D pixel” i’m intending each pixel of the first 2D plane, then each pixel of the 2D plane behind the first..and so onâ€¦

Is this a good way to approach the problem? any other ideas? wanna help?
Thanks a billion!!!!
Luigi.

#52772
Oct 15, 2010 at 4:13pm

I’m not sure if I understand your metaphors correctly but if I do…

The number of pixels on such a cube would be 384 (8x8x6), not 512 (8x8x8).

You say “drawing a gl scene with Jitter”; I assume you just meant that metaphorically, so that the physical cube would resemble a GL scene with, for example, 384 spherical objects located in the way you described. If that’s the case–if GL space is just a metaphor for you–then you don’t really need the GL aspect of Jitter.

You say “extract the alpha value of each ’3D pixel’”; but it’s just a brightness value you need, right? There’s nothing about such a value that inherently has to be related to the “alpha” channel as that term is used in Jitter (video, GL, etc.). They’re just numbers.

You could store and manipulate the brightness values in a 3D 8x8x6 Jitter matrix, or in a 2D 8×8 matrix with 6 planes, and then send those values to your Arduino.

#189698
Oct 15, 2010 at 4:36pm

actually i need to draw a scene not only on the surfaces of the cube, but inside too! :)
something like in this video found on YT:

I know that openGL is not strictly necessary to drive the leds, but i thought that using that the process of making animations would become more manageable….
i’m quite a newbie to jitter so i don’t know how to draw 3d shapes for example in a 2planes&3dimensions matrix without using open gl (well actually even with it :) ).

Tell me if what i ask is still obscure:) i’m not so good @explaining!

thanks again!

#189699
Oct 15, 2010 at 10:49pm

Hi,
From what you are saying it sounds like you want to visualize 3D light animations. An easy way to do this would be to use jit.gl.multiple. Check it out:

– Pasted Max Patch, click to expand. –
#189700
Oct 18, 2010 at 2:30pm

Thanks a lot Andrew, this is a great visualization tool…but atm i need something different:
imagine that you have a 3d scene drawn with jit.gl.render…
i need to replicate that scene in physical cube made by 512 leds (like the one shown in YouTube video above).

To drive those leds i need to send out from max a list of 512 values…representing the luminosity of each led (form 0 to 255).
e.g.: 255 0 0 0 [ ... ] 0 means that only one led is on at full power, while the others are off.

I think a way of doing this could be cutting eight 2d slices (one behind the other in depth) form a gl scene, downsample their resoultion to 8×8, and spill the alpha of each pixel.

Is this possible? i’m really sorry for my bad english, i can’t explain myself in a clear way :)

PS: there is another post in this forum about making 2d slices from 3d scenes… they mention jit.gl.volume and jit.gl.isosurf….unfortunately i don’t understand how to use them….any hint?

Thanks again!!

#189701
Oct 18, 2010 at 7:10pm

So, what you are looking for isn’t a way to visualize the LEDs but to unravel the 3D matrix into a 2D one so that it can be sent out to the controller? I would encourage you to look at jit.spill, jit.scanwrap, jit.iter, and jit.submatrix and see if any of those do what you want. If you have trouble, post a patch.

#189702
Oct 18, 2010 at 11:26pm

exactly..i need to unravel the 3d matrix (8 8 8)
actually i know that i can use spill (etc..) to have the data i need, but from an open GL render i don’t know a way to obtain a 3d matrix reproducing the scene….just a 2d one! (i need to preserve the informations about depth)

thanks a lot andrew for your patience…as i said i’m really a jitter n00b^^ trying to improve:)

#189703
Oct 19, 2010 at 12:09am

I’d love to help, but I really am having a hard time understanding exactly what you are trying to accomplish.

#189704
Oct 19, 2010 at 12:34am

I think what the OP is looking for is a way of converting a 3D OpenGL space into a 3D matrix of RGB values, which will then be processed and sent to the LED cube.

#189705
Oct 19, 2010 at 7:34am

exactly….3d opengl to 3d argb matrix.
then i’ll spill @plane 0 to have a list that i can send to arduino.

#189706
Oct 19, 2010 at 6:48pm

From what I can make of the question, I think that the data structure that you are using to drive your OpenGL animation, whether it is via jit.gl.multiple or otherwise, is going to contain the information that you need to drive the LED’s. There’s no need to read back from the GL, and there’s really no easy way to do so in the way that you’re thinking anyway. There is no abstract concept of “layers” in OpenGL, and to do what you want would take quite a bit of complex math to find intersections of shapes in arbitrary dimensions.

Andrew’s patch is worth looking at very closely. The key is to look at the values coming out of jit.noise in that patch. It has the values that are driving the color (including alpha) of each sphere (LED). This is the data you can use directly to drive your real-life LED’s.

You don’t need to use jit.noise to produce your animation, but if you can understand what it’s doing in this patch you’ll be well on your way.

Of course, if you want to create arbitrary OpenGL scenes and simply “down-res” these to a 8x8x8 LED matrix – the short answer is, there’s no easy way to do this.

#189707
Oct 19, 2010 at 8:50pm

Well, I don’t have time to make an example, but if one really wished to make “slices” of a 3D scene, one could render the scene multiple times (once for each slice), incrementally changing the near and far clipping plane, and reading back the slice with jit.gl.asyncread or another readback mechanism.

I have no idea how well the results would match what you’re expecting to accomplish. I assume you’d want to do some threshold detection or averaging in sub regions, rather than simple downsampling on each of your 2d slices.

You might want to explore other ways to accomplish your animation by using objects like jit.bfg, jit.expr, direct cell access in JS or Java, or some other method of accessing your 512 point cube.

Have fun!

#189708
Oct 19, 2010 at 9:53pm

great guys…i’ll check your suggestions carefully!
i’ll let you know if i succeed:)
thanks again!

#189709

You must be logged in to reply to this topic.