Forums > Java

using traer.physics in mxj


February 16, 2009 | 2:30 pm

Hi I’m trying to port some processing code from p5 to a mxj in max5, most of it ports and it compiles but I get a null pointer error as soon as it tries to instantiate any object from the traer physics library, the library’s jar is in max’s search path.

Any ideas ?

February 17, 2009 | 9:58 am

JARs aren’t loaded from Max’s search path: they need to be in /Cycling ’74/java/lib, or you need to point to the directory in max.java.config.txt.

Having said that, you should be getting ClassNotFound, not NullPointer, unless some class instantiation code in the app is faulty.

February 17, 2009 | 2:44 pm

Yeah I’d put them there sorry if I confused matters, it was actually my own fault for the null pointer, I’d done something stupid and not passed an object with a constructor blahblahblah

I think traer.physics works without any mods which is nice, I’ll post back if it does.

March 18, 2009 | 11:01 am

Traer physics runs fine in mxj, so yay for that. One observation is that you really have to be careful tweaking numerical parameters for the forces/step size or it blows up, this is the nature of the beast though.

April 7, 2009 | 2:21 am

would you be willing to post a simple patch of this? I would love to try this out as Ive been looking for a good dynamics solution. I am also really suprised as I didn’t know max worked with the same libraries that you can use in processing, Ive seen some great ones out there and I would love to try using some if its not too difficult.

April 7, 2009 | 10:06 am

yeah if i get time today, i don’t think all the p5 libraries will work, it depends how tied into the api they are. i decompiled the traer library and there’s not much going on in there other than a runge kutta integrator and some fancy method for working out the reciprocal of squared numbers, no hooks into anything p5.

all you have to do to get it to work is drop the jar into classes and code it like the p5 examples, except you replace the draw() with a bang() and attach a metro. I just pass the position of the particles out as vectors across the planes of a 3 dim matrix with one row and as many columns as particles.

Like I said I’ll try and dig something out, might be a blog post in it….

April 7, 2009 | 3:56 pm

Here is a patch that shows I use traer, I was wrong in the earlier post, rather than send out xyz values into a matrix I just use a jit.sketch that I’ve instatiated inside the mxj and draw directly to a texture.

Just stick the class files in classes, open the patch and click on generate. Tell me if it works.

Robin

April 8, 2009 | 7:19 pm

Jitter 1.7.0 installed
MXJ System CLASSPATH:
/Applications/Max5/Cycling ’74/java/lib/ej.jar
/Applications/Max5/Cycling ’74/java/lib/jitter.jar
/Applications/Max5/Cycling ’74/java/lib/jode-1.1.2-pre-embedded.jar
/Applications/Max5/Cycling ’74/java/lib/max.jar
/Applications/Max5/Cycling ’74/java/lib/physics.jar
MXJClassloader CLASSPATH:
/Applications/Max5/Cycling ’74/java/classes/
Jitter Java support installed
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at com.cycling74.max.MXJClassLoaderImpl.doLoadClass(MXJClassLoaderImpl.java:119)
at com.cycling74.max.MXJClassLoader.loadClazz(MXJClassLoader.java:88)
Could not load class ‘BlobViz’

April 8, 2009 | 7:33 pm

you on the mac? you probably need to recompile the mxj, compile blob first then blobviz

April 8, 2009 | 7:48 pm

I opened it up with the java compiler in max and got some errors posted below. Blob compiled fine, but just not blobviz

April 8, 2009 | 7:56 pm

Compiling /Users/Ron/Desktop/blobz/BlobViz.java………

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/javac -classpath /Applications/Max5/Cycling ’74/java/lib/ej.jar:/Applications/Max5/Cycling ’74/java/lib/jitter.jar:/Applications/Max5/Cycling ’74/java/lib/jode-1.1.2-pre-embedded.jar:/Applications/Max5/Cycling ’74/java/lib/max.jar:/Applications/Max5/Cycling ’74/java/lib/physics.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/.compatibility/14compatibility.jar:/Applications/Max5/Cycling ’74/java/classes/ /Users/Ron/Desktop/blobz/BlobViz.java

/Users/Ron/Desktop/blobz/BlobViz.java[ 64 ] cannot find symbol
symbol : class Blob
location: class BlobViz
Blob b = new Blob(physics, graviton, generator);
^
/Users/Ron/Desktop/blobz/BlobViz.java[ 64 ] cannot find symbol
symbol : class Blob
location: class BlobViz
Blob b = new Blob(physics, graviton, generator);
^
/Users/Ron/Desktop/blobz/BlobViz.java[ 69 ] cannot find symbol
symbol : class Blob
location: class BlobViz
Blob b = (Blob) particles.get(i);
^
/Users/Ron/Desktop/blobz/BlobViz.java[ 69 ] cannot find symbol
symbol : class Blob
location: class BlobViz
Blob b = (Blob) particles.get(i);
^
/Users/Ron/Desktop/blobz/BlobViz.java[ 104 ] cannot find symbol
symbol : class Blob
location: class BlobViz
Blob b = (Blob) particles.get(i);
^
/Users/Ron/Desktop/blobz/BlobViz.java[ 104 ] cannot find symbol
symbol : class Blob
location: class BlobViz
Blob b = (Blob) particles.get(i);
^
/Users/Ron/Desktop/blobz/BlobViz.java[ 112 ] cannot find symbol
symbol : class Blob
location: class BlobViz
Blob b = (Blob) particles.get(i);
^
/Users/Ron/Desktop/blobz/BlobViz.java[ 112 ] cannot find symbol
symbol : class Blob
location: class BlobViz
Blob b = (Blob) particles.get(i);
^
8 errors
[ Apr 8, 2009 3:55:50 PM ]
compilation of /Users/Ron/Desktop/blobz/BlobViz.java failed.

April 8, 2009 | 8:19 pm

hmmm this is confusing, it compiled blob but it can’t find it, did you compile the class in /classes ? looking at the output it seems like you have it in a folder in you desktop, try putting the class file /classes

my method for compiling something new like this would be
1) copy the java file to Cycling74/java/classes
2) open a new patcher, add an mxj quickie dummy and connect a bang
3) click the bang, the mxj with all the default crap opens, ignore this just click on open and open blob.java
4) ctr k (dunno the mac shortcut but bring up the compiler) compile
5) open blobviz, compile that
6) new mxj blobviz or just open the patch i posted

tell me how it goes

April 8, 2009 | 10:05 pm

ok it worked, I dont know if what I see is what should be happening though, its giant letters everywhere and spheres moving in somewhat random paths

April 8, 2009 | 10:06 pm

I should also mention your depthbuffer is off so it didn’t depth sort the spheres

April 8, 2009 | 10:25 pm

yeah that’s right massive fonts and spheres, you can waggle the numbers in the boxes till they look like you want. the spheres are all attracted to a central, invisible attractor but they repel each other. that’s about it really

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

Forums > Java