Why OpenGLES stretch my 3D Model?

吃可爱长大的小学妹 提交于 2020-01-03 01:42:12

问题


I created a simple 3D model in Blender, and imported this into OpenGLES for the iPhone SDK. The model imported with no problems for the most part but as you can see from the included photo links (photobucket), OpenGL is stretching the model beyond its intended proportions. The circular cylinders are made ovular, the squat rectangular body is made tall, etc. I'm a novice concerning OpenGL so please enlighten me: Why would OpenGL(ES) be stretching my 3D model and what are some troubleshooting steps?

PICS (pls open links in a new window yourself)

Lego Brick Modeled in Blender
Lego Brick Modeled in Blender
Lego Brick Rendered (Stretched) in OpenGLES
Lego Brick Rendered (Stretched)in OpenGLES
Lego Brick Rendered (Stretched) in OpenGLES


回答1:


Maybe your object in blender has one of its scales different from 1, it may not be exported ( for instance if you only export the mesh, not the blender object ).

In blender you can clear scales with Alt S -> Clear Scale while in object mode.




回答2:


I know this is old but it would be useful if someone is searching for this issue to have a correct reference.

When you render things in OpenGL, the Projection Matrix is set to the identity matrix at render in the template:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

This means that openGL will render to a screen of aspect ratio 1:1. To fix this, you can do the following:

float m[16] = {1.33,0,0,0,
        0,1,0,0,
        0,0,1,0,
        0,0,0,1};
    glMatrixMode(GL_PROJECTION);
    glLoadMatrixf(m);

This sets the aspect ratio to 1.33:1 or 3:2 which corresponds to the iPhone screen.



来源:https://stackoverflow.com/questions/1067833/why-opengles-stretch-my-3d-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!