Saito OBJLoader and Processing 3

edited December 2015 in Library Questions

I was just wondering if anyone has managed to get any of the Saito OBJLoader library examples to work in Processing 3.0.1. They still work in Processing 2.2.1 but each one throws out a series of (similar) errors in P3. This is the FaceLocation example. I am definitely no expert, but it looks like OpengL/JOGL errors - although there are PVector errors too.

This is probably to do with the library being old, but does anyone have any ideas?

I could not find the protocol for posting console messages so here is a (hopefully readable) screenshot.

console

Answers

  • edited December 2015

    This is the code for a different Saito example for reference, but the errors it throws are basically the same.

       import saito.objloader.*;
        OBJModel model;
        OBJModel tmpmodel;
        float rotX;
        float rotY;
        void setup()
        {
          size(600, 600, P3D);
          frameRate(30);
          model = new OBJModel(this);
          tmpmodel = new OBJModel(this);
          model.enableDebug();
          model.load("dma.obj");
          tmpmodel.load("dma.obj");
          stroke(255);
        }
        void draw()
        {
          background(128);
          lights();
          pushMatrix();
          translate(width/2, height/2, 0);
          rotateX(rotY);
          rotateY(rotX);
          scale(20.0);
    
          // renders the temporary model
          tmpmodel.draw();
    
          popMatrix();
    
          animation();
        }
        // transformation parameter
        float k = 0.0;
        // transforms the orignal model shape and stores transformed shape 
        // into temporary model storage
        void animation() {
    
          for (int i = 0; i < model.getVertexCount(); i++) {
            PVector orgv = model.getVertex(i);
            PVector tmpv = new PVector();
            tmpv.x = orgv.x * (abs(sin(k+i*0.04)) * 0.3 + 1.0);
            tmpv.y = orgv.y * (abs(cos(k+i*0.04)) * 0.3 + 1.0);
            tmpv.z = orgv.z * (abs(cos(k/5.)) * 0.3 + 1.0);
            tmpmodel.setVertex(i, tmpv);
          }
          k+=0.1;
        }
    
        void mouseDragged()
        {
          rotX += (mouseX - pmouseX) * 0.01;
          rotY -= (mouseY - pmouseY) * 0.01;
        }
    
  • To answer my own question - the Saito ObjLoader is not really compatible with Processing 3, and unless someone recompiles the library (unlikely), it never will be.

Sign In or Register to comment.