我有一個非常簡單的程序,加載波前obj文件,旋轉並顯示它。 問題是,該程序呈現它與一些問題(如缺少三角形)。當我嘗試使用NeHe的教程中提供的頂點緩衝區渲染金字塔時,我遇到了類似的問題。所以我不知道是什麼導致了這個渲染問題。你可以幫我嗎? 網格渲染問題libgdx
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() {
}
}
看看這個答案可以幫助:http://stackoverflow.com/questions/9019669/ android-mesh-render-issue – Wroclai 2012-08-13 22:41:34
謝謝你,我想也許是這個問題。我會嘗試「模擬」模型。 – 2012-08-14 13:14:11