计算将一组坐标转换为另一组坐标的矩阵

发布于 2024-10-07 04:04:46 字数 502 浏览 2 评论 0原文

我正在玩游戏glest 的一些模型。

这些模型由一个或多个网格组成;每个网格由许多帧组成,这些帧描述了每个动画帧的每个顶点的位置。在下面所示的模型中,每个帧中每个轮子中每个顶点的位置都是一个数组。

这些模型已从 Blender 等 3D 工具导出。某处有人有原件。

但我想知道,对于简单的动画,例如车轮转动,如何计算变换 - 旋转、缩放和平移的步骤,或者应用时的矩阵到前一帧会产生新帧吗?

(显然,并非所有帧都会进行此类变换,因为它们可能会扭曲模型等。)

此外,如何通过应用矩阵并再次渲染相同的顶点来检测镜像和其他减少顶点数据量的机会?

跑步速度——如果只需几分钟即可测量——不会成为问题。

格莱斯特弹射器

I am playing with some models for the game glest.

These models are made up of one or more meshes; each mesh is made up of many frames which describe the position of each vertex for each frame of animation. In the model shown below, the position of each vertex in each wheel in each frame is in an array.

These models have been exported from 3D tools like Blender. Someone somewhere has the originals.

But I am wondering, for simple animation such as a wheel turning, how can you compute the transforms - the steps of rotate, scale and translate, or the matrix that when applied to the previous frame will result in the new frame?

(Obviously not all frames will have such transforms, because they may distort the models and such.)

Also, how can you detect mirroring and other opportunities to reduce the amount of vertex data by applying a matrix and rendering the same vertices again?

Running speed - if its measured in just minutes - won't be a problem.

A glest catapult

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

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

发布评论

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

评论(1

音盲 2024-10-14 04:04:46

首先,一些假设:

  • 您正在处理 3D 仿射变换(线性变换加平移)。
  • 您拥有动画中每个帧的顶点
  • 您可以将一帧中的至少 4 个顶点与下一帧中的 4 个顶点相关联

然后您可以将 4 个顶点作为原始中的 4D 列向量(在每个向量的第四个元素中附加 1)空间并将它们连接起来创建一个 4x4 矩阵,称为 X。对变换后的空间中相应的向量执行相同的操作,并将它们称为 Y,这也将是一个 4x4 矩阵。一点点线性代数为您提供了一种找到 4x4 矩阵 A 的方法,将其应用于 X 时可以得到 Y。因此:

AX = Y
A = YX-1

使用它来获得旋转和缩放并不是微不足道的。然而,A 的最右列将包含连续帧之间对象的平移。

First off, some assumptions:

  • You're dealing with 3D affine transformations (linear transformation plus translation).
  • You have the vertices for each frame in your animation
  • You can associate at least 4 vertices in a frame with 4 vertices in the next frame

Then you can take 4 vertices as 4D collumn vectors (appending a 1 in each vector's 4th element) in the original space and concatenate them to create a 4x4 matrix, called X. Do the same for their corresponding vectors in the tranformed space and call them Y, which will also be a 4x4 matrix. A little linear algebra provides you with a method to find the 4x4 matrix A that when applied to X gives you Y. Thus:

AX = Y
A = YX-1

Using this to get rotations and scaling is not trivial. However, the rightmost column of A will contain the translation for the object between the successive frames.

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