I d like to parse an .obj file. My parser is working good, but my displaying is not good.
Obj file is here
my code is:
public ObjModelParser parse() {
long startTime = System.currentTimeMillis();
InputStream fileIn = resources.openRawResource(resourceID);
BufferedReader buffer = new BufferedReader(new InputStreamReader(fileIn));
String line="";
Log.e("model loader", "Start parsing object " + resourceID);
try {
while ((line = buffer.readLine()) != null) {
StringTokenizer parts = new StringTokenizer(line, " ");
int numTokens = parts.countTokens();
if (numTokens == 0) continue;
String part = parts.nextToken();
if (part.equals(VERTEX)) {
Log.e("v ", line);
vertices.add(Float.parseFloat(parts.nextToken()));
vertices.add(Float.parseFloat(parts.nextToken()));
vertices.add(Float.parseFloat(parts.nextToken()));
....
and my displaying code is:
draw that model with TRIANGLE_STRIP and gl.glDrawArrays(rendermode, 0, coords.length/dimension);

What is the mistake here?
edited: file here to show what is my good coords from my program for a cube, and what is from .obj file, that never show
Thanks, Leslie
You are trying to draw using TRIANGLE_STRIP instead of TRIANGLES, did you do the work and put the necessary degenerate triangles for STRIP to work ?
If you did put in those degenerate triangles I would bet a problem there, could we look at the data output from your parser ? say just the first 10 triangles…
If you didn’t create the degenerate triangles or don’t know what that is just change the draw from TRIANGLE_STRIP to TRIANGLES, also using a triangle strip with a model like this limits some trick you can make with the normals, to produce better looking graphics. (if your going with simple or cartoony look ignore this part).