Opengl-es draw an .obj file, but how?

Posted by lacas on Stack Overflow See other posts from Stack Overflow or by lacas
Published on 2011-11-24T09:05:34Z Indexed on 2011/11/24 9:50 UTC
Read the original article Hit count: 427

Filed under:
|

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);

enter image description here

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

© Stack Overflow or respective owner

Related posts about android

Related posts about opengl-es