I’m trying to import a 3D model of a space shuttle but processing is giving me a really hard time doing this for some reason. I watched examples and even opened the .OBJ file on ym computer and it renders nicely but processing doesn’t want to open it. The code snippet is really simple as shown below:
I made sure I added the file to the data folder and also tried with a .svg in 2D which worked but I need the 3D model for my project. i also tried adding it in the same folder as the sketch and it didn’t work. The error that I get is below. Any help would be appreciated! I am using processing 4.0.
The file "space-shuttle.obj" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
java.lang.NullPointerException: Cannot invoke "java.io.BufferedReader.readLine()" because "reader" is null
at processing.core.PShapeOBJ.parseOBJ(PShapeOBJ.java:168)
at processing.core.PShapeOBJ.<init>(PShapeOBJ.java:40)
at processing.core.PShapeOBJ.<init>(PShapeOBJ.java:27)
at processing.opengl.PGraphics3D.loadShapeImpl(PGraphics3D.java:128)
at processing.opengl.PGraphicsOpenGL.loadShape(PGraphicsOpenGL.java:3382)
at processing.core.PApplet.loadShape(PApplet.java:11254)
at simulation.setup(simulation.java:30)
at processing.core.PApplet.handleDraw(PApplet.java:2142)
at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:825)
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:782)
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:453)
at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
at java.base/java.util.TimerThread.mainLoop(Timer.java:566)
at java.base/java.util.TimerThread.run(Timer.java:516)
Error message says “reader” is null. Have you tried adding ‘import java.io.*’ at the top? Is it possible to post the url for the object so that others can test your code?
Does your data folder contain at least 3 files: .obj, .mtl, .png (or texture equivalent). See Examples/Shape/LoadDisplayOBJ.
thank you for the response! This is the link to the place where I downloaded the .obj file from. I tried adding import java.io.*; at the top but the problem still exists
Thank you for the URL. The following ‘sort of’ works on my Mac. You should see a shuttle image rotating in the window. The .mtl file is missing from the original download. Attached you can also see the files that I used. The main file should have only one .obj extension, not two as was included in the download.
No luck for me unfortunately. I created the file you suggested as well and still get the same error. I’m placing images of the files in the data folder that is next to the sketch.
‘data’ folder has to be inside of sketch folder. Get rid of that trailing underscore on ShuttleDiffuseMap; computers are finicky and text has to be exact. Works on a Mac.
Interesting. Still nothing. What’s funny is that I found another space shuttle .OBJ file and that worked just fine for some reason but this original one still doesn’t want to open. I have my data folder inside the sketch folder the same way you do and inside I have the 4 files (2 JPG, .mtl, and .obj). I might keep the new one that I found but it still bothers me that this specific model doesn’t open at all
I presume that you are using Windows operating system. There are lots of users here who are also Windows users and perhaps they can also run the demo to see if they have a problem.
I downloaded the files yout posted ont he drop box and it works perfectly! I wonder if one of the files was corrupted somehow on my system. Thank you for the help!
Hi, I’m having the same issue with a Mac OS. What am I doing wrong? How do I run the demo mode? I exported a model from thingiverse but it is only appearing black within the processing.js window.