Android的网格渲染问题 [英] Android Mesh Render issue

查看:152
本文介绍了Android的网格渲染问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一次,我有我的模型的实际呈现的问题。我可以加载它全部通过Libgdx loadObj()函数,并使用GL10_Triangles渲染它,但是我不断收到失踪三角形在我的模型(好像只有一半的模式正在呈现)。我试过老ObjLoad功能(注释掉)也是不同的渲染风格,但似乎没有任何工作。

是的,我已经检查了模型在搅拌机和模型是完全没有遗漏的面孔。

请参见下面的打印屏幕和下方的code。
任何帮助将是非常美妙的,这是非常令人沮丧,因为我很接近得到这个工作。


而这里的code。

 公共类的LifeCycle实现ApplicationListener {网格模型;
私人PerspectiveCamera摄像头;公共无效创建(){    InputStream的流= NULL;
    相机=新PerspectiveCamera(45,4,4);
    尝试
    {
        。流= Gdx.files.internal(锤/ test_hammer.obj)阅读();
        //模型= ModelLoaderOld.loadObj(流);
        模型= ObjLoader.loadObj(流,真);
        stream.close();
    }
    赶上(IOException异常五){
        // TODO自动生成catch块
        e.printStackTrace();
    }    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl10.glTranslatef(0.0,0.0,-3.0f);
}保护浮球rotateZ = 0.1F;
保护浮球增量= 0.1F;公共无效渲染()
{
    Gdx.app.log(生命周期,渲染());
    Gdx.gl.glClearColor(0.0,0.0,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.0,0.0,-3.0f);
    Gdx.gl10.glRotatef(rotateZ,rotateZ,5.0F,rotateZ);
    model.render(GL10.GL_TRIANGLES);    rotateZ + =增量;
    的System.out.println(+ rotateZ);
}
}


解决方案

这实际上看起来像OBJ文件存储四边形,而不是三角形,而是你的装载程序只是读取它们为三角形(只是读取脸部的前3个指标组)。而搅拌机可以(也应该)足以应付四边形聪明,你的装入程序是没有的。所以无论是写一个更好的OBJ装载机(但我想这不是你的类),配置您的OBJ装载机正确对待四边形(如果可能),或导出模型为三角形,而不是四边形(如果可能)。

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);
}
}

解决方案

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).

这篇关于Android的网格渲染问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆