计算将一组坐标转换为另一组坐标的矩阵
我正在玩游戏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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,一些假设:
然后您可以将 4 个顶点作为原始中的 4D 列向量(在每个向量的第四个元素中附加 1)空间并将它们连接起来创建一个 4x4 矩阵,称为 X。对变换后的空间中相应的向量执行相同的操作,并将它们称为 Y,这也将是一个 4x4 矩阵。一点点线性代数为您提供了一种找到 4x4 矩阵 A 的方法,将其应用于 X 时可以得到 Y。因此:
使用它来获得旋转和缩放并不是微不足道的。然而,A 的最右列将包含连续帧之间对象的平移。
First off, some assumptions:
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:
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.