.OBJ loader + Syphon
in
Contributed Library Questions
•
16 days ago
Hello,
I'm trying to process some 3d object with the 3d obj loader library from saito (
https://code.google.com/p/saitoobjloader/) in order to stream it via the Syphon library (
http://codeanticode.wordpress.com/2012/02/21/syphon-client-working-in-processing/).
With Processing, I usually create a PGraphics in which I draw all my elements that I'll send to my Syphon Client.
But as the draw method from the saito.objloader library is
directly
drawing the 3d model in the main PApplet, I can't find how to draw directly in my canvas created below (the PGraphics elements I'm trying to send via Syphon).
Here's a copy of my code without the Syphon implementation:
- import saito.objloader.*;
- import ddf.minim.spi.*;
- import ddf.minim.signals.*;
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- import ddf.minim.ugens.*;
- import ddf.minim.effects.*;
- import codeanticode.syphon.*;
- Minim minim;
- AudioInput in;
- FFT fft;
- PGraphics canvas;
- SyphonServer server;
- OBJModel model;
- void setup()
- {
- size(600, 600, P3D);
- server = new SyphonServer(this, "Frame");
- minim = new Minim(this);
- in = minim.getLineIn(Minim.STEREO, 512);
- fft = new FFT(in.bufferSize(), in.sampleRate());
- model = new OBJModel(this, "MaleLow.obj", "relative");
- model.disableDebug();
- model.shapeMode(POLYGON);
- model.scale(8);
- noStroke();
- }
- void stop() {
- in.close();
- minim.stop();
- super.stop();
- }
- float inc = 0;
- void draw()
- {
- inc++;
- background(32);
- lights();
- fft.forward(in.mix);
- if(in.mix.level()*2550<240) {
- model.enableMaterial();
- }
- else {
- model.disableMaterial();
- }
- stroke(fft.getBand(150)*100, fft.getBand(150)*150, fft.getBand(150)*100);
- directionalLight(0,0,fft.getBand(250)*2550, 100, 10, 0);
- directionalLight(0,0,fft.getBand(250)*2550, -100, 10, 0);
- //this will do nothing until the model material is turned off
- fill(255,0,255,90);
- pushMatrix();
- translate(width/2, 410, 360);
- rotateX(-0.6);
- rotateY(radians(inc*0.1));
- model.draw();
- popMatrix();
- }
Julien
1