加载 OBJ 时我得到这个

发布于 2024-10-24 07:54:46 字数 952 浏览 1 评论 0原文

这次我已经成功加载模型了!耶!!

但有一个小问题,我与另一个 obj 加载器遇到的问题...

如下所示:

http://img132.imageshack.us/i/newglitch2.jpg/

如果你不能立即看到它,这里是另一个角度:

http://img42.imageshack.us/i/newglitch3.jpg/

现在这应该看起来像一个立方体,但正如你所看到的,立方体上的面孔非常不稳定,

是否有其他人遇到这个问题,或者如果有人知道如何解决这个问题,请让我知道,

如果有任何需要显示的代码,我很乐意发布它。

嘿,我玩弄了代码(改变了一些东西),这就是我想出的

原始:

glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(50.f,(double)800 / (double)600,0.f,200.f);
    glTranslatef(0.f, 0.f, -10.0f);

结果:不稳定的图像(查看图像)

当前:

glMatrixMode(GL_MODELVIEW);
    gluPerspective(50.f,(double)800 / (double)600,0.f,200.f);
    glTranslatef(0.f, 0.f, -50.0f);
    glLoadIdentity();

结果:模型不不稳定,但无法移动相机(模型就在前面)我的)

and this time i have loaded a model successfully! yay!!

but theres a slight problem, one that i had with another obj loader...

heres what it looks like:

http://img132.imageshack.us/i/newglitch2.jpg/

heres another angle if u cant see it right away:

http://img42.imageshack.us/i/newglitch3.jpg/

now this is supposed to look like a cube, but as you can see, the edges of the faces on the cube are being very choppy

is anyone else having this problem, or if anyone knows how to solve this then let me know

also comment if theres any code that needs to be shown, ill be happy to post it.

hey i played around with the code(changed some stuff) and this is what i have come up with

ORIGINAL:

glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(50.f,(double)800 / (double)600,0.f,200.f);
    glTranslatef(0.f, 0.f, -10.0f);

result: choopy image(look at images)

CURRENT:

glMatrixMode(GL_MODELVIEW);
    gluPerspective(50.f,(double)800 / (double)600,0.f,200.f);
    glTranslatef(0.f, 0.f, -50.0f);
    glLoadIdentity();

result: model is not choppy but cannot move camera(model is right in front of me)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无声情话 2024-10-31 07:54:46
gluPerspective(50.f,(double)800 / (double)600,0.f,200.f);
                                              ^^^ 
                                               | 
That's your problem right there ---------------+

对于透视投影,近剪辑距离必须大于 0。实际上,您应该选择近的尽可能远,远的剪裁平面尽可能近。

假设您的深度缓冲区为 16 位宽,那么您将场景分割为 32768 个切片。切片分布遵循 1/x 定律。从技术上讲,你除以零。

gluPerspective(50.f,(double)800 / (double)600,0.f,200.f);
                                              ^^^ 
                                               | 
That's your problem right there ---------------+

The near clip distance must be greater than 0 for perspective projections. Actually you should choose near to be as far away as possible and the far clip plane to be as near as possible.

Say your depth buffer is 16 bits wide, then you slice the scene into 32768 slices. The slice distribution follows a 1/x law. Technically you're dividing by zero.

不再让梦枯萎 2024-10-31 07:54:46

嗯,这看起来像是投影设置问题。立方体的某些部分在转换为裁剪空间时会超出近/远平面。

据我所知,您正在使用正交投影矩阵 - 它是制作 2D UI 的标准。请检查您的glOrtho 调用的nearVal 和farVal。对于 2D UI,它们通常分别设置为 -1 和 1(或 0 和 1),因此可能需要 缩小立方体或通过修改提到的参数增加视锥体深度。

Well this looks like a projection setting issue. Some parts of your cube, when transformed into clip space, exceed near/far planes.

From what I see you are using orthogonal projection matrix - it's standard for making 2D UI. Please review nearVal and farVal of your glOrtho call. For 2D UI they are usually set as -1 and 1 respectively (or 0 and 1), so may want to either scale down cube or increase view frustum depth by modifying mentioned parameters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文