开发者

When loading an OBJ i get this

开发者 https://www.devze.com 2023-02-18 05:08 出处:网络
and this time i have loaded a model successfully! yay!! but theres a slight problem, one that i had with another obj loader...

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开发者_如何学Python.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)


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号