0

我正在编写的程序有问题。目前我正在读取一个 OBJ 文件并正确渲染它。但我的问题是,有些图像不适合我的窗口。

我尝试使用 glScalef 对其进行缩放,但图像仍然变形。(几乎总是在 Z 上)

这是我设置窗口的方式:

gl.glMatrixMode(GL.GL_PROJECTION); 
    gl.glLoadIdentity(); 
    float w = gLDrawable.getWidth(); 
    float h = gLDrawable.getHeight(); 

    if(w > h) gl.glOrtho(-1.0*(w/h), 1.0*w/h, -1.0, 1.0, -1.0, 1.0); 
    else gl.glOrtho(-1.0, 1.0, -1.0*(h/w), 1.0*h/w, -1.0, 1.0); 

这是我的规模尝试

        if(m.getXVertexMax() - m.getXVertexMin() >  w) gl.glScalef(w/(m.getXVertexMax() - m.getXVertexMin()), 1, 1);
    else gl.glScalef(1/(m.getXVertexMax() - m.getXVertexMin()), 1, 1);

    if(m.getYVertexMax() - m.getYVertexMin() > h) gl.glScalef(1, h/(m.getYVertexMax() - m.getYVertexMin()), 1);
    else gl.glScalef(1, 1/(m.getYVertexMax() - m.getYVertexMin()), 1);

    gl.glScalef(1, 1, (1/(m.getZVertexMax() - m.getZVertexMin())));

在此处输入图像描述

在此处输入图像描述

无论我尝试什么,图像在 x 上总是很短,或者在 z 上总是很大!

有人可以帮忙吗?谢谢 :-)

4

1 回答 1

1

您需要统一缩放,如果您缩放 X 轴,则将 Y 和 Z 缩放相同的量。

于 2013-11-28T14:09:04.777 回答