Skip to content

Commit

Permalink
fixed getBasePath()
Browse files Browse the repository at this point in the history
  • Loading branch information
codeanticode committed Oct 29, 2019
1 parent a32ede5 commit 1d343b7
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions core/src/processing/core/PShapeOBJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public PShapeOBJ(PApplet parent, BufferedReader reader, String basePath) {
ArrayList<PVector> coords = new ArrayList<PVector>();
ArrayList<PVector> normals = new ArrayList<PVector>();
ArrayList<PVector> texcoords = new ArrayList<PVector>();
parseOBJ(parent, basePath, reader,
faces, materials, coords, normals, texcoords);
parseOBJ(parent, basePath,
reader, faces, materials, coords, normals, texcoords);

// The OBJ geometry is stored with each face in a separate child shape.
parent = null;
Expand Down Expand Up @@ -222,23 +222,22 @@ static protected void parseOBJ(PApplet parent, String path,
if (parts[0].equals("v")) {
// vertex
PVector tempv = new PVector(Float.valueOf(parts[1]).floatValue(),
Float.valueOf(parts[2]).floatValue(),
Float.valueOf(parts[3]).floatValue());
Float.valueOf(parts[2]).floatValue(),
Float.valueOf(parts[3]).floatValue());
coords.add(tempv);
readv = true;
} else if (parts[0].equals("vn")) {
// normal
PVector tempn = new PVector(Float.valueOf(parts[1]).floatValue(),
Float.valueOf(parts[2]).floatValue(),
Float.valueOf(parts[3]).floatValue());
Float.valueOf(parts[2]).floatValue(),
Float.valueOf(parts[3]).floatValue());
normals.add(tempn);
readvn = true;
} else if (parts[0].equals("vt")) {
// uv, inverting v to take into account Processing's inverted Y axis
// with respect to OpenGL.
PVector tempv = new PVector(Float.valueOf(parts[1]).floatValue(),
1 - Float.valueOf(parts[2]).
floatValue());
1 - Float.valueOf(parts[2]).floatValue());
texcoords.add(tempv);
readvt = true;
} else if (parts[0].equals("o")) {
Expand All @@ -252,7 +251,8 @@ static protected void parseOBJ(PApplet parent, String path,
}
BufferedReader mreader = parent.createReader(fn);
if (mreader != null) {
parseMTL(parent, path, mreader, materials, mtlTable);
parseMTL(parent, path,
mreader, materials, mtlTable);
}
}
} else if (parts[0].equals("g")) {
Expand Down Expand Up @@ -432,14 +432,10 @@ static protected class OBJFace {


static protected String getBasePath(PApplet parent, String filename) {
// Obtaining the path
File file = new File(parent.dataPath(filename));
if (!file.exists()) {
file = parent.sketchFile(filename);
if (-1 < filename.indexOf(File.separator)) {
return filename.substring(0, filename.lastIndexOf(File.separator));
}
String absolutePath = file.getAbsolutePath();
return absolutePath.substring(0,
absolutePath.lastIndexOf(File.separator));
return "";
}


Expand Down

0 comments on commit 1d343b7

Please sign in to comment.