@@ -58,8 +58,8 @@ public PShapeOBJ(PApplet parent, BufferedReader reader, String basePath) {
58
58
ArrayList <PVector > coords = new ArrayList <PVector >();
59
59
ArrayList <PVector > normals = new ArrayList <PVector >();
60
60
ArrayList <PVector > texcoords = new ArrayList <PVector >();
61
- parseOBJ (parent , basePath , reader ,
62
- faces , materials , coords , normals , texcoords );
61
+ parseOBJ (parent , basePath ,
62
+ reader , faces , materials , coords , normals , texcoords );
63
63
64
64
// The OBJ geometry is stored with each face in a separate child shape.
65
65
parent = null ;
@@ -222,23 +222,22 @@ static protected void parseOBJ(PApplet parent, String path,
222
222
if (parts [0 ].equals ("v" )) {
223
223
// vertex
224
224
PVector tempv = new PVector (Float .valueOf (parts [1 ]).floatValue (),
225
- Float .valueOf (parts [2 ]).floatValue (),
226
- Float .valueOf (parts [3 ]).floatValue ());
225
+ Float .valueOf (parts [2 ]).floatValue (),
226
+ Float .valueOf (parts [3 ]).floatValue ());
227
227
coords .add (tempv );
228
228
readv = true ;
229
229
} else if (parts [0 ].equals ("vn" )) {
230
230
// normal
231
231
PVector tempn = new PVector (Float .valueOf (parts [1 ]).floatValue (),
232
- Float .valueOf (parts [2 ]).floatValue (),
233
- Float .valueOf (parts [3 ]).floatValue ());
232
+ Float .valueOf (parts [2 ]).floatValue (),
233
+ Float .valueOf (parts [3 ]).floatValue ());
234
234
normals .add (tempn );
235
235
readvn = true ;
236
236
} else if (parts [0 ].equals ("vt" )) {
237
237
// uv, inverting v to take into account Processing's inverted Y axis
238
238
// with respect to OpenGL.
239
239
PVector tempv = new PVector (Float .valueOf (parts [1 ]).floatValue (),
240
- 1 - Float .valueOf (parts [2 ]).
241
- floatValue ());
240
+ 1 - Float .valueOf (parts [2 ]).floatValue ());
242
241
texcoords .add (tempv );
243
242
readvt = true ;
244
243
} else if (parts [0 ].equals ("o" )) {
@@ -252,7 +251,8 @@ static protected void parseOBJ(PApplet parent, String path,
252
251
}
253
252
BufferedReader mreader = parent .createReader (fn );
254
253
if (mreader != null ) {
255
- parseMTL (parent , path , mreader , materials , mtlTable );
254
+ parseMTL (parent , path ,
255
+ mreader , materials , mtlTable );
256
256
}
257
257
}
258
258
} else if (parts [0 ].equals ("g" )) {
@@ -432,14 +432,10 @@ static protected class OBJFace {
432
432
433
433
434
434
static protected String getBasePath (PApplet parent , String filename ) {
435
- // Obtaining the path
436
- File file = new File (parent .dataPath (filename ));
437
- if (!file .exists ()) {
438
- file = parent .sketchFile (filename );
435
+ if (-1 < filename .indexOf (File .separator )) {
436
+ return filename .substring (0 , filename .lastIndexOf (File .separator ));
439
437
}
440
- String absolutePath = file .getAbsolutePath ();
441
- return absolutePath .substring (0 ,
442
- absolutePath .lastIndexOf (File .separator ));
438
+ return "" ;
443
439
}
444
440
445
441
0 commit comments