PDA

View Full Version : Android 3D Item not well displayed



romainb
02-02-2017, 09:04 AM
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(textureCoordHandl e);
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,

romainb
02-06-2017, 12:35 AM
Hi there,


I'm still stuck at the same point..

I come to you to show you what my problem is, with pictures this time : maybe could it help you understand it :)

Here is the original one :

https://imageshack.us/i/po20lhgVp

And here is what is displayed :

https://imageshack.us/i/pmhoqTwdp

I don't think that he texture I put on it is linked to my problem.


Thank you,

Silence
02-06-2017, 01:36 AM
Few hints:

* Your original model file uses face indices, but you don't in your code. So maybe something went wrong going from indices into without.
* From your model file, nothing means that you use triangle fans. So certainly you are using simple triangles.
* Or _modele3D.getNumObjectVertex() might be calculating wrong

I would first go for my second option.