投影视图矩阵,opengl es。 iOS系统

发布于 2024-12-28 03:09:43 字数 627 浏览 3 评论 0原文

让以下矩阵位于左手坐标系中(列主)

我使用苹果的 GLKMatrix4x4 结构和函数,因此可以假设数学运算是正确的。

我希望以下内容会产生正确的矩阵。

projectionViewModel = camera.projection * camera.view * model.view

然而这是不正确的,因为模型开始围绕相机的平移偏移旋转。

但当我执行以下操作时,结果是正确的。

projectionViewModel = camera.projection * camera.inverseView * model.view

我的问题是,我是否在其他地方搞砸了?或者这是生成projectionViewModel矩阵的正确方法?

 GLKMatrix4 modelView  = GLKMatrix4Multiply(*[_scene.camera inverseView],*[_frame worldMatrix]);

 GLKMatrix4 projectionViewModel =  GLKMatrix4Multiply(*[_scene.camera proj],modelView);

Let the the following matrices be in the left handed coordinate system(Column-major)

I'm using apple's GLKMatrix4x4 structs and functions, so the math operations can assumed to be correct.

I expect that the following would produce the correct matrix.

projectionViewModel = camera.projection * camera.view * model.view

However this is incorrect, as the model starts to rotate about the camera's translation offset.

But when I do the following, the result is correct.

projectionViewModel = camera.projection * camera.inverseView * model.view

My question is, did I mess up something else where? Or is this the correct way to yield the projectionViewModel matrix?

 GLKMatrix4 modelView  = GLKMatrix4Multiply(*[_scene.camera inverseView],*[_frame worldMatrix]);

 GLKMatrix4 projectionViewModel =  GLKMatrix4Multiply(*[_scene.camera proj],modelView);

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

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

发布评论

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

评论(1

烟酒忠诚 2025-01-04 03:09:43

考虑一下您希望将物体直接放置在相机上会发生什么情况。所以你有camera.view = model.view。在这种情况下,您真正​​想要的是无论相机正在做什么,无论模型正在做什么,都相乘以形成单位矩阵,因为您不希望在投影之前应用任何变换。

因此,您需要使用设置相机时用于定位的任何内容的倒数,因为根据定义,倒数就是与原始值相乘时给出的恒等式。

所以你没有搞砸任何事情 - 你给出的第二个公式和你所说的给你正确结果的公式是正确的。

Think about it in terms of what you'd want to happen with an object positioned directly on the camera. So you have camera.view = model.view. In that case what you really want is for whatever the camera is doing and whatever the model is doing to multiply together to make the identity matrix because you want no transform to be applied prior to projection.

You therefore want to use the inverse of whatever you'd use for positioning when setting up the camera, because the inverse is by definition the thing that when multiplied with the original will give the identity.

So you didn't mess anything up — the second formula you give and the one that you say gives you correct results is correct.

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