android - Writing Wavefront OBJ Parser For Use with OpenGL Indexed Vertex Buffer Objects -
I am trying to write the original warfter obj loader for my Android OpenGL ES 2.0 program. For now, I'm ignoring everything except parentheses, normal and face in the OBJ file. Even what I have written:
inputstream input strike = reference.get resource (). OpenRawResource (resource ID); BufferedReader Reader = New BufferedReader (New InputStreamReader (InputStream)); String line; Float ("line") = = ((line = Float.wooof (line split ("") [2]); float z = float.valouf (line split ("") [3]); verticesArrayList.add (x); verticesArrayList.add (y); verticesArrayList .add (z);} and if (with line star ("vn") {float x = float.valouf (line split ("") [1]); float y = float.lowoff (line split ("") [2]); float z = float.valouf (line split ("") [3]); normalsArrayList.add (x); normalsArrayList.add (y); normalsArrayList.add (z);}And if for 3x (int i = 1; i & lt; = 3; i ++) for each face / texture / coconut (with "line star" ("f")) {// loop 3 times 3 times (short intersection = (abbreviated) (short .wooof (line split ("") [i] .split ("/") [0]) - 1); indicesArrayList.add (summit); // my normal Make a copy of the array list, if (NormalsArray List2SEG ()) == 0 NormalsArray List 2 = New Array List and Lt; Float> (Normal Arrestist); // To normalize the sequence of normal classes try to re-normalize the normals. Normal = integer.valof (line split ("") [i] .split ("/") [2]) - 1; NormalsArrayList2.add (Top * 3, NormalsArerealist.Gate (Normal * 3)); NormalsArrayList2.add ((Top * 3) + 1, NormalsAralystGet ((Normal * 3) + 1); NormalsArrayList2.add ((Top * 3) + 2, NormalsAralystGet ((Normal * 3) + 2); }}} Reader.close ();
However, I'm not sure I'm setting my general rules correctly. Can you see what I am doing under my code? I am trying to re-organize the Normals so that they can match the order of Shiromani. I am doing this because I am using the GLES20.glDrawElements () method:
// Handle a member of the courtesy of courtesy, enable handles and prepare top data MPositionHandle = GLES20.glGetAttribLocation (Mprogram, "Avocation"); GLES20.glEnableVertexAttribArray (mPositionHandle); GLES20.glVertexAttribPointer (mPositionHandle, COORDINATES_PER_VERTEX, GLES20.GL_FLOAT, False, VERTEX_STRIDE, Vertical Buffer); // Get handle for a general member of shaders, enable handle, and create top data mnormalHandle = GLES20.glGetAttribLocation (Mprogram, "A normal"); GLES20.glEnableVertexAttribArray (mNormalHandle); GLES20.glVertexAttribPointer (mNormalHandle, COORDINATES_PER_VERTEX, GLES20.GL_FLOAT, False, VERTEX_STRIDE, normal buffer); // Cube GLES20.glDrawElements Draw (GLES20.GL_TRIANGLES, Number of Index, GLES20.GL_UNSIGNED_SHORT, Indesansbuffer);
I have got the idea of reorganizing this topic after countless hours of Goggle.
However, something is not going right. The light in my shader I work for all the shapes manually created with OpenGL, not just for the read model using my OBJ parser, so I do not think my light count is problematic, just how normal In addition, my OBJ parser is additionally, I opened my test obj files with maya and used the "Vertex Normal Edit Tool" so that it can be seen It is possible that all normals are correctly pointing out. Are there any obvious problems you can see with any of your codes?
Instead of using ArrayList's set () method, add ()
Comments
Post a Comment