@@ -216,7 +216,6 @@ static protected void parseOBJ(PApplet parent, String path,
216216 1 - Float .valueOf (parts [2 ]).
217217 floatValue ());
218218 texcoords .add (tempv );
219- PApplet .println (texcoords .size (), tempv );
220219 readvt = true ;
221220 } else if (parts [0 ].equals ("o" )) {
222221 // Object name is ignored, for now.
@@ -229,7 +228,7 @@ static protected void parseOBJ(PApplet parent, String path,
229228 }
230229 BufferedReader mreader = parent .createReader (fn );
231230 if (mreader != null ) {
232- parseMTL (parent , path , mreader , materials , mtlTable );
231+ parseMTL (parent , fn , path , mreader , materials , mtlTable );
233232 mreader .close ();
234233 }
235234 }
@@ -318,7 +317,7 @@ static protected void parseOBJ(PApplet parent, String path,
318317 }
319318
320319
321- static protected void parseMTL (PApplet parent , String path ,
320+ static protected void parseMTL (PApplet parent , String mtlfn , String path ,
322321 BufferedReader reader ,
323322 ArrayList <OBJMaterial > materials ,
324323 Map <String , Integer > materialsHash ) {
@@ -347,7 +346,17 @@ static protected void parseMTL(PApplet parent, String path,
347346 // Relative file name, adding the base path.
348347 texname = path + File .separator + texname ;
349348 }
350- currentMtl .kdMap = parent .loadImage (texname );
349+
350+ File file = new File (parent .dataPath (texname ));
351+ if (file .exists ()) {
352+ currentMtl .kdMap = parent .loadImage (texname );
353+ } else {
354+ System .err .println ("The texture map \" " + texname + "\" " +
355+ "in the materials definition file \" " + mtlfn + "\" " +
356+ "is missing or inaccessible, make sure " +
357+ "the URL is valid or that the file has been " +
358+ "added to your sketch and is readable." );
359+ }
351360 } else if (parts [0 ].equals ("Ka" ) && parts .length > 3 ) {
352361 // The ambient color of the material
353362 currentMtl .ka .x = Float .valueOf (parts [1 ]).floatValue ();
0 commit comments