Hi there,
I’m quite new to OpenGl and i’m a bit stuck right now …
I’m working on an Android project using the Vuforia AR Framework and I’m trying to draw
a 3D object from a .obj file .To test, i use the following obj file :
# diamond.obj
g Object001
v 0.000000E+00 0.000000E+00 78.0000
v 45.0000 45.0000 0.000000E+00
v 45.0000 -45.0000 0.000000E+00
v -45.0000 -45.0000 0.000000E+00
v -45.0000 45.0000 0.000000E+00
v 0.000000E+00 0.000000E+00 -78.0000
f 1 2 3
f 1 3 4
f 1 4 5
f 1 5 2
f 6 5 4
f 6 4 3
f 6 3 2
f 6 2 1
f 6 1 5
So, what i do is parsing this file and putting datas into the corresponding variables in my Android program.
Here is the piece of code used to draw the shape :
GLES20.glDisable(GLES20.GL_CULL_FACE);
GLES20.glVertexAttribPointer(vertexHandle, 3, GLES20.GL_FLOAT,
false, 0, _modele3D.getVertices());
GLES20.glVertexAttribPointer(textureCoordHandle, 2,
GLES20.GL_FLOAT, false, 0,
_modele3D.getTexCoords());
GLES20.glEnableVertexAttribArray(vertexHandle);
GLES20.glEnableVertexAttribArray(textureCoordHandle);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,
mTextures.get(0).mTextureID[0]);
GLES20.glUniformMatrix4fv(mvpMatrixHandle, 1, false,
modelViewProjection, 0);
GLES20.glUniform1i(texSampler2DHandle, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN, 0,
_modele3D.getNumObjectVertex());
_modele3D.getVertices() returns an array containing the vertices read in my obj file
_modele3D.getTextCoords() returns an array containing the texture coords read in my obj files
(even if it’s not true in the piece of code written here, in my app i made a test to avoid using a null texture array)
The problem i’m having is that all the faces of my 3D objects are not drawn …
Only half of them are drawn …
Tell me if you have ideas to help me !
Regards,