Getting java.lang.NoSuchMethod error. Can you see why?

edited January 2016 in Library Questions

Most of this code was taken from a source online. Not trying to pass it off as my own. Just trying to make sure I can successfully load an OBJ file into processing before I begin work in Blender then Processing.

The code I have is below. I have loaded, through drag and drop, my own OBJ file and MTL files, both called Lancer. It is a very plain 3D cube. Any help much appreciated. Like I said, at the moment, I am just trying to load the OBJ shape into Processing.

import processing.opengl.*;
import saito.objloader.*;

// declare that we need a OBJModel and we'll be calling it "model"
OBJModel model;

float rotX;
float rotY;
PImage tex;
// these booleans will be used to turn on and off bits of the OBJModel
boolean bTexture = true;
boolean bStroke = false;
boolean bMaterial = false;

void setup()
{
    size(800, 800, P3D);

    // making an object called "model" that is a new instance of OBJModel
    model = new OBJModel(this,"Lancer.obj", "relative", POLYGON);

    // turning on the debug output (it's all the stuff that spews out in the black box down the bottom)
    model.enableDebug();
    model.translateToCenter();
    model.scale(.9);
    model.printModelInfo();
    noStroke();
}

void draw()
{
    background(255);
    lights();

    //this will do nothing until the model material is turned off
  //  fill(255,0,255);

    pushMatrix();
    translate(width/2, height/2, 0);
    rotateX(rotY);
    rotateY(rotX);
    model.draw();
    popMatrix();
}

void mouseDragged()
{
    rotX += (mouseX - pmouseX) * 0.01;
    rotY -= (mouseY - pmouseY) * 0.01;
}

I think the errors are longer than the code.

draw mode:      POLYGON
Loading this = Lancer.obj
Loading this = untitled.mtl
untitled.mtl does not exist or could not be read
java.lang.NullPointerException
    at saito.objloader.OBJModel.parseMTL(OBJModel.java:973)
    at saito.objloader.OBJModel.parseOBJ(OBJModel.java:813)
Could not find this file untitled.mtl
    at saito.objloader.OBJModel.load(OBJModel.java:577)
    at saito.objloader.OBJModel.<init>(OBJModel.java:124)
    at sketch_160121a.setup(sketch_160121a.java:40)
    at processing.core.PApplet.handleDraw(PApplet.java:2374)
    at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:731)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
    at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759)
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
    at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
    at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)
Obj Name:       Cube.001

V  Size:    8
Vt Size:    0
Vn Size:    6
G  Size:    1
S  Size:        1    

objloader version 021
18 August 2010
http:// code.google.com/p/saitoobjloader/

OBJBoundingBox -    Getting the Bounding Box
java.lang.RuntimeException: java.lang.NoSuchMethodError: processing.core.PVector.add(Lprocessing/core/PVector;)V
    at processing.opengl.PSurfaceJOGL$2.run(PSurfaceJOGL.java:443)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: processing.core.PVector.add(Lprocessing/core/PVector;)V
    at saito.objloader.BoundingBox.<init>(BoundingBox.java:46)
    at saito.objloader.OBJModel.translateToCenter(OBJModel.java:645)
    at sketch_160121a.setup(sketch_160121a.java:44)
    at processing.core.PApplet.handleDraw(PApplet.java:2374)
    at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:731)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
    at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759)
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
    at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
    at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.

I have a window open for the output too, but there is just a plain window, no box is displayed.

Thank you

Answers

  • edited January 2016

    Most of the results in that search are you posting the search results :)

    One reply did say

    "the Saito ObjLoader is not really compatible with Processing 3, and unless someone recompiles the library (unlikely), it never will be."

    Is this correct?

    Does that mean that

    a) there is no way of loading an OBJ file into Processing 3.x (there doesn't appear to be an alternative to OBJLoader)

    b) OBJLoader is only really necessary if there are textures involved? I really only want the wire frame of the 3D model - no textures.

    I found this code online. Has the poster omitted

    import...
    
    PShape house;
    
    float ry;
    
    public void setup() {
      size(640, 360, P3D);
    
      house = loadShape("huts/huts.obj");
    }
    
    public void draw() {
      background(100);
      lights();
    
      translate(width/3, height/3, 0); 
      //rotateX(QUARTER_PI * 1.0);            
      rotateZ(-PI );
    
      rotateY(map(mouseX, mouseY, width, 2.5, -2.5));
    
      //rotateY(ry);
      pushMatrix();
      translate(1500,-400,0);
      shape(house);
      popMatrix();
     }
    

    c) I would be better off running 2.x and OBJLoader

    Thanks for the help GoToLoop

  • please format your code. highlight it, hit ctrl-o...

  • Answer ✓

    AFAIK, PShape in 3d mode represents obj files and you don't need additional libraries to load it.

Sign In or Register to comment.