Reputation: 1029
This time i'm having an issue with the actual rendering of my model. I can load it all through the Libgdx loadObj() function, and render it using GL10_Triangles, however i keep getting missing triangles in my model (it seems like only half the models are being rendered). I've tried the old ObjLoad function (commented out) and also the different render styles but nothing seems to work.
And yes I have checked the model in Blender and the model is complete without missing faces.
See the print screen below, and the code below that. Any help would be fantastic, it's very frustrating as i'm so close to getting this to work.
And here's the code.
public class LifeCycle implements ApplicationListener {
Mesh model;
private PerspectiveCamera camera;
public void create() {
InputStream stream = null;
camera = new PerspectiveCamera(45, 4, 4);
try
{
stream = Gdx.files.internal("Hammer/test_hammer.obj").read();
//model = ModelLoaderOld.loadObj(stream);
model = ObjLoader.loadObj(stream,true);
stream.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
Gdx.gl10.glTranslatef(0.0f, 0.0f, -3.0f);
}
protected float rotateZ = 0.1f;
protected float increment = 0.1f;
public void render()
{
Gdx.app.log("LifeCycle", "render()");
Gdx.gl.glClearColor(0.0f, 0.0f, 0.5f, 1.0f);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
camera.update();
camera.apply(Gdx.gl10);
Gdx.gl10.glTranslatef(0.0f, 0.0f, -3.0f);
Gdx.gl10.glRotatef(rotateZ, rotateZ, 5.0f, rotateZ);
model.render(GL10.GL_TRIANGLES);
rotateZ += increment;
System.out.println(""+rotateZ);
}
}
Upvotes: 0
Views: 1204
Reputation: 45948
This actually looks like the OBJ file stores quads instead of triangles, but your loading routine just reads them as triangles (just reads the first 3 index groups of a face). Whereas Blender might (and should) be smart enough to handle quads, your loader routine isn't. So either write a better OBJ loader (but I guess this isn't your class), configure your OBJ loader to treat quads correctly (if possible), or export the model as triangles instead of quads (if possible).
Upvotes: 2