设置视口以获得更大的顶点值? iPhone - OpenGL ES

发布于 01-06 11:53 字数 859 浏览 4 评论 0原文

我正在处理一些从 DAE 文件解析的较大顶点值。例如:

{-79.6536, -2230.43, -213.8},{-79.6536, 2377.36, -213.8},{79.6536, 2377.36, -213.8},{79.6536, -2230.43, -213.8},{-79.6536, -2230.43, 958.953},{79.6536, -2230.43, 958.953},{79.6536, 2377.36, 958.953},{-79.6536, 2377.36, 958.953},...

我的问题是我需要对视口的设置进行哪些更改才能适应这些较大的顶点?我目前有以下内容:

- (void)setupView
{       
// Set up the window that we will view the scene through
glViewport(0, 0, backingWidth, backingHeight);

// switch to the projection matrix and setup our 'camera lens'
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);    

// switch to model mode and set our background color
glMatrixMode(GL_MODELVIEW);
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
}

但是,当我运行代码时,我只是得到一个充满白色的屏幕 - 我想是因为我的对象放大到了极限。

感谢您提前提供任何建议。

I am working with some larger vertice values which I have parsed from a DAE file. E.g :

{-79.6536, -2230.43, -213.8},{-79.6536, 2377.36, -213.8},{79.6536, 2377.36, -213.8},{79.6536, -2230.43, -213.8},{-79.6536, -2230.43, 958.953},{79.6536, -2230.43, 958.953},{79.6536, 2377.36, 958.953},{-79.6536, 2377.36, 958.953},...

My question is what changes do I need to make to the setting up of my viewport in order to accomodate these larger vertices ? I currently have the following :

- (void)setupView
{       
// Set up the window that we will view the scene through
glViewport(0, 0, backingWidth, backingHeight);

// switch to the projection matrix and setup our 'camera lens'
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);    

// switch to model mode and set our background color
glMatrixMode(GL_MODELVIEW);
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
}

However when I run the code, I just get a screen filled with white - I presume because my object is zoomed in to an extreme degree.

Thanks for any advice in advance.

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

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

发布评论

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

评论(1

蓝戈者2025-01-13 11:53:47

使用glScalef(max_s, max_s, max_s);

其中

max_s = 2.0 / max(max(Xi) - min(Xi), max(Yi) - min(Yi), max(Zi) - min(Zi))

Use glScalef(max_s, max_s, max_s);

Where

max_s = 2.0 / max(max(Xi) - min(Xi), max(Yi) - min(Yi), max(Zi) - min(Zi))

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