# loadShape() cannot find .obj file in data folder

**URL:** https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745
**Category:** Coding Questions
**Created:** [June 28, 2022, 1:11pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745 "2022-06-28T13:11:49Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![miiguell](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@miiguell](https://discourse.processing.org/u/miiguell)
#### Post date: [June 28, 2022, 1:11pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/1 "2022-06-28T13:11:49Z")

</div>

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:

```auto
PShape rocket;

int windowSize = 1000; // size of square window

void setup() {
  size(1000, 1000, P3D);
  rocket = loadShape("space-shuttle.obj");
}

void draw() {
  background(100);
  shape(rocket);
}

```

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.

```auto
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)

```

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [June 28, 2022, 3:21pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/2 "2022-06-28T15:21:14Z")

</div>

Error message says “reader” is null. Have you tried adding ‘import [java.io](http://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.

---

<div class="post-metadata">

### Author: ![miiguell](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@miiguell](https://discourse.processing.org/u/miiguell)
#### Post date: [June 28, 2022, 6:19pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/3 "2022-06-28T18:19:12Z")

</div>

Hi Svan,

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

[https://sketchfab.com/3d-models/space-shuttle-ff4b00b7ebb24fdd98fb96b08f2c43c9](https://sketchfab.com/3d-models/space-shuttle-ff4b00b7ebb24fdd98fb96b08f2c43c9)

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [June 28, 2022, 7:20pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/4 "2022-06-28T19:20:51Z")

</div>

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.

```auto
PShape rocket;

float ry;
void setup() {
  size(500, 500, P3D);
  rocket = loadShape("space-shuttle.obj");
}

void draw() {
  background(200);
  lights();
  translate(width/2, height/2, 300);
  rotateZ(PI);
  rotateY(ry);
  shape(rocket);
  ry += 0.02;
}

```

**Files in ‘data’ folder. add missing .mtl file (see below).**

 ![data_files](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/0/70e4c84f942c4e9a46e8b71f5e313371d8cb506f.png)

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [June 28, 2022, 7:52pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/5 "2022-06-28T19:52:14Z")

</div>

Try adding the following file entitled ‘space-shuttle.mtl’ to the data folder:

```auto
newmtl Default
illum 2
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.533333 0.533333 0.533333
Ks 0.100000 0.100000 0.100000
Ni 1.000000
d 1.000000
map_Kd ShuttleDiffuseMap.jpg

```

---

<div class="post-metadata">

### Author: ![miiguell](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@miiguell](https://discourse.processing.org/u/miiguell)
#### Post date: [June 28, 2022, 8:24pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/6 "2022-06-28T20:24:36Z")

</div>

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.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/0/e/0e1f6a3e8055111aaa4472a39ac26d6c1f0288f7.png)

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [June 28, 2022, 9:15pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/7 "2022-06-28T21:15:45Z")

</div>

‘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.

![shuttle](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/5/b5d45466b7897166e7f08f25a2e69a9c38445d9a.png)

**Sketch folder:**

![sketch](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/9/f9c2b18e289d412a26704eedf7c8125e8b6d85d8.png)

---

<div class="post-metadata">

### Author: ![miiguell](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@miiguell](https://discourse.processing.org/u/miiguell)
#### Post date: [June 28, 2022, 10:11pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/8 "2022-06-28T22:11:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [June 28, 2022, 11:02pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/9 "2022-06-28T23:02:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![miiguell](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@miiguell](https://discourse.processing.org/u/miiguell)
#### Post date: [June 29, 2022, 5:51am UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/10 "2022-06-29T05:51:34Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)
#### Post date: [December 25, 2022, 7:00pm UTC](https://discourse.processing.org/t/loadshape-cannot-find-obj-file-in-data-folder/37745/11 "2022-12-25T19:00:02Z")

</div>

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.
