Not all faces being rendered?

Hey guys!
I’m very very new to OpenGL. Sorry if my mistake seems trivial to you. I assure you I tried everything I could think of first.
I’m trying to load this 3ds model in an Android application:

I parsed the 3ds file correctly and drawn them all but it seems that some of the vertexes/faces are missing. Here’s how it looks rendered (and rotated a bit). I’m aware that I have no lightning /normals/shading for it but before I get there, shouldn’t all the peaces still be drawn correctly?

Any idea why this is happening? (it seems to happen for any other model I load - big chunks are missing).

As for the code I use for drawing:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
  gl.glClearColor(1, 1, 1, 1); 
  try {
    this.model = Model3dsLoader.load("treemodel.3ds");
  } catch (Exception e) {
    e.printStackTrace();
    Log.e("model", "Failed to load model from file!",e);
  }
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
  gl.glViewport(0, 0, width, height); 
  gl.glMatrixMode(GL_PROJECTION); 
  gl.glLoadIdentity(); 
  gl.glFrustumf( -1, 1, -1, 1, 1, 1000 );
  gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); 
}
public void onDrawFrame(GL10 gl) {
  gl.glClear(GL_COLOR_BUFFER_BIT); 
  gl.glMatrixMode(GL_MODELVIEW); 
  gl.glLoadIdentity();
  gl.glTranslatef(0, -1f, -3f); 
  gl.glScalef(0.02f, 0.02f, 0.02f);
  gl.glRotatef(-90, 1, 0, 0);
  gl.glColor4f(0.7f,0.7f, 0.7f, 1f); 
  for(int i=0;i<model.objects.length;i++){
    if(model.objects[i]!=null){
      gl.glVertexPointer(3, GL_FIXED, 0, model.objects[i].vertexesBuffer); 
      gl.glDrawElements(GL_TRIANGLES, model.objects[i].nrTriangles, GL10.GL_UNSIGNED_SHORT, model.objects[i].trianglesBuffer);
    }
  }
}

What method are you using to convert your data from 3ds to an array OpenGL ES can use with a VertexPointer? Oh nevermind, I see the function. I’m not familiar with Model3dsLoader…

Have you tried to switch the which side is the Front and back of the faces to see if it’s switched?
You can call gl.glFrontFace(GL10.GL_CW); to test that. Everything that’s shown should disappear and everything missing should appear.

Your frustum should be something more like:

gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);

Where the ratio is width/height.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.