diff --git a/core/src/processing/core/PShapeOBJ.java b/core/src/processing/core/PShapeOBJ.java index 4343f79819..a46e6ab8a8 100644 --- a/core/src/processing/core/PShapeOBJ.java +++ b/core/src/processing/core/PShapeOBJ.java @@ -216,7 +216,6 @@ static protected void parseOBJ(PApplet parent, String path, 1 - Float.valueOf(parts[2]). floatValue()); texcoords.add(tempv); - PApplet.println(texcoords.size(), tempv); readvt = true; } else if (parts[0].equals("o")) { // Object name is ignored, for now. @@ -229,7 +228,7 @@ static protected void parseOBJ(PApplet parent, String path, } BufferedReader mreader = parent.createReader(fn); if (mreader != null) { - parseMTL(parent, path, mreader, materials, mtlTable); + parseMTL(parent, fn, path, mreader, materials, mtlTable); mreader.close(); } } @@ -318,7 +317,7 @@ static protected void parseOBJ(PApplet parent, String path, } - static protected void parseMTL(PApplet parent, String path, + static protected void parseMTL(PApplet parent, String mtlfn, String path, BufferedReader reader, ArrayList materials, Map materialsHash) { @@ -347,7 +346,17 @@ static protected void parseMTL(PApplet parent, String path, // Relative file name, adding the base path. texname = path + File.separator + texname; } - currentMtl.kdMap = parent.loadImage(texname); + + File file = new File(parent.dataPath(texname)); + if (file.exists()) { + currentMtl.kdMap = parent.loadImage(texname); + } else { + System.err.println("The texture map \"" + texname + "\" " + + "in the materials definition file \"" + mtlfn + "\" " + + "is missing or inaccessible, make sure " + + "the URL is valid or that the file has been " + + "added to your sketch and is readable."); + } } else if (parts[0].equals("Ka") && parts.length > 3) { // The ambient color of the material currentMtl.ka.x = Float.valueOf(parts[1]).floatValue();