Forums > Java

Is functionality within Java possible?

May 11, 2012 | 1:47 am

Hi list,

I want to make a java wrapper for the object to make some slab thingies easier to do.

But I immediately run into a fundamental problem: I can’t get the input and output of a object work.

I basically did this:
1. I instantiated a JitterObject with ‘ new JitterObject("") ‘.
2. I made the ‘anything’ method forward all incoming data to this JitterObject via the ‘call’ method.
3. I set up a JitterListener to listen to outcoming textures when the slab is done processing them.

The JitterListener however doesn’t seem to register the out coming ‘jit_gl_texture’ messages.

Also, when I use the ‘call’ method, no Atom[] array is returned, in stead I get only null.

So much for the straightforward solution.
So I tried sending out the resulting textures (with their names defined in the ‘capture’ attribute) simply after receiving incoming jit.matrices. That only gives me a black window.
So I tried sending out the resulting textures after any of the messages that the JitterListener dóes register. Still no luck.

As you can see in the java file (attached) and the max patch (I tried to comment it all quite clearly), I’ve tried basically every point that I could think of to send out the resulting texture. Without success.

Can anybody tell me how to make a shader / slab work within Java code?

Thank you to anyone pointing me in the right direction!

- tarik

– Pasted Max Patch, click to expand. –

May 11, 2012 | 9:47 am

There’s a get-only attribute called out_name that will give you the name of the that is the slab’s output. You can use its value to chain together slabs and texture other objects. You can use the relevant attr getting java methods to get its value, but here’s a patcher version:

– Pasted Max Patch, click to expand. –

May 11, 2012 | 10:43 am

Thanks! But the ‘out_name’ attribute gives the exact same name as the ‘capture’ attribute that I send out through the mxj outlet. So the outcoming textures are named correctly I believe. Only, for some reason, they are empty at the moment that I send them. (btw, just to be sure, I just now tested the use of the out_name attribute in my Java file, which as expected gave the same results).
I think there might be a timing problem: I might be sending out the texture while its being created, or right before or something.

I believe I would be helped a lot if a JitterListener could actually see when the object sends out the resulting texture. But for some reason it seems to ignore this.

May 11, 2012 | 11:01 am

Oh wow, I found the staggeringly simple answer:

In ‘normal’ max, sending a object a matrix or a texture will make it automatically process a texture.

Within Java however, this does NOT happen automatically. The texture does not get drawn until you explicity give it the "draw" command.

A subtle inconsistency which got me thinking in waaay too complex ways.

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