rotating icosahedron textured with video frame.

edited February 2016 in Library Questions

hello, i am new on this forum and new on processing too. I have started months ago with this software. i am working now with a program that run an imported obj file, an icosahedron precisely, the idea is: texturing each face with the frame of a video that run in an invisible layer. the code work, with error, but run on my pc but in the pc of my mate, don't. i ask at you, that have much experience. i need help me to fix the code. sry for my bad english. thank you

the obj file: https://drive.google.com/file/d/0B--XqWTDy8jQVi1lN2k5WTFSVXc/view?usp=sharing

the video: https://drive.google.com/file/d/0B--XqWTDy8jQVkNVWE5pajBpcXM/view?usp=sharing

import saito.objloader.*; 
import processing.video.*;
PShape house;
PShape[] triangoli;
PImage img;
float ry=0.7;
int numerotriangoli, numero;
int n, a, z=0;
int[] tri={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0}; // number of the faces
PGraphics video;
String PATH = "/home/ma-nu33/kdenlive/untitled.mp4";
Movie myMovie;
///
void setup() {
  size(1280, 720, P3D); 
  video = createGraphics(1280, 720, P3D);   
  myMovie = new Movie(this, PATH);
  myMovie.loop();
  house = loadShape("oggetto3d.obj");
  spezzaTriangoli();
  frameRate(30);
  for (int i = 0; i < 20; i++) {   //the black texture
    TextureNera(i);
  }
}
void draw() {
  background(0);
  smooth();
  video.beginDraw();               //invisible layer
  video.image(myMovie, 0, 0);
  video.endDraw();
  translate(width/2, height/2, -600);
  scale(30);
  lights();
  ry -= 0.0314/2; 
  rotateY(ry);
  disegnaSolido();
  if (a >=20) {
    a=0;
  }
  if (n % 20 == 0) {
    if (a <= 20) {
      funzione();
      numero = tri[a];
      triangoli[numero] = house.getChild(numero);
      triangoli[numero].disableStyle();                     
      Texture(numero, z);
      a++;

      if (a%5==0) {
        z=0;
      } else {
        z=1;
      }
    }
  }
  n++;
}

void spezzaTriangoli() {          //getChild 
  numerotriangoli = house.getChildCount();
  triangoli = new PShape[numerotriangoli];
  for (int i = 0; i<numerotriangoli; i++) {
    triangoli[i] = house.getChild(i);
  }
}

void disegnaSolido() {
  for (int i = 0; i < numerotriangoli; i++) {
    shape(triangoli[i]);
  }
}
void Texture(int c, int z) {              //texture with the image
  PShape s = createShape();
  s.beginShape();
  s.textureMode(NORMAL);
  s.texture(img);
  for (int j=0; j<triangoli[c].getVertexCount(); j++) {
    int[] r1 = {0, 1-z, 0+z};
    int[] r2 = {0+z, 1-z, 1-z};
    s.vertex(triangoli[c].getVertex(j).x, triangoli[c].getVertex(j).y, triangoli[c].getVertex(j).z, r1[j], r2[j]);
  }
  s.endShape();
  triangoli[c] = s;
}
void TextureNera(int c) {                  //for black texture
  PShape s = createShape();
  s.beginShape();
  s.textureMode(NORMAL);
  s.fill(0);
  for (int j=0; j<triangoli[c].getVertexCount(); j++) {

    s.vertex(triangoli[c].getVertex(j).x, triangoli[c].getVertex(j).y, triangoli[c].getVertex(j).z, 0, 0);
  }
  s.endShape();
  triangoli[c] = s;
}
void funzione() {                    //create an image of the video
  video.beginDraw();
  video.save("a.png");
  video.endDraw();
  img = loadImage("a.png");
}

void movieEvent(Movie m) {
  m.read();
}

this is the error output in the console!

libEGL warning: DRI2: failed to authenticate
java.lang.NullPointerException
    at processing.opengl.Texture.copyBufferFromSource(Texture.java:825)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at processing.video.Movie.read(Unknown Source)
    at Icosaedro_Video.movieEvent(Icosaedro_Video.java:138)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at processing.video.Movie.fireMovieEvent(Unknown Source)
    at processing.video.Movie.invokeEvent(Unknown Source)
    at processing.video.Movie$1.bufferFrame(Unknown Source)
    at org.gstreamer.elements.BufferDataAppSink$AppSinkNewBufferListener.newBuffer(BufferDataAppSink.java:163)
    at org.gstreamer.elements.AppSink$2.callback(AppSink.java:184)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:485)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:515)
Sign In or Register to comment.