我有一个非常简单的程序,它加载一个波前 obj 文件,旋转并显示它。问题是程序渲染它有一些问题(比如缺少三角形)。当我尝试使用取自 NeHe 教程的顶点缓冲区渲染 Pyramid 时,我遇到了类似的问题。所以我不知道是什么导致了这个渲染问题。你能帮助我吗?
package com.jam.libgdx3DTest;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g3d.loaders.obj.ObjLoader;
import java.io.InputStream;
public class Libgdx3DTest extends Game {
private Mesh shuttleMesh;
private Camera camera;
private float rotateAngle;
public void create() {
if (shuttleMesh == null) {
InputStream in = Gdx.files.internal("shuttle.obj").read();
shuttleMesh = ObjLoader.loadObj(in, false);
}
}
public void render() {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
Gdx.gl10.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
Gdx.gl10.glLoadIdentity();
camera.update();
camera.apply(Gdx.gl10);
rotateAngle += 0.5f;
Gdx.gl10.glRotatef(rotateAngle, 0f, 1f, 0f);
Gdx.gl10.glRotatef(-90f, 1f, 0f, 0f);
shuttleMesh.render(GL11.GL_TRIANGLES);
}
public void resize(int width, int height) {
float aspectRatio = (float) width / (float) height;
camera = new PerspectiveCamera(67, 2f * aspectRatio, 2f);
camera.translate(0f, 0f, 12f);
}
public void pause(){
}
public void resume(){
}
public void dispose() {
}
}