Processing Forum
Any help must be appreciated...import processing.opengl.*;import codeanticode.glgraphics.*;import codeanticode.gsvideo.*;
GSCapture cam;GSMovie[] movie=new GSMovie[3];GLTexture[] tex=new GLTexture[3];int index;GSMovie mv;PImage prevFrame;int counter=0;void setup() {size(640, 480, GLConstants.GLGRAPHICS);
cam = new GSCapture(this, 640, 480);cam.start();
// Use texture tex as the destination for the camera pixels.tex[0] = new GLTexture(this);tex[1] = new GLTexture(this);tex[2] = new GLTexture(this);
movie[0]=new GSMovie(this, "smoke.mov");movie[1]=new GSMovie(this, "Drift.mov");movie[2]=new GSMovie(this, "Galardo.mov");
for (int i=0;i<movie.length;i++) {movie[i].setPixelDest(tex[i]);}
prevFrame = createImage(cam.width, cam.height, RGB);for(int i=movie.length-1;i>0;i--){int j=int(random(i+1));//swapmv=movie[i];movie[i]=movie[j];movie[j]=mv;}}
void captureEvent(GSCapture cam) {cam.read();}void movieEvent(GSMovie movie) {
movie.read();}
void draw() {background(255);image(cam, 0, 0);
MovieonMovementDisplay();
for (int i=0;i<tex.length;i++) {if (tex[i].putPixelsIntoTexture()) {image(tex[i], 0, 0);}}}void MovieonMovementDisplay() {if (cam.available()) {prevFrame.copy(cam, 0, 0, cam.width, cam.height, 0, 0, cam.width, cam.height);prevFrame.updatePixels();cam.read();}
loadPixels();cam.loadPixels();prevFrame.loadPixels();
float totalMotion=0;
for (int i = 0; i < cam.pixels.length; i ++ ) {color current = cam.pixels[i];
color previous= prevFrame.pixels[i];
float r1 = red(current);float g1 = green(current);float b1 = blue(current);float r2 = red(previous);float g2 = green(previous);float b2 = blue(previous);
float diff = dist(r1, g1, b1, r2, g2, b2);totalMotion += diff;}float avgMotion = totalMotion / cam.pixels.length;
println(avgMotion+"----AvgMotion");println("---------");
for (int i=0;i<movie.length;i++) {println(movie[i].time());}int index=constrain(movie.length,0,2);float time=movie[index].time();
if((avgMotion>30)&&(avgMotion<80)){movie[index].play();}if(movie[index].isPlaying()){if(time==movie[index].time()){movie[int(random(0,movie.length))].jump(0);}}}
after that i made second .dae file in sketchup free version, then it gives again an error:Exception in thread "Animation Thread" cooladaLoader.ColladaLoaderException: WARNING: the actual file is made by Google SketchUp 8.0.14346 and not 'Google SketchUp 8.0.3117'. It might contain a different XML-Structurethrowed by a java.lang.NullPointerException.
I dont know .. how to solve it..Exception in thread "Animation Thread" cooladaLoader.ColladaLoaderException: Google SketchUp 8.0.3117throwed by a java.lang.NullPointerException
import codeanticode.glgraphics.*;import processing.opengl.*;import javax.media.opengl.*;import saito.objloader.*;
// declare that we need a OBJModel and we'll be calling it "model"OBJModel model;GLModel glModel;float rotX;float rotY;
void setup(){size(1000, 700,GLConstants.GLGRAPHICS);
// making an object called "model" that is a new instance of OBJModelmodel = new OBJModel(this, "male01.obj", "relative", TRIANGLES);glModel=new GLModel(this,model.getFaceCount()*3,TRIANGLES,GLModel.STATIC);glModel.beginUpdateVertices();int i = 0;for (int f = 0; f < model.getFaceCount(); f++) {PVector[] fverts = model.getFaceVertices(f);for (int v = 0; v < fverts.length; v++) {glModel.updateVertex(i++, fverts[v].x, fverts[v].y, fverts[v].z);}}glModel.endUpdateVertices();
// Enabling colors.glModel.initColors();glModel.beginUpdateColors();for (int c = 0; c < model.getFaceCount() * 3; c++) {glModel.updateColor(c, 255, 255, 225, 255);}glModel.endUpdateColors();
//********************UPDATE NORMALS//************************************************glModel.initNormals();glModel.beginUpdateNormals();int index = 0;for (int s = 0; s < model.getSegmentCount(); s++) {Segment segment = model.getSegment(s);Face[] faces = segment.getFaces();for (int nn = 0; nn < faces.length; nn++) {PVector[] vs = faces[nn].getVertices();PVector[] ns = faces[nn].getNormals();for (int k = 0; k < vs.length; k++) {glModel.updateNormal(index++, ns[k].x, ns[k].y, ns[k].z);}}}glModel.endUpdateNormals();*///Enabling the use of texturingint index=0;glModel.initTextures(1);img=new GLTexture(this,"male01_1.jpg");glModel.beginUpdateTexCoords(0);for(int s = 0; s < model.getSegmentCount(); s++) {Segment segment = model.getSegment(s);Face[] faces = segment.getFaces();for (int u = 0; u < faces.length; u++) {PVector[] vs = faces[u].getVertices();PVector[] ns = faces[u].getUvs();for (int k = 0; k < vs.length; k++) {glModel.updateTexCoord(index, ns[k].x, ns[k].y);}}}glModel.endUpdateTexCoords();
// turning on the debug output (it's all the stuff that spews out in the black box down the bottom)model.enableDebug();model.printModelInfo();model.translateToCenter();model.scale(3);
noStroke();}
void draw(){background(255);lights();
pushMatrix();translate(width/2, height/2, 0);rotateX(rotY);rotateY(rotX);model.enableTexture();model.enableMaterial();model.draw();popMatrix();}
void mouseDragged(){rotX += (mouseX - pmouseX) * 0.01;rotY -= (mouseY - pmouseY) * 0.01;}