bang() always returns doesn't understand bang()

May 1, 2009 at 9:27pm

bang() always returns doesn't understand bang()

I’ve been trying to use Jitter ob3d objects in java with automatic set to zero, when i try and bang using the .bang() method the api tells they have I get doesn’t understand “bang” in the max console.

Does anyone else have this problem?

#43632
May 1, 2009 at 9:33pm

here is an example

import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class textureTest extends MaxObject {

	JitterObject texture;
	JitterObject gridshape;

	private static final String[] INLET_ASSIST = new String[]{
		"inlet 1 help"
	};
	private static final String[] OUTLET_ASSIST = new String[]{
		"outlet 1 help"
	};

	public textureTest(Atom[] args) {

		declareInlets(new int[]{DataTypes.ALL});
		declareOutlets(new int[]{DataTypes.ALL});

		setInletAssist(INLET_ASSIST);
		setOutletAssist(OUTLET_ASSIST);

		texture = new JitterObject("jit.gl.texture");
		texture.setAttr("drawto", "test");
		texture.setAttr("name", "tex2");

		gridshape = new JitterObject("jit.gl.gridshape");
		gridshape.setAttr("drawto", "test");
		gridshape.setAttr("shape", "plane");
		gridshape.setAttr("texture", "tex2");
		gridshape.setAttr("automatic", 1);
	}

	public void bang() {
		//gridshape.bang(); //< -- this line causes trouble !!
	}

	public void read(String s) {
		texture.send("read", new Atom[] { Atom.newAtom(s) });
	}

	public void notifyDeleted() {
		texture.freePeer();
		gridshape.freePeer();
	}

}
#156552
May 9, 2009 at 11:17pm

could someone try compiling this and explaining why it raises does not understand bang ?

]
import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class test extends MaxObject
{

	JitterObject sketch;

	private static final String[] INLET_ASSIST = new String[]{
		"inlet 1 help"
	};
	private static final String[] OUTLET_ASSIST = new String[]{
		"outlet 1 help"
	};

	public test(Atom[] args)
	{
		sketch = new JitterObject("jit.gl.sketch");
		declareInlets(new int[]{DataTypes.ALL});
		declareOutlets(new int[]{DataTypes.ALL});

		setInletAssist(INLET_ASSIST);
		setOutletAssist(OUTLET_ASSIST);

	}

	public void bang()
	{
	//just pass it on
	sketch.bang();
	//try again
	sketch.send("bang");
	}
}
#156553
May 16, 2009 at 6:15pm

I have never used the jitter api, but as far as I could tell from the reference, neither of the jit.gl objects you used above support the bang message. Why do you want to send it?

#156554
May 26, 2009 at 3:05pm

Gridshape supports bang, you need to bang it to draw it if you have automatic turned off. According to the api all Jitter Objects inherit the bang method.

#156555
May 26, 2009 at 3:51pm

Are we using the same version of the api? On my machine, the only classes contained in javadocs at java-docapi-jitter are:

JitterEvent
JitterListener
JitterMatrix
JitterNotifiable
JitterObject

A native jitter object can not inherit a java object. As far as the I can tell form the docs, JitterObject is simply a front-end that sends messages to a native “peer”. If you replace

gridshape.bang();

with

post(gridshape.understands("bang"));

what does it print?

#156556
May 26, 2009 at 4:03pm

Sorry perhaps the space between Jitter and Object confused matters. I’m using the api with Max 5.07 and the api docs state JitterObject contains a method bang, since the gridshape or sketch in the mxj is an instance of JitterObject it should respond to the method. The objects when in normal patcher use respond to bangs.

I’m checking out what understands spits out now.

#156557
May 26, 2009 at 4:15pm

post(gridshape.understands(“bang”) + “n”);

returns false in the console.

#156558
May 27, 2009 at 12:30pm

Well this implies that the C object initialized by mxj really don’t understand the bang message.

crx091081gb wrote on Tue, 26 May 2009 10:15
since the gridshape or sketch in the mxj is an instance of JitterObject it should respond to the method

No, your gridshape variable holds an instance of a JitterObject. This is a java object that can call native code to initiate native jitter objects (in the constructor) and send messages to them. jit.gl.gridshape is NOT instance of JitterObject, so JitterObject won’t know about which method the actual object may support. This is what the understands() method is for.

Quote:
The objects when in normal patcher use respond to bangs

Really? Can you put up an example patch where jit.gl.gridshape supports bang?

#156559
May 27, 2009 at 12:32pm

Btw, I shouldn’t use the term C object here. They are native objects, though surely written in C.

#156560
May 27, 2009 at 12:40pm

This is an example

– Pasted Max Patch, click to expand. –

Believe me now?

I got an email back from technical support and apparently bang calls the objects draw method so I’m going to try calling that.

#156561
May 27, 2009 at 1:00pm

Success, calling .call(“draw”) whenever I want it to draw does the trick.

import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class bangTest extends MaxObject
{

JitterObject gridshape;

private static final String[] INLET_ASSIST = new String[]{
“inlet 1 help”
};
private static final String[] OUTLET_ASSIST = new String[]{
“outlet 1 help”
};

public bangTest(Atom[] args)
{
gridshape = new JitterObject(“jit.gl.gridshape”);
gridshape.setAttr(“drawto”, “example”);
gridshape.setAttr(“shape”, “plane”);
gridshape.setAttr(“automatic”, 0);
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});

setInletAssist(INLET_ASSIST);
setOutletAssist(OUTLET_ASSIST);

}

public void bang() {
gridshape.send(“draw”);
}
}

– Pasted Max Patch, click to expand. –

This works

#156562
Jun 2, 2009 at 2:07pm

Nice, strange that this method is not documented in the reference though. Is ‘draw’ a generic OpenGL function?

#156563
Jun 2, 2009 at 2:27pm

It is documented here

Messages and attributes common to the GL group

Bang is supposed to call it, maybe this is handled by something that is not exposed to the jitter java api hence having to call it by name?

If you try sending “draw” from a message box it has the same effect as bang. I suppose it’s left in to differentiate it from drawraw.

#156564
Jun 2, 2009 at 3:10pm

Aha, I didn’t notice that page. You’re probably right about the method not being exposed, that is a bug in JitterObject then.

Maybe it would be nice to create java wrappers for the jit.gl objects to call them more java-style? Methods could be ported like this for instance:

public void dim(int x, int y) {
    peer.send("dim", new Atom[]{ new Atom(x), new Atom(y) });
}

Takes a lot of work though, maybe not worth it..

#156565

You must be logged in to reply to this topic.