Android OpenGL-ES: Object is showing up with wrong Chirality -


i have object rendering in android opengl es 3.0, on nexus 9. object has somewhere around 80000 vertices , couple hundred thousand triangles.

i know fact vertices in right-handed coordinate system. when use pc view object (using program paraview), see object in right-handed coordinate system. render object on app in opengl, object has wrong chirality.

as mentioned above, i'm pretty vertices correct. therefore, wrong must occurring during coordinate transformations. have idea matrix (view, model, projection) might source of problem? need maintain integrity of vertices , not perform transformations (like flipping values manually) on vertex data itself.

edit: asked code: can't post because incredibly large project, i'll show lines matrices have been set up:

in onsurfacecreated():

final float eyex = 0.0f; final float eyey = 0.0f; final float eyez = -3.0f;   final float lookx = 0.0f; final float looky = 0.0f; final float lookz = 0.0f;   final float upx = 0.0f; final float upy = 1.0f; final float upz = 0.0f;   matrix.setlookatm(mviewmatrix, 0, eyex, eyey, eyez, lookx, looky, lookz, upx, upy, upz);         matrix.setlookatm(mviewmatrix2, 0, eyex, eyey, eyez, lookx, looky, lookz, upx, upy, upz);    matrix.setlookatm(mviewmatrix3, 0, eyex, eyey, eyez, lookx, looky, lookz, upx, upy, upz);    matrix.setlookatm(mviewmatrix4, 0, eyex, eyey, eyez, lookx, looky, lookz, upx, upy, upz);   ` 

in onsurfacechanged(gl10 glunused, int width, int height):

    gles30.glviewport(0, 0, width, height);     viewport[0] = 0;     viewport[1] = 0;     viewport[2] = width;     viewport[3] = height;      final float ratio = (float) width / height;     final float left = -ratio;     final float right = ratio;     final float bottom = -1.0f;     final float top = 1.0f;     final float near = 1.0f;     final float far = 500.0f;       matrix.frustumm(mprojectionmatrix, 0, left, right, bottom, top, near, far);     matrix.frustumm(mprojectionmatrix2, 0, left, right, bottom, top, near, far);     matrix.frustumm(mprojectionmatrix3, 0, left, right, bottom, top, near, far);     matrix.frustumm(mprojectionmatrix4, 0, left, right, bottom, top, near, far); 

to clarify, object referring uses mviewmatrix , mprojectionmatrix, not other view matrices , projection matrices. if there isn't wrong code, can post more showing places manipulated these matrices.

edit2: not understand why, manually flipping coordinates (for instance, flipping z-coordinate) either changing vertex data or applying scale matrix modelview, not fix chirality problem. absolutely stumped how fix this.

finally figured out problem (after 16 hours of trying). turns out culling wrong side. switching gl_back gl_front did trick me.


Comments