将三维世界矢量转换为模型视图矩阵

Converting 3D world vectors to model-view matrix

本文关键字:模型 视图 转换 三维 世界      更新时间:2023-09-26

我在计算WebGL场景的矩阵数学时遇到了问题。我尝试过的似乎都没有正确显示。

在我的3D世界里,我有很多模型。每个模型都有一个XYZ矢量,用于表示世界中的位置、旋转和比例。摄影机有一个用于定位和旋转的矢量。

将这些向量转换为每个模型传递给着色器的模型视图矩阵的最佳(显然有效)方法是什么?

提前感谢!:)

生成模型视图矩阵的完整配方通常如下所示:

1. Set up view matrix V (inverse of camera) from camera orientation vectors
2. Set up model translation matrix T from model position vector
3. Set up model rotation matrix R from model orientation vectors
4. Set up model scaling matrix S
5. MV = V       // initialize model-view matrix MV with the view matrix V
6. MV = V*T     // apply the model translation matrix T
7. MV = V*T*R   // apply the model rotation matrix R
8. MV = V*T*R*S // apply the model scaling matrix S